diff --git a/CHANGELOG.md b/CHANGELOG.md index c4ac6235ad46..d56944131570 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,16 @@ # CHANGELOG +## `v55.4.0` + +### New Packages + +- `github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-06-15/documentdb` +- `github.com/Azure/azure-sdk-for-go/services/postgresql/mgmt/2021-06-01/postgresqlflexibleservers` +- `github.com/Azure/azure-sdk-for-go/services/preview/azurestackhci/mgmt/2021-01-01-preview/azurestackhci` +- `github.com/Azure/azure-sdk-for-go/services/preview/hybridkubernetes/mgmt/2021-04-01-preview/hybridkubernetes` +- `github.com/Azure/azure-sdk-for-go/services/preview/monitor/mgmt/2021-04-01-preview/insights` +- `github.com/Azure/azure-sdk-for-go/services/preview/sql/mgmt/v5.0/sql` + ## `v55.3.0` ### New Packages diff --git a/profiles/latest/cosmos-db/mgmt/documentdb/documentdbapi/models.go b/profiles/latest/cosmos-db/mgmt/documentdb/documentdbapi/models.go index 3a946fffb9b9..43c7d291e036 100644 --- a/profiles/latest/cosmos-db/mgmt/documentdb/documentdbapi/models.go +++ b/profiles/latest/cosmos-db/mgmt/documentdb/documentdbapi/models.go @@ -8,7 +8,7 @@ package documentdbapi -import original "github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-05-15/documentdb/documentdbapi" +import original "github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-06-15/documentdb/documentdbapi" type CassandraResourcesClientAPI = original.CassandraResourcesClientAPI type CollectionClientAPI = original.CollectionClientAPI @@ -29,5 +29,12 @@ type PercentileSourceTargetClientAPI = original.PercentileSourceTargetClientAPI type PercentileTargetClientAPI = original.PercentileTargetClientAPI type PrivateEndpointConnectionsClientAPI = original.PrivateEndpointConnectionsClientAPI type PrivateLinkResourcesClientAPI = original.PrivateLinkResourcesClientAPI +type RestorableDatabaseAccountsClientAPI = original.RestorableDatabaseAccountsClientAPI +type RestorableMongodbCollectionsClientAPI = original.RestorableMongodbCollectionsClientAPI +type RestorableMongodbDatabasesClientAPI = original.RestorableMongodbDatabasesClientAPI +type RestorableMongodbResourcesClientAPI = original.RestorableMongodbResourcesClientAPI +type RestorableSQLContainersClientAPI = original.RestorableSQLContainersClientAPI +type RestorableSQLDatabasesClientAPI = original.RestorableSQLDatabasesClientAPI +type RestorableSQLResourcesClientAPI = original.RestorableSQLResourcesClientAPI type SQLResourcesClientAPI = original.SQLResourcesClientAPI type TableResourcesClientAPI = original.TableResourcesClientAPI diff --git a/profiles/latest/cosmos-db/mgmt/documentdb/models.go b/profiles/latest/cosmos-db/mgmt/documentdb/models.go index 567d242490cb..e48cc5634f10 100644 --- a/profiles/latest/cosmos-db/mgmt/documentdb/models.go +++ b/profiles/latest/cosmos-db/mgmt/documentdb/models.go @@ -11,13 +11,24 @@ package documentdb import ( "context" - original "github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-05-15/documentdb" + original "github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-06-15/documentdb" ) const ( DefaultBaseURI = original.DefaultBaseURI ) +type APIType = original.APIType + +const ( + APITypeCassandra APIType = original.APITypeCassandra + APITypeGremlin APIType = original.APITypeGremlin + APITypeGremlinV2 APIType = original.APITypeGremlinV2 + APITypeMongoDB APIType = original.APITypeMongoDB + APITypeSQL APIType = original.APITypeSQL + APITypeTable APIType = original.APITypeTable +) + type AnalyticalStorageSchemaType = original.AnalyticalStorageSchemaType const ( @@ -25,6 +36,15 @@ const ( AnalyticalStorageSchemaTypeWellDefined AnalyticalStorageSchemaType = original.AnalyticalStorageSchemaTypeWellDefined ) +type BackupPolicyMigrationStatus = original.BackupPolicyMigrationStatus + +const ( + BackupPolicyMigrationStatusCompleted BackupPolicyMigrationStatus = original.BackupPolicyMigrationStatusCompleted + BackupPolicyMigrationStatusFailed BackupPolicyMigrationStatus = original.BackupPolicyMigrationStatusFailed + BackupPolicyMigrationStatusInProgress BackupPolicyMigrationStatus = original.BackupPolicyMigrationStatusInProgress + BackupPolicyMigrationStatusInvalid BackupPolicyMigrationStatus = original.BackupPolicyMigrationStatusInvalid +) + type BackupPolicyType = original.BackupPolicyType const ( @@ -52,6 +72,22 @@ const ( ConnectorOfferSmall ConnectorOffer = original.ConnectorOfferSmall ) +type CreateMode = original.CreateMode + +const ( + CreateModeDefault CreateMode = original.CreateModeDefault + CreateModeRestore CreateMode = original.CreateModeRestore +) + +type CreatedByType = original.CreatedByType + +const ( + CreatedByTypeApplication CreatedByType = original.CreatedByTypeApplication + CreatedByTypeKey CreatedByType = original.CreatedByTypeKey + CreatedByTypeManagedIdentity CreatedByType = original.CreatedByTypeManagedIdentity + CreatedByTypeUser CreatedByType = original.CreatedByTypeUser +) + type DataType = original.DataType const ( @@ -119,6 +155,15 @@ const ( NetworkACLBypassNone NetworkACLBypass = original.NetworkACLBypassNone ) +type OperationType = original.OperationType + +const ( + OperationTypeCreate OperationType = original.OperationTypeCreate + OperationTypeDelete OperationType = original.OperationTypeDelete + OperationTypeReplace OperationType = original.OperationTypeReplace + OperationTypeSystemOperation OperationType = original.OperationTypeSystemOperation +) + type PartitionKind = original.PartitionKind const ( @@ -154,6 +199,12 @@ const ( ResourceIdentityTypeUserAssigned ResourceIdentityType = original.ResourceIdentityTypeUserAssigned ) +type RestoreMode = original.RestoreMode + +const ( + RestoreModePointInTime RestoreMode = original.RestoreModePointInTime +) + type RoleDefinitionType = original.RoleDefinitionType const ( @@ -223,7 +274,9 @@ type AutoUpgradePolicyResource = original.AutoUpgradePolicyResource type AutoscaleSettings = original.AutoscaleSettings type AutoscaleSettingsResource = original.AutoscaleSettingsResource type AzureEntityResource = original.AzureEntityResource +type BackupInformation = original.BackupInformation type BackupPolicy = original.BackupPolicy +type BackupPolicyMigrationState = original.BackupPolicyMigrationState type BaseClient = original.BaseClient type BasicBackupPolicy = original.BasicBackupPolicy type Capability = original.Capability @@ -267,6 +320,8 @@ type CompositePath = original.CompositePath type ConflictResolutionPolicy = original.ConflictResolutionPolicy type ConsistencyPolicy = original.ConsistencyPolicy type ContainerPartitionKey = original.ContainerPartitionKey +type ContinuousBackupInformation = original.ContinuousBackupInformation +type ContinuousBackupRestoreLocation = original.ContinuousBackupRestoreLocation type ContinuousModeBackupPolicy = original.ContinuousModeBackupPolicy type CorsPolicy = original.CorsPolicy type CreateUpdateOptions = original.CreateUpdateOptions @@ -292,6 +347,7 @@ type DatabaseAccountsOnlineRegionFuture = original.DatabaseAccountsOnlineRegionF type DatabaseAccountsRegenerateKeyFuture = original.DatabaseAccountsRegenerateKeyFuture type DatabaseAccountsUpdateFuture = original.DatabaseAccountsUpdateFuture type DatabaseClient = original.DatabaseClient +type DatabaseRestoreResource = original.DatabaseRestoreResource type ErrorResponse = original.ErrorResponse type ExcludedPath = original.ExcludedPath type ExtendedResourceProperties = original.ExtendedResourceProperties @@ -415,6 +471,38 @@ type PrivateLinkServiceConnectionStateProperty = original.PrivateLinkServiceConn type ProxyResource = original.ProxyResource type RegionForOnlineOffline = original.RegionForOnlineOffline type Resource = original.Resource +type RestorableDatabaseAccountGetResult = original.RestorableDatabaseAccountGetResult +type RestorableDatabaseAccountProperties = original.RestorableDatabaseAccountProperties +type RestorableDatabaseAccountsClient = original.RestorableDatabaseAccountsClient +type RestorableDatabaseAccountsListResult = original.RestorableDatabaseAccountsListResult +type RestorableLocationResource = original.RestorableLocationResource +type RestorableMongodbCollectionGetResult = original.RestorableMongodbCollectionGetResult +type RestorableMongodbCollectionProperties = original.RestorableMongodbCollectionProperties +type RestorableMongodbCollectionPropertiesResource = original.RestorableMongodbCollectionPropertiesResource +type RestorableMongodbCollectionsClient = original.RestorableMongodbCollectionsClient +type RestorableMongodbCollectionsListResult = original.RestorableMongodbCollectionsListResult +type RestorableMongodbDatabaseGetResult = original.RestorableMongodbDatabaseGetResult +type RestorableMongodbDatabaseProperties = original.RestorableMongodbDatabaseProperties +type RestorableMongodbDatabasePropertiesResource = original.RestorableMongodbDatabasePropertiesResource +type RestorableMongodbDatabasesClient = original.RestorableMongodbDatabasesClient +type RestorableMongodbDatabasesListResult = original.RestorableMongodbDatabasesListResult +type RestorableMongodbResourcesClient = original.RestorableMongodbResourcesClient +type RestorableMongodbResourcesListResult = original.RestorableMongodbResourcesListResult +type RestorableSQLContainerGetResult = original.RestorableSQLContainerGetResult +type RestorableSQLContainerProperties = original.RestorableSQLContainerProperties +type RestorableSQLContainerPropertiesResource = original.RestorableSQLContainerPropertiesResource +type RestorableSQLContainerPropertiesResourceContainer = original.RestorableSQLContainerPropertiesResourceContainer +type RestorableSQLContainersClient = original.RestorableSQLContainersClient +type RestorableSQLContainersListResult = original.RestorableSQLContainersListResult +type RestorableSQLDatabaseGetResult = original.RestorableSQLDatabaseGetResult +type RestorableSQLDatabaseProperties = original.RestorableSQLDatabaseProperties +type RestorableSQLDatabasePropertiesResource = original.RestorableSQLDatabasePropertiesResource +type RestorableSQLDatabasePropertiesResourceDatabase = original.RestorableSQLDatabasePropertiesResourceDatabase +type RestorableSQLDatabasesClient = original.RestorableSQLDatabasesClient +type RestorableSQLDatabasesListResult = original.RestorableSQLDatabasesListResult +type RestorableSQLResourcesClient = original.RestorableSQLResourcesClient +type RestorableSQLResourcesListResult = original.RestorableSQLResourcesListResult +type RestoreParameters = original.RestoreParameters type SQLContainerCreateUpdateParameters = original.SQLContainerCreateUpdateParameters type SQLContainerCreateUpdateProperties = original.SQLContainerCreateUpdateProperties type SQLContainerGetProperties = original.SQLContainerGetProperties @@ -450,6 +538,7 @@ type SQLResourcesMigrateSQLContainerToAutoscaleFuture = original.SQLResourcesMig type SQLResourcesMigrateSQLContainerToManualThroughputFuture = original.SQLResourcesMigrateSQLContainerToManualThroughputFuture type SQLResourcesMigrateSQLDatabaseToAutoscaleFuture = original.SQLResourcesMigrateSQLDatabaseToAutoscaleFuture type SQLResourcesMigrateSQLDatabaseToManualThroughputFuture = original.SQLResourcesMigrateSQLDatabaseToManualThroughputFuture +type SQLResourcesRetrieveContinuousBackupInformationFuture = original.SQLResourcesRetrieveContinuousBackupInformationFuture type SQLResourcesUpdateSQLContainerThroughputFuture = original.SQLResourcesUpdateSQLContainerThroughputFuture type SQLResourcesUpdateSQLDatabaseThroughputFuture = original.SQLResourcesUpdateSQLDatabaseThroughputFuture type SQLRoleAssignmentCreateUpdateParameters = original.SQLRoleAssignmentCreateUpdateParameters @@ -482,6 +571,7 @@ type SQLUserDefinedFunctionGetResults = original.SQLUserDefinedFunctionGetResult type SQLUserDefinedFunctionListResult = original.SQLUserDefinedFunctionListResult type SQLUserDefinedFunctionResource = original.SQLUserDefinedFunctionResource type SpatialSpec = original.SpatialSpec +type SystemData = original.SystemData type TableCreateUpdateParameters = original.TableCreateUpdateParameters type TableCreateUpdateProperties = original.TableCreateUpdateProperties type TableGetProperties = original.TableGetProperties @@ -633,6 +723,48 @@ func NewPrivateLinkResourcesClient(subscriptionID string) PrivateLinkResourcesCl func NewPrivateLinkResourcesClientWithBaseURI(baseURI string, subscriptionID string) PrivateLinkResourcesClient { return original.NewPrivateLinkResourcesClientWithBaseURI(baseURI, subscriptionID) } +func NewRestorableDatabaseAccountsClient(subscriptionID string) RestorableDatabaseAccountsClient { + return original.NewRestorableDatabaseAccountsClient(subscriptionID) +} +func NewRestorableDatabaseAccountsClientWithBaseURI(baseURI string, subscriptionID string) RestorableDatabaseAccountsClient { + return original.NewRestorableDatabaseAccountsClientWithBaseURI(baseURI, subscriptionID) +} +func NewRestorableMongodbCollectionsClient(subscriptionID string) RestorableMongodbCollectionsClient { + return original.NewRestorableMongodbCollectionsClient(subscriptionID) +} +func NewRestorableMongodbCollectionsClientWithBaseURI(baseURI string, subscriptionID string) RestorableMongodbCollectionsClient { + return original.NewRestorableMongodbCollectionsClientWithBaseURI(baseURI, subscriptionID) +} +func NewRestorableMongodbDatabasesClient(subscriptionID string) RestorableMongodbDatabasesClient { + return original.NewRestorableMongodbDatabasesClient(subscriptionID) +} +func NewRestorableMongodbDatabasesClientWithBaseURI(baseURI string, subscriptionID string) RestorableMongodbDatabasesClient { + return original.NewRestorableMongodbDatabasesClientWithBaseURI(baseURI, subscriptionID) +} +func NewRestorableMongodbResourcesClient(subscriptionID string) RestorableMongodbResourcesClient { + return original.NewRestorableMongodbResourcesClient(subscriptionID) +} +func NewRestorableMongodbResourcesClientWithBaseURI(baseURI string, subscriptionID string) RestorableMongodbResourcesClient { + return original.NewRestorableMongodbResourcesClientWithBaseURI(baseURI, subscriptionID) +} +func NewRestorableSQLContainersClient(subscriptionID string) RestorableSQLContainersClient { + return original.NewRestorableSQLContainersClient(subscriptionID) +} +func NewRestorableSQLContainersClientWithBaseURI(baseURI string, subscriptionID string) RestorableSQLContainersClient { + return original.NewRestorableSQLContainersClientWithBaseURI(baseURI, subscriptionID) +} +func NewRestorableSQLDatabasesClient(subscriptionID string) RestorableSQLDatabasesClient { + return original.NewRestorableSQLDatabasesClient(subscriptionID) +} +func NewRestorableSQLDatabasesClientWithBaseURI(baseURI string, subscriptionID string) RestorableSQLDatabasesClient { + return original.NewRestorableSQLDatabasesClientWithBaseURI(baseURI, subscriptionID) +} +func NewRestorableSQLResourcesClient(subscriptionID string) RestorableSQLResourcesClient { + return original.NewRestorableSQLResourcesClient(subscriptionID) +} +func NewRestorableSQLResourcesClientWithBaseURI(baseURI string, subscriptionID string) RestorableSQLResourcesClient { + return original.NewRestorableSQLResourcesClientWithBaseURI(baseURI, subscriptionID) +} func NewSQLResourcesClient(subscriptionID string) SQLResourcesClient { return original.NewSQLResourcesClient(subscriptionID) } @@ -648,9 +780,15 @@ func NewTableResourcesClientWithBaseURI(baseURI string, subscriptionID string) T func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { return original.NewWithBaseURI(baseURI, subscriptionID) } +func PossibleAPITypeValues() []APIType { + return original.PossibleAPITypeValues() +} func PossibleAnalyticalStorageSchemaTypeValues() []AnalyticalStorageSchemaType { return original.PossibleAnalyticalStorageSchemaTypeValues() } +func PossibleBackupPolicyMigrationStatusValues() []BackupPolicyMigrationStatus { + return original.PossibleBackupPolicyMigrationStatusValues() +} func PossibleBackupPolicyTypeValues() []BackupPolicyType { return original.PossibleBackupPolicyTypeValues() } @@ -663,6 +801,12 @@ func PossibleConflictResolutionModeValues() []ConflictResolutionMode { func PossibleConnectorOfferValues() []ConnectorOffer { return original.PossibleConnectorOfferValues() } +func PossibleCreateModeValues() []CreateMode { + return original.PossibleCreateModeValues() +} +func PossibleCreatedByTypeValues() []CreatedByType { + return original.PossibleCreatedByTypeValues() +} func PossibleDataTypeValues() []DataType { return original.PossibleDataTypeValues() } @@ -687,6 +831,9 @@ func PossibleKeyKindValues() []KeyKind { func PossibleNetworkACLBypassValues() []NetworkACLBypass { return original.PossibleNetworkACLBypassValues() } +func PossibleOperationTypeValues() []OperationType { + return original.PossibleOperationTypeValues() +} func PossiblePartitionKindValues() []PartitionKind { return original.PossiblePartitionKindValues() } @@ -699,6 +846,9 @@ func PossiblePublicNetworkAccessValues() []PublicNetworkAccess { func PossibleResourceIdentityTypeValues() []ResourceIdentityType { return original.PossibleResourceIdentityTypeValues() } +func PossibleRestoreModeValues() []RestoreMode { + return original.PossibleRestoreModeValues() +} func PossibleRoleDefinitionTypeValues() []RoleDefinitionType { return original.PossibleRoleDefinitionTypeValues() } diff --git a/profiles/latest/postgresql/mgmt/postgresqlflexibleservers/models.go b/profiles/latest/postgresql/mgmt/postgresqlflexibleservers/models.go new file mode 100644 index 000000000000..8fb3e83d0686 --- /dev/null +++ b/profiles/latest/postgresql/mgmt/postgresqlflexibleservers/models.go @@ -0,0 +1,349 @@ +// +build go1.9 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +// This code was auto-generated by: +// github.com/Azure/azure-sdk-for-go/tools/profileBuilder + +package postgresqlflexibleservers + +import ( + "context" + + original "github.com/Azure/azure-sdk-for-go/services/postgresql/mgmt/2021-06-01/postgresqlflexibleservers" +) + +const ( + DefaultBaseURI = original.DefaultBaseURI +) + +type ConfigurationDataType = original.ConfigurationDataType + +const ( + ConfigurationDataTypeBoolean ConfigurationDataType = original.ConfigurationDataTypeBoolean + ConfigurationDataTypeEnumeration ConfigurationDataType = original.ConfigurationDataTypeEnumeration + ConfigurationDataTypeInteger ConfigurationDataType = original.ConfigurationDataTypeInteger + ConfigurationDataTypeNumeric ConfigurationDataType = original.ConfigurationDataTypeNumeric +) + +type CreateMode = original.CreateMode + +const ( + CreateModeCreate CreateMode = original.CreateModeCreate + CreateModeDefault CreateMode = original.CreateModeDefault + CreateModePointInTimeRestore CreateMode = original.CreateModePointInTimeRestore + CreateModeUpdate CreateMode = original.CreateModeUpdate +) + +type CreateModeForUpdate = original.CreateModeForUpdate + +const ( + CreateModeForUpdateDefault CreateModeForUpdate = original.CreateModeForUpdateDefault + CreateModeForUpdateUpdate CreateModeForUpdate = original.CreateModeForUpdateUpdate +) + +type CreatedByType = original.CreatedByType + +const ( + CreatedByTypeApplication CreatedByType = original.CreatedByTypeApplication + CreatedByTypeKey CreatedByType = original.CreatedByTypeKey + CreatedByTypeManagedIdentity CreatedByType = original.CreatedByTypeManagedIdentity + CreatedByTypeUser CreatedByType = original.CreatedByTypeUser +) + +type GeoRedundantBackupEnum = original.GeoRedundantBackupEnum + +const ( + GeoRedundantBackupEnumDisabled GeoRedundantBackupEnum = original.GeoRedundantBackupEnumDisabled + GeoRedundantBackupEnumEnabled GeoRedundantBackupEnum = original.GeoRedundantBackupEnumEnabled +) + +type HighAvailabilityMode = original.HighAvailabilityMode + +const ( + HighAvailabilityModeDisabled HighAvailabilityMode = original.HighAvailabilityModeDisabled + HighAvailabilityModeZoneRedundant HighAvailabilityMode = original.HighAvailabilityModeZoneRedundant +) + +type OperationOrigin = original.OperationOrigin + +const ( + OperationOriginNotSpecified OperationOrigin = original.OperationOriginNotSpecified + OperationOriginSystem OperationOrigin = original.OperationOriginSystem + OperationOriginUser OperationOrigin = original.OperationOriginUser +) + +type ResourceIdentityType = original.ResourceIdentityType + +const ( + ResourceIdentityTypeSystemAssigned ResourceIdentityType = original.ResourceIdentityTypeSystemAssigned +) + +type ServerHAState = original.ServerHAState + +const ( + ServerHAStateCreatingStandby ServerHAState = original.ServerHAStateCreatingStandby + ServerHAStateFailingOver ServerHAState = original.ServerHAStateFailingOver + ServerHAStateHealthy ServerHAState = original.ServerHAStateHealthy + ServerHAStateNotEnabled ServerHAState = original.ServerHAStateNotEnabled + ServerHAStateRemovingStandby ServerHAState = original.ServerHAStateRemovingStandby + ServerHAStateReplicatingData ServerHAState = original.ServerHAStateReplicatingData +) + +type ServerPublicNetworkAccessState = original.ServerPublicNetworkAccessState + +const ( + ServerPublicNetworkAccessStateDisabled ServerPublicNetworkAccessState = original.ServerPublicNetworkAccessStateDisabled + ServerPublicNetworkAccessStateEnabled ServerPublicNetworkAccessState = original.ServerPublicNetworkAccessStateEnabled +) + +type ServerState = original.ServerState + +const ( + ServerStateDisabled ServerState = original.ServerStateDisabled + ServerStateDropping ServerState = original.ServerStateDropping + ServerStateReady ServerState = original.ServerStateReady + ServerStateStarting ServerState = original.ServerStateStarting + ServerStateStopped ServerState = original.ServerStateStopped + ServerStateStopping ServerState = original.ServerStateStopping + ServerStateUpdating ServerState = original.ServerStateUpdating +) + +type ServerVersion = original.ServerVersion + +const ( + ServerVersionOneOne ServerVersion = original.ServerVersionOneOne + ServerVersionOneThree ServerVersion = original.ServerVersionOneThree + ServerVersionOneTwo ServerVersion = original.ServerVersionOneTwo +) + +type SkuTier = original.SkuTier + +const ( + SkuTierBurstable SkuTier = original.SkuTierBurstable + SkuTierGeneralPurpose SkuTier = original.SkuTierGeneralPurpose + SkuTierMemoryOptimized SkuTier = original.SkuTierMemoryOptimized +) + +type AzureEntityResource = original.AzureEntityResource +type Backup = original.Backup +type BaseClient = original.BaseClient +type CapabilitiesListResult = original.CapabilitiesListResult +type CapabilitiesListResultIterator = original.CapabilitiesListResultIterator +type CapabilitiesListResultPage = original.CapabilitiesListResultPage +type CapabilityProperties = original.CapabilityProperties +type CheckNameAvailabilityClient = original.CheckNameAvailabilityClient +type CloudError = original.CloudError +type Configuration = original.Configuration +type ConfigurationListResult = original.ConfigurationListResult +type ConfigurationListResultIterator = original.ConfigurationListResultIterator +type ConfigurationListResultPage = original.ConfigurationListResultPage +type ConfigurationProperties = original.ConfigurationProperties +type ConfigurationsClient = original.ConfigurationsClient +type ConfigurationsPutFuture = original.ConfigurationsPutFuture +type ConfigurationsUpdateFuture = original.ConfigurationsUpdateFuture +type Database = original.Database +type DatabaseListResult = original.DatabaseListResult +type DatabaseListResultIterator = original.DatabaseListResultIterator +type DatabaseListResultPage = original.DatabaseListResultPage +type DatabaseProperties = original.DatabaseProperties +type DatabasesClient = original.DatabasesClient +type DatabasesCreateFuture = original.DatabasesCreateFuture +type DatabasesDeleteFuture = original.DatabasesDeleteFuture +type DelegatedSubnetUsage = original.DelegatedSubnetUsage +type ErrorAdditionalInfo = original.ErrorAdditionalInfo +type ErrorResponse = original.ErrorResponse +type FirewallRule = original.FirewallRule +type FirewallRuleListResult = original.FirewallRuleListResult +type FirewallRuleListResultIterator = original.FirewallRuleListResultIterator +type FirewallRuleListResultPage = original.FirewallRuleListResultPage +type FirewallRuleProperties = original.FirewallRuleProperties +type FirewallRulesClient = original.FirewallRulesClient +type FirewallRulesCreateOrUpdateFuture = original.FirewallRulesCreateOrUpdateFuture +type FirewallRulesDeleteFuture = original.FirewallRulesDeleteFuture +type FlexibleServerEditionCapability = original.FlexibleServerEditionCapability +type GetPrivateDNSZoneSuffixClient = original.GetPrivateDNSZoneSuffixClient +type HighAvailability = original.HighAvailability +type HyperscaleNodeEditionCapability = original.HyperscaleNodeEditionCapability +type Identity = original.Identity +type LocationBasedCapabilitiesClient = original.LocationBasedCapabilitiesClient +type MaintenanceWindow = original.MaintenanceWindow +type NameAvailability = original.NameAvailability +type NameAvailabilityRequest = original.NameAvailabilityRequest +type Network = original.Network +type NodeTypeCapability = original.NodeTypeCapability +type Operation = original.Operation +type OperationDisplay = original.OperationDisplay +type OperationListResult = original.OperationListResult +type OperationsClient = original.OperationsClient +type Plan = original.Plan +type ProxyResource = original.ProxyResource +type Resource = original.Resource +type ResourceModelWithAllowedPropertySet = original.ResourceModelWithAllowedPropertySet +type ResourceModelWithAllowedPropertySetIdentity = original.ResourceModelWithAllowedPropertySetIdentity +type ResourceModelWithAllowedPropertySetPlan = original.ResourceModelWithAllowedPropertySetPlan +type ResourceModelWithAllowedPropertySetSku = original.ResourceModelWithAllowedPropertySetSku +type RestartParameter = original.RestartParameter +type Server = original.Server +type ServerForUpdate = original.ServerForUpdate +type ServerListResult = original.ServerListResult +type ServerListResultIterator = original.ServerListResultIterator +type ServerListResultPage = original.ServerListResultPage +type ServerProperties = original.ServerProperties +type ServerPropertiesForUpdate = original.ServerPropertiesForUpdate +type ServerVersionCapability = original.ServerVersionCapability +type ServersClient = original.ServersClient +type ServersCreateFuture = original.ServersCreateFuture +type ServersDeleteFuture = original.ServersDeleteFuture +type ServersRestartFuture = original.ServersRestartFuture +type ServersStartFuture = original.ServersStartFuture +type ServersStopFuture = original.ServersStopFuture +type ServersUpdateFuture = original.ServersUpdateFuture +type Sku = original.Sku +type Storage = original.Storage +type StorageEditionCapability = original.StorageEditionCapability +type StorageMBCapability = original.StorageMBCapability +type String = original.String +type SystemData = original.SystemData +type TrackedResource = original.TrackedResource +type VcoreCapability = original.VcoreCapability +type VirtualNetworkSubnetUsageClient = original.VirtualNetworkSubnetUsageClient +type VirtualNetworkSubnetUsageParameter = original.VirtualNetworkSubnetUsageParameter +type VirtualNetworkSubnetUsageResult = original.VirtualNetworkSubnetUsageResult + +func New(subscriptionID string) BaseClient { + return original.New(subscriptionID) +} +func NewCapabilitiesListResultIterator(page CapabilitiesListResultPage) CapabilitiesListResultIterator { + return original.NewCapabilitiesListResultIterator(page) +} +func NewCapabilitiesListResultPage(cur CapabilitiesListResult, getNextPage func(context.Context, CapabilitiesListResult) (CapabilitiesListResult, error)) CapabilitiesListResultPage { + return original.NewCapabilitiesListResultPage(cur, getNextPage) +} +func NewCheckNameAvailabilityClient(subscriptionID string) CheckNameAvailabilityClient { + return original.NewCheckNameAvailabilityClient(subscriptionID) +} +func NewCheckNameAvailabilityClientWithBaseURI(baseURI string, subscriptionID string) CheckNameAvailabilityClient { + return original.NewCheckNameAvailabilityClientWithBaseURI(baseURI, subscriptionID) +} +func NewConfigurationListResultIterator(page ConfigurationListResultPage) ConfigurationListResultIterator { + return original.NewConfigurationListResultIterator(page) +} +func NewConfigurationListResultPage(cur ConfigurationListResult, getNextPage func(context.Context, ConfigurationListResult) (ConfigurationListResult, error)) ConfigurationListResultPage { + return original.NewConfigurationListResultPage(cur, getNextPage) +} +func NewConfigurationsClient(subscriptionID string) ConfigurationsClient { + return original.NewConfigurationsClient(subscriptionID) +} +func NewConfigurationsClientWithBaseURI(baseURI string, subscriptionID string) ConfigurationsClient { + return original.NewConfigurationsClientWithBaseURI(baseURI, subscriptionID) +} +func NewDatabaseListResultIterator(page DatabaseListResultPage) DatabaseListResultIterator { + return original.NewDatabaseListResultIterator(page) +} +func NewDatabaseListResultPage(cur DatabaseListResult, getNextPage func(context.Context, DatabaseListResult) (DatabaseListResult, error)) DatabaseListResultPage { + return original.NewDatabaseListResultPage(cur, getNextPage) +} +func NewDatabasesClient(subscriptionID string) DatabasesClient { + return original.NewDatabasesClient(subscriptionID) +} +func NewDatabasesClientWithBaseURI(baseURI string, subscriptionID string) DatabasesClient { + return original.NewDatabasesClientWithBaseURI(baseURI, subscriptionID) +} +func NewFirewallRuleListResultIterator(page FirewallRuleListResultPage) FirewallRuleListResultIterator { + return original.NewFirewallRuleListResultIterator(page) +} +func NewFirewallRuleListResultPage(cur FirewallRuleListResult, getNextPage func(context.Context, FirewallRuleListResult) (FirewallRuleListResult, error)) FirewallRuleListResultPage { + return original.NewFirewallRuleListResultPage(cur, getNextPage) +} +func NewFirewallRulesClient(subscriptionID string) FirewallRulesClient { + return original.NewFirewallRulesClient(subscriptionID) +} +func NewFirewallRulesClientWithBaseURI(baseURI string, subscriptionID string) FirewallRulesClient { + return original.NewFirewallRulesClientWithBaseURI(baseURI, subscriptionID) +} +func NewGetPrivateDNSZoneSuffixClient(subscriptionID string) GetPrivateDNSZoneSuffixClient { + return original.NewGetPrivateDNSZoneSuffixClient(subscriptionID) +} +func NewGetPrivateDNSZoneSuffixClientWithBaseURI(baseURI string, subscriptionID string) GetPrivateDNSZoneSuffixClient { + return original.NewGetPrivateDNSZoneSuffixClientWithBaseURI(baseURI, subscriptionID) +} +func NewLocationBasedCapabilitiesClient(subscriptionID string) LocationBasedCapabilitiesClient { + return original.NewLocationBasedCapabilitiesClient(subscriptionID) +} +func NewLocationBasedCapabilitiesClientWithBaseURI(baseURI string, subscriptionID string) LocationBasedCapabilitiesClient { + return original.NewLocationBasedCapabilitiesClientWithBaseURI(baseURI, subscriptionID) +} +func NewOperationsClient(subscriptionID string) OperationsClient { + return original.NewOperationsClient(subscriptionID) +} +func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient { + return original.NewOperationsClientWithBaseURI(baseURI, subscriptionID) +} +func NewServerListResultIterator(page ServerListResultPage) ServerListResultIterator { + return original.NewServerListResultIterator(page) +} +func NewServerListResultPage(cur ServerListResult, getNextPage func(context.Context, ServerListResult) (ServerListResult, error)) ServerListResultPage { + return original.NewServerListResultPage(cur, getNextPage) +} +func NewServersClient(subscriptionID string) ServersClient { + return original.NewServersClient(subscriptionID) +} +func NewServersClientWithBaseURI(baseURI string, subscriptionID string) ServersClient { + return original.NewServersClientWithBaseURI(baseURI, subscriptionID) +} +func NewVirtualNetworkSubnetUsageClient(subscriptionID string) VirtualNetworkSubnetUsageClient { + return original.NewVirtualNetworkSubnetUsageClient(subscriptionID) +} +func NewVirtualNetworkSubnetUsageClientWithBaseURI(baseURI string, subscriptionID string) VirtualNetworkSubnetUsageClient { + return original.NewVirtualNetworkSubnetUsageClientWithBaseURI(baseURI, subscriptionID) +} +func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { + return original.NewWithBaseURI(baseURI, subscriptionID) +} +func PossibleConfigurationDataTypeValues() []ConfigurationDataType { + return original.PossibleConfigurationDataTypeValues() +} +func PossibleCreateModeForUpdateValues() []CreateModeForUpdate { + return original.PossibleCreateModeForUpdateValues() +} +func PossibleCreateModeValues() []CreateMode { + return original.PossibleCreateModeValues() +} +func PossibleCreatedByTypeValues() []CreatedByType { + return original.PossibleCreatedByTypeValues() +} +func PossibleGeoRedundantBackupEnumValues() []GeoRedundantBackupEnum { + return original.PossibleGeoRedundantBackupEnumValues() +} +func PossibleHighAvailabilityModeValues() []HighAvailabilityMode { + return original.PossibleHighAvailabilityModeValues() +} +func PossibleOperationOriginValues() []OperationOrigin { + return original.PossibleOperationOriginValues() +} +func PossibleResourceIdentityTypeValues() []ResourceIdentityType { + return original.PossibleResourceIdentityTypeValues() +} +func PossibleServerHAStateValues() []ServerHAState { + return original.PossibleServerHAStateValues() +} +func PossibleServerPublicNetworkAccessStateValues() []ServerPublicNetworkAccessState { + return original.PossibleServerPublicNetworkAccessStateValues() +} +func PossibleServerStateValues() []ServerState { + return original.PossibleServerStateValues() +} +func PossibleServerVersionValues() []ServerVersion { + return original.PossibleServerVersionValues() +} +func PossibleSkuTierValues() []SkuTier { + return original.PossibleSkuTierValues() +} +func UserAgent() string { + return original.UserAgent() + " profiles/latest" +} +func Version() string { + return original.Version() +} diff --git a/profiles/latest/postgresql/mgmt/postgresqlflexibleservers/postgresqlflexibleserversapi/models.go b/profiles/latest/postgresql/mgmt/postgresqlflexibleservers/postgresqlflexibleserversapi/models.go new file mode 100644 index 000000000000..ae05a51e94fe --- /dev/null +++ b/profiles/latest/postgresql/mgmt/postgresqlflexibleservers/postgresqlflexibleserversapi/models.go @@ -0,0 +1,21 @@ +// +build go1.9 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +// This code was auto-generated by: +// github.com/Azure/azure-sdk-for-go/tools/profileBuilder + +package postgresqlflexibleserversapi + +import original "github.com/Azure/azure-sdk-for-go/services/postgresql/mgmt/2021-06-01/postgresqlflexibleservers/postgresqlflexibleserversapi" + +type CheckNameAvailabilityClientAPI = original.CheckNameAvailabilityClientAPI +type ConfigurationsClientAPI = original.ConfigurationsClientAPI +type DatabasesClientAPI = original.DatabasesClientAPI +type FirewallRulesClientAPI = original.FirewallRulesClientAPI +type GetPrivateDNSZoneSuffixClientAPI = original.GetPrivateDNSZoneSuffixClientAPI +type LocationBasedCapabilitiesClientAPI = original.LocationBasedCapabilitiesClientAPI +type OperationsClientAPI = original.OperationsClientAPI +type ServersClientAPI = original.ServersClientAPI +type VirtualNetworkSubnetUsageClientAPI = original.VirtualNetworkSubnetUsageClientAPI diff --git a/profiles/preview/cosmos-db/mgmt/documentdb/documentdbapi/models.go b/profiles/preview/cosmos-db/mgmt/documentdb/documentdbapi/models.go index 3a946fffb9b9..43c7d291e036 100644 --- a/profiles/preview/cosmos-db/mgmt/documentdb/documentdbapi/models.go +++ b/profiles/preview/cosmos-db/mgmt/documentdb/documentdbapi/models.go @@ -8,7 +8,7 @@ package documentdbapi -import original "github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-05-15/documentdb/documentdbapi" +import original "github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-06-15/documentdb/documentdbapi" type CassandraResourcesClientAPI = original.CassandraResourcesClientAPI type CollectionClientAPI = original.CollectionClientAPI @@ -29,5 +29,12 @@ type PercentileSourceTargetClientAPI = original.PercentileSourceTargetClientAPI type PercentileTargetClientAPI = original.PercentileTargetClientAPI type PrivateEndpointConnectionsClientAPI = original.PrivateEndpointConnectionsClientAPI type PrivateLinkResourcesClientAPI = original.PrivateLinkResourcesClientAPI +type RestorableDatabaseAccountsClientAPI = original.RestorableDatabaseAccountsClientAPI +type RestorableMongodbCollectionsClientAPI = original.RestorableMongodbCollectionsClientAPI +type RestorableMongodbDatabasesClientAPI = original.RestorableMongodbDatabasesClientAPI +type RestorableMongodbResourcesClientAPI = original.RestorableMongodbResourcesClientAPI +type RestorableSQLContainersClientAPI = original.RestorableSQLContainersClientAPI +type RestorableSQLDatabasesClientAPI = original.RestorableSQLDatabasesClientAPI +type RestorableSQLResourcesClientAPI = original.RestorableSQLResourcesClientAPI type SQLResourcesClientAPI = original.SQLResourcesClientAPI type TableResourcesClientAPI = original.TableResourcesClientAPI diff --git a/profiles/preview/cosmos-db/mgmt/documentdb/models.go b/profiles/preview/cosmos-db/mgmt/documentdb/models.go index f3926294faf8..a50393293b14 100644 --- a/profiles/preview/cosmos-db/mgmt/documentdb/models.go +++ b/profiles/preview/cosmos-db/mgmt/documentdb/models.go @@ -11,13 +11,24 @@ package documentdb import ( "context" - original "github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-05-15/documentdb" + original "github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-06-15/documentdb" ) const ( DefaultBaseURI = original.DefaultBaseURI ) +type APIType = original.APIType + +const ( + APITypeCassandra APIType = original.APITypeCassandra + APITypeGremlin APIType = original.APITypeGremlin + APITypeGremlinV2 APIType = original.APITypeGremlinV2 + APITypeMongoDB APIType = original.APITypeMongoDB + APITypeSQL APIType = original.APITypeSQL + APITypeTable APIType = original.APITypeTable +) + type AnalyticalStorageSchemaType = original.AnalyticalStorageSchemaType const ( @@ -25,6 +36,15 @@ const ( AnalyticalStorageSchemaTypeWellDefined AnalyticalStorageSchemaType = original.AnalyticalStorageSchemaTypeWellDefined ) +type BackupPolicyMigrationStatus = original.BackupPolicyMigrationStatus + +const ( + BackupPolicyMigrationStatusCompleted BackupPolicyMigrationStatus = original.BackupPolicyMigrationStatusCompleted + BackupPolicyMigrationStatusFailed BackupPolicyMigrationStatus = original.BackupPolicyMigrationStatusFailed + BackupPolicyMigrationStatusInProgress BackupPolicyMigrationStatus = original.BackupPolicyMigrationStatusInProgress + BackupPolicyMigrationStatusInvalid BackupPolicyMigrationStatus = original.BackupPolicyMigrationStatusInvalid +) + type BackupPolicyType = original.BackupPolicyType const ( @@ -52,6 +72,22 @@ const ( ConnectorOfferSmall ConnectorOffer = original.ConnectorOfferSmall ) +type CreateMode = original.CreateMode + +const ( + CreateModeDefault CreateMode = original.CreateModeDefault + CreateModeRestore CreateMode = original.CreateModeRestore +) + +type CreatedByType = original.CreatedByType + +const ( + CreatedByTypeApplication CreatedByType = original.CreatedByTypeApplication + CreatedByTypeKey CreatedByType = original.CreatedByTypeKey + CreatedByTypeManagedIdentity CreatedByType = original.CreatedByTypeManagedIdentity + CreatedByTypeUser CreatedByType = original.CreatedByTypeUser +) + type DataType = original.DataType const ( @@ -119,6 +155,15 @@ const ( NetworkACLBypassNone NetworkACLBypass = original.NetworkACLBypassNone ) +type OperationType = original.OperationType + +const ( + OperationTypeCreate OperationType = original.OperationTypeCreate + OperationTypeDelete OperationType = original.OperationTypeDelete + OperationTypeReplace OperationType = original.OperationTypeReplace + OperationTypeSystemOperation OperationType = original.OperationTypeSystemOperation +) + type PartitionKind = original.PartitionKind const ( @@ -154,6 +199,12 @@ const ( ResourceIdentityTypeUserAssigned ResourceIdentityType = original.ResourceIdentityTypeUserAssigned ) +type RestoreMode = original.RestoreMode + +const ( + RestoreModePointInTime RestoreMode = original.RestoreModePointInTime +) + type RoleDefinitionType = original.RoleDefinitionType const ( @@ -223,7 +274,9 @@ type AutoUpgradePolicyResource = original.AutoUpgradePolicyResource type AutoscaleSettings = original.AutoscaleSettings type AutoscaleSettingsResource = original.AutoscaleSettingsResource type AzureEntityResource = original.AzureEntityResource +type BackupInformation = original.BackupInformation type BackupPolicy = original.BackupPolicy +type BackupPolicyMigrationState = original.BackupPolicyMigrationState type BaseClient = original.BaseClient type BasicBackupPolicy = original.BasicBackupPolicy type Capability = original.Capability @@ -267,6 +320,8 @@ type CompositePath = original.CompositePath type ConflictResolutionPolicy = original.ConflictResolutionPolicy type ConsistencyPolicy = original.ConsistencyPolicy type ContainerPartitionKey = original.ContainerPartitionKey +type ContinuousBackupInformation = original.ContinuousBackupInformation +type ContinuousBackupRestoreLocation = original.ContinuousBackupRestoreLocation type ContinuousModeBackupPolicy = original.ContinuousModeBackupPolicy type CorsPolicy = original.CorsPolicy type CreateUpdateOptions = original.CreateUpdateOptions @@ -292,6 +347,7 @@ type DatabaseAccountsOnlineRegionFuture = original.DatabaseAccountsOnlineRegionF type DatabaseAccountsRegenerateKeyFuture = original.DatabaseAccountsRegenerateKeyFuture type DatabaseAccountsUpdateFuture = original.DatabaseAccountsUpdateFuture type DatabaseClient = original.DatabaseClient +type DatabaseRestoreResource = original.DatabaseRestoreResource type ErrorResponse = original.ErrorResponse type ExcludedPath = original.ExcludedPath type ExtendedResourceProperties = original.ExtendedResourceProperties @@ -415,6 +471,38 @@ type PrivateLinkServiceConnectionStateProperty = original.PrivateLinkServiceConn type ProxyResource = original.ProxyResource type RegionForOnlineOffline = original.RegionForOnlineOffline type Resource = original.Resource +type RestorableDatabaseAccountGetResult = original.RestorableDatabaseAccountGetResult +type RestorableDatabaseAccountProperties = original.RestorableDatabaseAccountProperties +type RestorableDatabaseAccountsClient = original.RestorableDatabaseAccountsClient +type RestorableDatabaseAccountsListResult = original.RestorableDatabaseAccountsListResult +type RestorableLocationResource = original.RestorableLocationResource +type RestorableMongodbCollectionGetResult = original.RestorableMongodbCollectionGetResult +type RestorableMongodbCollectionProperties = original.RestorableMongodbCollectionProperties +type RestorableMongodbCollectionPropertiesResource = original.RestorableMongodbCollectionPropertiesResource +type RestorableMongodbCollectionsClient = original.RestorableMongodbCollectionsClient +type RestorableMongodbCollectionsListResult = original.RestorableMongodbCollectionsListResult +type RestorableMongodbDatabaseGetResult = original.RestorableMongodbDatabaseGetResult +type RestorableMongodbDatabaseProperties = original.RestorableMongodbDatabaseProperties +type RestorableMongodbDatabasePropertiesResource = original.RestorableMongodbDatabasePropertiesResource +type RestorableMongodbDatabasesClient = original.RestorableMongodbDatabasesClient +type RestorableMongodbDatabasesListResult = original.RestorableMongodbDatabasesListResult +type RestorableMongodbResourcesClient = original.RestorableMongodbResourcesClient +type RestorableMongodbResourcesListResult = original.RestorableMongodbResourcesListResult +type RestorableSQLContainerGetResult = original.RestorableSQLContainerGetResult +type RestorableSQLContainerProperties = original.RestorableSQLContainerProperties +type RestorableSQLContainerPropertiesResource = original.RestorableSQLContainerPropertiesResource +type RestorableSQLContainerPropertiesResourceContainer = original.RestorableSQLContainerPropertiesResourceContainer +type RestorableSQLContainersClient = original.RestorableSQLContainersClient +type RestorableSQLContainersListResult = original.RestorableSQLContainersListResult +type RestorableSQLDatabaseGetResult = original.RestorableSQLDatabaseGetResult +type RestorableSQLDatabaseProperties = original.RestorableSQLDatabaseProperties +type RestorableSQLDatabasePropertiesResource = original.RestorableSQLDatabasePropertiesResource +type RestorableSQLDatabasePropertiesResourceDatabase = original.RestorableSQLDatabasePropertiesResourceDatabase +type RestorableSQLDatabasesClient = original.RestorableSQLDatabasesClient +type RestorableSQLDatabasesListResult = original.RestorableSQLDatabasesListResult +type RestorableSQLResourcesClient = original.RestorableSQLResourcesClient +type RestorableSQLResourcesListResult = original.RestorableSQLResourcesListResult +type RestoreParameters = original.RestoreParameters type SQLContainerCreateUpdateParameters = original.SQLContainerCreateUpdateParameters type SQLContainerCreateUpdateProperties = original.SQLContainerCreateUpdateProperties type SQLContainerGetProperties = original.SQLContainerGetProperties @@ -450,6 +538,7 @@ type SQLResourcesMigrateSQLContainerToAutoscaleFuture = original.SQLResourcesMig type SQLResourcesMigrateSQLContainerToManualThroughputFuture = original.SQLResourcesMigrateSQLContainerToManualThroughputFuture type SQLResourcesMigrateSQLDatabaseToAutoscaleFuture = original.SQLResourcesMigrateSQLDatabaseToAutoscaleFuture type SQLResourcesMigrateSQLDatabaseToManualThroughputFuture = original.SQLResourcesMigrateSQLDatabaseToManualThroughputFuture +type SQLResourcesRetrieveContinuousBackupInformationFuture = original.SQLResourcesRetrieveContinuousBackupInformationFuture type SQLResourcesUpdateSQLContainerThroughputFuture = original.SQLResourcesUpdateSQLContainerThroughputFuture type SQLResourcesUpdateSQLDatabaseThroughputFuture = original.SQLResourcesUpdateSQLDatabaseThroughputFuture type SQLRoleAssignmentCreateUpdateParameters = original.SQLRoleAssignmentCreateUpdateParameters @@ -482,6 +571,7 @@ type SQLUserDefinedFunctionGetResults = original.SQLUserDefinedFunctionGetResult type SQLUserDefinedFunctionListResult = original.SQLUserDefinedFunctionListResult type SQLUserDefinedFunctionResource = original.SQLUserDefinedFunctionResource type SpatialSpec = original.SpatialSpec +type SystemData = original.SystemData type TableCreateUpdateParameters = original.TableCreateUpdateParameters type TableCreateUpdateProperties = original.TableCreateUpdateProperties type TableGetProperties = original.TableGetProperties @@ -633,6 +723,48 @@ func NewPrivateLinkResourcesClient(subscriptionID string) PrivateLinkResourcesCl func NewPrivateLinkResourcesClientWithBaseURI(baseURI string, subscriptionID string) PrivateLinkResourcesClient { return original.NewPrivateLinkResourcesClientWithBaseURI(baseURI, subscriptionID) } +func NewRestorableDatabaseAccountsClient(subscriptionID string) RestorableDatabaseAccountsClient { + return original.NewRestorableDatabaseAccountsClient(subscriptionID) +} +func NewRestorableDatabaseAccountsClientWithBaseURI(baseURI string, subscriptionID string) RestorableDatabaseAccountsClient { + return original.NewRestorableDatabaseAccountsClientWithBaseURI(baseURI, subscriptionID) +} +func NewRestorableMongodbCollectionsClient(subscriptionID string) RestorableMongodbCollectionsClient { + return original.NewRestorableMongodbCollectionsClient(subscriptionID) +} +func NewRestorableMongodbCollectionsClientWithBaseURI(baseURI string, subscriptionID string) RestorableMongodbCollectionsClient { + return original.NewRestorableMongodbCollectionsClientWithBaseURI(baseURI, subscriptionID) +} +func NewRestorableMongodbDatabasesClient(subscriptionID string) RestorableMongodbDatabasesClient { + return original.NewRestorableMongodbDatabasesClient(subscriptionID) +} +func NewRestorableMongodbDatabasesClientWithBaseURI(baseURI string, subscriptionID string) RestorableMongodbDatabasesClient { + return original.NewRestorableMongodbDatabasesClientWithBaseURI(baseURI, subscriptionID) +} +func NewRestorableMongodbResourcesClient(subscriptionID string) RestorableMongodbResourcesClient { + return original.NewRestorableMongodbResourcesClient(subscriptionID) +} +func NewRestorableMongodbResourcesClientWithBaseURI(baseURI string, subscriptionID string) RestorableMongodbResourcesClient { + return original.NewRestorableMongodbResourcesClientWithBaseURI(baseURI, subscriptionID) +} +func NewRestorableSQLContainersClient(subscriptionID string) RestorableSQLContainersClient { + return original.NewRestorableSQLContainersClient(subscriptionID) +} +func NewRestorableSQLContainersClientWithBaseURI(baseURI string, subscriptionID string) RestorableSQLContainersClient { + return original.NewRestorableSQLContainersClientWithBaseURI(baseURI, subscriptionID) +} +func NewRestorableSQLDatabasesClient(subscriptionID string) RestorableSQLDatabasesClient { + return original.NewRestorableSQLDatabasesClient(subscriptionID) +} +func NewRestorableSQLDatabasesClientWithBaseURI(baseURI string, subscriptionID string) RestorableSQLDatabasesClient { + return original.NewRestorableSQLDatabasesClientWithBaseURI(baseURI, subscriptionID) +} +func NewRestorableSQLResourcesClient(subscriptionID string) RestorableSQLResourcesClient { + return original.NewRestorableSQLResourcesClient(subscriptionID) +} +func NewRestorableSQLResourcesClientWithBaseURI(baseURI string, subscriptionID string) RestorableSQLResourcesClient { + return original.NewRestorableSQLResourcesClientWithBaseURI(baseURI, subscriptionID) +} func NewSQLResourcesClient(subscriptionID string) SQLResourcesClient { return original.NewSQLResourcesClient(subscriptionID) } @@ -648,9 +780,15 @@ func NewTableResourcesClientWithBaseURI(baseURI string, subscriptionID string) T func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { return original.NewWithBaseURI(baseURI, subscriptionID) } +func PossibleAPITypeValues() []APIType { + return original.PossibleAPITypeValues() +} func PossibleAnalyticalStorageSchemaTypeValues() []AnalyticalStorageSchemaType { return original.PossibleAnalyticalStorageSchemaTypeValues() } +func PossibleBackupPolicyMigrationStatusValues() []BackupPolicyMigrationStatus { + return original.PossibleBackupPolicyMigrationStatusValues() +} func PossibleBackupPolicyTypeValues() []BackupPolicyType { return original.PossibleBackupPolicyTypeValues() } @@ -663,6 +801,12 @@ func PossibleConflictResolutionModeValues() []ConflictResolutionMode { func PossibleConnectorOfferValues() []ConnectorOffer { return original.PossibleConnectorOfferValues() } +func PossibleCreateModeValues() []CreateMode { + return original.PossibleCreateModeValues() +} +func PossibleCreatedByTypeValues() []CreatedByType { + return original.PossibleCreatedByTypeValues() +} func PossibleDataTypeValues() []DataType { return original.PossibleDataTypeValues() } @@ -687,6 +831,9 @@ func PossibleKeyKindValues() []KeyKind { func PossibleNetworkACLBypassValues() []NetworkACLBypass { return original.PossibleNetworkACLBypassValues() } +func PossibleOperationTypeValues() []OperationType { + return original.PossibleOperationTypeValues() +} func PossiblePartitionKindValues() []PartitionKind { return original.PossiblePartitionKindValues() } @@ -699,6 +846,9 @@ func PossiblePublicNetworkAccessValues() []PublicNetworkAccess { func PossibleResourceIdentityTypeValues() []ResourceIdentityType { return original.PossibleResourceIdentityTypeValues() } +func PossibleRestoreModeValues() []RestoreMode { + return original.PossibleRestoreModeValues() +} func PossibleRoleDefinitionTypeValues() []RoleDefinitionType { return original.PossibleRoleDefinitionTypeValues() } diff --git a/profiles/preview/postgresql/mgmt/postgresqlflexibleservers/models.go b/profiles/preview/postgresql/mgmt/postgresqlflexibleservers/models.go new file mode 100644 index 000000000000..f0fd0ef79060 --- /dev/null +++ b/profiles/preview/postgresql/mgmt/postgresqlflexibleservers/models.go @@ -0,0 +1,349 @@ +// +build go1.9 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +// This code was auto-generated by: +// github.com/Azure/azure-sdk-for-go/tools/profileBuilder + +package postgresqlflexibleservers + +import ( + "context" + + original "github.com/Azure/azure-sdk-for-go/services/postgresql/mgmt/2021-06-01/postgresqlflexibleservers" +) + +const ( + DefaultBaseURI = original.DefaultBaseURI +) + +type ConfigurationDataType = original.ConfigurationDataType + +const ( + ConfigurationDataTypeBoolean ConfigurationDataType = original.ConfigurationDataTypeBoolean + ConfigurationDataTypeEnumeration ConfigurationDataType = original.ConfigurationDataTypeEnumeration + ConfigurationDataTypeInteger ConfigurationDataType = original.ConfigurationDataTypeInteger + ConfigurationDataTypeNumeric ConfigurationDataType = original.ConfigurationDataTypeNumeric +) + +type CreateMode = original.CreateMode + +const ( + CreateModeCreate CreateMode = original.CreateModeCreate + CreateModeDefault CreateMode = original.CreateModeDefault + CreateModePointInTimeRestore CreateMode = original.CreateModePointInTimeRestore + CreateModeUpdate CreateMode = original.CreateModeUpdate +) + +type CreateModeForUpdate = original.CreateModeForUpdate + +const ( + CreateModeForUpdateDefault CreateModeForUpdate = original.CreateModeForUpdateDefault + CreateModeForUpdateUpdate CreateModeForUpdate = original.CreateModeForUpdateUpdate +) + +type CreatedByType = original.CreatedByType + +const ( + CreatedByTypeApplication CreatedByType = original.CreatedByTypeApplication + CreatedByTypeKey CreatedByType = original.CreatedByTypeKey + CreatedByTypeManagedIdentity CreatedByType = original.CreatedByTypeManagedIdentity + CreatedByTypeUser CreatedByType = original.CreatedByTypeUser +) + +type GeoRedundantBackupEnum = original.GeoRedundantBackupEnum + +const ( + GeoRedundantBackupEnumDisabled GeoRedundantBackupEnum = original.GeoRedundantBackupEnumDisabled + GeoRedundantBackupEnumEnabled GeoRedundantBackupEnum = original.GeoRedundantBackupEnumEnabled +) + +type HighAvailabilityMode = original.HighAvailabilityMode + +const ( + HighAvailabilityModeDisabled HighAvailabilityMode = original.HighAvailabilityModeDisabled + HighAvailabilityModeZoneRedundant HighAvailabilityMode = original.HighAvailabilityModeZoneRedundant +) + +type OperationOrigin = original.OperationOrigin + +const ( + OperationOriginNotSpecified OperationOrigin = original.OperationOriginNotSpecified + OperationOriginSystem OperationOrigin = original.OperationOriginSystem + OperationOriginUser OperationOrigin = original.OperationOriginUser +) + +type ResourceIdentityType = original.ResourceIdentityType + +const ( + ResourceIdentityTypeSystemAssigned ResourceIdentityType = original.ResourceIdentityTypeSystemAssigned +) + +type ServerHAState = original.ServerHAState + +const ( + ServerHAStateCreatingStandby ServerHAState = original.ServerHAStateCreatingStandby + ServerHAStateFailingOver ServerHAState = original.ServerHAStateFailingOver + ServerHAStateHealthy ServerHAState = original.ServerHAStateHealthy + ServerHAStateNotEnabled ServerHAState = original.ServerHAStateNotEnabled + ServerHAStateRemovingStandby ServerHAState = original.ServerHAStateRemovingStandby + ServerHAStateReplicatingData ServerHAState = original.ServerHAStateReplicatingData +) + +type ServerPublicNetworkAccessState = original.ServerPublicNetworkAccessState + +const ( + ServerPublicNetworkAccessStateDisabled ServerPublicNetworkAccessState = original.ServerPublicNetworkAccessStateDisabled + ServerPublicNetworkAccessStateEnabled ServerPublicNetworkAccessState = original.ServerPublicNetworkAccessStateEnabled +) + +type ServerState = original.ServerState + +const ( + ServerStateDisabled ServerState = original.ServerStateDisabled + ServerStateDropping ServerState = original.ServerStateDropping + ServerStateReady ServerState = original.ServerStateReady + ServerStateStarting ServerState = original.ServerStateStarting + ServerStateStopped ServerState = original.ServerStateStopped + ServerStateStopping ServerState = original.ServerStateStopping + ServerStateUpdating ServerState = original.ServerStateUpdating +) + +type ServerVersion = original.ServerVersion + +const ( + ServerVersionOneOne ServerVersion = original.ServerVersionOneOne + ServerVersionOneThree ServerVersion = original.ServerVersionOneThree + ServerVersionOneTwo ServerVersion = original.ServerVersionOneTwo +) + +type SkuTier = original.SkuTier + +const ( + SkuTierBurstable SkuTier = original.SkuTierBurstable + SkuTierGeneralPurpose SkuTier = original.SkuTierGeneralPurpose + SkuTierMemoryOptimized SkuTier = original.SkuTierMemoryOptimized +) + +type AzureEntityResource = original.AzureEntityResource +type Backup = original.Backup +type BaseClient = original.BaseClient +type CapabilitiesListResult = original.CapabilitiesListResult +type CapabilitiesListResultIterator = original.CapabilitiesListResultIterator +type CapabilitiesListResultPage = original.CapabilitiesListResultPage +type CapabilityProperties = original.CapabilityProperties +type CheckNameAvailabilityClient = original.CheckNameAvailabilityClient +type CloudError = original.CloudError +type Configuration = original.Configuration +type ConfigurationListResult = original.ConfigurationListResult +type ConfigurationListResultIterator = original.ConfigurationListResultIterator +type ConfigurationListResultPage = original.ConfigurationListResultPage +type ConfigurationProperties = original.ConfigurationProperties +type ConfigurationsClient = original.ConfigurationsClient +type ConfigurationsPutFuture = original.ConfigurationsPutFuture +type ConfigurationsUpdateFuture = original.ConfigurationsUpdateFuture +type Database = original.Database +type DatabaseListResult = original.DatabaseListResult +type DatabaseListResultIterator = original.DatabaseListResultIterator +type DatabaseListResultPage = original.DatabaseListResultPage +type DatabaseProperties = original.DatabaseProperties +type DatabasesClient = original.DatabasesClient +type DatabasesCreateFuture = original.DatabasesCreateFuture +type DatabasesDeleteFuture = original.DatabasesDeleteFuture +type DelegatedSubnetUsage = original.DelegatedSubnetUsage +type ErrorAdditionalInfo = original.ErrorAdditionalInfo +type ErrorResponse = original.ErrorResponse +type FirewallRule = original.FirewallRule +type FirewallRuleListResult = original.FirewallRuleListResult +type FirewallRuleListResultIterator = original.FirewallRuleListResultIterator +type FirewallRuleListResultPage = original.FirewallRuleListResultPage +type FirewallRuleProperties = original.FirewallRuleProperties +type FirewallRulesClient = original.FirewallRulesClient +type FirewallRulesCreateOrUpdateFuture = original.FirewallRulesCreateOrUpdateFuture +type FirewallRulesDeleteFuture = original.FirewallRulesDeleteFuture +type FlexibleServerEditionCapability = original.FlexibleServerEditionCapability +type GetPrivateDNSZoneSuffixClient = original.GetPrivateDNSZoneSuffixClient +type HighAvailability = original.HighAvailability +type HyperscaleNodeEditionCapability = original.HyperscaleNodeEditionCapability +type Identity = original.Identity +type LocationBasedCapabilitiesClient = original.LocationBasedCapabilitiesClient +type MaintenanceWindow = original.MaintenanceWindow +type NameAvailability = original.NameAvailability +type NameAvailabilityRequest = original.NameAvailabilityRequest +type Network = original.Network +type NodeTypeCapability = original.NodeTypeCapability +type Operation = original.Operation +type OperationDisplay = original.OperationDisplay +type OperationListResult = original.OperationListResult +type OperationsClient = original.OperationsClient +type Plan = original.Plan +type ProxyResource = original.ProxyResource +type Resource = original.Resource +type ResourceModelWithAllowedPropertySet = original.ResourceModelWithAllowedPropertySet +type ResourceModelWithAllowedPropertySetIdentity = original.ResourceModelWithAllowedPropertySetIdentity +type ResourceModelWithAllowedPropertySetPlan = original.ResourceModelWithAllowedPropertySetPlan +type ResourceModelWithAllowedPropertySetSku = original.ResourceModelWithAllowedPropertySetSku +type RestartParameter = original.RestartParameter +type Server = original.Server +type ServerForUpdate = original.ServerForUpdate +type ServerListResult = original.ServerListResult +type ServerListResultIterator = original.ServerListResultIterator +type ServerListResultPage = original.ServerListResultPage +type ServerProperties = original.ServerProperties +type ServerPropertiesForUpdate = original.ServerPropertiesForUpdate +type ServerVersionCapability = original.ServerVersionCapability +type ServersClient = original.ServersClient +type ServersCreateFuture = original.ServersCreateFuture +type ServersDeleteFuture = original.ServersDeleteFuture +type ServersRestartFuture = original.ServersRestartFuture +type ServersStartFuture = original.ServersStartFuture +type ServersStopFuture = original.ServersStopFuture +type ServersUpdateFuture = original.ServersUpdateFuture +type Sku = original.Sku +type Storage = original.Storage +type StorageEditionCapability = original.StorageEditionCapability +type StorageMBCapability = original.StorageMBCapability +type String = original.String +type SystemData = original.SystemData +type TrackedResource = original.TrackedResource +type VcoreCapability = original.VcoreCapability +type VirtualNetworkSubnetUsageClient = original.VirtualNetworkSubnetUsageClient +type VirtualNetworkSubnetUsageParameter = original.VirtualNetworkSubnetUsageParameter +type VirtualNetworkSubnetUsageResult = original.VirtualNetworkSubnetUsageResult + +func New(subscriptionID string) BaseClient { + return original.New(subscriptionID) +} +func NewCapabilitiesListResultIterator(page CapabilitiesListResultPage) CapabilitiesListResultIterator { + return original.NewCapabilitiesListResultIterator(page) +} +func NewCapabilitiesListResultPage(cur CapabilitiesListResult, getNextPage func(context.Context, CapabilitiesListResult) (CapabilitiesListResult, error)) CapabilitiesListResultPage { + return original.NewCapabilitiesListResultPage(cur, getNextPage) +} +func NewCheckNameAvailabilityClient(subscriptionID string) CheckNameAvailabilityClient { + return original.NewCheckNameAvailabilityClient(subscriptionID) +} +func NewCheckNameAvailabilityClientWithBaseURI(baseURI string, subscriptionID string) CheckNameAvailabilityClient { + return original.NewCheckNameAvailabilityClientWithBaseURI(baseURI, subscriptionID) +} +func NewConfigurationListResultIterator(page ConfigurationListResultPage) ConfigurationListResultIterator { + return original.NewConfigurationListResultIterator(page) +} +func NewConfigurationListResultPage(cur ConfigurationListResult, getNextPage func(context.Context, ConfigurationListResult) (ConfigurationListResult, error)) ConfigurationListResultPage { + return original.NewConfigurationListResultPage(cur, getNextPage) +} +func NewConfigurationsClient(subscriptionID string) ConfigurationsClient { + return original.NewConfigurationsClient(subscriptionID) +} +func NewConfigurationsClientWithBaseURI(baseURI string, subscriptionID string) ConfigurationsClient { + return original.NewConfigurationsClientWithBaseURI(baseURI, subscriptionID) +} +func NewDatabaseListResultIterator(page DatabaseListResultPage) DatabaseListResultIterator { + return original.NewDatabaseListResultIterator(page) +} +func NewDatabaseListResultPage(cur DatabaseListResult, getNextPage func(context.Context, DatabaseListResult) (DatabaseListResult, error)) DatabaseListResultPage { + return original.NewDatabaseListResultPage(cur, getNextPage) +} +func NewDatabasesClient(subscriptionID string) DatabasesClient { + return original.NewDatabasesClient(subscriptionID) +} +func NewDatabasesClientWithBaseURI(baseURI string, subscriptionID string) DatabasesClient { + return original.NewDatabasesClientWithBaseURI(baseURI, subscriptionID) +} +func NewFirewallRuleListResultIterator(page FirewallRuleListResultPage) FirewallRuleListResultIterator { + return original.NewFirewallRuleListResultIterator(page) +} +func NewFirewallRuleListResultPage(cur FirewallRuleListResult, getNextPage func(context.Context, FirewallRuleListResult) (FirewallRuleListResult, error)) FirewallRuleListResultPage { + return original.NewFirewallRuleListResultPage(cur, getNextPage) +} +func NewFirewallRulesClient(subscriptionID string) FirewallRulesClient { + return original.NewFirewallRulesClient(subscriptionID) +} +func NewFirewallRulesClientWithBaseURI(baseURI string, subscriptionID string) FirewallRulesClient { + return original.NewFirewallRulesClientWithBaseURI(baseURI, subscriptionID) +} +func NewGetPrivateDNSZoneSuffixClient(subscriptionID string) GetPrivateDNSZoneSuffixClient { + return original.NewGetPrivateDNSZoneSuffixClient(subscriptionID) +} +func NewGetPrivateDNSZoneSuffixClientWithBaseURI(baseURI string, subscriptionID string) GetPrivateDNSZoneSuffixClient { + return original.NewGetPrivateDNSZoneSuffixClientWithBaseURI(baseURI, subscriptionID) +} +func NewLocationBasedCapabilitiesClient(subscriptionID string) LocationBasedCapabilitiesClient { + return original.NewLocationBasedCapabilitiesClient(subscriptionID) +} +func NewLocationBasedCapabilitiesClientWithBaseURI(baseURI string, subscriptionID string) LocationBasedCapabilitiesClient { + return original.NewLocationBasedCapabilitiesClientWithBaseURI(baseURI, subscriptionID) +} +func NewOperationsClient(subscriptionID string) OperationsClient { + return original.NewOperationsClient(subscriptionID) +} +func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient { + return original.NewOperationsClientWithBaseURI(baseURI, subscriptionID) +} +func NewServerListResultIterator(page ServerListResultPage) ServerListResultIterator { + return original.NewServerListResultIterator(page) +} +func NewServerListResultPage(cur ServerListResult, getNextPage func(context.Context, ServerListResult) (ServerListResult, error)) ServerListResultPage { + return original.NewServerListResultPage(cur, getNextPage) +} +func NewServersClient(subscriptionID string) ServersClient { + return original.NewServersClient(subscriptionID) +} +func NewServersClientWithBaseURI(baseURI string, subscriptionID string) ServersClient { + return original.NewServersClientWithBaseURI(baseURI, subscriptionID) +} +func NewVirtualNetworkSubnetUsageClient(subscriptionID string) VirtualNetworkSubnetUsageClient { + return original.NewVirtualNetworkSubnetUsageClient(subscriptionID) +} +func NewVirtualNetworkSubnetUsageClientWithBaseURI(baseURI string, subscriptionID string) VirtualNetworkSubnetUsageClient { + return original.NewVirtualNetworkSubnetUsageClientWithBaseURI(baseURI, subscriptionID) +} +func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { + return original.NewWithBaseURI(baseURI, subscriptionID) +} +func PossibleConfigurationDataTypeValues() []ConfigurationDataType { + return original.PossibleConfigurationDataTypeValues() +} +func PossibleCreateModeForUpdateValues() []CreateModeForUpdate { + return original.PossibleCreateModeForUpdateValues() +} +func PossibleCreateModeValues() []CreateMode { + return original.PossibleCreateModeValues() +} +func PossibleCreatedByTypeValues() []CreatedByType { + return original.PossibleCreatedByTypeValues() +} +func PossibleGeoRedundantBackupEnumValues() []GeoRedundantBackupEnum { + return original.PossibleGeoRedundantBackupEnumValues() +} +func PossibleHighAvailabilityModeValues() []HighAvailabilityMode { + return original.PossibleHighAvailabilityModeValues() +} +func PossibleOperationOriginValues() []OperationOrigin { + return original.PossibleOperationOriginValues() +} +func PossibleResourceIdentityTypeValues() []ResourceIdentityType { + return original.PossibleResourceIdentityTypeValues() +} +func PossibleServerHAStateValues() []ServerHAState { + return original.PossibleServerHAStateValues() +} +func PossibleServerPublicNetworkAccessStateValues() []ServerPublicNetworkAccessState { + return original.PossibleServerPublicNetworkAccessStateValues() +} +func PossibleServerStateValues() []ServerState { + return original.PossibleServerStateValues() +} +func PossibleServerVersionValues() []ServerVersion { + return original.PossibleServerVersionValues() +} +func PossibleSkuTierValues() []SkuTier { + return original.PossibleSkuTierValues() +} +func UserAgent() string { + return original.UserAgent() + " profiles/preview" +} +func Version() string { + return original.Version() +} diff --git a/profiles/preview/postgresql/mgmt/postgresqlflexibleservers/postgresqlflexibleserversapi/models.go b/profiles/preview/postgresql/mgmt/postgresqlflexibleservers/postgresqlflexibleserversapi/models.go new file mode 100644 index 000000000000..ae05a51e94fe --- /dev/null +++ b/profiles/preview/postgresql/mgmt/postgresqlflexibleservers/postgresqlflexibleserversapi/models.go @@ -0,0 +1,21 @@ +// +build go1.9 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +// This code was auto-generated by: +// github.com/Azure/azure-sdk-for-go/tools/profileBuilder + +package postgresqlflexibleserversapi + +import original "github.com/Azure/azure-sdk-for-go/services/postgresql/mgmt/2021-06-01/postgresqlflexibleservers/postgresqlflexibleserversapi" + +type CheckNameAvailabilityClientAPI = original.CheckNameAvailabilityClientAPI +type ConfigurationsClientAPI = original.ConfigurationsClientAPI +type DatabasesClientAPI = original.DatabasesClientAPI +type FirewallRulesClientAPI = original.FirewallRulesClientAPI +type GetPrivateDNSZoneSuffixClientAPI = original.GetPrivateDNSZoneSuffixClientAPI +type LocationBasedCapabilitiesClientAPI = original.LocationBasedCapabilitiesClientAPI +type OperationsClientAPI = original.OperationsClientAPI +type ServersClientAPI = original.ServersClientAPI +type VirtualNetworkSubnetUsageClientAPI = original.VirtualNetworkSubnetUsageClientAPI diff --git a/profiles/preview/preview/azurestackhci/mgmt/azurestackhci/azurestackhciapi/models.go b/profiles/preview/preview/azurestackhci/mgmt/azurestackhci/azurestackhciapi/models.go index 79d9621b70da..b317365d8109 100644 --- a/profiles/preview/preview/azurestackhci/mgmt/azurestackhci/azurestackhciapi/models.go +++ b/profiles/preview/preview/azurestackhci/mgmt/azurestackhci/azurestackhciapi/models.go @@ -8,7 +8,9 @@ package azurestackhciapi -import original "github.com/Azure/azure-sdk-for-go/services/preview/azurestackhci/mgmt/2020-03-01-preview/azurestackhci/azurestackhciapi" +import original "github.com/Azure/azure-sdk-for-go/services/preview/azurestackhci/mgmt/2021-01-01-preview/azurestackhci/azurestackhciapi" +type ArcSettingsClientAPI = original.ArcSettingsClientAPI type ClustersClientAPI = original.ClustersClientAPI +type ExtensionsClientAPI = original.ExtensionsClientAPI type OperationsClientAPI = original.OperationsClientAPI diff --git a/profiles/preview/preview/azurestackhci/mgmt/azurestackhci/models.go b/profiles/preview/preview/azurestackhci/mgmt/azurestackhci/models.go index 45475b75f5f5..eb952d549513 100644 --- a/profiles/preview/preview/azurestackhci/mgmt/azurestackhci/models.go +++ b/profiles/preview/preview/azurestackhci/mgmt/azurestackhci/models.go @@ -11,34 +11,137 @@ package azurestackhci import ( "context" - original "github.com/Azure/azure-sdk-for-go/services/preview/azurestackhci/mgmt/2020-03-01-preview/azurestackhci" + original "github.com/Azure/azure-sdk-for-go/services/preview/azurestackhci/mgmt/2021-01-01-preview/azurestackhci" ) const ( DefaultBaseURI = original.DefaultBaseURI ) +type ActionType = original.ActionType + +const ( + ActionTypeInternal ActionType = original.ActionTypeInternal +) + +type ArcSettingAggregateState = original.ArcSettingAggregateState + +const ( + ArcSettingAggregateStateCanceled ArcSettingAggregateState = original.ArcSettingAggregateStateCanceled + ArcSettingAggregateStateConnected ArcSettingAggregateState = original.ArcSettingAggregateStateConnected + ArcSettingAggregateStateCreating ArcSettingAggregateState = original.ArcSettingAggregateStateCreating + ArcSettingAggregateStateDeleted ArcSettingAggregateState = original.ArcSettingAggregateStateDeleted + ArcSettingAggregateStateDeleting ArcSettingAggregateState = original.ArcSettingAggregateStateDeleting + ArcSettingAggregateStateDisconnected ArcSettingAggregateState = original.ArcSettingAggregateStateDisconnected + ArcSettingAggregateStateError ArcSettingAggregateState = original.ArcSettingAggregateStateError + ArcSettingAggregateStateFailed ArcSettingAggregateState = original.ArcSettingAggregateStateFailed + ArcSettingAggregateStateInProgress ArcSettingAggregateState = original.ArcSettingAggregateStateInProgress + ArcSettingAggregateStateMoving ArcSettingAggregateState = original.ArcSettingAggregateStateMoving + ArcSettingAggregateStateNotSpecified ArcSettingAggregateState = original.ArcSettingAggregateStateNotSpecified + ArcSettingAggregateStatePartiallyConnected ArcSettingAggregateState = original.ArcSettingAggregateStatePartiallyConnected + ArcSettingAggregateStatePartiallySucceeded ArcSettingAggregateState = original.ArcSettingAggregateStatePartiallySucceeded + ArcSettingAggregateStateSucceeded ArcSettingAggregateState = original.ArcSettingAggregateStateSucceeded + ArcSettingAggregateStateUpdating ArcSettingAggregateState = original.ArcSettingAggregateStateUpdating +) + +type CreatedByType = original.CreatedByType + +const ( + CreatedByTypeApplication CreatedByType = original.CreatedByTypeApplication + CreatedByTypeKey CreatedByType = original.CreatedByTypeKey + CreatedByTypeManagedIdentity CreatedByType = original.CreatedByTypeManagedIdentity + CreatedByTypeUser CreatedByType = original.CreatedByTypeUser +) + +type ExtensionAggregateState = original.ExtensionAggregateState + +const ( + ExtensionAggregateStateCanceled ExtensionAggregateState = original.ExtensionAggregateStateCanceled + ExtensionAggregateStateConnected ExtensionAggregateState = original.ExtensionAggregateStateConnected + ExtensionAggregateStateCreating ExtensionAggregateState = original.ExtensionAggregateStateCreating + ExtensionAggregateStateDeleted ExtensionAggregateState = original.ExtensionAggregateStateDeleted + ExtensionAggregateStateDeleting ExtensionAggregateState = original.ExtensionAggregateStateDeleting + ExtensionAggregateStateDisconnected ExtensionAggregateState = original.ExtensionAggregateStateDisconnected + ExtensionAggregateStateError ExtensionAggregateState = original.ExtensionAggregateStateError + ExtensionAggregateStateFailed ExtensionAggregateState = original.ExtensionAggregateStateFailed + ExtensionAggregateStateInProgress ExtensionAggregateState = original.ExtensionAggregateStateInProgress + ExtensionAggregateStateMoving ExtensionAggregateState = original.ExtensionAggregateStateMoving + ExtensionAggregateStateNotSpecified ExtensionAggregateState = original.ExtensionAggregateStateNotSpecified + ExtensionAggregateStatePartiallyConnected ExtensionAggregateState = original.ExtensionAggregateStatePartiallyConnected + ExtensionAggregateStatePartiallySucceeded ExtensionAggregateState = original.ExtensionAggregateStatePartiallySucceeded + ExtensionAggregateStateSucceeded ExtensionAggregateState = original.ExtensionAggregateStateSucceeded + ExtensionAggregateStateUpdating ExtensionAggregateState = original.ExtensionAggregateStateUpdating +) + +type NodeArcState = original.NodeArcState + +const ( + NodeArcStateCanceled NodeArcState = original.NodeArcStateCanceled + NodeArcStateConnected NodeArcState = original.NodeArcStateConnected + NodeArcStateCreating NodeArcState = original.NodeArcStateCreating + NodeArcStateDeleted NodeArcState = original.NodeArcStateDeleted + NodeArcStateDeleting NodeArcState = original.NodeArcStateDeleting + NodeArcStateDisconnected NodeArcState = original.NodeArcStateDisconnected + NodeArcStateError NodeArcState = original.NodeArcStateError + NodeArcStateFailed NodeArcState = original.NodeArcStateFailed + NodeArcStateMoving NodeArcState = original.NodeArcStateMoving + NodeArcStateNotSpecified NodeArcState = original.NodeArcStateNotSpecified + NodeArcStateSucceeded NodeArcState = original.NodeArcStateSucceeded + NodeArcStateUpdating NodeArcState = original.NodeArcStateUpdating +) + +type NodeExtensionState = original.NodeExtensionState + +const ( + NodeExtensionStateCanceled NodeExtensionState = original.NodeExtensionStateCanceled + NodeExtensionStateConnected NodeExtensionState = original.NodeExtensionStateConnected + NodeExtensionStateCreating NodeExtensionState = original.NodeExtensionStateCreating + NodeExtensionStateDeleted NodeExtensionState = original.NodeExtensionStateDeleted + NodeExtensionStateDeleting NodeExtensionState = original.NodeExtensionStateDeleting + NodeExtensionStateDisconnected NodeExtensionState = original.NodeExtensionStateDisconnected + NodeExtensionStateError NodeExtensionState = original.NodeExtensionStateError + NodeExtensionStateFailed NodeExtensionState = original.NodeExtensionStateFailed + NodeExtensionStateMoving NodeExtensionState = original.NodeExtensionStateMoving + NodeExtensionStateNotSpecified NodeExtensionState = original.NodeExtensionStateNotSpecified + NodeExtensionStateSucceeded NodeExtensionState = original.NodeExtensionStateSucceeded + NodeExtensionStateUpdating NodeExtensionState = original.NodeExtensionStateUpdating +) + +type Origin = original.Origin + +const ( + OriginSystem Origin = original.OriginSystem + OriginUser Origin = original.OriginUser + OriginUsersystem Origin = original.OriginUsersystem +) + type ProvisioningState = original.ProvisioningState const ( - Accepted ProvisioningState = original.Accepted - Canceled ProvisioningState = original.Canceled - Failed ProvisioningState = original.Failed - Provisioning ProvisioningState = original.Provisioning - Succeeded ProvisioningState = original.Succeeded + ProvisioningStateAccepted ProvisioningState = original.ProvisioningStateAccepted + ProvisioningStateCanceled ProvisioningState = original.ProvisioningStateCanceled + ProvisioningStateFailed ProvisioningState = original.ProvisioningStateFailed + ProvisioningStateProvisioning ProvisioningState = original.ProvisioningStateProvisioning + ProvisioningStateSucceeded ProvisioningState = original.ProvisioningStateSucceeded ) type Status = original.Status const ( - ConnectedRecently Status = original.ConnectedRecently - Disconnected Status = original.Disconnected - Error Status = original.Error - NotConnectedRecently Status = original.NotConnectedRecently - NotYetRegistered Status = original.NotYetRegistered + StatusConnectedRecently Status = original.StatusConnectedRecently + StatusDisconnected Status = original.StatusDisconnected + StatusError Status = original.StatusError + StatusNotConnectedRecently Status = original.StatusNotConnectedRecently + StatusNotYetRegistered Status = original.StatusNotYetRegistered ) -type AvailableOperations = original.AvailableOperations +type ArcSetting = original.ArcSetting +type ArcSettingList = original.ArcSettingList +type ArcSettingListIterator = original.ArcSettingListIterator +type ArcSettingListPage = original.ArcSettingListPage +type ArcSettingProperties = original.ArcSettingProperties +type ArcSettingsClient = original.ArcSettingsClient +type ArcSettingsDeleteFuture = original.ArcSettingsDeleteFuture type AzureEntityResource = original.AzureEntityResource type BaseClient = original.BaseClient type Cluster = original.Cluster @@ -46,23 +149,50 @@ type ClusterList = original.ClusterList type ClusterListIterator = original.ClusterListIterator type ClusterListPage = original.ClusterListPage type ClusterNode = original.ClusterNode +type ClusterPatch = original.ClusterPatch +type ClusterPatchProperties = original.ClusterPatchProperties type ClusterProperties = original.ClusterProperties type ClusterReportedProperties = original.ClusterReportedProperties -type ClusterUpdate = original.ClusterUpdate type ClustersClient = original.ClustersClient type ErrorAdditionalInfo = original.ErrorAdditionalInfo type ErrorDetail = original.ErrorDetail type ErrorResponse = original.ErrorResponse -type OperationDetail = original.OperationDetail +type Extension = original.Extension +type ExtensionList = original.ExtensionList +type ExtensionListIterator = original.ExtensionListIterator +type ExtensionListPage = original.ExtensionListPage +type ExtensionParameters = original.ExtensionParameters +type ExtensionProperties = original.ExtensionProperties +type ExtensionsClient = original.ExtensionsClient +type ExtensionsCreateFuture = original.ExtensionsCreateFuture +type ExtensionsDeleteFuture = original.ExtensionsDeleteFuture +type ExtensionsUpdateFuture = original.ExtensionsUpdateFuture +type Operation = original.Operation type OperationDisplay = original.OperationDisplay +type OperationListResult = original.OperationListResult type OperationsClient = original.OperationsClient +type PerNodeExtensionState = original.PerNodeExtensionState +type PerNodeState = original.PerNodeState type ProxyResource = original.ProxyResource type Resource = original.Resource +type SystemData = original.SystemData type TrackedResource = original.TrackedResource func New(subscriptionID string) BaseClient { return original.New(subscriptionID) } +func NewArcSettingListIterator(page ArcSettingListPage) ArcSettingListIterator { + return original.NewArcSettingListIterator(page) +} +func NewArcSettingListPage(cur ArcSettingList, getNextPage func(context.Context, ArcSettingList) (ArcSettingList, error)) ArcSettingListPage { + return original.NewArcSettingListPage(cur, getNextPage) +} +func NewArcSettingsClient(subscriptionID string) ArcSettingsClient { + return original.NewArcSettingsClient(subscriptionID) +} +func NewArcSettingsClientWithBaseURI(baseURI string, subscriptionID string) ArcSettingsClient { + return original.NewArcSettingsClientWithBaseURI(baseURI, subscriptionID) +} func NewClusterListIterator(page ClusterListPage) ClusterListIterator { return original.NewClusterListIterator(page) } @@ -75,6 +205,18 @@ func NewClustersClient(subscriptionID string) ClustersClient { func NewClustersClientWithBaseURI(baseURI string, subscriptionID string) ClustersClient { return original.NewClustersClientWithBaseURI(baseURI, subscriptionID) } +func NewExtensionListIterator(page ExtensionListPage) ExtensionListIterator { + return original.NewExtensionListIterator(page) +} +func NewExtensionListPage(cur ExtensionList, getNextPage func(context.Context, ExtensionList) (ExtensionList, error)) ExtensionListPage { + return original.NewExtensionListPage(cur, getNextPage) +} +func NewExtensionsClient(subscriptionID string) ExtensionsClient { + return original.NewExtensionsClient(subscriptionID) +} +func NewExtensionsClientWithBaseURI(baseURI string, subscriptionID string) ExtensionsClient { + return original.NewExtensionsClientWithBaseURI(baseURI, subscriptionID) +} func NewOperationsClient(subscriptionID string) OperationsClient { return original.NewOperationsClient(subscriptionID) } @@ -84,6 +226,27 @@ func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) Opera func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { return original.NewWithBaseURI(baseURI, subscriptionID) } +func PossibleActionTypeValues() []ActionType { + return original.PossibleActionTypeValues() +} +func PossibleArcSettingAggregateStateValues() []ArcSettingAggregateState { + return original.PossibleArcSettingAggregateStateValues() +} +func PossibleCreatedByTypeValues() []CreatedByType { + return original.PossibleCreatedByTypeValues() +} +func PossibleExtensionAggregateStateValues() []ExtensionAggregateState { + return original.PossibleExtensionAggregateStateValues() +} +func PossibleNodeArcStateValues() []NodeArcState { + return original.PossibleNodeArcStateValues() +} +func PossibleNodeExtensionStateValues() []NodeExtensionState { + return original.PossibleNodeExtensionStateValues() +} +func PossibleOriginValues() []Origin { + return original.PossibleOriginValues() +} func PossibleProvisioningStateValues() []ProvisioningState { return original.PossibleProvisioningStateValues() } diff --git a/profiles/preview/preview/hybridkubernetes/mgmt/hybridkubernetes/hybridkubernetesapi/models.go b/profiles/preview/preview/hybridkubernetes/mgmt/hybridkubernetes/hybridkubernetesapi/models.go index 887226d61c52..9336e234472d 100644 --- a/profiles/preview/preview/hybridkubernetes/mgmt/hybridkubernetes/hybridkubernetesapi/models.go +++ b/profiles/preview/preview/hybridkubernetes/mgmt/hybridkubernetes/hybridkubernetesapi/models.go @@ -8,7 +8,7 @@ package hybridkubernetesapi -import original "github.com/Azure/azure-sdk-for-go/services/preview/hybridkubernetes/mgmt/2020-01-01-preview/hybridkubernetes/hybridkubernetesapi" +import original "github.com/Azure/azure-sdk-for-go/services/preview/hybridkubernetes/mgmt/2021-04-01-preview/hybridkubernetes/hybridkubernetesapi" type ConnectedClusterClientAPI = original.ConnectedClusterClientAPI type OperationsClientAPI = original.OperationsClientAPI diff --git a/profiles/preview/preview/hybridkubernetes/mgmt/hybridkubernetes/models.go b/profiles/preview/preview/hybridkubernetes/mgmt/hybridkubernetes/models.go index a10c09c00389..e944856b1f95 100644 --- a/profiles/preview/preview/hybridkubernetes/mgmt/hybridkubernetes/models.go +++ b/profiles/preview/preview/hybridkubernetes/mgmt/hybridkubernetes/models.go @@ -11,47 +11,76 @@ package hybridkubernetes import ( "context" - original "github.com/Azure/azure-sdk-for-go/services/preview/hybridkubernetes/mgmt/2020-01-01-preview/hybridkubernetes" + original "github.com/Azure/azure-sdk-for-go/services/preview/hybridkubernetes/mgmt/2021-04-01-preview/hybridkubernetes" ) const ( DefaultBaseURI = original.DefaultBaseURI ) +type AuthenticationMethod = original.AuthenticationMethod + +const ( + AuthenticationMethodAAD AuthenticationMethod = original.AuthenticationMethodAAD + AuthenticationMethodToken AuthenticationMethod = original.AuthenticationMethodToken +) + type ConnectivityStatus = original.ConnectivityStatus const ( - Connected ConnectivityStatus = original.Connected - Connecting ConnectivityStatus = original.Connecting - Expired ConnectivityStatus = original.Expired - Offline ConnectivityStatus = original.Offline + ConnectivityStatusConnected ConnectivityStatus = original.ConnectivityStatusConnected + ConnectivityStatusConnecting ConnectivityStatus = original.ConnectivityStatusConnecting + ConnectivityStatusExpired ConnectivityStatus = original.ConnectivityStatusExpired + ConnectivityStatusOffline ConnectivityStatus = original.ConnectivityStatusOffline +) + +type CreatedByType = original.CreatedByType + +const ( + CreatedByTypeApplication CreatedByType = original.CreatedByTypeApplication + CreatedByTypeKey CreatedByType = original.CreatedByTypeKey + CreatedByTypeManagedIdentity CreatedByType = original.CreatedByTypeManagedIdentity + CreatedByTypeUser CreatedByType = original.CreatedByTypeUser +) + +type LastModifiedByType = original.LastModifiedByType + +const ( + LastModifiedByTypeApplication LastModifiedByType = original.LastModifiedByTypeApplication + LastModifiedByTypeKey LastModifiedByType = original.LastModifiedByTypeKey + LastModifiedByTypeManagedIdentity LastModifiedByType = original.LastModifiedByTypeManagedIdentity + LastModifiedByTypeUser LastModifiedByType = original.LastModifiedByTypeUser +) + +type PrivateLinkState = original.PrivateLinkState + +const ( + PrivateLinkStateDisabled PrivateLinkState = original.PrivateLinkStateDisabled + PrivateLinkStateEnabled PrivateLinkState = original.PrivateLinkStateEnabled ) type ProvisioningState = original.ProvisioningState const ( - Accepted ProvisioningState = original.Accepted - Canceled ProvisioningState = original.Canceled - Deleting ProvisioningState = original.Deleting - Failed ProvisioningState = original.Failed - Provisioning ProvisioningState = original.Provisioning - Succeeded ProvisioningState = original.Succeeded - Updating ProvisioningState = original.Updating + ProvisioningStateAccepted ProvisioningState = original.ProvisioningStateAccepted + ProvisioningStateCanceled ProvisioningState = original.ProvisioningStateCanceled + ProvisioningStateDeleting ProvisioningState = original.ProvisioningStateDeleting + ProvisioningStateFailed ProvisioningState = original.ProvisioningStateFailed + ProvisioningStateProvisioning ProvisioningState = original.ProvisioningStateProvisioning + ProvisioningStateSucceeded ProvisioningState = original.ProvisioningStateSucceeded + ProvisioningStateUpdating ProvisioningState = original.ProvisioningStateUpdating ) type ResourceIdentityType = original.ResourceIdentityType const ( - None ResourceIdentityType = original.None - SystemAssigned ResourceIdentityType = original.SystemAssigned + ResourceIdentityTypeNone ResourceIdentityType = original.ResourceIdentityTypeNone + ResourceIdentityTypeSystemAssigned ResourceIdentityType = original.ResourceIdentityTypeSystemAssigned ) -type AuthenticationDetails = original.AuthenticationDetails -type AuthenticationDetailsValue = original.AuthenticationDetailsValue type AzureEntityResource = original.AzureEntityResource type BaseClient = original.BaseClient type ConnectedCluster = original.ConnectedCluster -type ConnectedClusterAADProfile = original.ConnectedClusterAADProfile type ConnectedClusterClient = original.ConnectedClusterClient type ConnectedClusterCreateFuture = original.ConnectedClusterCreateFuture type ConnectedClusterDeleteFuture = original.ConnectedClusterDeleteFuture @@ -62,12 +91,14 @@ type ConnectedClusterListPage = original.ConnectedClusterListPage type ConnectedClusterPatch = original.ConnectedClusterPatch type ConnectedClusterPatchProperties = original.ConnectedClusterPatchProperties type ConnectedClusterProperties = original.ConnectedClusterProperties +type ConnectedClusterUpdateFuture = original.ConnectedClusterUpdateFuture type CredentialResult = original.CredentialResult type CredentialResults = original.CredentialResults type ErrorAdditionalInfo = original.ErrorAdditionalInfo type ErrorDetail = original.ErrorDetail type ErrorResponse = original.ErrorResponse type HybridConnectionConfig = original.HybridConnectionConfig +type ListClusterUserCredentialsProperties = original.ListClusterUserCredentialsProperties type Operation = original.Operation type OperationDisplay = original.OperationDisplay type OperationList = original.OperationList @@ -76,6 +107,7 @@ type OperationListPage = original.OperationListPage type OperationsClient = original.OperationsClient type ProxyResource = original.ProxyResource type Resource = original.Resource +type SystemData = original.SystemData type TrackedResource = original.TrackedResource func New(subscriptionID string) BaseClient { @@ -108,9 +140,21 @@ func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) Opera func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { return original.NewWithBaseURI(baseURI, subscriptionID) } +func PossibleAuthenticationMethodValues() []AuthenticationMethod { + return original.PossibleAuthenticationMethodValues() +} func PossibleConnectivityStatusValues() []ConnectivityStatus { return original.PossibleConnectivityStatusValues() } +func PossibleCreatedByTypeValues() []CreatedByType { + return original.PossibleCreatedByTypeValues() +} +func PossibleLastModifiedByTypeValues() []LastModifiedByType { + return original.PossibleLastModifiedByTypeValues() +} +func PossiblePrivateLinkStateValues() []PrivateLinkState { + return original.PossiblePrivateLinkStateValues() +} func PossibleProvisioningStateValues() []ProvisioningState { return original.PossibleProvisioningStateValues() } diff --git a/profiles/preview/preview/monitor/mgmt/insights/insightsapi/models.go b/profiles/preview/preview/monitor/mgmt/insights/insightsapi/models.go index e6203dc3d7c7..9de55e074dae 100644 --- a/profiles/preview/preview/monitor/mgmt/insights/insightsapi/models.go +++ b/profiles/preview/preview/monitor/mgmt/insights/insightsapi/models.go @@ -8,7 +8,7 @@ package insightsapi -import original "github.com/Azure/azure-sdk-for-go/services/preview/monitor/mgmt/2019-11-01-preview/insights/insightsapi" +import original "github.com/Azure/azure-sdk-for-go/services/preview/monitor/mgmt/2021-04-01-preview/insights/insightsapi" type ActionGroupsClientAPI = original.ActionGroupsClientAPI type ActivityLogAlertsClientAPI = original.ActivityLogAlertsClientAPI @@ -17,13 +17,15 @@ type AlertRuleIncidentsClientAPI = original.AlertRuleIncidentsClientAPI type AlertRulesClientAPI = original.AlertRulesClientAPI type AutoscaleSettingsClientAPI = original.AutoscaleSettingsClientAPI type BaselinesClientAPI = original.BaselinesClientAPI +type DataCollectionEndpointsClientAPI = original.DataCollectionEndpointsClientAPI +type DataCollectionRuleAssociationsClientAPI = original.DataCollectionRuleAssociationsClientAPI +type DataCollectionRulesClientAPI = original.DataCollectionRulesClientAPI type DiagnosticSettingsCategoryClientAPI = original.DiagnosticSettingsCategoryClientAPI type DiagnosticSettingsClientAPI = original.DiagnosticSettingsClientAPI type EventCategoriesClientAPI = original.EventCategoriesClientAPI type LogProfilesClientAPI = original.LogProfilesClientAPI type MetricAlertsClientAPI = original.MetricAlertsClientAPI type MetricAlertsStatusClientAPI = original.MetricAlertsStatusClientAPI -type MetricBaselineClientAPI = original.MetricBaselineClientAPI type MetricDefinitionsClientAPI = original.MetricDefinitionsClientAPI type MetricNamespacesClientAPI = original.MetricNamespacesClientAPI type MetricsClientAPI = original.MetricsClientAPI @@ -34,6 +36,5 @@ type PrivateLinkScopeOperationStatusClientAPI = original.PrivateLinkScopeOperati type PrivateLinkScopedResourcesClientAPI = original.PrivateLinkScopedResourcesClientAPI type PrivateLinkScopesClientAPI = original.PrivateLinkScopesClientAPI type ScheduledQueryRulesClientAPI = original.ScheduledQueryRulesClientAPI -type SubscriptionDiagnosticSettingsClientAPI = original.SubscriptionDiagnosticSettingsClientAPI type TenantActivityLogsClientAPI = original.TenantActivityLogsClientAPI type VMInsightsClientAPI = original.VMInsightsClientAPI diff --git a/profiles/preview/preview/monitor/mgmt/insights/models.go b/profiles/preview/preview/monitor/mgmt/insights/models.go index 50a44ceb2d72..1802f7d92873 100644 --- a/profiles/preview/preview/monitor/mgmt/insights/models.go +++ b/profiles/preview/preview/monitor/mgmt/insights/models.go @@ -11,7 +11,7 @@ package insights import ( "context" - original "github.com/Azure/azure-sdk-for-go/services/preview/monitor/mgmt/2019-11-01-preview/insights" + original "github.com/Azure/azure-sdk-for-go/services/preview/monitor/mgmt/2021-04-01-preview/insights" ) const ( @@ -21,48 +21,58 @@ const ( type AggregationType = original.AggregationType const ( - Average AggregationType = original.Average - Count AggregationType = original.Count - Maximum AggregationType = original.Maximum - Minimum AggregationType = original.Minimum - None AggregationType = original.None - Total AggregationType = original.Total + AggregationTypeAverage AggregationType = original.AggregationTypeAverage + AggregationTypeCount AggregationType = original.AggregationTypeCount + AggregationTypeMaximum AggregationType = original.AggregationTypeMaximum + AggregationTypeMinimum AggregationType = original.AggregationTypeMinimum + AggregationTypeNone AggregationType = original.AggregationTypeNone + AggregationTypeTotal AggregationType = original.AggregationTypeTotal +) + +type AggregationTypeEnum = original.AggregationTypeEnum + +const ( + AggregationTypeEnumAverage AggregationTypeEnum = original.AggregationTypeEnumAverage + AggregationTypeEnumCount AggregationTypeEnum = original.AggregationTypeEnumCount + AggregationTypeEnumMaximum AggregationTypeEnum = original.AggregationTypeEnumMaximum + AggregationTypeEnumMinimum AggregationTypeEnum = original.AggregationTypeEnumMinimum + AggregationTypeEnumTotal AggregationTypeEnum = original.AggregationTypeEnumTotal ) type AlertSeverity = original.AlertSeverity const ( - Four AlertSeverity = original.Four - One AlertSeverity = original.One - Three AlertSeverity = original.Three - Two AlertSeverity = original.Two - Zero AlertSeverity = original.Zero + AlertSeverityFour AlertSeverity = original.AlertSeverityFour + AlertSeverityOne AlertSeverity = original.AlertSeverityOne + AlertSeverityThree AlertSeverity = original.AlertSeverityThree + AlertSeverityTwo AlertSeverity = original.AlertSeverityTwo + AlertSeverityZero AlertSeverity = original.AlertSeverityZero ) type BaselineSensitivity = original.BaselineSensitivity const ( - High BaselineSensitivity = original.High - Low BaselineSensitivity = original.Low - Medium BaselineSensitivity = original.Medium + BaselineSensitivityHigh BaselineSensitivity = original.BaselineSensitivityHigh + BaselineSensitivityLow BaselineSensitivity = original.BaselineSensitivityLow + BaselineSensitivityMedium BaselineSensitivity = original.BaselineSensitivityMedium ) type CategoryType = original.CategoryType const ( - Logs CategoryType = original.Logs - Metrics CategoryType = original.Metrics + CategoryTypeLogs CategoryType = original.CategoryTypeLogs + CategoryTypeMetrics CategoryType = original.CategoryTypeMetrics ) type ComparisonOperationType = original.ComparisonOperationType const ( - Equals ComparisonOperationType = original.Equals - GreaterThan ComparisonOperationType = original.GreaterThan - GreaterThanOrEqual ComparisonOperationType = original.GreaterThanOrEqual - LessThan ComparisonOperationType = original.LessThan - LessThanOrEqual ComparisonOperationType = original.LessThanOrEqual - NotEquals ComparisonOperationType = original.NotEquals + ComparisonOperationTypeEquals ComparisonOperationType = original.ComparisonOperationTypeEquals + ComparisonOperationTypeGreaterThan ComparisonOperationType = original.ComparisonOperationTypeGreaterThan + ComparisonOperationTypeGreaterThanOrEqual ComparisonOperationType = original.ComparisonOperationTypeGreaterThanOrEqual + ComparisonOperationTypeLessThan ComparisonOperationType = original.ComparisonOperationTypeLessThan + ComparisonOperationTypeLessThanOrEqual ComparisonOperationType = original.ComparisonOperationTypeLessThanOrEqual + ComparisonOperationTypeNotEquals ComparisonOperationType = original.ComparisonOperationTypeNotEquals ) type ConditionOperator = original.ConditionOperator @@ -77,9 +87,20 @@ const ( type ConditionalOperator = original.ConditionalOperator const ( - ConditionalOperatorEqual ConditionalOperator = original.ConditionalOperatorEqual - ConditionalOperatorGreaterThan ConditionalOperator = original.ConditionalOperatorGreaterThan - ConditionalOperatorLessThan ConditionalOperator = original.ConditionalOperatorLessThan + ConditionalOperatorEqual ConditionalOperator = original.ConditionalOperatorEqual + ConditionalOperatorGreaterThan ConditionalOperator = original.ConditionalOperatorGreaterThan + ConditionalOperatorGreaterThanOrEqual ConditionalOperator = original.ConditionalOperatorGreaterThanOrEqual + ConditionalOperatorLessThan ConditionalOperator = original.ConditionalOperatorLessThan + ConditionalOperatorLessThanOrEqual ConditionalOperator = original.ConditionalOperatorLessThanOrEqual +) + +type CreatedByType = original.CreatedByType + +const ( + CreatedByTypeApplication CreatedByType = original.CreatedByTypeApplication + CreatedByTypeKey CreatedByType = original.CreatedByTypeKey + CreatedByTypeManagedIdentity CreatedByType = original.CreatedByTypeManagedIdentity + CreatedByTypeUser CreatedByType = original.CreatedByTypeUser ) type CriterionType = original.CriterionType @@ -93,8 +114,8 @@ const ( type DataStatus = original.DataStatus const ( - NotPresent DataStatus = original.NotPresent - Present DataStatus = original.Present + DataStatusNotPresent DataStatus = original.DataStatusNotPresent + DataStatusPresent DataStatus = original.DataStatusPresent ) type DynamicThresholdOperator = original.DynamicThresholdOperator @@ -116,8 +137,8 @@ const ( type Enabled = original.Enabled const ( - False Enabled = original.False - True Enabled = original.True + EnabledFalse Enabled = original.EnabledFalse + EnabledTrue Enabled = original.EnabledTrue ) type EventLevel = original.EventLevel @@ -130,6 +151,147 @@ const ( EventLevelWarning EventLevel = original.EventLevelWarning ) +type KnownDataCollectionEndpointProvisioningState = original.KnownDataCollectionEndpointProvisioningState + +const ( + KnownDataCollectionEndpointProvisioningStateCreating KnownDataCollectionEndpointProvisioningState = original.KnownDataCollectionEndpointProvisioningStateCreating + KnownDataCollectionEndpointProvisioningStateDeleting KnownDataCollectionEndpointProvisioningState = original.KnownDataCollectionEndpointProvisioningStateDeleting + KnownDataCollectionEndpointProvisioningStateFailed KnownDataCollectionEndpointProvisioningState = original.KnownDataCollectionEndpointProvisioningStateFailed + KnownDataCollectionEndpointProvisioningStateSucceeded KnownDataCollectionEndpointProvisioningState = original.KnownDataCollectionEndpointProvisioningStateSucceeded + KnownDataCollectionEndpointProvisioningStateUpdating KnownDataCollectionEndpointProvisioningState = original.KnownDataCollectionEndpointProvisioningStateUpdating +) + +type KnownDataCollectionEndpointResourceKind = original.KnownDataCollectionEndpointResourceKind + +const ( + KnownDataCollectionEndpointResourceKindLinux KnownDataCollectionEndpointResourceKind = original.KnownDataCollectionEndpointResourceKindLinux + KnownDataCollectionEndpointResourceKindWindows KnownDataCollectionEndpointResourceKind = original.KnownDataCollectionEndpointResourceKindWindows +) + +type KnownDataCollectionRuleAssociationProvisioningState = original.KnownDataCollectionRuleAssociationProvisioningState + +const ( + KnownDataCollectionRuleAssociationProvisioningStateCreating KnownDataCollectionRuleAssociationProvisioningState = original.KnownDataCollectionRuleAssociationProvisioningStateCreating + KnownDataCollectionRuleAssociationProvisioningStateDeleting KnownDataCollectionRuleAssociationProvisioningState = original.KnownDataCollectionRuleAssociationProvisioningStateDeleting + KnownDataCollectionRuleAssociationProvisioningStateFailed KnownDataCollectionRuleAssociationProvisioningState = original.KnownDataCollectionRuleAssociationProvisioningStateFailed + KnownDataCollectionRuleAssociationProvisioningStateSucceeded KnownDataCollectionRuleAssociationProvisioningState = original.KnownDataCollectionRuleAssociationProvisioningStateSucceeded + KnownDataCollectionRuleAssociationProvisioningStateUpdating KnownDataCollectionRuleAssociationProvisioningState = original.KnownDataCollectionRuleAssociationProvisioningStateUpdating +) + +type KnownDataCollectionRuleProvisioningState = original.KnownDataCollectionRuleProvisioningState + +const ( + KnownDataCollectionRuleProvisioningStateCreating KnownDataCollectionRuleProvisioningState = original.KnownDataCollectionRuleProvisioningStateCreating + KnownDataCollectionRuleProvisioningStateDeleting KnownDataCollectionRuleProvisioningState = original.KnownDataCollectionRuleProvisioningStateDeleting + KnownDataCollectionRuleProvisioningStateFailed KnownDataCollectionRuleProvisioningState = original.KnownDataCollectionRuleProvisioningStateFailed + KnownDataCollectionRuleProvisioningStateSucceeded KnownDataCollectionRuleProvisioningState = original.KnownDataCollectionRuleProvisioningStateSucceeded + KnownDataCollectionRuleProvisioningStateUpdating KnownDataCollectionRuleProvisioningState = original.KnownDataCollectionRuleProvisioningStateUpdating +) + +type KnownDataCollectionRuleResourceKind = original.KnownDataCollectionRuleResourceKind + +const ( + KnownDataCollectionRuleResourceKindLinux KnownDataCollectionRuleResourceKind = original.KnownDataCollectionRuleResourceKindLinux + KnownDataCollectionRuleResourceKindWindows KnownDataCollectionRuleResourceKind = original.KnownDataCollectionRuleResourceKindWindows +) + +type KnownDataFlowStreams = original.KnownDataFlowStreams + +const ( + KnownDataFlowStreamsMicrosoftEvent KnownDataFlowStreams = original.KnownDataFlowStreamsMicrosoftEvent + KnownDataFlowStreamsMicrosoftInsightsMetrics KnownDataFlowStreams = original.KnownDataFlowStreamsMicrosoftInsightsMetrics + KnownDataFlowStreamsMicrosoftPerf KnownDataFlowStreams = original.KnownDataFlowStreamsMicrosoftPerf + KnownDataFlowStreamsMicrosoftSyslog KnownDataFlowStreams = original.KnownDataFlowStreamsMicrosoftSyslog + KnownDataFlowStreamsMicrosoftWindowsEvent KnownDataFlowStreams = original.KnownDataFlowStreamsMicrosoftWindowsEvent +) + +type KnownExtensionDataSourceStreams = original.KnownExtensionDataSourceStreams + +const ( + KnownExtensionDataSourceStreamsMicrosoftEvent KnownExtensionDataSourceStreams = original.KnownExtensionDataSourceStreamsMicrosoftEvent + KnownExtensionDataSourceStreamsMicrosoftInsightsMetrics KnownExtensionDataSourceStreams = original.KnownExtensionDataSourceStreamsMicrosoftInsightsMetrics + KnownExtensionDataSourceStreamsMicrosoftPerf KnownExtensionDataSourceStreams = original.KnownExtensionDataSourceStreamsMicrosoftPerf + KnownExtensionDataSourceStreamsMicrosoftSyslog KnownExtensionDataSourceStreams = original.KnownExtensionDataSourceStreamsMicrosoftSyslog + KnownExtensionDataSourceStreamsMicrosoftWindowsEvent KnownExtensionDataSourceStreams = original.KnownExtensionDataSourceStreamsMicrosoftWindowsEvent +) + +type KnownPerfCounterDataSourceStreams = original.KnownPerfCounterDataSourceStreams + +const ( + KnownPerfCounterDataSourceStreamsMicrosoftInsightsMetrics KnownPerfCounterDataSourceStreams = original.KnownPerfCounterDataSourceStreamsMicrosoftInsightsMetrics + KnownPerfCounterDataSourceStreamsMicrosoftPerf KnownPerfCounterDataSourceStreams = original.KnownPerfCounterDataSourceStreamsMicrosoftPerf +) + +type KnownPublicNetworkAccessOptions = original.KnownPublicNetworkAccessOptions + +const ( + KnownPublicNetworkAccessOptionsDisabled KnownPublicNetworkAccessOptions = original.KnownPublicNetworkAccessOptionsDisabled + KnownPublicNetworkAccessOptionsEnabled KnownPublicNetworkAccessOptions = original.KnownPublicNetworkAccessOptionsEnabled +) + +type KnownSyslogDataSourceFacilityNames = original.KnownSyslogDataSourceFacilityNames + +const ( + KnownSyslogDataSourceFacilityNamesAsterisk KnownSyslogDataSourceFacilityNames = original.KnownSyslogDataSourceFacilityNamesAsterisk + KnownSyslogDataSourceFacilityNamesAuth KnownSyslogDataSourceFacilityNames = original.KnownSyslogDataSourceFacilityNamesAuth + KnownSyslogDataSourceFacilityNamesAuthpriv KnownSyslogDataSourceFacilityNames = original.KnownSyslogDataSourceFacilityNamesAuthpriv + KnownSyslogDataSourceFacilityNamesCron KnownSyslogDataSourceFacilityNames = original.KnownSyslogDataSourceFacilityNamesCron + KnownSyslogDataSourceFacilityNamesDaemon KnownSyslogDataSourceFacilityNames = original.KnownSyslogDataSourceFacilityNamesDaemon + KnownSyslogDataSourceFacilityNamesKern KnownSyslogDataSourceFacilityNames = original.KnownSyslogDataSourceFacilityNamesKern + KnownSyslogDataSourceFacilityNamesLocal0 KnownSyslogDataSourceFacilityNames = original.KnownSyslogDataSourceFacilityNamesLocal0 + KnownSyslogDataSourceFacilityNamesLocal1 KnownSyslogDataSourceFacilityNames = original.KnownSyslogDataSourceFacilityNamesLocal1 + KnownSyslogDataSourceFacilityNamesLocal2 KnownSyslogDataSourceFacilityNames = original.KnownSyslogDataSourceFacilityNamesLocal2 + KnownSyslogDataSourceFacilityNamesLocal3 KnownSyslogDataSourceFacilityNames = original.KnownSyslogDataSourceFacilityNamesLocal3 + KnownSyslogDataSourceFacilityNamesLocal4 KnownSyslogDataSourceFacilityNames = original.KnownSyslogDataSourceFacilityNamesLocal4 + KnownSyslogDataSourceFacilityNamesLocal5 KnownSyslogDataSourceFacilityNames = original.KnownSyslogDataSourceFacilityNamesLocal5 + KnownSyslogDataSourceFacilityNamesLocal6 KnownSyslogDataSourceFacilityNames = original.KnownSyslogDataSourceFacilityNamesLocal6 + KnownSyslogDataSourceFacilityNamesLocal7 KnownSyslogDataSourceFacilityNames = original.KnownSyslogDataSourceFacilityNamesLocal7 + KnownSyslogDataSourceFacilityNamesLpr KnownSyslogDataSourceFacilityNames = original.KnownSyslogDataSourceFacilityNamesLpr + KnownSyslogDataSourceFacilityNamesMail KnownSyslogDataSourceFacilityNames = original.KnownSyslogDataSourceFacilityNamesMail + KnownSyslogDataSourceFacilityNamesMark KnownSyslogDataSourceFacilityNames = original.KnownSyslogDataSourceFacilityNamesMark + KnownSyslogDataSourceFacilityNamesNews KnownSyslogDataSourceFacilityNames = original.KnownSyslogDataSourceFacilityNamesNews + KnownSyslogDataSourceFacilityNamesSyslog KnownSyslogDataSourceFacilityNames = original.KnownSyslogDataSourceFacilityNamesSyslog + KnownSyslogDataSourceFacilityNamesUser KnownSyslogDataSourceFacilityNames = original.KnownSyslogDataSourceFacilityNamesUser + KnownSyslogDataSourceFacilityNamesUucp KnownSyslogDataSourceFacilityNames = original.KnownSyslogDataSourceFacilityNamesUucp +) + +type KnownSyslogDataSourceLogLevels = original.KnownSyslogDataSourceLogLevels + +const ( + KnownSyslogDataSourceLogLevelsAlert KnownSyslogDataSourceLogLevels = original.KnownSyslogDataSourceLogLevelsAlert + KnownSyslogDataSourceLogLevelsAsterisk KnownSyslogDataSourceLogLevels = original.KnownSyslogDataSourceLogLevelsAsterisk + KnownSyslogDataSourceLogLevelsCritical KnownSyslogDataSourceLogLevels = original.KnownSyslogDataSourceLogLevelsCritical + KnownSyslogDataSourceLogLevelsDebug KnownSyslogDataSourceLogLevels = original.KnownSyslogDataSourceLogLevelsDebug + KnownSyslogDataSourceLogLevelsEmergency KnownSyslogDataSourceLogLevels = original.KnownSyslogDataSourceLogLevelsEmergency + KnownSyslogDataSourceLogLevelsError KnownSyslogDataSourceLogLevels = original.KnownSyslogDataSourceLogLevelsError + KnownSyslogDataSourceLogLevelsInfo KnownSyslogDataSourceLogLevels = original.KnownSyslogDataSourceLogLevelsInfo + KnownSyslogDataSourceLogLevelsNotice KnownSyslogDataSourceLogLevels = original.KnownSyslogDataSourceLogLevelsNotice + KnownSyslogDataSourceLogLevelsWarning KnownSyslogDataSourceLogLevels = original.KnownSyslogDataSourceLogLevelsWarning +) + +type KnownSyslogDataSourceStreams = original.KnownSyslogDataSourceStreams + +const ( + KnownSyslogDataSourceStreamsMicrosoftSyslog KnownSyslogDataSourceStreams = original.KnownSyslogDataSourceStreamsMicrosoftSyslog +) + +type KnownWindowsEventLogDataSourceStreams = original.KnownWindowsEventLogDataSourceStreams + +const ( + KnownWindowsEventLogDataSourceStreamsMicrosoftEvent KnownWindowsEventLogDataSourceStreams = original.KnownWindowsEventLogDataSourceStreamsMicrosoftEvent + KnownWindowsEventLogDataSourceStreamsMicrosoftWindowsEvent KnownWindowsEventLogDataSourceStreams = original.KnownWindowsEventLogDataSourceStreamsMicrosoftWindowsEvent +) + +type MetricClass = original.MetricClass + +const ( + MetricClassAvailability MetricClass = original.MetricClassAvailability + MetricClassErrors MetricClass = original.MetricClassErrors + MetricClassLatency MetricClass = original.MetricClassLatency + MetricClassSaturation MetricClass = original.MetricClassSaturation + MetricClassTransactions MetricClass = original.MetricClassTransactions +) + type MetricStatisticType = original.MetricStatisticType const ( @@ -146,6 +308,32 @@ const ( MetricTriggerTypeTotal MetricTriggerType = original.MetricTriggerTypeTotal ) +type MetricUnit = original.MetricUnit + +const ( + MetricUnitBitsPerSecond MetricUnit = original.MetricUnitBitsPerSecond + MetricUnitBytes MetricUnit = original.MetricUnitBytes + MetricUnitByteSeconds MetricUnit = original.MetricUnitByteSeconds + MetricUnitBytesPerSecond MetricUnit = original.MetricUnitBytesPerSecond + MetricUnitCores MetricUnit = original.MetricUnitCores + MetricUnitCount MetricUnit = original.MetricUnitCount + MetricUnitCountPerSecond MetricUnit = original.MetricUnitCountPerSecond + MetricUnitMilliCores MetricUnit = original.MetricUnitMilliCores + MetricUnitMilliSeconds MetricUnit = original.MetricUnitMilliSeconds + MetricUnitNanoCores MetricUnit = original.MetricUnitNanoCores + MetricUnitPercent MetricUnit = original.MetricUnitPercent + MetricUnitSeconds MetricUnit = original.MetricUnitSeconds + MetricUnitUnspecified MetricUnit = original.MetricUnitUnspecified +) + +type NamespaceClassification = original.NamespaceClassification + +const ( + NamespaceClassificationCustom NamespaceClassification = original.NamespaceClassificationCustom + NamespaceClassificationPlatform NamespaceClassification = original.NamespaceClassificationPlatform + NamespaceClassificationQos NamespaceClassification = original.NamespaceClassificationQos +) + type OdataType = original.OdataType const ( @@ -157,43 +345,43 @@ const ( type OdataTypeBasicAction = original.OdataTypeBasicAction const ( - OdataTypeAction OdataTypeBasicAction = original.OdataTypeAction - OdataTypeMicrosoftWindowsAzureManagementMonitoringAlertsModelsMicrosoftAppInsightsNexusDataContractsResourcesScheduledQueryRulesAlertingAction OdataTypeBasicAction = original.OdataTypeMicrosoftWindowsAzureManagementMonitoringAlertsModelsMicrosoftAppInsightsNexusDataContractsResourcesScheduledQueryRulesAlertingAction - OdataTypeMicrosoftWindowsAzureManagementMonitoringAlertsModelsMicrosoftAppInsightsNexusDataContractsResourcesScheduledQueryRulesLogToMetricAction OdataTypeBasicAction = original.OdataTypeMicrosoftWindowsAzureManagementMonitoringAlertsModelsMicrosoftAppInsightsNexusDataContractsResourcesScheduledQueryRulesLogToMetricAction + OdataTypeBasicActionOdataTypeAction OdataTypeBasicAction = original.OdataTypeBasicActionOdataTypeAction + OdataTypeBasicActionOdataTypeMicrosoftWindowsAzureManagementMonitoringAlertsModelsMicrosoftAppInsightsNexusDataContractsResourcesScheduledQueryRulesAlertingAction OdataTypeBasicAction = original.OdataTypeBasicActionOdataTypeMicrosoftWindowsAzureManagementMonitoringAlertsModelsMicrosoftAppInsightsNexusDataContractsResourcesScheduledQueryRulesAlertingAction + OdataTypeBasicActionOdataTypeMicrosoftWindowsAzureManagementMonitoringAlertsModelsMicrosoftAppInsightsNexusDataContractsResourcesScheduledQueryRulesLogToMetricAction OdataTypeBasicAction = original.OdataTypeBasicActionOdataTypeMicrosoftWindowsAzureManagementMonitoringAlertsModelsMicrosoftAppInsightsNexusDataContractsResourcesScheduledQueryRulesLogToMetricAction ) type OdataTypeBasicMetricAlertCriteria = original.OdataTypeBasicMetricAlertCriteria const ( - OdataTypeMetricAlertCriteria OdataTypeBasicMetricAlertCriteria = original.OdataTypeMetricAlertCriteria - OdataTypeMicrosoftAzureMonitorMultipleResourceMultipleMetricCriteria OdataTypeBasicMetricAlertCriteria = original.OdataTypeMicrosoftAzureMonitorMultipleResourceMultipleMetricCriteria - OdataTypeMicrosoftAzureMonitorSingleResourceMultipleMetricCriteria OdataTypeBasicMetricAlertCriteria = original.OdataTypeMicrosoftAzureMonitorSingleResourceMultipleMetricCriteria - OdataTypeMicrosoftAzureMonitorWebtestLocationAvailabilityCriteria OdataTypeBasicMetricAlertCriteria = original.OdataTypeMicrosoftAzureMonitorWebtestLocationAvailabilityCriteria + OdataTypeBasicMetricAlertCriteriaOdataTypeMetricAlertCriteria OdataTypeBasicMetricAlertCriteria = original.OdataTypeBasicMetricAlertCriteriaOdataTypeMetricAlertCriteria + OdataTypeBasicMetricAlertCriteriaOdataTypeMicrosoftAzureMonitorMultipleResourceMultipleMetricCriteria OdataTypeBasicMetricAlertCriteria = original.OdataTypeBasicMetricAlertCriteriaOdataTypeMicrosoftAzureMonitorMultipleResourceMultipleMetricCriteria + OdataTypeBasicMetricAlertCriteriaOdataTypeMicrosoftAzureMonitorSingleResourceMultipleMetricCriteria OdataTypeBasicMetricAlertCriteria = original.OdataTypeBasicMetricAlertCriteriaOdataTypeMicrosoftAzureMonitorSingleResourceMultipleMetricCriteria + OdataTypeBasicMetricAlertCriteriaOdataTypeMicrosoftAzureMonitorWebtestLocationAvailabilityCriteria OdataTypeBasicMetricAlertCriteria = original.OdataTypeBasicMetricAlertCriteriaOdataTypeMicrosoftAzureMonitorWebtestLocationAvailabilityCriteria ) type OdataTypeBasicRuleAction = original.OdataTypeBasicRuleAction const ( - OdataTypeMicrosoftAzureManagementInsightsModelsRuleEmailAction OdataTypeBasicRuleAction = original.OdataTypeMicrosoftAzureManagementInsightsModelsRuleEmailAction - OdataTypeMicrosoftAzureManagementInsightsModelsRuleWebhookAction OdataTypeBasicRuleAction = original.OdataTypeMicrosoftAzureManagementInsightsModelsRuleWebhookAction - OdataTypeRuleAction OdataTypeBasicRuleAction = original.OdataTypeRuleAction + OdataTypeBasicRuleActionOdataTypeMicrosoftAzureManagementInsightsModelsRuleEmailAction OdataTypeBasicRuleAction = original.OdataTypeBasicRuleActionOdataTypeMicrosoftAzureManagementInsightsModelsRuleEmailAction + OdataTypeBasicRuleActionOdataTypeMicrosoftAzureManagementInsightsModelsRuleWebhookAction OdataTypeBasicRuleAction = original.OdataTypeBasicRuleActionOdataTypeMicrosoftAzureManagementInsightsModelsRuleWebhookAction + OdataTypeBasicRuleActionOdataTypeRuleAction OdataTypeBasicRuleAction = original.OdataTypeBasicRuleActionOdataTypeRuleAction ) type OdataTypeBasicRuleCondition = original.OdataTypeBasicRuleCondition const ( - OdataTypeMicrosoftAzureManagementInsightsModelsLocationThresholdRuleCondition OdataTypeBasicRuleCondition = original.OdataTypeMicrosoftAzureManagementInsightsModelsLocationThresholdRuleCondition - OdataTypeMicrosoftAzureManagementInsightsModelsManagementEventRuleCondition OdataTypeBasicRuleCondition = original.OdataTypeMicrosoftAzureManagementInsightsModelsManagementEventRuleCondition - OdataTypeMicrosoftAzureManagementInsightsModelsThresholdRuleCondition OdataTypeBasicRuleCondition = original.OdataTypeMicrosoftAzureManagementInsightsModelsThresholdRuleCondition - OdataTypeRuleCondition OdataTypeBasicRuleCondition = original.OdataTypeRuleCondition + OdataTypeBasicRuleConditionOdataTypeMicrosoftAzureManagementInsightsModelsLocationThresholdRuleCondition OdataTypeBasicRuleCondition = original.OdataTypeBasicRuleConditionOdataTypeMicrosoftAzureManagementInsightsModelsLocationThresholdRuleCondition + OdataTypeBasicRuleConditionOdataTypeMicrosoftAzureManagementInsightsModelsManagementEventRuleCondition OdataTypeBasicRuleCondition = original.OdataTypeBasicRuleConditionOdataTypeMicrosoftAzureManagementInsightsModelsManagementEventRuleCondition + OdataTypeBasicRuleConditionOdataTypeMicrosoftAzureManagementInsightsModelsThresholdRuleCondition OdataTypeBasicRuleCondition = original.OdataTypeBasicRuleConditionOdataTypeMicrosoftAzureManagementInsightsModelsThresholdRuleCondition + OdataTypeBasicRuleConditionOdataTypeRuleCondition OdataTypeBasicRuleCondition = original.OdataTypeBasicRuleConditionOdataTypeRuleCondition ) type OnboardingStatus = original.OnboardingStatus const ( - NotOnboarded OnboardingStatus = original.NotOnboarded - Onboarded OnboardingStatus = original.Onboarded - Unknown OnboardingStatus = original.Unknown + OnboardingStatusNotOnboarded OnboardingStatus = original.OnboardingStatusNotOnboarded + OnboardingStatusOnboarded OnboardingStatus = original.OnboardingStatusOnboarded + OnboardingStatusUnknown OnboardingStatus = original.OnboardingStatusUnknown ) type Operator = original.Operator @@ -210,16 +398,16 @@ const ( type ProvisioningState = original.ProvisioningState const ( - Canceled ProvisioningState = original.Canceled - Deploying ProvisioningState = original.Deploying - Failed ProvisioningState = original.Failed - Succeeded ProvisioningState = original.Succeeded + ProvisioningStateCanceled ProvisioningState = original.ProvisioningStateCanceled + ProvisioningStateDeploying ProvisioningState = original.ProvisioningStateDeploying + ProvisioningStateFailed ProvisioningState = original.ProvisioningStateFailed + ProvisioningStateSucceeded ProvisioningState = original.ProvisioningStateSucceeded ) type QueryType = original.QueryType const ( - ResultCount QueryType = original.ResultCount + QueryTypeResultCount QueryType = original.QueryTypeResultCount ) type ReceiverStatus = original.ReceiverStatus @@ -246,8 +434,8 @@ const ( type ResultType = original.ResultType const ( - Data ResultType = original.Data - Metadata ResultType = original.Metadata + ResultTypeData ResultType = original.ResultTypeData + ResultTypeMetadata ResultType = original.ResultTypeMetadata ) type ScaleDirection = original.ScaleDirection @@ -268,17 +456,9 @@ const ( type ScaleType = original.ScaleType const ( - ChangeCount ScaleType = original.ChangeCount - ExactCount ScaleType = original.ExactCount - PercentChangeCount ScaleType = original.PercentChangeCount -) - -type Sensitivity = original.Sensitivity - -const ( - SensitivityHigh Sensitivity = original.SensitivityHigh - SensitivityLow Sensitivity = original.SensitivityLow - SensitivityMedium Sensitivity = original.SensitivityMedium + ScaleTypeChangeCount ScaleType = original.ScaleTypeChangeCount + ScaleTypeExactCount ScaleType = original.ScaleTypeExactCount + ScaleTypePercentChangeCount ScaleType = original.ScaleTypePercentChangeCount ) type TimeAggregationOperator = original.TimeAggregationOperator @@ -302,24 +482,6 @@ const ( TimeAggregationTypeTotal TimeAggregationType = original.TimeAggregationTypeTotal ) -type Unit = original.Unit - -const ( - UnitBitsPerSecond Unit = original.UnitBitsPerSecond - UnitBytes Unit = original.UnitBytes - UnitByteSeconds Unit = original.UnitByteSeconds - UnitBytesPerSecond Unit = original.UnitBytesPerSecond - UnitCores Unit = original.UnitCores - UnitCount Unit = original.UnitCount - UnitCountPerSecond Unit = original.UnitCountPerSecond - UnitMilliCores Unit = original.UnitMilliCores - UnitMilliSeconds Unit = original.UnitMilliSeconds - UnitNanoCores Unit = original.UnitNanoCores - UnitPercent Unit = original.UnitPercent - UnitSeconds Unit = original.UnitSeconds - UnitUnspecified Unit = original.UnitUnspecified -) - type Action = original.Action type ActionGroup = original.ActionGroup type ActionGroupList = original.ActionGroupList @@ -359,17 +521,15 @@ type AutoscaleSettingsClient = original.AutoscaleSettingsClient type AzNsActionGroup = original.AzNsActionGroup type AzureAppPushReceiver = original.AzureAppPushReceiver type AzureFunctionReceiver = original.AzureFunctionReceiver +type AzureMonitorMetricsDestination = original.AzureMonitorMetricsDestination type AzureMonitorPrivateLinkScope = original.AzureMonitorPrivateLinkScope type AzureMonitorPrivateLinkScopeListResult = original.AzureMonitorPrivateLinkScopeListResult type AzureMonitorPrivateLinkScopeListResultIterator = original.AzureMonitorPrivateLinkScopeListResultIterator type AzureMonitorPrivateLinkScopeListResultPage = original.AzureMonitorPrivateLinkScopeListResultPage type AzureMonitorPrivateLinkScopeProperties = original.AzureMonitorPrivateLinkScopeProperties +type AzureResource = original.AzureResource type BaseClient = original.BaseClient -type Baseline = original.Baseline type BaselineMetadata = original.BaselineMetadata -type BaselineMetadataValue = original.BaselineMetadataValue -type BaselineProperties = original.BaselineProperties -type BaselineResponse = original.BaselineResponse type BaselinesClient = original.BaselinesClient type BasicAction = original.BasicAction type BasicMetricAlertCriteria = original.BasicMetricAlertCriteria @@ -377,9 +537,42 @@ type BasicMultiMetricCriteria = original.BasicMultiMetricCriteria type BasicRuleAction = original.BasicRuleAction type BasicRuleCondition = original.BasicRuleCondition type BasicRuleDataSource = original.BasicRuleDataSource -type CalculateBaselineResponse = original.CalculateBaselineResponse +type ConfigurationAccessEndpointSpec = original.ConfigurationAccessEndpointSpec type Criteria = original.Criteria +type DataCollectionEndpoint = original.DataCollectionEndpoint +type DataCollectionEndpointConfigurationAccess = original.DataCollectionEndpointConfigurationAccess +type DataCollectionEndpointLogsIngestion = original.DataCollectionEndpointLogsIngestion +type DataCollectionEndpointNetworkAcls = original.DataCollectionEndpointNetworkAcls +type DataCollectionEndpointResource = original.DataCollectionEndpointResource +type DataCollectionEndpointResourceListResult = original.DataCollectionEndpointResourceListResult +type DataCollectionEndpointResourceListResultIterator = original.DataCollectionEndpointResourceListResultIterator +type DataCollectionEndpointResourceListResultPage = original.DataCollectionEndpointResourceListResultPage +type DataCollectionEndpointResourceProperties = original.DataCollectionEndpointResourceProperties +type DataCollectionEndpointResourceSystemData = original.DataCollectionEndpointResourceSystemData +type DataCollectionEndpointsClient = original.DataCollectionEndpointsClient +type DataCollectionRule = original.DataCollectionRule +type DataCollectionRuleAssociation = original.DataCollectionRuleAssociation +type DataCollectionRuleAssociationProxyOnlyResource = original.DataCollectionRuleAssociationProxyOnlyResource +type DataCollectionRuleAssociationProxyOnlyResourceListResult = original.DataCollectionRuleAssociationProxyOnlyResourceListResult +type DataCollectionRuleAssociationProxyOnlyResourceListResultIterator = original.DataCollectionRuleAssociationProxyOnlyResourceListResultIterator +type DataCollectionRuleAssociationProxyOnlyResourceListResultPage = original.DataCollectionRuleAssociationProxyOnlyResourceListResultPage +type DataCollectionRuleAssociationProxyOnlyResourceProperties = original.DataCollectionRuleAssociationProxyOnlyResourceProperties +type DataCollectionRuleAssociationProxyOnlyResourceSystemData = original.DataCollectionRuleAssociationProxyOnlyResourceSystemData +type DataCollectionRuleAssociationsClient = original.DataCollectionRuleAssociationsClient +type DataCollectionRuleDataSources = original.DataCollectionRuleDataSources +type DataCollectionRuleDestinations = original.DataCollectionRuleDestinations +type DataCollectionRuleResource = original.DataCollectionRuleResource +type DataCollectionRuleResourceListResult = original.DataCollectionRuleResourceListResult +type DataCollectionRuleResourceListResultIterator = original.DataCollectionRuleResourceListResultIterator +type DataCollectionRuleResourceListResultPage = original.DataCollectionRuleResourceListResultPage +type DataCollectionRuleResourceProperties = original.DataCollectionRuleResourceProperties +type DataCollectionRuleResourceSystemData = original.DataCollectionRuleResourceSystemData +type DataCollectionRulesClient = original.DataCollectionRulesClient type DataContainer = original.DataContainer +type DataFlow = original.DataFlow +type DataSourcesSpec = original.DataSourcesSpec +type DestinationsSpec = original.DestinationsSpec +type DestinationsSpecAzureMonitorMetrics = original.DestinationsSpecAzureMonitorMetrics type DiagnosticSettings = original.DiagnosticSettings type DiagnosticSettingsCategory = original.DiagnosticSettingsCategory type DiagnosticSettingsCategoryClient = original.DiagnosticSettingsCategoryClient @@ -396,20 +589,25 @@ type EmailReceiver = original.EmailReceiver type EnableRequest = original.EnableRequest type Error = original.Error type ErrorAdditionalInfo = original.ErrorAdditionalInfo +type ErrorContract = original.ErrorContract +type ErrorDetail = original.ErrorDetail type ErrorResponse = original.ErrorResponse type ErrorResponseCommon = original.ErrorResponseCommon +type ErrorResponseCommonV2 = original.ErrorResponseCommonV2 type EventCategoriesClient = original.EventCategoriesClient type EventCategoryCollection = original.EventCategoryCollection type EventData = original.EventData type EventDataCollection = original.EventDataCollection type EventDataCollectionIterator = original.EventDataCollectionIterator type EventDataCollectionPage = original.EventDataCollectionPage +type ExtensionDataSource = original.ExtensionDataSource type HTTPRequestInfo = original.HTTPRequestInfo type Incident = original.Incident type IncidentListResult = original.IncidentListResult type ItsmReceiver = original.ItsmReceiver type LocalizableString = original.LocalizableString type LocationThresholdRuleCondition = original.LocationThresholdRuleCondition +type LogAnalyticsDestination = original.LogAnalyticsDestination type LogMetricTrigger = original.LogMetricTrigger type LogProfileCollection = original.LogProfileCollection type LogProfileProperties = original.LogProfileProperties @@ -424,6 +622,7 @@ type LogSearchRuleResourcePatch = original.LogSearchRuleResourcePatch type LogSettings = original.LogSettings type LogToMetricAction = original.LogToMetricAction type LogicAppReceiver = original.LogicAppReceiver +type LogsIngestionEndpointSpec = original.LogsIngestionEndpointSpec type ManagementEventAggregationCondition = original.ManagementEventAggregationCondition type ManagementEventRuleCondition = original.ManagementEventRuleCondition type MetadataValue = original.MetadataValue @@ -443,7 +642,6 @@ type MetricAlertStatusProperties = original.MetricAlertStatusProperties type MetricAlertsClient = original.MetricAlertsClient type MetricAlertsStatusClient = original.MetricAlertsStatusClient type MetricAvailability = original.MetricAvailability -type MetricBaselineClient = original.MetricBaselineClient type MetricBaselinesProperties = original.MetricBaselinesProperties type MetricBaselinesResponse = original.MetricBaselinesResponse type MetricCriteria = original.MetricCriteria @@ -461,11 +659,13 @@ type MetricTrigger = original.MetricTrigger type MetricValue = original.MetricValue type MetricsClient = original.MetricsClient type MultiMetricCriteria = original.MultiMetricCriteria +type NetworkRuleSet = original.NetworkRuleSet type Operation = original.Operation type OperationDisplay = original.OperationDisplay type OperationListResult = original.OperationListResult type OperationStatus = original.OperationStatus type OperationsClient = original.OperationsClient +type PerfCounterDataSource = original.PerfCounterDataSource type PrivateEndpointConnection = original.PrivateEndpointConnection type PrivateEndpointConnectionListResult = original.PrivateEndpointConnectionListResult type PrivateEndpointConnectionListResultIterator = original.PrivateEndpointConnectionListResultIterator @@ -494,6 +694,7 @@ type ProxyResource = original.ProxyResource type Recurrence = original.Recurrence type RecurrentSchedule = original.RecurrentSchedule type Resource = original.Resource +type ResourceForUpdate = original.ResourceForUpdate type Response = original.Response type ResponseWithError = original.ResponseWithError type RetentionPolicy = original.RetentionPolicy @@ -521,18 +722,13 @@ type SingleBaseline = original.SingleBaseline type SingleMetricBaseline = original.SingleMetricBaseline type SmsReceiver = original.SmsReceiver type Source = original.Source -type SubscriptionDiagnosticSettings = original.SubscriptionDiagnosticSettings -type SubscriptionDiagnosticSettingsClient = original.SubscriptionDiagnosticSettingsClient -type SubscriptionDiagnosticSettingsResource = original.SubscriptionDiagnosticSettingsResource -type SubscriptionDiagnosticSettingsResourceCollection = original.SubscriptionDiagnosticSettingsResourceCollection -type SubscriptionLogSettings = original.SubscriptionLogSettings -type SubscriptionProxyOnlyResource = original.SubscriptionProxyOnlyResource +type SyslogDataSource = original.SyslogDataSource +type SystemData = original.SystemData type TagsResource = original.TagsResource type TenantActivityLogsClient = original.TenantActivityLogsClient type ThresholdRuleCondition = original.ThresholdRuleCondition type TimeSeriesBaseline = original.TimeSeriesBaseline type TimeSeriesElement = original.TimeSeriesElement -type TimeSeriesInformation = original.TimeSeriesInformation type TimeWindow = original.TimeWindow type TriggerCondition = original.TriggerCondition type VMInsightsClient = original.VMInsightsClient @@ -542,6 +738,7 @@ type VoiceReceiver = original.VoiceReceiver type WebhookNotification = original.WebhookNotification type WebhookReceiver = original.WebhookReceiver type WebtestLocationAvailabilityCriteria = original.WebtestLocationAvailabilityCriteria +type WindowsEventLogDataSource = original.WindowsEventLogDataSource type WorkspaceInfo = original.WorkspaceInfo type WorkspaceInfoProperties = original.WorkspaceInfoProperties @@ -602,6 +799,42 @@ func NewBaselinesClient(subscriptionID string) BaselinesClient { func NewBaselinesClientWithBaseURI(baseURI string, subscriptionID string) BaselinesClient { return original.NewBaselinesClientWithBaseURI(baseURI, subscriptionID) } +func NewDataCollectionEndpointResourceListResultIterator(page DataCollectionEndpointResourceListResultPage) DataCollectionEndpointResourceListResultIterator { + return original.NewDataCollectionEndpointResourceListResultIterator(page) +} +func NewDataCollectionEndpointResourceListResultPage(cur DataCollectionEndpointResourceListResult, getNextPage func(context.Context, DataCollectionEndpointResourceListResult) (DataCollectionEndpointResourceListResult, error)) DataCollectionEndpointResourceListResultPage { + return original.NewDataCollectionEndpointResourceListResultPage(cur, getNextPage) +} +func NewDataCollectionEndpointsClient(subscriptionID string) DataCollectionEndpointsClient { + return original.NewDataCollectionEndpointsClient(subscriptionID) +} +func NewDataCollectionEndpointsClientWithBaseURI(baseURI string, subscriptionID string) DataCollectionEndpointsClient { + return original.NewDataCollectionEndpointsClientWithBaseURI(baseURI, subscriptionID) +} +func NewDataCollectionRuleAssociationProxyOnlyResourceListResultIterator(page DataCollectionRuleAssociationProxyOnlyResourceListResultPage) DataCollectionRuleAssociationProxyOnlyResourceListResultIterator { + return original.NewDataCollectionRuleAssociationProxyOnlyResourceListResultIterator(page) +} +func NewDataCollectionRuleAssociationProxyOnlyResourceListResultPage(cur DataCollectionRuleAssociationProxyOnlyResourceListResult, getNextPage func(context.Context, DataCollectionRuleAssociationProxyOnlyResourceListResult) (DataCollectionRuleAssociationProxyOnlyResourceListResult, error)) DataCollectionRuleAssociationProxyOnlyResourceListResultPage { + return original.NewDataCollectionRuleAssociationProxyOnlyResourceListResultPage(cur, getNextPage) +} +func NewDataCollectionRuleAssociationsClient(subscriptionID string) DataCollectionRuleAssociationsClient { + return original.NewDataCollectionRuleAssociationsClient(subscriptionID) +} +func NewDataCollectionRuleAssociationsClientWithBaseURI(baseURI string, subscriptionID string) DataCollectionRuleAssociationsClient { + return original.NewDataCollectionRuleAssociationsClientWithBaseURI(baseURI, subscriptionID) +} +func NewDataCollectionRuleResourceListResultIterator(page DataCollectionRuleResourceListResultPage) DataCollectionRuleResourceListResultIterator { + return original.NewDataCollectionRuleResourceListResultIterator(page) +} +func NewDataCollectionRuleResourceListResultPage(cur DataCollectionRuleResourceListResult, getNextPage func(context.Context, DataCollectionRuleResourceListResult) (DataCollectionRuleResourceListResult, error)) DataCollectionRuleResourceListResultPage { + return original.NewDataCollectionRuleResourceListResultPage(cur, getNextPage) +} +func NewDataCollectionRulesClient(subscriptionID string) DataCollectionRulesClient { + return original.NewDataCollectionRulesClient(subscriptionID) +} +func NewDataCollectionRulesClientWithBaseURI(baseURI string, subscriptionID string) DataCollectionRulesClient { + return original.NewDataCollectionRulesClientWithBaseURI(baseURI, subscriptionID) +} func NewDiagnosticSettingsCategoryClient(subscriptionID string) DiagnosticSettingsCategoryClient { return original.NewDiagnosticSettingsCategoryClient(subscriptionID) } @@ -644,12 +877,6 @@ func NewMetricAlertsStatusClient(subscriptionID string) MetricAlertsStatusClient func NewMetricAlertsStatusClientWithBaseURI(baseURI string, subscriptionID string) MetricAlertsStatusClient { return original.NewMetricAlertsStatusClientWithBaseURI(baseURI, subscriptionID) } -func NewMetricBaselineClient(subscriptionID string) MetricBaselineClient { - return original.NewMetricBaselineClient(subscriptionID) -} -func NewMetricBaselineClientWithBaseURI(baseURI string, subscriptionID string) MetricBaselineClient { - return original.NewMetricBaselineClientWithBaseURI(baseURI, subscriptionID) -} func NewMetricDefinitionsClient(subscriptionID string) MetricDefinitionsClient { return original.NewMetricDefinitionsClient(subscriptionID) } @@ -728,12 +955,6 @@ func NewScopedResourceListResultIterator(page ScopedResourceListResultPage) Scop func NewScopedResourceListResultPage(cur ScopedResourceListResult, getNextPage func(context.Context, ScopedResourceListResult) (ScopedResourceListResult, error)) ScopedResourceListResultPage { return original.NewScopedResourceListResultPage(cur, getNextPage) } -func NewSubscriptionDiagnosticSettingsClient(subscriptionID string) SubscriptionDiagnosticSettingsClient { - return original.NewSubscriptionDiagnosticSettingsClient(subscriptionID) -} -func NewSubscriptionDiagnosticSettingsClientWithBaseURI(baseURI string, subscriptionID string) SubscriptionDiagnosticSettingsClient { - return original.NewSubscriptionDiagnosticSettingsClientWithBaseURI(baseURI, subscriptionID) -} func NewTenantActivityLogsClient(subscriptionID string) TenantActivityLogsClient { return original.NewTenantActivityLogsClient(subscriptionID) } @@ -749,6 +970,9 @@ func NewVMInsightsClientWithBaseURI(baseURI string, subscriptionID string) VMIns func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { return original.NewWithBaseURI(baseURI, subscriptionID) } +func PossibleAggregationTypeEnumValues() []AggregationTypeEnum { + return original.PossibleAggregationTypeEnumValues() +} func PossibleAggregationTypeValues() []AggregationType { return original.PossibleAggregationTypeValues() } @@ -770,6 +994,9 @@ func PossibleConditionOperatorValues() []ConditionOperator { func PossibleConditionalOperatorValues() []ConditionalOperator { return original.PossibleConditionalOperatorValues() } +func PossibleCreatedByTypeValues() []CreatedByType { + return original.PossibleCreatedByTypeValues() +} func PossibleCriterionTypeValues() []CriterionType { return original.PossibleCriterionTypeValues() } @@ -788,12 +1015,60 @@ func PossibleEnabledValues() []Enabled { func PossibleEventLevelValues() []EventLevel { return original.PossibleEventLevelValues() } +func PossibleKnownDataCollectionEndpointProvisioningStateValues() []KnownDataCollectionEndpointProvisioningState { + return original.PossibleKnownDataCollectionEndpointProvisioningStateValues() +} +func PossibleKnownDataCollectionEndpointResourceKindValues() []KnownDataCollectionEndpointResourceKind { + return original.PossibleKnownDataCollectionEndpointResourceKindValues() +} +func PossibleKnownDataCollectionRuleAssociationProvisioningStateValues() []KnownDataCollectionRuleAssociationProvisioningState { + return original.PossibleKnownDataCollectionRuleAssociationProvisioningStateValues() +} +func PossibleKnownDataCollectionRuleProvisioningStateValues() []KnownDataCollectionRuleProvisioningState { + return original.PossibleKnownDataCollectionRuleProvisioningStateValues() +} +func PossibleKnownDataCollectionRuleResourceKindValues() []KnownDataCollectionRuleResourceKind { + return original.PossibleKnownDataCollectionRuleResourceKindValues() +} +func PossibleKnownDataFlowStreamsValues() []KnownDataFlowStreams { + return original.PossibleKnownDataFlowStreamsValues() +} +func PossibleKnownExtensionDataSourceStreamsValues() []KnownExtensionDataSourceStreams { + return original.PossibleKnownExtensionDataSourceStreamsValues() +} +func PossibleKnownPerfCounterDataSourceStreamsValues() []KnownPerfCounterDataSourceStreams { + return original.PossibleKnownPerfCounterDataSourceStreamsValues() +} +func PossibleKnownPublicNetworkAccessOptionsValues() []KnownPublicNetworkAccessOptions { + return original.PossibleKnownPublicNetworkAccessOptionsValues() +} +func PossibleKnownSyslogDataSourceFacilityNamesValues() []KnownSyslogDataSourceFacilityNames { + return original.PossibleKnownSyslogDataSourceFacilityNamesValues() +} +func PossibleKnownSyslogDataSourceLogLevelsValues() []KnownSyslogDataSourceLogLevels { + return original.PossibleKnownSyslogDataSourceLogLevelsValues() +} +func PossibleKnownSyslogDataSourceStreamsValues() []KnownSyslogDataSourceStreams { + return original.PossibleKnownSyslogDataSourceStreamsValues() +} +func PossibleKnownWindowsEventLogDataSourceStreamsValues() []KnownWindowsEventLogDataSourceStreams { + return original.PossibleKnownWindowsEventLogDataSourceStreamsValues() +} +func PossibleMetricClassValues() []MetricClass { + return original.PossibleMetricClassValues() +} func PossibleMetricStatisticTypeValues() []MetricStatisticType { return original.PossibleMetricStatisticTypeValues() } func PossibleMetricTriggerTypeValues() []MetricTriggerType { return original.PossibleMetricTriggerTypeValues() } +func PossibleMetricUnitValues() []MetricUnit { + return original.PossibleMetricUnitValues() +} +func PossibleNamespaceClassificationValues() []NamespaceClassification { + return original.PossibleNamespaceClassificationValues() +} func PossibleOdataTypeBasicActionValues() []OdataTypeBasicAction { return original.PossibleOdataTypeBasicActionValues() } @@ -839,18 +1114,12 @@ func PossibleScaleRuleMetricDimensionOperationTypeValues() []ScaleRuleMetricDime func PossibleScaleTypeValues() []ScaleType { return original.PossibleScaleTypeValues() } -func PossibleSensitivityValues() []Sensitivity { - return original.PossibleSensitivityValues() -} func PossibleTimeAggregationOperatorValues() []TimeAggregationOperator { return original.PossibleTimeAggregationOperatorValues() } func PossibleTimeAggregationTypeValues() []TimeAggregationType { return original.PossibleTimeAggregationTypeValues() } -func PossibleUnitValues() []Unit { - return original.PossibleUnitValues() -} func UserAgent() string { return original.UserAgent() + " profiles/preview" } diff --git a/services/cosmos-db/mgmt/2021-06-15/documentdb/CHANGELOG.md b/services/cosmos-db/mgmt/2021-06-15/documentdb/CHANGELOG.md new file mode 100644 index 000000000000..52911e4cc5e4 --- /dev/null +++ b/services/cosmos-db/mgmt/2021-06-15/documentdb/CHANGELOG.md @@ -0,0 +1,2 @@ +# Change History + diff --git a/services/cosmos-db/mgmt/2021-06-15/documentdb/_meta.json b/services/cosmos-db/mgmt/2021-06-15/documentdb/_meta.json new file mode 100644 index 000000000000..c5f7163af016 --- /dev/null +++ b/services/cosmos-db/mgmt/2021-06-15/documentdb/_meta.json @@ -0,0 +1,11 @@ +{ + "commit": "8dff86df71bee429af84ea4713288ef3cdd1db2f", + "readme": "/_/azure-rest-api-specs/specification/cosmos-db/resource-manager/readme.md", + "tag": "package-2021-06", + "use": "@microsoft.azure/autorest.go@2.1.183", + "repository_url": "https://github.com/Azure/azure-rest-api-specs.git", + "autorest_command": "autorest --use=@microsoft.azure/autorest.go@2.1.183 --tag=package-2021-06 --go-sdk-folder=/_/azure-sdk-for-go --go --verbose --use-onever --version=V2 --go.license-header=MICROSOFT_MIT_NO_VERSION --enum-prefix /_/azure-rest-api-specs/specification/cosmos-db/resource-manager/readme.md", + "additional_properties": { + "additional_options": "--go --verbose --use-onever --version=V2 --go.license-header=MICROSOFT_MIT_NO_VERSION --enum-prefix" + } +} \ No newline at end of file diff --git a/services/cosmos-db/mgmt/2021-06-15/documentdb/cassandraresources.go b/services/cosmos-db/mgmt/2021-06-15/documentdb/cassandraresources.go new file mode 100644 index 000000000000..764f61da01c5 --- /dev/null +++ b/services/cosmos-db/mgmt/2021-06-15/documentdb/cassandraresources.go @@ -0,0 +1,1563 @@ +package documentdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// CassandraResourcesClient is the client for the CassandraResources methods of the Documentdb service. +type CassandraResourcesClient struct { + BaseClient +} + +// NewCassandraResourcesClient creates an instance of the CassandraResourcesClient client. +func NewCassandraResourcesClient(subscriptionID string) CassandraResourcesClient { + return NewCassandraResourcesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewCassandraResourcesClientWithBaseURI creates an instance of the CassandraResourcesClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewCassandraResourcesClientWithBaseURI(baseURI string, subscriptionID string) CassandraResourcesClient { + return CassandraResourcesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateUpdateCassandraKeyspace create or update an Azure Cosmos DB Cassandra keyspace +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// keyspaceName - cosmos DB keyspace name. +// createUpdateCassandraKeyspaceParameters - the parameters to provide for the current Cassandra keyspace. +func (client CassandraResourcesClient) CreateUpdateCassandraKeyspace(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string, createUpdateCassandraKeyspaceParameters CassandraKeyspaceCreateUpdateParameters) (result CassandraResourcesCreateUpdateCassandraKeyspaceFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CassandraResourcesClient.CreateUpdateCassandraKeyspace") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}, + {TargetValue: createUpdateCassandraKeyspaceParameters, + Constraints: []validation.Constraint{{Target: "createUpdateCassandraKeyspaceParameters.CassandraKeyspaceCreateUpdateProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "createUpdateCassandraKeyspaceParameters.CassandraKeyspaceCreateUpdateProperties.Resource", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "createUpdateCassandraKeyspaceParameters.CassandraKeyspaceCreateUpdateProperties.Resource.ID", Name: validation.Null, Rule: true, Chain: nil}}}, + }}}}}); err != nil { + return result, validation.NewError("documentdb.CassandraResourcesClient", "CreateUpdateCassandraKeyspace", err.Error()) + } + + req, err := client.CreateUpdateCassandraKeyspacePreparer(ctx, resourceGroupName, accountName, keyspaceName, createUpdateCassandraKeyspaceParameters) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "CreateUpdateCassandraKeyspace", nil, "Failure preparing request") + return + } + + result, err = client.CreateUpdateCassandraKeyspaceSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "CreateUpdateCassandraKeyspace", nil, "Failure sending request") + return + } + + return +} + +// CreateUpdateCassandraKeyspacePreparer prepares the CreateUpdateCassandraKeyspace request. +func (client CassandraResourcesClient) CreateUpdateCassandraKeyspacePreparer(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string, createUpdateCassandraKeyspaceParameters CassandraKeyspaceCreateUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "keyspaceName": autorest.Encode("path", keyspaceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + 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.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}", pathParameters), + autorest.WithJSON(createUpdateCassandraKeyspaceParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateUpdateCassandraKeyspaceSender sends the CreateUpdateCassandraKeyspace request. The method will close the +// http.Response Body if it receives an error. +func (client CassandraResourcesClient) CreateUpdateCassandraKeyspaceSender(req *http.Request) (future CassandraResourcesCreateUpdateCassandraKeyspaceFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateUpdateCassandraKeyspaceResponder handles the response to the CreateUpdateCassandraKeyspace request. The method always +// closes the http.Response Body. +func (client CassandraResourcesClient) CreateUpdateCassandraKeyspaceResponder(resp *http.Response) (result CassandraKeyspaceGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// CreateUpdateCassandraTable create or update an Azure Cosmos DB Cassandra Table +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// keyspaceName - cosmos DB keyspace name. +// tableName - cosmos DB table name. +// createUpdateCassandraTableParameters - the parameters to provide for the current Cassandra Table. +func (client CassandraResourcesClient) CreateUpdateCassandraTable(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string, tableName string, createUpdateCassandraTableParameters CassandraTableCreateUpdateParameters) (result CassandraResourcesCreateUpdateCassandraTableFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CassandraResourcesClient.CreateUpdateCassandraTable") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}, + {TargetValue: createUpdateCassandraTableParameters, + Constraints: []validation.Constraint{{Target: "createUpdateCassandraTableParameters.CassandraTableCreateUpdateProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "createUpdateCassandraTableParameters.CassandraTableCreateUpdateProperties.Resource", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "createUpdateCassandraTableParameters.CassandraTableCreateUpdateProperties.Resource.ID", Name: validation.Null, Rule: true, Chain: nil}}}, + }}}}}); err != nil { + return result, validation.NewError("documentdb.CassandraResourcesClient", "CreateUpdateCassandraTable", err.Error()) + } + + req, err := client.CreateUpdateCassandraTablePreparer(ctx, resourceGroupName, accountName, keyspaceName, tableName, createUpdateCassandraTableParameters) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "CreateUpdateCassandraTable", nil, "Failure preparing request") + return + } + + result, err = client.CreateUpdateCassandraTableSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "CreateUpdateCassandraTable", nil, "Failure sending request") + return + } + + return +} + +// CreateUpdateCassandraTablePreparer prepares the CreateUpdateCassandraTable request. +func (client CassandraResourcesClient) CreateUpdateCassandraTablePreparer(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string, tableName string, createUpdateCassandraTableParameters CassandraTableCreateUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "keyspaceName": autorest.Encode("path", keyspaceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "tableName": autorest.Encode("path", tableName), + } + + const APIVersion = "2021-06-15" + 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.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/tables/{tableName}", pathParameters), + autorest.WithJSON(createUpdateCassandraTableParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateUpdateCassandraTableSender sends the CreateUpdateCassandraTable request. The method will close the +// http.Response Body if it receives an error. +func (client CassandraResourcesClient) CreateUpdateCassandraTableSender(req *http.Request) (future CassandraResourcesCreateUpdateCassandraTableFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateUpdateCassandraTableResponder handles the response to the CreateUpdateCassandraTable request. The method always +// closes the http.Response Body. +func (client CassandraResourcesClient) CreateUpdateCassandraTableResponder(resp *http.Response) (result CassandraTableGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// DeleteCassandraKeyspace deletes an existing Azure Cosmos DB Cassandra keyspace. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// keyspaceName - cosmos DB keyspace name. +func (client CassandraResourcesClient) DeleteCassandraKeyspace(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string) (result CassandraResourcesDeleteCassandraKeyspaceFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CassandraResourcesClient.DeleteCassandraKeyspace") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.CassandraResourcesClient", "DeleteCassandraKeyspace", err.Error()) + } + + req, err := client.DeleteCassandraKeyspacePreparer(ctx, resourceGroupName, accountName, keyspaceName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "DeleteCassandraKeyspace", nil, "Failure preparing request") + return + } + + result, err = client.DeleteCassandraKeyspaceSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "DeleteCassandraKeyspace", nil, "Failure sending request") + return + } + + return +} + +// DeleteCassandraKeyspacePreparer prepares the DeleteCassandraKeyspace request. +func (client CassandraResourcesClient) DeleteCassandraKeyspacePreparer(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "keyspaceName": autorest.Encode("path", keyspaceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteCassandraKeyspaceSender sends the DeleteCassandraKeyspace request. The method will close the +// http.Response Body if it receives an error. +func (client CassandraResourcesClient) DeleteCassandraKeyspaceSender(req *http.Request) (future CassandraResourcesDeleteCassandraKeyspaceFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteCassandraKeyspaceResponder handles the response to the DeleteCassandraKeyspace request. The method always +// closes the http.Response Body. +func (client CassandraResourcesClient) DeleteCassandraKeyspaceResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// DeleteCassandraTable deletes an existing Azure Cosmos DB Cassandra table. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// keyspaceName - cosmos DB keyspace name. +// tableName - cosmos DB table name. +func (client CassandraResourcesClient) DeleteCassandraTable(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string, tableName string) (result CassandraResourcesDeleteCassandraTableFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CassandraResourcesClient.DeleteCassandraTable") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.CassandraResourcesClient", "DeleteCassandraTable", err.Error()) + } + + req, err := client.DeleteCassandraTablePreparer(ctx, resourceGroupName, accountName, keyspaceName, tableName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "DeleteCassandraTable", nil, "Failure preparing request") + return + } + + result, err = client.DeleteCassandraTableSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "DeleteCassandraTable", nil, "Failure sending request") + return + } + + return +} + +// DeleteCassandraTablePreparer prepares the DeleteCassandraTable request. +func (client CassandraResourcesClient) DeleteCassandraTablePreparer(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string, tableName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "keyspaceName": autorest.Encode("path", keyspaceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "tableName": autorest.Encode("path", tableName), + } + + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/tables/{tableName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteCassandraTableSender sends the DeleteCassandraTable request. The method will close the +// http.Response Body if it receives an error. +func (client CassandraResourcesClient) DeleteCassandraTableSender(req *http.Request) (future CassandraResourcesDeleteCassandraTableFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteCassandraTableResponder handles the response to the DeleteCassandraTable request. The method always +// closes the http.Response Body. +func (client CassandraResourcesClient) DeleteCassandraTableResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// GetCassandraKeyspace gets the Cassandra keyspaces under an existing Azure Cosmos DB database account with the +// provided name. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// keyspaceName - cosmos DB keyspace name. +func (client CassandraResourcesClient) GetCassandraKeyspace(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string) (result CassandraKeyspaceGetResults, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CassandraResourcesClient.GetCassandraKeyspace") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.CassandraResourcesClient", "GetCassandraKeyspace", err.Error()) + } + + req, err := client.GetCassandraKeyspacePreparer(ctx, resourceGroupName, accountName, keyspaceName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "GetCassandraKeyspace", nil, "Failure preparing request") + return + } + + resp, err := client.GetCassandraKeyspaceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "GetCassandraKeyspace", resp, "Failure sending request") + return + } + + result, err = client.GetCassandraKeyspaceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "GetCassandraKeyspace", resp, "Failure responding to request") + return + } + + return +} + +// GetCassandraKeyspacePreparer prepares the GetCassandraKeyspace request. +func (client CassandraResourcesClient) GetCassandraKeyspacePreparer(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "keyspaceName": autorest.Encode("path", keyspaceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetCassandraKeyspaceSender sends the GetCassandraKeyspace request. The method will close the +// http.Response Body if it receives an error. +func (client CassandraResourcesClient) GetCassandraKeyspaceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetCassandraKeyspaceResponder handles the response to the GetCassandraKeyspace request. The method always +// closes the http.Response Body. +func (client CassandraResourcesClient) GetCassandraKeyspaceResponder(resp *http.Response) (result CassandraKeyspaceGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetCassandraKeyspaceThroughput gets the RUs per second of the Cassandra Keyspace under an existing Azure Cosmos DB +// database account with the provided name. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// keyspaceName - cosmos DB keyspace name. +func (client CassandraResourcesClient) GetCassandraKeyspaceThroughput(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string) (result ThroughputSettingsGetResults, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CassandraResourcesClient.GetCassandraKeyspaceThroughput") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.CassandraResourcesClient", "GetCassandraKeyspaceThroughput", err.Error()) + } + + req, err := client.GetCassandraKeyspaceThroughputPreparer(ctx, resourceGroupName, accountName, keyspaceName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "GetCassandraKeyspaceThroughput", nil, "Failure preparing request") + return + } + + resp, err := client.GetCassandraKeyspaceThroughputSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "GetCassandraKeyspaceThroughput", resp, "Failure sending request") + return + } + + result, err = client.GetCassandraKeyspaceThroughputResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "GetCassandraKeyspaceThroughput", resp, "Failure responding to request") + return + } + + return +} + +// GetCassandraKeyspaceThroughputPreparer prepares the GetCassandraKeyspaceThroughput request. +func (client CassandraResourcesClient) GetCassandraKeyspaceThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "keyspaceName": autorest.Encode("path", keyspaceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/throughputSettings/default", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetCassandraKeyspaceThroughputSender sends the GetCassandraKeyspaceThroughput request. The method will close the +// http.Response Body if it receives an error. +func (client CassandraResourcesClient) GetCassandraKeyspaceThroughputSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetCassandraKeyspaceThroughputResponder handles the response to the GetCassandraKeyspaceThroughput request. The method always +// closes the http.Response Body. +func (client CassandraResourcesClient) GetCassandraKeyspaceThroughputResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetCassandraTable gets the Cassandra table under an existing Azure Cosmos DB database account. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// keyspaceName - cosmos DB keyspace name. +// tableName - cosmos DB table name. +func (client CassandraResourcesClient) GetCassandraTable(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string, tableName string) (result CassandraTableGetResults, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CassandraResourcesClient.GetCassandraTable") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.CassandraResourcesClient", "GetCassandraTable", err.Error()) + } + + req, err := client.GetCassandraTablePreparer(ctx, resourceGroupName, accountName, keyspaceName, tableName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "GetCassandraTable", nil, "Failure preparing request") + return + } + + resp, err := client.GetCassandraTableSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "GetCassandraTable", resp, "Failure sending request") + return + } + + result, err = client.GetCassandraTableResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "GetCassandraTable", resp, "Failure responding to request") + return + } + + return +} + +// GetCassandraTablePreparer prepares the GetCassandraTable request. +func (client CassandraResourcesClient) GetCassandraTablePreparer(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string, tableName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "keyspaceName": autorest.Encode("path", keyspaceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "tableName": autorest.Encode("path", tableName), + } + + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/tables/{tableName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetCassandraTableSender sends the GetCassandraTable request. The method will close the +// http.Response Body if it receives an error. +func (client CassandraResourcesClient) GetCassandraTableSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetCassandraTableResponder handles the response to the GetCassandraTable request. The method always +// closes the http.Response Body. +func (client CassandraResourcesClient) GetCassandraTableResponder(resp *http.Response) (result CassandraTableGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetCassandraTableThroughput gets the RUs per second of the Cassandra table under an existing Azure Cosmos DB +// database account with the provided name. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// keyspaceName - cosmos DB keyspace name. +// tableName - cosmos DB table name. +func (client CassandraResourcesClient) GetCassandraTableThroughput(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string, tableName string) (result ThroughputSettingsGetResults, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CassandraResourcesClient.GetCassandraTableThroughput") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.CassandraResourcesClient", "GetCassandraTableThroughput", err.Error()) + } + + req, err := client.GetCassandraTableThroughputPreparer(ctx, resourceGroupName, accountName, keyspaceName, tableName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "GetCassandraTableThroughput", nil, "Failure preparing request") + return + } + + resp, err := client.GetCassandraTableThroughputSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "GetCassandraTableThroughput", resp, "Failure sending request") + return + } + + result, err = client.GetCassandraTableThroughputResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "GetCassandraTableThroughput", resp, "Failure responding to request") + return + } + + return +} + +// GetCassandraTableThroughputPreparer prepares the GetCassandraTableThroughput request. +func (client CassandraResourcesClient) GetCassandraTableThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string, tableName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "keyspaceName": autorest.Encode("path", keyspaceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "tableName": autorest.Encode("path", tableName), + } + + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/tables/{tableName}/throughputSettings/default", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetCassandraTableThroughputSender sends the GetCassandraTableThroughput request. The method will close the +// http.Response Body if it receives an error. +func (client CassandraResourcesClient) GetCassandraTableThroughputSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetCassandraTableThroughputResponder handles the response to the GetCassandraTableThroughput request. The method always +// closes the http.Response Body. +func (client CassandraResourcesClient) GetCassandraTableThroughputResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListCassandraKeyspaces lists the Cassandra keyspaces under an existing Azure Cosmos DB database account. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +func (client CassandraResourcesClient) ListCassandraKeyspaces(ctx context.Context, resourceGroupName string, accountName string) (result CassandraKeyspaceListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CassandraResourcesClient.ListCassandraKeyspaces") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.CassandraResourcesClient", "ListCassandraKeyspaces", err.Error()) + } + + req, err := client.ListCassandraKeyspacesPreparer(ctx, resourceGroupName, accountName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "ListCassandraKeyspaces", nil, "Failure preparing request") + return + } + + resp, err := client.ListCassandraKeyspacesSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "ListCassandraKeyspaces", resp, "Failure sending request") + return + } + + result, err = client.ListCassandraKeyspacesResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "ListCassandraKeyspaces", resp, "Failure responding to request") + return + } + + return +} + +// ListCassandraKeyspacesPreparer prepares the ListCassandraKeyspaces request. +func (client CassandraResourcesClient) ListCassandraKeyspacesPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListCassandraKeyspacesSender sends the ListCassandraKeyspaces request. The method will close the +// http.Response Body if it receives an error. +func (client CassandraResourcesClient) ListCassandraKeyspacesSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListCassandraKeyspacesResponder handles the response to the ListCassandraKeyspaces request. The method always +// closes the http.Response Body. +func (client CassandraResourcesClient) ListCassandraKeyspacesResponder(resp *http.Response) (result CassandraKeyspaceListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListCassandraTables lists the Cassandra table under an existing Azure Cosmos DB database account. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// keyspaceName - cosmos DB keyspace name. +func (client CassandraResourcesClient) ListCassandraTables(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string) (result CassandraTableListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CassandraResourcesClient.ListCassandraTables") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.CassandraResourcesClient", "ListCassandraTables", err.Error()) + } + + req, err := client.ListCassandraTablesPreparer(ctx, resourceGroupName, accountName, keyspaceName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "ListCassandraTables", nil, "Failure preparing request") + return + } + + resp, err := client.ListCassandraTablesSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "ListCassandraTables", resp, "Failure sending request") + return + } + + result, err = client.ListCassandraTablesResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "ListCassandraTables", resp, "Failure responding to request") + return + } + + return +} + +// ListCassandraTablesPreparer prepares the ListCassandraTables request. +func (client CassandraResourcesClient) ListCassandraTablesPreparer(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "keyspaceName": autorest.Encode("path", keyspaceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/tables", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListCassandraTablesSender sends the ListCassandraTables request. The method will close the +// http.Response Body if it receives an error. +func (client CassandraResourcesClient) ListCassandraTablesSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListCassandraTablesResponder handles the response to the ListCassandraTables request. The method always +// closes the http.Response Body. +func (client CassandraResourcesClient) ListCassandraTablesResponder(resp *http.Response) (result CassandraTableListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// MigrateCassandraKeyspaceToAutoscale migrate an Azure Cosmos DB Cassandra Keyspace from manual throughput to +// autoscale +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// keyspaceName - cosmos DB keyspace name. +func (client CassandraResourcesClient) MigrateCassandraKeyspaceToAutoscale(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string) (result CassandraResourcesMigrateCassandraKeyspaceToAutoscaleFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CassandraResourcesClient.MigrateCassandraKeyspaceToAutoscale") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.CassandraResourcesClient", "MigrateCassandraKeyspaceToAutoscale", err.Error()) + } + + req, err := client.MigrateCassandraKeyspaceToAutoscalePreparer(ctx, resourceGroupName, accountName, keyspaceName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "MigrateCassandraKeyspaceToAutoscale", nil, "Failure preparing request") + return + } + + result, err = client.MigrateCassandraKeyspaceToAutoscaleSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "MigrateCassandraKeyspaceToAutoscale", nil, "Failure sending request") + return + } + + return +} + +// MigrateCassandraKeyspaceToAutoscalePreparer prepares the MigrateCassandraKeyspaceToAutoscale request. +func (client CassandraResourcesClient) MigrateCassandraKeyspaceToAutoscalePreparer(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "keyspaceName": autorest.Encode("path", keyspaceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/throughputSettings/default/migrateToAutoscale", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// MigrateCassandraKeyspaceToAutoscaleSender sends the MigrateCassandraKeyspaceToAutoscale request. The method will close the +// http.Response Body if it receives an error. +func (client CassandraResourcesClient) MigrateCassandraKeyspaceToAutoscaleSender(req *http.Request) (future CassandraResourcesMigrateCassandraKeyspaceToAutoscaleFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// MigrateCassandraKeyspaceToAutoscaleResponder handles the response to the MigrateCassandraKeyspaceToAutoscale request. The method always +// closes the http.Response Body. +func (client CassandraResourcesClient) MigrateCassandraKeyspaceToAutoscaleResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// MigrateCassandraKeyspaceToManualThroughput migrate an Azure Cosmos DB Cassandra Keyspace from autoscale to manual +// throughput +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// keyspaceName - cosmos DB keyspace name. +func (client CassandraResourcesClient) MigrateCassandraKeyspaceToManualThroughput(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string) (result CassandraResourcesMigrateCassandraKeyspaceToManualThroughputFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CassandraResourcesClient.MigrateCassandraKeyspaceToManualThroughput") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.CassandraResourcesClient", "MigrateCassandraKeyspaceToManualThroughput", err.Error()) + } + + req, err := client.MigrateCassandraKeyspaceToManualThroughputPreparer(ctx, resourceGroupName, accountName, keyspaceName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "MigrateCassandraKeyspaceToManualThroughput", nil, "Failure preparing request") + return + } + + result, err = client.MigrateCassandraKeyspaceToManualThroughputSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "MigrateCassandraKeyspaceToManualThroughput", nil, "Failure sending request") + return + } + + return +} + +// MigrateCassandraKeyspaceToManualThroughputPreparer prepares the MigrateCassandraKeyspaceToManualThroughput request. +func (client CassandraResourcesClient) MigrateCassandraKeyspaceToManualThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "keyspaceName": autorest.Encode("path", keyspaceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/throughputSettings/default/migrateToManualThroughput", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// MigrateCassandraKeyspaceToManualThroughputSender sends the MigrateCassandraKeyspaceToManualThroughput request. The method will close the +// http.Response Body if it receives an error. +func (client CassandraResourcesClient) MigrateCassandraKeyspaceToManualThroughputSender(req *http.Request) (future CassandraResourcesMigrateCassandraKeyspaceToManualThroughputFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// MigrateCassandraKeyspaceToManualThroughputResponder handles the response to the MigrateCassandraKeyspaceToManualThroughput request. The method always +// closes the http.Response Body. +func (client CassandraResourcesClient) MigrateCassandraKeyspaceToManualThroughputResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// MigrateCassandraTableToAutoscale migrate an Azure Cosmos DB Cassandra table from manual throughput to autoscale +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// keyspaceName - cosmos DB keyspace name. +// tableName - cosmos DB table name. +func (client CassandraResourcesClient) MigrateCassandraTableToAutoscale(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string, tableName string) (result CassandraResourcesMigrateCassandraTableToAutoscaleFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CassandraResourcesClient.MigrateCassandraTableToAutoscale") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.CassandraResourcesClient", "MigrateCassandraTableToAutoscale", err.Error()) + } + + req, err := client.MigrateCassandraTableToAutoscalePreparer(ctx, resourceGroupName, accountName, keyspaceName, tableName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "MigrateCassandraTableToAutoscale", nil, "Failure preparing request") + return + } + + result, err = client.MigrateCassandraTableToAutoscaleSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "MigrateCassandraTableToAutoscale", nil, "Failure sending request") + return + } + + return +} + +// MigrateCassandraTableToAutoscalePreparer prepares the MigrateCassandraTableToAutoscale request. +func (client CassandraResourcesClient) MigrateCassandraTableToAutoscalePreparer(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string, tableName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "keyspaceName": autorest.Encode("path", keyspaceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "tableName": autorest.Encode("path", tableName), + } + + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/tables/{tableName}/throughputSettings/default/migrateToAutoscale", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// MigrateCassandraTableToAutoscaleSender sends the MigrateCassandraTableToAutoscale request. The method will close the +// http.Response Body if it receives an error. +func (client CassandraResourcesClient) MigrateCassandraTableToAutoscaleSender(req *http.Request) (future CassandraResourcesMigrateCassandraTableToAutoscaleFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// MigrateCassandraTableToAutoscaleResponder handles the response to the MigrateCassandraTableToAutoscale request. The method always +// closes the http.Response Body. +func (client CassandraResourcesClient) MigrateCassandraTableToAutoscaleResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// MigrateCassandraTableToManualThroughput migrate an Azure Cosmos DB Cassandra table from autoscale to manual +// throughput +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// keyspaceName - cosmos DB keyspace name. +// tableName - cosmos DB table name. +func (client CassandraResourcesClient) MigrateCassandraTableToManualThroughput(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string, tableName string) (result CassandraResourcesMigrateCassandraTableToManualThroughputFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CassandraResourcesClient.MigrateCassandraTableToManualThroughput") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.CassandraResourcesClient", "MigrateCassandraTableToManualThroughput", err.Error()) + } + + req, err := client.MigrateCassandraTableToManualThroughputPreparer(ctx, resourceGroupName, accountName, keyspaceName, tableName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "MigrateCassandraTableToManualThroughput", nil, "Failure preparing request") + return + } + + result, err = client.MigrateCassandraTableToManualThroughputSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "MigrateCassandraTableToManualThroughput", nil, "Failure sending request") + return + } + + return +} + +// MigrateCassandraTableToManualThroughputPreparer prepares the MigrateCassandraTableToManualThroughput request. +func (client CassandraResourcesClient) MigrateCassandraTableToManualThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string, tableName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "keyspaceName": autorest.Encode("path", keyspaceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "tableName": autorest.Encode("path", tableName), + } + + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/tables/{tableName}/throughputSettings/default/migrateToManualThroughput", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// MigrateCassandraTableToManualThroughputSender sends the MigrateCassandraTableToManualThroughput request. The method will close the +// http.Response Body if it receives an error. +func (client CassandraResourcesClient) MigrateCassandraTableToManualThroughputSender(req *http.Request) (future CassandraResourcesMigrateCassandraTableToManualThroughputFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// MigrateCassandraTableToManualThroughputResponder handles the response to the MigrateCassandraTableToManualThroughput request. The method always +// closes the http.Response Body. +func (client CassandraResourcesClient) MigrateCassandraTableToManualThroughputResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// UpdateCassandraKeyspaceThroughput update RUs per second of an Azure Cosmos DB Cassandra Keyspace +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// keyspaceName - cosmos DB keyspace name. +// updateThroughputParameters - the RUs per second of the parameters to provide for the current Cassandra +// Keyspace. +func (client CassandraResourcesClient) UpdateCassandraKeyspaceThroughput(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string, updateThroughputParameters ThroughputSettingsUpdateParameters) (result CassandraResourcesUpdateCassandraKeyspaceThroughputFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CassandraResourcesClient.UpdateCassandraKeyspaceThroughput") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}, + {TargetValue: updateThroughputParameters, + Constraints: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties.Resource", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties.Resource.AutoscaleSettings", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties.Resource.AutoscaleSettings.MaxThroughput", Name: validation.Null, Rule: true, Chain: nil}}}, + }}, + }}}}}); err != nil { + return result, validation.NewError("documentdb.CassandraResourcesClient", "UpdateCassandraKeyspaceThroughput", err.Error()) + } + + req, err := client.UpdateCassandraKeyspaceThroughputPreparer(ctx, resourceGroupName, accountName, keyspaceName, updateThroughputParameters) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "UpdateCassandraKeyspaceThroughput", nil, "Failure preparing request") + return + } + + result, err = client.UpdateCassandraKeyspaceThroughputSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "UpdateCassandraKeyspaceThroughput", nil, "Failure sending request") + return + } + + return +} + +// UpdateCassandraKeyspaceThroughputPreparer prepares the UpdateCassandraKeyspaceThroughput request. +func (client CassandraResourcesClient) UpdateCassandraKeyspaceThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string, updateThroughputParameters ThroughputSettingsUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "keyspaceName": autorest.Encode("path", keyspaceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + 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.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/throughputSettings/default", pathParameters), + autorest.WithJSON(updateThroughputParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateCassandraKeyspaceThroughputSender sends the UpdateCassandraKeyspaceThroughput request. The method will close the +// http.Response Body if it receives an error. +func (client CassandraResourcesClient) UpdateCassandraKeyspaceThroughputSender(req *http.Request) (future CassandraResourcesUpdateCassandraKeyspaceThroughputFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// UpdateCassandraKeyspaceThroughputResponder handles the response to the UpdateCassandraKeyspaceThroughput request. The method always +// closes the http.Response Body. +func (client CassandraResourcesClient) UpdateCassandraKeyspaceThroughputResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// UpdateCassandraTableThroughput update RUs per second of an Azure Cosmos DB Cassandra table +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// keyspaceName - cosmos DB keyspace name. +// tableName - cosmos DB table name. +// updateThroughputParameters - the RUs per second of the parameters to provide for the current Cassandra +// table. +func (client CassandraResourcesClient) UpdateCassandraTableThroughput(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string, tableName string, updateThroughputParameters ThroughputSettingsUpdateParameters) (result CassandraResourcesUpdateCassandraTableThroughputFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CassandraResourcesClient.UpdateCassandraTableThroughput") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}, + {TargetValue: updateThroughputParameters, + Constraints: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties.Resource", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties.Resource.AutoscaleSettings", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties.Resource.AutoscaleSettings.MaxThroughput", Name: validation.Null, Rule: true, Chain: nil}}}, + }}, + }}}}}); err != nil { + return result, validation.NewError("documentdb.CassandraResourcesClient", "UpdateCassandraTableThroughput", err.Error()) + } + + req, err := client.UpdateCassandraTableThroughputPreparer(ctx, resourceGroupName, accountName, keyspaceName, tableName, updateThroughputParameters) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "UpdateCassandraTableThroughput", nil, "Failure preparing request") + return + } + + result, err = client.UpdateCassandraTableThroughputSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "UpdateCassandraTableThroughput", nil, "Failure sending request") + return + } + + return +} + +// UpdateCassandraTableThroughputPreparer prepares the UpdateCassandraTableThroughput request. +func (client CassandraResourcesClient) UpdateCassandraTableThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string, tableName string, updateThroughputParameters ThroughputSettingsUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "keyspaceName": autorest.Encode("path", keyspaceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "tableName": autorest.Encode("path", tableName), + } + + const APIVersion = "2021-06-15" + 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.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/tables/{tableName}/throughputSettings/default", pathParameters), + autorest.WithJSON(updateThroughputParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateCassandraTableThroughputSender sends the UpdateCassandraTableThroughput request. The method will close the +// http.Response Body if it receives an error. +func (client CassandraResourcesClient) UpdateCassandraTableThroughputSender(req *http.Request) (future CassandraResourcesUpdateCassandraTableThroughputFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// UpdateCassandraTableThroughputResponder handles the response to the UpdateCassandraTableThroughput request. The method always +// closes the http.Response Body. +func (client CassandraResourcesClient) UpdateCassandraTableThroughputResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/cosmos-db/mgmt/2021-06-15/documentdb/client.go b/services/cosmos-db/mgmt/2021-06-15/documentdb/client.go new file mode 100644 index 000000000000..07e069042592 --- /dev/null +++ b/services/cosmos-db/mgmt/2021-06-15/documentdb/client.go @@ -0,0 +1,41 @@ +// Package documentdb implements the Azure ARM Documentdb service API version 2021-06-15. +// +// +package documentdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" +) + +const ( + // DefaultBaseURI is the default URI used for the service Documentdb + DefaultBaseURI = "https://management.azure.com" +) + +// BaseClient is the base client for Documentdb. +type BaseClient struct { + autorest.Client + BaseURI string + SubscriptionID string +} + +// New creates an instance of the BaseClient client. +func New(subscriptionID string) BaseClient { + return NewWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewWithBaseURI creates an instance of the BaseClient client using a custom endpoint. Use this when interacting with +// an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { + return BaseClient{ + Client: autorest.NewClientWithUserAgent(UserAgent()), + BaseURI: baseURI, + SubscriptionID: subscriptionID, + } +} diff --git a/services/cosmos-db/mgmt/2021-06-15/documentdb/collection.go b/services/cosmos-db/mgmt/2021-06-15/documentdb/collection.go new file mode 100644 index 000000000000..8fec3c00c68c --- /dev/null +++ b/services/cosmos-db/mgmt/2021-06-15/documentdb/collection.go @@ -0,0 +1,320 @@ +package documentdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// CollectionClient is the client for the Collection methods of the Documentdb service. +type CollectionClient struct { + BaseClient +} + +// NewCollectionClient creates an instance of the CollectionClient client. +func NewCollectionClient(subscriptionID string) CollectionClient { + return NewCollectionClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewCollectionClientWithBaseURI creates an instance of the CollectionClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewCollectionClientWithBaseURI(baseURI string, subscriptionID string) CollectionClient { + return CollectionClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListMetricDefinitions retrieves metric definitions for the given collection. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseRid - cosmos DB database rid. +// collectionRid - cosmos DB collection rid. +func (client CollectionClient) ListMetricDefinitions(ctx context.Context, resourceGroupName string, accountName string, databaseRid string, collectionRid string) (result MetricDefinitionsListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CollectionClient.ListMetricDefinitions") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.CollectionClient", "ListMetricDefinitions", err.Error()) + } + + req, err := client.ListMetricDefinitionsPreparer(ctx, resourceGroupName, accountName, databaseRid, collectionRid) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CollectionClient", "ListMetricDefinitions", nil, "Failure preparing request") + return + } + + resp, err := client.ListMetricDefinitionsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.CollectionClient", "ListMetricDefinitions", resp, "Failure sending request") + return + } + + result, err = client.ListMetricDefinitionsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CollectionClient", "ListMetricDefinitions", resp, "Failure responding to request") + return + } + + return +} + +// ListMetricDefinitionsPreparer prepares the ListMetricDefinitions request. +func (client CollectionClient) ListMetricDefinitionsPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseRid string, collectionRid string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "collectionRid": autorest.Encode("path", collectionRid), + "databaseRid": autorest.Encode("path", databaseRid), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/collections/{collectionRid}/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 CollectionClient) ListMetricDefinitionsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListMetricDefinitionsResponder handles the response to the ListMetricDefinitions request. The method always +// closes the http.Response Body. +func (client CollectionClient) ListMetricDefinitionsResponder(resp *http.Response) (result MetricDefinitionsListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListMetrics retrieves the metrics determined by the given filter for the given database account and collection. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseRid - cosmos DB database rid. +// collectionRid - cosmos DB collection rid. +// filter - an OData filter expression that describes a subset of metrics to return. The parameters that can be +// filtered are name.value (name of the metric, can have an or of multiple names), startTime, endTime, and +// timeGrain. The supported operator is eq. +func (client CollectionClient) ListMetrics(ctx context.Context, resourceGroupName string, accountName string, databaseRid string, collectionRid string, filter string) (result MetricListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CollectionClient.ListMetrics") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.CollectionClient", "ListMetrics", err.Error()) + } + + req, err := client.ListMetricsPreparer(ctx, resourceGroupName, accountName, databaseRid, collectionRid, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CollectionClient", "ListMetrics", nil, "Failure preparing request") + return + } + + resp, err := client.ListMetricsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.CollectionClient", "ListMetrics", resp, "Failure sending request") + return + } + + result, err = client.ListMetricsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CollectionClient", "ListMetrics", resp, "Failure responding to request") + return + } + + return +} + +// ListMetricsPreparer prepares the ListMetrics request. +func (client CollectionClient) ListMetricsPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseRid string, collectionRid string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "collectionRid": autorest.Encode("path", collectionRid), + "databaseRid": autorest.Encode("path", databaseRid), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + 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.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/collections/{collectionRid}/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 CollectionClient) ListMetricsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListMetricsResponder handles the response to the ListMetrics request. The method always +// closes the http.Response Body. +func (client CollectionClient) ListMetricsResponder(resp *http.Response) (result MetricListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListUsages retrieves the usages (most recent storage data) for the given collection. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseRid - cosmos DB database rid. +// collectionRid - cosmos DB collection rid. +// filter - an OData filter expression that describes a subset of usages to return. The supported parameter is +// name.value (name of the metric, can have an or of multiple names). +func (client CollectionClient) ListUsages(ctx context.Context, resourceGroupName string, accountName string, databaseRid string, collectionRid string, filter string) (result UsagesResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CollectionClient.ListUsages") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.CollectionClient", "ListUsages", err.Error()) + } + + req, err := client.ListUsagesPreparer(ctx, resourceGroupName, accountName, databaseRid, collectionRid, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CollectionClient", "ListUsages", nil, "Failure preparing request") + return + } + + resp, err := client.ListUsagesSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.CollectionClient", "ListUsages", resp, "Failure sending request") + return + } + + result, err = client.ListUsagesResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CollectionClient", "ListUsages", resp, "Failure responding to request") + return + } + + return +} + +// ListUsagesPreparer prepares the ListUsages request. +func (client CollectionClient) ListUsagesPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseRid string, collectionRid string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "collectionRid": autorest.Encode("path", collectionRid), + "databaseRid": autorest.Encode("path", databaseRid), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/collections/{collectionRid}/usages", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListUsagesSender sends the ListUsages request. The method will close the +// http.Response Body if it receives an error. +func (client CollectionClient) ListUsagesSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListUsagesResponder handles the response to the ListUsages request. The method always +// closes the http.Response Body. +func (client CollectionClient) ListUsagesResponder(resp *http.Response) (result UsagesResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/cosmos-db/mgmt/2021-06-15/documentdb/collectionpartition.go b/services/cosmos-db/mgmt/2021-06-15/documentdb/collectionpartition.go new file mode 100644 index 000000000000..6187dcbd458e --- /dev/null +++ b/services/cosmos-db/mgmt/2021-06-15/documentdb/collectionpartition.go @@ -0,0 +1,228 @@ +package documentdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// CollectionPartitionClient is the client for the CollectionPartition methods of the Documentdb service. +type CollectionPartitionClient struct { + BaseClient +} + +// NewCollectionPartitionClient creates an instance of the CollectionPartitionClient client. +func NewCollectionPartitionClient(subscriptionID string) CollectionPartitionClient { + return NewCollectionPartitionClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewCollectionPartitionClientWithBaseURI creates an instance of the CollectionPartitionClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewCollectionPartitionClientWithBaseURI(baseURI string, subscriptionID string) CollectionPartitionClient { + return CollectionPartitionClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListMetrics retrieves the metrics determined by the given filter for the given collection, split by partition. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseRid - cosmos DB database rid. +// collectionRid - cosmos DB collection rid. +// filter - an OData filter expression that describes a subset of metrics to return. The parameters that can be +// filtered are name.value (name of the metric, can have an or of multiple names), startTime, endTime, and +// timeGrain. The supported operator is eq. +func (client CollectionPartitionClient) ListMetrics(ctx context.Context, resourceGroupName string, accountName string, databaseRid string, collectionRid string, filter string) (result PartitionMetricListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CollectionPartitionClient.ListMetrics") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.CollectionPartitionClient", "ListMetrics", err.Error()) + } + + req, err := client.ListMetricsPreparer(ctx, resourceGroupName, accountName, databaseRid, collectionRid, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CollectionPartitionClient", "ListMetrics", nil, "Failure preparing request") + return + } + + resp, err := client.ListMetricsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.CollectionPartitionClient", "ListMetrics", resp, "Failure sending request") + return + } + + result, err = client.ListMetricsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CollectionPartitionClient", "ListMetrics", resp, "Failure responding to request") + return + } + + return +} + +// ListMetricsPreparer prepares the ListMetrics request. +func (client CollectionPartitionClient) ListMetricsPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseRid string, collectionRid string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "collectionRid": autorest.Encode("path", collectionRid), + "databaseRid": autorest.Encode("path", databaseRid), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + 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.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/collections/{collectionRid}/partitions/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 CollectionPartitionClient) ListMetricsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListMetricsResponder handles the response to the ListMetrics request. The method always +// closes the http.Response Body. +func (client CollectionPartitionClient) ListMetricsResponder(resp *http.Response) (result PartitionMetricListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListUsages retrieves the usages (most recent storage data) for the given collection, split by partition. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseRid - cosmos DB database rid. +// collectionRid - cosmos DB collection rid. +// filter - an OData filter expression that describes a subset of usages to return. The supported parameter is +// name.value (name of the metric, can have an or of multiple names). +func (client CollectionPartitionClient) ListUsages(ctx context.Context, resourceGroupName string, accountName string, databaseRid string, collectionRid string, filter string) (result PartitionUsagesResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CollectionPartitionClient.ListUsages") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.CollectionPartitionClient", "ListUsages", err.Error()) + } + + req, err := client.ListUsagesPreparer(ctx, resourceGroupName, accountName, databaseRid, collectionRid, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CollectionPartitionClient", "ListUsages", nil, "Failure preparing request") + return + } + + resp, err := client.ListUsagesSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.CollectionPartitionClient", "ListUsages", resp, "Failure sending request") + return + } + + result, err = client.ListUsagesResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CollectionPartitionClient", "ListUsages", resp, "Failure responding to request") + return + } + + return +} + +// ListUsagesPreparer prepares the ListUsages request. +func (client CollectionPartitionClient) ListUsagesPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseRid string, collectionRid string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "collectionRid": autorest.Encode("path", collectionRid), + "databaseRid": autorest.Encode("path", databaseRid), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/collections/{collectionRid}/partitions/usages", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListUsagesSender sends the ListUsages request. The method will close the +// http.Response Body if it receives an error. +func (client CollectionPartitionClient) ListUsagesSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListUsagesResponder handles the response to the ListUsages request. The method always +// closes the http.Response Body. +func (client CollectionPartitionClient) ListUsagesResponder(resp *http.Response) (result PartitionUsagesResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/cosmos-db/mgmt/2021-06-15/documentdb/collectionpartitionregion.go b/services/cosmos-db/mgmt/2021-06-15/documentdb/collectionpartitionregion.go new file mode 100644 index 000000000000..6fbb8b524cd1 --- /dev/null +++ b/services/cosmos-db/mgmt/2021-06-15/documentdb/collectionpartitionregion.go @@ -0,0 +1,133 @@ +package documentdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// CollectionPartitionRegionClient is the client for the CollectionPartitionRegion methods of the Documentdb service. +type CollectionPartitionRegionClient struct { + BaseClient +} + +// NewCollectionPartitionRegionClient creates an instance of the CollectionPartitionRegionClient client. +func NewCollectionPartitionRegionClient(subscriptionID string) CollectionPartitionRegionClient { + return NewCollectionPartitionRegionClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewCollectionPartitionRegionClientWithBaseURI creates an instance of the CollectionPartitionRegionClient client +// using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign +// clouds, Azure stack). +func NewCollectionPartitionRegionClientWithBaseURI(baseURI string, subscriptionID string) CollectionPartitionRegionClient { + return CollectionPartitionRegionClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListMetrics retrieves the metrics determined by the given filter for the given collection and region, split by +// partition. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// region - cosmos DB region, with spaces between words and each word capitalized. +// databaseRid - cosmos DB database rid. +// collectionRid - cosmos DB collection rid. +// filter - an OData filter expression that describes a subset of metrics to return. The parameters that can be +// filtered are name.value (name of the metric, can have an or of multiple names), startTime, endTime, and +// timeGrain. The supported operator is eq. +func (client CollectionPartitionRegionClient) ListMetrics(ctx context.Context, resourceGroupName string, accountName string, region string, databaseRid string, collectionRid string, filter string) (result PartitionMetricListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CollectionPartitionRegionClient.ListMetrics") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.CollectionPartitionRegionClient", "ListMetrics", err.Error()) + } + + req, err := client.ListMetricsPreparer(ctx, resourceGroupName, accountName, region, databaseRid, collectionRid, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CollectionPartitionRegionClient", "ListMetrics", nil, "Failure preparing request") + return + } + + resp, err := client.ListMetricsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.CollectionPartitionRegionClient", "ListMetrics", resp, "Failure sending request") + return + } + + result, err = client.ListMetricsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CollectionPartitionRegionClient", "ListMetrics", resp, "Failure responding to request") + return + } + + return +} + +// ListMetricsPreparer prepares the ListMetrics request. +func (client CollectionPartitionRegionClient) ListMetricsPreparer(ctx context.Context, resourceGroupName string, accountName string, region string, databaseRid string, collectionRid string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "collectionRid": autorest.Encode("path", collectionRid), + "databaseRid": autorest.Encode("path", databaseRid), + "region": autorest.Encode("path", region), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + 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.DocumentDB/databaseAccounts/{accountName}/region/{region}/databases/{databaseRid}/collections/{collectionRid}/partitions/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 CollectionPartitionRegionClient) ListMetricsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListMetricsResponder handles the response to the ListMetrics request. The method always +// closes the http.Response Body. +func (client CollectionPartitionRegionClient) ListMetricsResponder(resp *http.Response) (result PartitionMetricListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/cosmos-db/mgmt/2021-06-15/documentdb/collectionregion.go b/services/cosmos-db/mgmt/2021-06-15/documentdb/collectionregion.go new file mode 100644 index 000000000000..90e7d6de41b5 --- /dev/null +++ b/services/cosmos-db/mgmt/2021-06-15/documentdb/collectionregion.go @@ -0,0 +1,133 @@ +package documentdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// CollectionRegionClient is the client for the CollectionRegion methods of the Documentdb service. +type CollectionRegionClient struct { + BaseClient +} + +// NewCollectionRegionClient creates an instance of the CollectionRegionClient client. +func NewCollectionRegionClient(subscriptionID string) CollectionRegionClient { + return NewCollectionRegionClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewCollectionRegionClientWithBaseURI creates an instance of the CollectionRegionClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewCollectionRegionClientWithBaseURI(baseURI string, subscriptionID string) CollectionRegionClient { + return CollectionRegionClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListMetrics retrieves the metrics determined by the given filter for the given database account, collection and +// region. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// region - cosmos DB region, with spaces between words and each word capitalized. +// databaseRid - cosmos DB database rid. +// collectionRid - cosmos DB collection rid. +// filter - an OData filter expression that describes a subset of metrics to return. The parameters that can be +// filtered are name.value (name of the metric, can have an or of multiple names), startTime, endTime, and +// timeGrain. The supported operator is eq. +func (client CollectionRegionClient) ListMetrics(ctx context.Context, resourceGroupName string, accountName string, region string, databaseRid string, collectionRid string, filter string) (result MetricListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CollectionRegionClient.ListMetrics") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.CollectionRegionClient", "ListMetrics", err.Error()) + } + + req, err := client.ListMetricsPreparer(ctx, resourceGroupName, accountName, region, databaseRid, collectionRid, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CollectionRegionClient", "ListMetrics", nil, "Failure preparing request") + return + } + + resp, err := client.ListMetricsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.CollectionRegionClient", "ListMetrics", resp, "Failure sending request") + return + } + + result, err = client.ListMetricsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CollectionRegionClient", "ListMetrics", resp, "Failure responding to request") + return + } + + return +} + +// ListMetricsPreparer prepares the ListMetrics request. +func (client CollectionRegionClient) ListMetricsPreparer(ctx context.Context, resourceGroupName string, accountName string, region string, databaseRid string, collectionRid string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "collectionRid": autorest.Encode("path", collectionRid), + "databaseRid": autorest.Encode("path", databaseRid), + "region": autorest.Encode("path", region), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + 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.DocumentDB/databaseAccounts/{accountName}/region/{region}/databases/{databaseRid}/collections/{collectionRid}/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 CollectionRegionClient) ListMetricsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListMetricsResponder handles the response to the ListMetrics request. The method always +// closes the http.Response Body. +func (client CollectionRegionClient) ListMetricsResponder(resp *http.Response) (result MetricListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/cosmos-db/mgmt/2021-06-15/documentdb/database.go b/services/cosmos-db/mgmt/2021-06-15/documentdb/database.go new file mode 100644 index 000000000000..162ce93ba6bb --- /dev/null +++ b/services/cosmos-db/mgmt/2021-06-15/documentdb/database.go @@ -0,0 +1,314 @@ +package documentdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// DatabaseClient is the client for the Database methods of the Documentdb service. +type DatabaseClient struct { + BaseClient +} + +// NewDatabaseClient creates an instance of the DatabaseClient client. +func NewDatabaseClient(subscriptionID string) DatabaseClient { + return NewDatabaseClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewDatabaseClientWithBaseURI creates an instance of the DatabaseClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewDatabaseClientWithBaseURI(baseURI string, subscriptionID string) DatabaseClient { + return DatabaseClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListMetricDefinitions retrieves metric definitions for the given database. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseRid - cosmos DB database rid. +func (client DatabaseClient) ListMetricDefinitions(ctx context.Context, resourceGroupName string, accountName string, databaseRid string) (result MetricDefinitionsListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseClient.ListMetricDefinitions") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.DatabaseClient", "ListMetricDefinitions", err.Error()) + } + + req, err := client.ListMetricDefinitionsPreparer(ctx, resourceGroupName, accountName, databaseRid) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseClient", "ListMetricDefinitions", nil, "Failure preparing request") + return + } + + resp, err := client.ListMetricDefinitionsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.DatabaseClient", "ListMetricDefinitions", resp, "Failure sending request") + return + } + + result, err = client.ListMetricDefinitionsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseClient", "ListMetricDefinitions", resp, "Failure responding to request") + return + } + + return +} + +// ListMetricDefinitionsPreparer prepares the ListMetricDefinitions request. +func (client DatabaseClient) ListMetricDefinitionsPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseRid string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "databaseRid": autorest.Encode("path", databaseRid), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/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 DatabaseClient) ListMetricDefinitionsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListMetricDefinitionsResponder handles the response to the ListMetricDefinitions request. The method always +// closes the http.Response Body. +func (client DatabaseClient) ListMetricDefinitionsResponder(resp *http.Response) (result MetricDefinitionsListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListMetrics retrieves the metrics determined by the given filter for the given database account and database. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseRid - cosmos DB database rid. +// filter - an OData filter expression that describes a subset of metrics to return. The parameters that can be +// filtered are name.value (name of the metric, can have an or of multiple names), startTime, endTime, and +// timeGrain. The supported operator is eq. +func (client DatabaseClient) ListMetrics(ctx context.Context, resourceGroupName string, accountName string, databaseRid string, filter string) (result MetricListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseClient.ListMetrics") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.DatabaseClient", "ListMetrics", err.Error()) + } + + req, err := client.ListMetricsPreparer(ctx, resourceGroupName, accountName, databaseRid, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseClient", "ListMetrics", nil, "Failure preparing request") + return + } + + resp, err := client.ListMetricsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.DatabaseClient", "ListMetrics", resp, "Failure sending request") + return + } + + result, err = client.ListMetricsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseClient", "ListMetrics", resp, "Failure responding to request") + return + } + + return +} + +// ListMetricsPreparer prepares the ListMetrics request. +func (client DatabaseClient) ListMetricsPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseRid string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "databaseRid": autorest.Encode("path", databaseRid), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + 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.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/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 DatabaseClient) ListMetricsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListMetricsResponder handles the response to the ListMetrics request. The method always +// closes the http.Response Body. +func (client DatabaseClient) ListMetricsResponder(resp *http.Response) (result MetricListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListUsages retrieves the usages (most recent data) for the given database. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseRid - cosmos DB database rid. +// filter - an OData filter expression that describes a subset of usages to return. The supported parameter is +// name.value (name of the metric, can have an or of multiple names). +func (client DatabaseClient) ListUsages(ctx context.Context, resourceGroupName string, accountName string, databaseRid string, filter string) (result UsagesResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseClient.ListUsages") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.DatabaseClient", "ListUsages", err.Error()) + } + + req, err := client.ListUsagesPreparer(ctx, resourceGroupName, accountName, databaseRid, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseClient", "ListUsages", nil, "Failure preparing request") + return + } + + resp, err := client.ListUsagesSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.DatabaseClient", "ListUsages", resp, "Failure sending request") + return + } + + result, err = client.ListUsagesResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseClient", "ListUsages", resp, "Failure responding to request") + return + } + + return +} + +// ListUsagesPreparer prepares the ListUsages request. +func (client DatabaseClient) ListUsagesPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseRid string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "databaseRid": autorest.Encode("path", databaseRid), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/usages", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListUsagesSender sends the ListUsages request. The method will close the +// http.Response Body if it receives an error. +func (client DatabaseClient) ListUsagesSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListUsagesResponder handles the response to the ListUsages request. The method always +// closes the http.Response Body. +func (client DatabaseClient) ListUsagesResponder(resp *http.Response) (result UsagesResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/cosmos-db/mgmt/2021-06-15/documentdb/databaseaccountregion.go b/services/cosmos-db/mgmt/2021-06-15/documentdb/databaseaccountregion.go new file mode 100644 index 000000000000..41eec709fe56 --- /dev/null +++ b/services/cosmos-db/mgmt/2021-06-15/documentdb/databaseaccountregion.go @@ -0,0 +1,128 @@ +package documentdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// DatabaseAccountRegionClient is the client for the DatabaseAccountRegion methods of the Documentdb service. +type DatabaseAccountRegionClient struct { + BaseClient +} + +// NewDatabaseAccountRegionClient creates an instance of the DatabaseAccountRegionClient client. +func NewDatabaseAccountRegionClient(subscriptionID string) DatabaseAccountRegionClient { + return NewDatabaseAccountRegionClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewDatabaseAccountRegionClientWithBaseURI creates an instance of the DatabaseAccountRegionClient client using a +// custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, +// Azure stack). +func NewDatabaseAccountRegionClientWithBaseURI(baseURI string, subscriptionID string) DatabaseAccountRegionClient { + return DatabaseAccountRegionClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListMetrics retrieves the metrics determined by the given filter for the given database account and region. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// region - cosmos DB region, with spaces between words and each word capitalized. +// filter - an OData filter expression that describes a subset of metrics to return. The parameters that can be +// filtered are name.value (name of the metric, can have an or of multiple names), startTime, endTime, and +// timeGrain. The supported operator is eq. +func (client DatabaseAccountRegionClient) ListMetrics(ctx context.Context, resourceGroupName string, accountName string, region string, filter string) (result MetricListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountRegionClient.ListMetrics") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.DatabaseAccountRegionClient", "ListMetrics", err.Error()) + } + + req, err := client.ListMetricsPreparer(ctx, resourceGroupName, accountName, region, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountRegionClient", "ListMetrics", nil, "Failure preparing request") + return + } + + resp, err := client.ListMetricsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountRegionClient", "ListMetrics", resp, "Failure sending request") + return + } + + result, err = client.ListMetricsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountRegionClient", "ListMetrics", resp, "Failure responding to request") + return + } + + return +} + +// ListMetricsPreparer prepares the ListMetrics request. +func (client DatabaseAccountRegionClient) ListMetricsPreparer(ctx context.Context, resourceGroupName string, accountName string, region string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "region": autorest.Encode("path", region), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + 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.DocumentDB/databaseAccounts/{accountName}/region/{region}/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 DatabaseAccountRegionClient) ListMetricsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListMetricsResponder handles the response to the ListMetrics request. The method always +// closes the http.Response Body. +func (client DatabaseAccountRegionClient) ListMetricsResponder(resp *http.Response) (result MetricListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/cosmos-db/mgmt/2021-06-15/documentdb/databaseaccounts.go b/services/cosmos-db/mgmt/2021-06-15/documentdb/databaseaccounts.go new file mode 100644 index 000000000000..0f0e8f8b275c --- /dev/null +++ b/services/cosmos-db/mgmt/2021-06-15/documentdb/databaseaccounts.go @@ -0,0 +1,1669 @@ +package documentdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// DatabaseAccountsClient is the client for the DatabaseAccounts methods of the Documentdb service. +type DatabaseAccountsClient struct { + BaseClient +} + +// NewDatabaseAccountsClient creates an instance of the DatabaseAccountsClient client. +func NewDatabaseAccountsClient(subscriptionID string) DatabaseAccountsClient { + return NewDatabaseAccountsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewDatabaseAccountsClientWithBaseURI creates an instance of the DatabaseAccountsClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewDatabaseAccountsClientWithBaseURI(baseURI string, subscriptionID string) DatabaseAccountsClient { + return DatabaseAccountsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CheckNameExists checks that the Azure Cosmos DB account name already exists. A valid account name may contain only +// lowercase letters, numbers, and the '-' character, and must be between 3 and 50 characters. +// Parameters: +// accountName - cosmos DB database account name. +func (client DatabaseAccountsClient) CheckNameExists(ctx context.Context, accountName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.CheckNameExists") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.DatabaseAccountsClient", "CheckNameExists", err.Error()) + } + + req, err := client.CheckNameExistsPreparer(ctx, accountName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "CheckNameExists", nil, "Failure preparing request") + return + } + + resp, err := client.CheckNameExistsSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "CheckNameExists", resp, "Failure sending request") + return + } + + result, err = client.CheckNameExistsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "CheckNameExists", resp, "Failure responding to request") + return + } + + return +} + +// CheckNameExistsPreparer prepares the CheckNameExists request. +func (client DatabaseAccountsClient) CheckNameExistsPreparer(ctx context.Context, accountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + } + + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsHead(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.DocumentDB/databaseAccountNames/{accountName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CheckNameExistsSender sends the CheckNameExists request. The method will close the +// http.Response Body if it receives an error. +func (client DatabaseAccountsClient) CheckNameExistsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// CheckNameExistsResponder handles the response to the CheckNameExists request. The method always +// closes the http.Response Body. +func (client DatabaseAccountsClient) CheckNameExistsResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNotFound), + autorest.ByClosing()) + result.Response = resp + return +} + +// CreateOrUpdate creates or updates an Azure Cosmos DB database account. The "Update" method is preferred when +// performing updates on an account. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// createUpdateParameters - the parameters to provide for the current database account. +func (client DatabaseAccountsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, accountName string, createUpdateParameters DatabaseAccountCreateUpdateParameters) (result DatabaseAccountsCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}, + {TargetValue: createUpdateParameters, + Constraints: []validation.Constraint{{Target: "createUpdateParameters.DatabaseAccountCreateUpdateProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "createUpdateParameters.DatabaseAccountCreateUpdateProperties.ConsistencyPolicy", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "createUpdateParameters.DatabaseAccountCreateUpdateProperties.ConsistencyPolicy.MaxStalenessPrefix", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "createUpdateParameters.DatabaseAccountCreateUpdateProperties.ConsistencyPolicy.MaxStalenessPrefix", Name: validation.InclusiveMaximum, Rule: int64(2147483647), Chain: nil}, + {Target: "createUpdateParameters.DatabaseAccountCreateUpdateProperties.ConsistencyPolicy.MaxStalenessPrefix", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}, + }}, + {Target: "createUpdateParameters.DatabaseAccountCreateUpdateProperties.ConsistencyPolicy.MaxIntervalInSeconds", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "createUpdateParameters.DatabaseAccountCreateUpdateProperties.ConsistencyPolicy.MaxIntervalInSeconds", Name: validation.InclusiveMaximum, Rule: int64(86400), Chain: nil}, + {Target: "createUpdateParameters.DatabaseAccountCreateUpdateProperties.ConsistencyPolicy.MaxIntervalInSeconds", Name: validation.InclusiveMinimum, Rule: int64(5), Chain: nil}, + }}, + }}, + {Target: "createUpdateParameters.DatabaseAccountCreateUpdateProperties.Locations", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "createUpdateParameters.DatabaseAccountCreateUpdateProperties.DatabaseAccountOfferType", Name: validation.Null, Rule: true, Chain: nil}, + }}}}}); err != nil { + return result, validation.NewError("documentdb.DatabaseAccountsClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, accountName, createUpdateParameters) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "CreateOrUpdate", nil, "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client DatabaseAccountsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, accountName string, createUpdateParameters DatabaseAccountCreateUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + 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.DocumentDB/databaseAccounts/{accountName}", pathParameters), + autorest.WithJSON(createUpdateParameters), + 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 DatabaseAccountsClient) CreateOrUpdateSender(req *http.Request) (future DatabaseAccountsCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client DatabaseAccountsClient) CreateOrUpdateResponder(resp *http.Response) (result DatabaseAccountGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes an existing Azure Cosmos DB database account. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +func (client DatabaseAccountsClient) Delete(ctx context.Context, resourceGroupName string, accountName string) (result DatabaseAccountsDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.DatabaseAccountsClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, accountName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "Delete", nil, "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client DatabaseAccountsClient) DeletePreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}", 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 DatabaseAccountsClient) DeleteSender(req *http.Request) (future DatabaseAccountsDeleteFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client DatabaseAccountsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// FailoverPriorityChange changes the failover priority for the Azure Cosmos DB database account. A failover priority +// of 0 indicates a write region. The maximum value for a failover priority = (total number of regions - 1). Failover +// priority values must be unique for each of the regions in which the database account exists. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// failoverParameters - the new failover policies for the database account. +func (client DatabaseAccountsClient) FailoverPriorityChange(ctx context.Context, resourceGroupName string, accountName string, failoverParameters FailoverPolicies) (result DatabaseAccountsFailoverPriorityChangeFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.FailoverPriorityChange") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}, + {TargetValue: failoverParameters, + Constraints: []validation.Constraint{{Target: "failoverParameters.FailoverPolicies", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.DatabaseAccountsClient", "FailoverPriorityChange", err.Error()) + } + + req, err := client.FailoverPriorityChangePreparer(ctx, resourceGroupName, accountName, failoverParameters) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "FailoverPriorityChange", nil, "Failure preparing request") + return + } + + result, err = client.FailoverPriorityChangeSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "FailoverPriorityChange", nil, "Failure sending request") + return + } + + return +} + +// FailoverPriorityChangePreparer prepares the FailoverPriorityChange request. +func (client DatabaseAccountsClient) FailoverPriorityChangePreparer(ctx context.Context, resourceGroupName string, accountName string, failoverParameters FailoverPolicies) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + 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.DocumentDB/databaseAccounts/{accountName}/failoverPriorityChange", pathParameters), + autorest.WithJSON(failoverParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// FailoverPriorityChangeSender sends the FailoverPriorityChange request. The method will close the +// http.Response Body if it receives an error. +func (client DatabaseAccountsClient) FailoverPriorityChangeSender(req *http.Request) (future DatabaseAccountsFailoverPriorityChangeFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// FailoverPriorityChangeResponder handles the response to the FailoverPriorityChange request. The method always +// closes the http.Response Body. +func (client DatabaseAccountsClient) FailoverPriorityChangeResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get retrieves the properties of an existing Azure Cosmos DB database account. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +func (client DatabaseAccountsClient) Get(ctx context.Context, resourceGroupName string, accountName string) (result DatabaseAccountGetResults, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.DatabaseAccountsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, accountName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client DatabaseAccountsClient) GetPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}", 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 DatabaseAccountsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client DatabaseAccountsClient) GetResponder(resp *http.Response) (result DatabaseAccountGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetReadOnlyKeys lists the read-only access keys for the specified Azure Cosmos DB database account. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +func (client DatabaseAccountsClient) GetReadOnlyKeys(ctx context.Context, resourceGroupName string, accountName string) (result DatabaseAccountListReadOnlyKeysResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.GetReadOnlyKeys") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.DatabaseAccountsClient", "GetReadOnlyKeys", err.Error()) + } + + req, err := client.GetReadOnlyKeysPreparer(ctx, resourceGroupName, accountName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "GetReadOnlyKeys", nil, "Failure preparing request") + return + } + + resp, err := client.GetReadOnlyKeysSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "GetReadOnlyKeys", resp, "Failure sending request") + return + } + + result, err = client.GetReadOnlyKeysResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "GetReadOnlyKeys", resp, "Failure responding to request") + return + } + + return +} + +// GetReadOnlyKeysPreparer prepares the GetReadOnlyKeys request. +func (client DatabaseAccountsClient) GetReadOnlyKeysPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/readonlykeys", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetReadOnlyKeysSender sends the GetReadOnlyKeys request. The method will close the +// http.Response Body if it receives an error. +func (client DatabaseAccountsClient) GetReadOnlyKeysSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetReadOnlyKeysResponder handles the response to the GetReadOnlyKeys request. The method always +// closes the http.Response Body. +func (client DatabaseAccountsClient) GetReadOnlyKeysResponder(resp *http.Response) (result DatabaseAccountListReadOnlyKeysResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List lists all the Azure Cosmos DB database accounts available under the subscription. +func (client DatabaseAccountsClient) List(ctx context.Context) (result DatabaseAccountsListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.List") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.DatabaseAccountsClient", "List", err.Error()) + } + + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "List", resp, "Failure responding to request") + return + } + + return +} + +// ListPreparer prepares the List request. +func (client DatabaseAccountsClient) ListPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/databaseAccounts", 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 DatabaseAccountsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client DatabaseAccountsClient) ListResponder(resp *http.Response) (result DatabaseAccountsListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByResourceGroup lists all the Azure Cosmos DB database accounts available under the given resource group. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +func (client DatabaseAccountsClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result DatabaseAccountsListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.DatabaseAccountsClient", "ListByResourceGroup", err.Error()) + } + + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "ListByResourceGroup", resp, "Failure responding to request") + return + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client DatabaseAccountsClient) 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 = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts", 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 DatabaseAccountsClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client DatabaseAccountsClient) ListByResourceGroupResponder(resp *http.Response) (result DatabaseAccountsListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListConnectionStrings lists the connection strings for the specified Azure Cosmos DB database account. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +func (client DatabaseAccountsClient) ListConnectionStrings(ctx context.Context, resourceGroupName string, accountName string) (result DatabaseAccountListConnectionStringsResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.ListConnectionStrings") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.DatabaseAccountsClient", "ListConnectionStrings", err.Error()) + } + + req, err := client.ListConnectionStringsPreparer(ctx, resourceGroupName, accountName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "ListConnectionStrings", nil, "Failure preparing request") + return + } + + resp, err := client.ListConnectionStringsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "ListConnectionStrings", resp, "Failure sending request") + return + } + + result, err = client.ListConnectionStringsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "ListConnectionStrings", resp, "Failure responding to request") + return + } + + return +} + +// ListConnectionStringsPreparer prepares the ListConnectionStrings request. +func (client DatabaseAccountsClient) ListConnectionStringsPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/listConnectionStrings", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListConnectionStringsSender sends the ListConnectionStrings request. The method will close the +// http.Response Body if it receives an error. +func (client DatabaseAccountsClient) ListConnectionStringsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListConnectionStringsResponder handles the response to the ListConnectionStrings request. The method always +// closes the http.Response Body. +func (client DatabaseAccountsClient) ListConnectionStringsResponder(resp *http.Response) (result DatabaseAccountListConnectionStringsResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListKeys lists the access keys for the specified Azure Cosmos DB database account. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +func (client DatabaseAccountsClient) ListKeys(ctx context.Context, resourceGroupName string, accountName string) (result DatabaseAccountListKeysResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.ListKeys") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.DatabaseAccountsClient", "ListKeys", err.Error()) + } + + req, err := client.ListKeysPreparer(ctx, resourceGroupName, accountName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "ListKeys", nil, "Failure preparing request") + return + } + + resp, err := client.ListKeysSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "ListKeys", resp, "Failure sending request") + return + } + + result, err = client.ListKeysResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "ListKeys", resp, "Failure responding to request") + return + } + + return +} + +// ListKeysPreparer prepares the ListKeys request. +func (client DatabaseAccountsClient) ListKeysPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/listKeys", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListKeysSender sends the ListKeys request. The method will close the +// http.Response Body if it receives an error. +func (client DatabaseAccountsClient) ListKeysSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListKeysResponder handles the response to the ListKeys request. The method always +// closes the http.Response Body. +func (client DatabaseAccountsClient) ListKeysResponder(resp *http.Response) (result DatabaseAccountListKeysResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListMetricDefinitions retrieves metric definitions for the given database account. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +func (client DatabaseAccountsClient) ListMetricDefinitions(ctx context.Context, resourceGroupName string, accountName string) (result MetricDefinitionsListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.ListMetricDefinitions") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.DatabaseAccountsClient", "ListMetricDefinitions", err.Error()) + } + + req, err := client.ListMetricDefinitionsPreparer(ctx, resourceGroupName, accountName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "ListMetricDefinitions", nil, "Failure preparing request") + return + } + + resp, err := client.ListMetricDefinitionsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "ListMetricDefinitions", resp, "Failure sending request") + return + } + + result, err = client.ListMetricDefinitionsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "ListMetricDefinitions", resp, "Failure responding to request") + return + } + + return +} + +// ListMetricDefinitionsPreparer prepares the ListMetricDefinitions request. +func (client DatabaseAccountsClient) ListMetricDefinitionsPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/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 DatabaseAccountsClient) ListMetricDefinitionsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListMetricDefinitionsResponder handles the response to the ListMetricDefinitions request. The method always +// closes the http.Response Body. +func (client DatabaseAccountsClient) ListMetricDefinitionsResponder(resp *http.Response) (result MetricDefinitionsListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListMetrics retrieves the metrics determined by the given filter for the given database account. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// filter - an OData filter expression that describes a subset of metrics to return. The parameters that can be +// filtered are name.value (name of the metric, can have an or of multiple names), startTime, endTime, and +// timeGrain. The supported operator is eq. +func (client DatabaseAccountsClient) ListMetrics(ctx context.Context, resourceGroupName string, accountName string, filter string) (result MetricListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.ListMetrics") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.DatabaseAccountsClient", "ListMetrics", err.Error()) + } + + req, err := client.ListMetricsPreparer(ctx, resourceGroupName, accountName, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "ListMetrics", nil, "Failure preparing request") + return + } + + resp, err := client.ListMetricsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "ListMetrics", resp, "Failure sending request") + return + } + + result, err = client.ListMetricsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "ListMetrics", resp, "Failure responding to request") + return + } + + return +} + +// ListMetricsPreparer prepares the ListMetrics request. +func (client DatabaseAccountsClient) ListMetricsPreparer(ctx context.Context, resourceGroupName string, accountName string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + 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.DocumentDB/databaseAccounts/{accountName}/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 DatabaseAccountsClient) ListMetricsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListMetricsResponder handles the response to the ListMetrics request. The method always +// closes the http.Response Body. +func (client DatabaseAccountsClient) ListMetricsResponder(resp *http.Response) (result MetricListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListReadOnlyKeys lists the read-only access keys for the specified Azure Cosmos DB database account. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +func (client DatabaseAccountsClient) ListReadOnlyKeys(ctx context.Context, resourceGroupName string, accountName string) (result DatabaseAccountListReadOnlyKeysResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.ListReadOnlyKeys") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.DatabaseAccountsClient", "ListReadOnlyKeys", err.Error()) + } + + req, err := client.ListReadOnlyKeysPreparer(ctx, resourceGroupName, accountName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "ListReadOnlyKeys", nil, "Failure preparing request") + return + } + + resp, err := client.ListReadOnlyKeysSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "ListReadOnlyKeys", resp, "Failure sending request") + return + } + + result, err = client.ListReadOnlyKeysResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "ListReadOnlyKeys", resp, "Failure responding to request") + return + } + + return +} + +// ListReadOnlyKeysPreparer prepares the ListReadOnlyKeys request. +func (client DatabaseAccountsClient) ListReadOnlyKeysPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/readonlykeys", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListReadOnlyKeysSender sends the ListReadOnlyKeys request. The method will close the +// http.Response Body if it receives an error. +func (client DatabaseAccountsClient) ListReadOnlyKeysSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListReadOnlyKeysResponder handles the response to the ListReadOnlyKeys request. The method always +// closes the http.Response Body. +func (client DatabaseAccountsClient) ListReadOnlyKeysResponder(resp *http.Response) (result DatabaseAccountListReadOnlyKeysResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListUsages retrieves the usages (most recent data) for the given database account. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// filter - an OData filter expression that describes a subset of usages to return. The supported parameter is +// name.value (name of the metric, can have an or of multiple names). +func (client DatabaseAccountsClient) ListUsages(ctx context.Context, resourceGroupName string, accountName string, filter string) (result UsagesResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.ListUsages") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.DatabaseAccountsClient", "ListUsages", err.Error()) + } + + req, err := client.ListUsagesPreparer(ctx, resourceGroupName, accountName, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "ListUsages", nil, "Failure preparing request") + return + } + + resp, err := client.ListUsagesSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "ListUsages", resp, "Failure sending request") + return + } + + result, err = client.ListUsagesResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "ListUsages", resp, "Failure responding to request") + return + } + + return +} + +// ListUsagesPreparer prepares the ListUsages request. +func (client DatabaseAccountsClient) ListUsagesPreparer(ctx context.Context, resourceGroupName string, accountName string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/usages", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListUsagesSender sends the ListUsages request. The method will close the +// http.Response Body if it receives an error. +func (client DatabaseAccountsClient) ListUsagesSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListUsagesResponder handles the response to the ListUsages request. The method always +// closes the http.Response Body. +func (client DatabaseAccountsClient) ListUsagesResponder(resp *http.Response) (result UsagesResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// OfflineRegion offline the specified region for the specified Azure Cosmos DB database account. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// regionParameterForOffline - cosmos DB region to offline for the database account. +func (client DatabaseAccountsClient) OfflineRegion(ctx context.Context, resourceGroupName string, accountName string, regionParameterForOffline RegionForOnlineOffline) (result DatabaseAccountsOfflineRegionFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.OfflineRegion") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}, + {TargetValue: regionParameterForOffline, + Constraints: []validation.Constraint{{Target: "regionParameterForOffline.Region", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.DatabaseAccountsClient", "OfflineRegion", err.Error()) + } + + req, err := client.OfflineRegionPreparer(ctx, resourceGroupName, accountName, regionParameterForOffline) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "OfflineRegion", nil, "Failure preparing request") + return + } + + result, err = client.OfflineRegionSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "OfflineRegion", nil, "Failure sending request") + return + } + + return +} + +// OfflineRegionPreparer prepares the OfflineRegion request. +func (client DatabaseAccountsClient) OfflineRegionPreparer(ctx context.Context, resourceGroupName string, accountName string, regionParameterForOffline RegionForOnlineOffline) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + 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.DocumentDB/databaseAccounts/{accountName}/offlineRegion", pathParameters), + autorest.WithJSON(regionParameterForOffline), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// OfflineRegionSender sends the OfflineRegion request. The method will close the +// http.Response Body if it receives an error. +func (client DatabaseAccountsClient) OfflineRegionSender(req *http.Request) (future DatabaseAccountsOfflineRegionFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// OfflineRegionResponder handles the response to the OfflineRegion request. The method always +// closes the http.Response Body. +func (client DatabaseAccountsClient) OfflineRegionResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + +// OnlineRegion online the specified region for the specified Azure Cosmos DB database account. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// regionParameterForOnline - cosmos DB region to online for the database account. +func (client DatabaseAccountsClient) OnlineRegion(ctx context.Context, resourceGroupName string, accountName string, regionParameterForOnline RegionForOnlineOffline) (result DatabaseAccountsOnlineRegionFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.OnlineRegion") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}, + {TargetValue: regionParameterForOnline, + Constraints: []validation.Constraint{{Target: "regionParameterForOnline.Region", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.DatabaseAccountsClient", "OnlineRegion", err.Error()) + } + + req, err := client.OnlineRegionPreparer(ctx, resourceGroupName, accountName, regionParameterForOnline) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "OnlineRegion", nil, "Failure preparing request") + return + } + + result, err = client.OnlineRegionSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "OnlineRegion", nil, "Failure sending request") + return + } + + return +} + +// OnlineRegionPreparer prepares the OnlineRegion request. +func (client DatabaseAccountsClient) OnlineRegionPreparer(ctx context.Context, resourceGroupName string, accountName string, regionParameterForOnline RegionForOnlineOffline) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + 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.DocumentDB/databaseAccounts/{accountName}/onlineRegion", pathParameters), + autorest.WithJSON(regionParameterForOnline), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// OnlineRegionSender sends the OnlineRegion request. The method will close the +// http.Response Body if it receives an error. +func (client DatabaseAccountsClient) OnlineRegionSender(req *http.Request) (future DatabaseAccountsOnlineRegionFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// OnlineRegionResponder handles the response to the OnlineRegion request. The method always +// closes the http.Response Body. +func (client DatabaseAccountsClient) OnlineRegionResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + +// RegenerateKey regenerates an access key for the specified Azure Cosmos DB database account. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// keyToRegenerate - the name of the key to regenerate. +func (client DatabaseAccountsClient) RegenerateKey(ctx context.Context, resourceGroupName string, accountName string, keyToRegenerate DatabaseAccountRegenerateKeyParameters) (result DatabaseAccountsRegenerateKeyFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.RegenerateKey") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.DatabaseAccountsClient", "RegenerateKey", err.Error()) + } + + req, err := client.RegenerateKeyPreparer(ctx, resourceGroupName, accountName, keyToRegenerate) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "RegenerateKey", nil, "Failure preparing request") + return + } + + result, err = client.RegenerateKeySender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "RegenerateKey", nil, "Failure sending request") + return + } + + return +} + +// RegenerateKeyPreparer prepares the RegenerateKey request. +func (client DatabaseAccountsClient) RegenerateKeyPreparer(ctx context.Context, resourceGroupName string, accountName string, keyToRegenerate DatabaseAccountRegenerateKeyParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + 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.DocumentDB/databaseAccounts/{accountName}/regenerateKey", pathParameters), + autorest.WithJSON(keyToRegenerate), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// RegenerateKeySender sends the RegenerateKey request. The method will close the +// http.Response Body if it receives an error. +func (client DatabaseAccountsClient) RegenerateKeySender(req *http.Request) (future DatabaseAccountsRegenerateKeyFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// RegenerateKeyResponder handles the response to the RegenerateKey request. The method always +// closes the http.Response Body. +func (client DatabaseAccountsClient) RegenerateKeyResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + +// Update updates the properties of an existing Azure Cosmos DB database account. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// updateParameters - the parameters to provide for the current database account. +func (client DatabaseAccountsClient) Update(ctx context.Context, resourceGroupName string, accountName string, updateParameters DatabaseAccountUpdateParameters) (result DatabaseAccountsUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.Update") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.DatabaseAccountsClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, accountName, updateParameters) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "Update", nil, "Failure sending request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client DatabaseAccountsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, accountName string, updateParameters DatabaseAccountUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + 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.DocumentDB/databaseAccounts/{accountName}", pathParameters), + autorest.WithJSON(updateParameters), + 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 DatabaseAccountsClient) UpdateSender(req *http.Request) (future DatabaseAccountsUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client DatabaseAccountsClient) UpdateResponder(resp *http.Response) (result DatabaseAccountGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/cosmos-db/mgmt/2021-06-15/documentdb/documentdbapi/interfaces.go b/services/cosmos-db/mgmt/2021-06-15/documentdb/documentdbapi/interfaces.go new file mode 100644 index 000000000000..60a8b7095bd4 --- /dev/null +++ b/services/cosmos-db/mgmt/2021-06-15/documentdb/documentdbapi/interfaces.go @@ -0,0 +1,332 @@ +package documentdbapi + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-06-15/documentdb" + "github.com/Azure/go-autorest/autorest" +) + +// DatabaseAccountsClientAPI contains the set of methods on the DatabaseAccountsClient type. +type DatabaseAccountsClientAPI interface { + CheckNameExists(ctx context.Context, accountName string) (result autorest.Response, err error) + CreateOrUpdate(ctx context.Context, resourceGroupName string, accountName string, createUpdateParameters documentdb.DatabaseAccountCreateUpdateParameters) (result documentdb.DatabaseAccountsCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, accountName string) (result documentdb.DatabaseAccountsDeleteFuture, err error) + FailoverPriorityChange(ctx context.Context, resourceGroupName string, accountName string, failoverParameters documentdb.FailoverPolicies) (result documentdb.DatabaseAccountsFailoverPriorityChangeFuture, err error) + Get(ctx context.Context, resourceGroupName string, accountName string) (result documentdb.DatabaseAccountGetResults, err error) + GetReadOnlyKeys(ctx context.Context, resourceGroupName string, accountName string) (result documentdb.DatabaseAccountListReadOnlyKeysResult, err error) + List(ctx context.Context) (result documentdb.DatabaseAccountsListResult, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string) (result documentdb.DatabaseAccountsListResult, err error) + ListConnectionStrings(ctx context.Context, resourceGroupName string, accountName string) (result documentdb.DatabaseAccountListConnectionStringsResult, err error) + ListKeys(ctx context.Context, resourceGroupName string, accountName string) (result documentdb.DatabaseAccountListKeysResult, err error) + ListMetricDefinitions(ctx context.Context, resourceGroupName string, accountName string) (result documentdb.MetricDefinitionsListResult, err error) + ListMetrics(ctx context.Context, resourceGroupName string, accountName string, filter string) (result documentdb.MetricListResult, err error) + ListReadOnlyKeys(ctx context.Context, resourceGroupName string, accountName string) (result documentdb.DatabaseAccountListReadOnlyKeysResult, err error) + ListUsages(ctx context.Context, resourceGroupName string, accountName string, filter string) (result documentdb.UsagesResult, err error) + OfflineRegion(ctx context.Context, resourceGroupName string, accountName string, regionParameterForOffline documentdb.RegionForOnlineOffline) (result documentdb.DatabaseAccountsOfflineRegionFuture, err error) + OnlineRegion(ctx context.Context, resourceGroupName string, accountName string, regionParameterForOnline documentdb.RegionForOnlineOffline) (result documentdb.DatabaseAccountsOnlineRegionFuture, err error) + RegenerateKey(ctx context.Context, resourceGroupName string, accountName string, keyToRegenerate documentdb.DatabaseAccountRegenerateKeyParameters) (result documentdb.DatabaseAccountsRegenerateKeyFuture, err error) + Update(ctx context.Context, resourceGroupName string, accountName string, updateParameters documentdb.DatabaseAccountUpdateParameters) (result documentdb.DatabaseAccountsUpdateFuture, err error) +} + +var _ DatabaseAccountsClientAPI = (*documentdb.DatabaseAccountsClient)(nil) + +// OperationsClientAPI contains the set of methods on the OperationsClient type. +type OperationsClientAPI interface { + List(ctx context.Context) (result documentdb.OperationListResultPage, err error) + ListComplete(ctx context.Context) (result documentdb.OperationListResultIterator, err error) +} + +var _ OperationsClientAPI = (*documentdb.OperationsClient)(nil) + +// DatabaseClientAPI contains the set of methods on the DatabaseClient type. +type DatabaseClientAPI interface { + ListMetricDefinitions(ctx context.Context, resourceGroupName string, accountName string, databaseRid string) (result documentdb.MetricDefinitionsListResult, err error) + ListMetrics(ctx context.Context, resourceGroupName string, accountName string, databaseRid string, filter string) (result documentdb.MetricListResult, err error) + ListUsages(ctx context.Context, resourceGroupName string, accountName string, databaseRid string, filter string) (result documentdb.UsagesResult, err error) +} + +var _ DatabaseClientAPI = (*documentdb.DatabaseClient)(nil) + +// CollectionClientAPI contains the set of methods on the CollectionClient type. +type CollectionClientAPI interface { + ListMetricDefinitions(ctx context.Context, resourceGroupName string, accountName string, databaseRid string, collectionRid string) (result documentdb.MetricDefinitionsListResult, err error) + ListMetrics(ctx context.Context, resourceGroupName string, accountName string, databaseRid string, collectionRid string, filter string) (result documentdb.MetricListResult, err error) + ListUsages(ctx context.Context, resourceGroupName string, accountName string, databaseRid string, collectionRid string, filter string) (result documentdb.UsagesResult, err error) +} + +var _ CollectionClientAPI = (*documentdb.CollectionClient)(nil) + +// CollectionRegionClientAPI contains the set of methods on the CollectionRegionClient type. +type CollectionRegionClientAPI interface { + ListMetrics(ctx context.Context, resourceGroupName string, accountName string, region string, databaseRid string, collectionRid string, filter string) (result documentdb.MetricListResult, err error) +} + +var _ CollectionRegionClientAPI = (*documentdb.CollectionRegionClient)(nil) + +// DatabaseAccountRegionClientAPI contains the set of methods on the DatabaseAccountRegionClient type. +type DatabaseAccountRegionClientAPI interface { + ListMetrics(ctx context.Context, resourceGroupName string, accountName string, region string, filter string) (result documentdb.MetricListResult, err error) +} + +var _ DatabaseAccountRegionClientAPI = (*documentdb.DatabaseAccountRegionClient)(nil) + +// PercentileSourceTargetClientAPI contains the set of methods on the PercentileSourceTargetClient type. +type PercentileSourceTargetClientAPI interface { + ListMetrics(ctx context.Context, resourceGroupName string, accountName string, sourceRegion string, targetRegion string, filter string) (result documentdb.PercentileMetricListResult, err error) +} + +var _ PercentileSourceTargetClientAPI = (*documentdb.PercentileSourceTargetClient)(nil) + +// PercentileTargetClientAPI contains the set of methods on the PercentileTargetClient type. +type PercentileTargetClientAPI interface { + ListMetrics(ctx context.Context, resourceGroupName string, accountName string, targetRegion string, filter string) (result documentdb.PercentileMetricListResult, err error) +} + +var _ PercentileTargetClientAPI = (*documentdb.PercentileTargetClient)(nil) + +// PercentileClientAPI contains the set of methods on the PercentileClient type. +type PercentileClientAPI interface { + ListMetrics(ctx context.Context, resourceGroupName string, accountName string, filter string) (result documentdb.PercentileMetricListResult, err error) +} + +var _ PercentileClientAPI = (*documentdb.PercentileClient)(nil) + +// CollectionPartitionRegionClientAPI contains the set of methods on the CollectionPartitionRegionClient type. +type CollectionPartitionRegionClientAPI interface { + ListMetrics(ctx context.Context, resourceGroupName string, accountName string, region string, databaseRid string, collectionRid string, filter string) (result documentdb.PartitionMetricListResult, err error) +} + +var _ CollectionPartitionRegionClientAPI = (*documentdb.CollectionPartitionRegionClient)(nil) + +// CollectionPartitionClientAPI contains the set of methods on the CollectionPartitionClient type. +type CollectionPartitionClientAPI interface { + ListMetrics(ctx context.Context, resourceGroupName string, accountName string, databaseRid string, collectionRid string, filter string) (result documentdb.PartitionMetricListResult, err error) + ListUsages(ctx context.Context, resourceGroupName string, accountName string, databaseRid string, collectionRid string, filter string) (result documentdb.PartitionUsagesResult, err error) +} + +var _ CollectionPartitionClientAPI = (*documentdb.CollectionPartitionClient)(nil) + +// PartitionKeyRangeIDClientAPI contains the set of methods on the PartitionKeyRangeIDClient type. +type PartitionKeyRangeIDClientAPI interface { + ListMetrics(ctx context.Context, resourceGroupName string, accountName string, databaseRid string, collectionRid string, partitionKeyRangeID string, filter string) (result documentdb.PartitionMetricListResult, err error) +} + +var _ PartitionKeyRangeIDClientAPI = (*documentdb.PartitionKeyRangeIDClient)(nil) + +// PartitionKeyRangeIDRegionClientAPI contains the set of methods on the PartitionKeyRangeIDRegionClient type. +type PartitionKeyRangeIDRegionClientAPI interface { + ListMetrics(ctx context.Context, resourceGroupName string, accountName string, region string, databaseRid string, collectionRid string, partitionKeyRangeID string, filter string) (result documentdb.PartitionMetricListResult, err error) +} + +var _ PartitionKeyRangeIDRegionClientAPI = (*documentdb.PartitionKeyRangeIDRegionClient)(nil) + +// SQLResourcesClientAPI contains the set of methods on the SQLResourcesClient type. +type SQLResourcesClientAPI interface { + CreateUpdateSQLContainer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string, createUpdateSQLContainerParameters documentdb.SQLContainerCreateUpdateParameters) (result documentdb.SQLResourcesCreateUpdateSQLContainerFuture, err error) + CreateUpdateSQLDatabase(ctx context.Context, resourceGroupName string, accountName string, databaseName string, createUpdateSQLDatabaseParameters documentdb.SQLDatabaseCreateUpdateParameters) (result documentdb.SQLResourcesCreateUpdateSQLDatabaseFuture, err error) + CreateUpdateSQLRoleAssignment(ctx context.Context, roleAssignmentID string, resourceGroupName string, accountName string, createUpdateSQLRoleAssignmentParameters documentdb.SQLRoleAssignmentCreateUpdateParameters) (result documentdb.SQLResourcesCreateUpdateSQLRoleAssignmentFuture, err error) + CreateUpdateSQLRoleDefinition(ctx context.Context, roleDefinitionID string, resourceGroupName string, accountName string, createUpdateSQLRoleDefinitionParameters documentdb.SQLRoleDefinitionCreateUpdateParameters) (result documentdb.SQLResourcesCreateUpdateSQLRoleDefinitionFuture, err error) + CreateUpdateSQLStoredProcedure(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string, storedProcedureName string, createUpdateSQLStoredProcedureParameters documentdb.SQLStoredProcedureCreateUpdateParameters) (result documentdb.SQLResourcesCreateUpdateSQLStoredProcedureFuture, err error) + CreateUpdateSQLTrigger(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string, triggerName string, createUpdateSQLTriggerParameters documentdb.SQLTriggerCreateUpdateParameters) (result documentdb.SQLResourcesCreateUpdateSQLTriggerFuture, err error) + CreateUpdateSQLUserDefinedFunction(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string, userDefinedFunctionName string, createUpdateSQLUserDefinedFunctionParameters documentdb.SQLUserDefinedFunctionCreateUpdateParameters) (result documentdb.SQLResourcesCreateUpdateSQLUserDefinedFunctionFuture, err error) + DeleteSQLContainer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string) (result documentdb.SQLResourcesDeleteSQLContainerFuture, err error) + DeleteSQLDatabase(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result documentdb.SQLResourcesDeleteSQLDatabaseFuture, err error) + DeleteSQLRoleAssignment(ctx context.Context, roleAssignmentID string, resourceGroupName string, accountName string) (result documentdb.SQLResourcesDeleteSQLRoleAssignmentFuture, err error) + DeleteSQLRoleDefinition(ctx context.Context, roleDefinitionID string, resourceGroupName string, accountName string) (result documentdb.SQLResourcesDeleteSQLRoleDefinitionFuture, err error) + DeleteSQLStoredProcedure(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string, storedProcedureName string) (result documentdb.SQLResourcesDeleteSQLStoredProcedureFuture, err error) + DeleteSQLTrigger(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string, triggerName string) (result documentdb.SQLResourcesDeleteSQLTriggerFuture, err error) + DeleteSQLUserDefinedFunction(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string, userDefinedFunctionName string) (result documentdb.SQLResourcesDeleteSQLUserDefinedFunctionFuture, err error) + GetSQLContainer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string) (result documentdb.SQLContainerGetResults, err error) + GetSQLContainerThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string) (result documentdb.ThroughputSettingsGetResults, err error) + GetSQLDatabase(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result documentdb.SQLDatabaseGetResults, err error) + GetSQLDatabaseThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result documentdb.ThroughputSettingsGetResults, err error) + GetSQLRoleAssignment(ctx context.Context, roleAssignmentID string, resourceGroupName string, accountName string) (result documentdb.SQLRoleAssignmentGetResults, err error) + GetSQLRoleDefinition(ctx context.Context, roleDefinitionID string, resourceGroupName string, accountName string) (result documentdb.SQLRoleDefinitionGetResults, err error) + GetSQLStoredProcedure(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string, storedProcedureName string) (result documentdb.SQLStoredProcedureGetResults, err error) + GetSQLTrigger(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string, triggerName string) (result documentdb.SQLTriggerGetResults, err error) + GetSQLUserDefinedFunction(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string, userDefinedFunctionName string) (result documentdb.SQLUserDefinedFunctionGetResults, err error) + ListSQLContainers(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result documentdb.SQLContainerListResult, err error) + ListSQLDatabases(ctx context.Context, resourceGroupName string, accountName string) (result documentdb.SQLDatabaseListResult, err error) + ListSQLRoleAssignments(ctx context.Context, resourceGroupName string, accountName string) (result documentdb.SQLRoleAssignmentListResult, err error) + ListSQLRoleDefinitions(ctx context.Context, resourceGroupName string, accountName string) (result documentdb.SQLRoleDefinitionListResult, err error) + ListSQLStoredProcedures(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string) (result documentdb.SQLStoredProcedureListResult, err error) + ListSQLTriggers(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string) (result documentdb.SQLTriggerListResult, err error) + ListSQLUserDefinedFunctions(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string) (result documentdb.SQLUserDefinedFunctionListResult, err error) + MigrateSQLContainerToAutoscale(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string) (result documentdb.SQLResourcesMigrateSQLContainerToAutoscaleFuture, err error) + MigrateSQLContainerToManualThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string) (result documentdb.SQLResourcesMigrateSQLContainerToManualThroughputFuture, err error) + MigrateSQLDatabaseToAutoscale(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result documentdb.SQLResourcesMigrateSQLDatabaseToAutoscaleFuture, err error) + MigrateSQLDatabaseToManualThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result documentdb.SQLResourcesMigrateSQLDatabaseToManualThroughputFuture, err error) + RetrieveContinuousBackupInformation(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string, location documentdb.ContinuousBackupRestoreLocation) (result documentdb.SQLResourcesRetrieveContinuousBackupInformationFuture, err error) + UpdateSQLContainerThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string, updateThroughputParameters documentdb.ThroughputSettingsUpdateParameters) (result documentdb.SQLResourcesUpdateSQLContainerThroughputFuture, err error) + UpdateSQLDatabaseThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string, updateThroughputParameters documentdb.ThroughputSettingsUpdateParameters) (result documentdb.SQLResourcesUpdateSQLDatabaseThroughputFuture, err error) +} + +var _ SQLResourcesClientAPI = (*documentdb.SQLResourcesClient)(nil) + +// MongoDBResourcesClientAPI contains the set of methods on the MongoDBResourcesClient type. +type MongoDBResourcesClientAPI interface { + CreateUpdateMongoDBCollection(ctx context.Context, resourceGroupName string, accountName string, databaseName string, collectionName string, createUpdateMongoDBCollectionParameters documentdb.MongoDBCollectionCreateUpdateParameters) (result documentdb.MongoDBResourcesCreateUpdateMongoDBCollectionFuture, err error) + CreateUpdateMongoDBDatabase(ctx context.Context, resourceGroupName string, accountName string, databaseName string, createUpdateMongoDBDatabaseParameters documentdb.MongoDBDatabaseCreateUpdateParameters) (result documentdb.MongoDBResourcesCreateUpdateMongoDBDatabaseFuture, err error) + DeleteMongoDBCollection(ctx context.Context, resourceGroupName string, accountName string, databaseName string, collectionName string) (result documentdb.MongoDBResourcesDeleteMongoDBCollectionFuture, err error) + DeleteMongoDBDatabase(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result documentdb.MongoDBResourcesDeleteMongoDBDatabaseFuture, err error) + GetMongoDBCollection(ctx context.Context, resourceGroupName string, accountName string, databaseName string, collectionName string) (result documentdb.MongoDBCollectionGetResults, err error) + GetMongoDBCollectionThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string, collectionName string) (result documentdb.ThroughputSettingsGetResults, err error) + GetMongoDBDatabase(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result documentdb.MongoDBDatabaseGetResults, err error) + GetMongoDBDatabaseThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result documentdb.ThroughputSettingsGetResults, err error) + ListMongoDBCollections(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result documentdb.MongoDBCollectionListResult, err error) + ListMongoDBDatabases(ctx context.Context, resourceGroupName string, accountName string) (result documentdb.MongoDBDatabaseListResult, err error) + MigrateMongoDBCollectionToAutoscale(ctx context.Context, resourceGroupName string, accountName string, databaseName string, collectionName string) (result documentdb.MongoDBResourcesMigrateMongoDBCollectionToAutoscaleFuture, err error) + MigrateMongoDBCollectionToManualThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string, collectionName string) (result documentdb.MongoDBResourcesMigrateMongoDBCollectionToManualThroughputFuture, err error) + MigrateMongoDBDatabaseToAutoscale(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result documentdb.MongoDBResourcesMigrateMongoDBDatabaseToAutoscaleFuture, err error) + MigrateMongoDBDatabaseToManualThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result documentdb.MongoDBResourcesMigrateMongoDBDatabaseToManualThroughputFuture, err error) + UpdateMongoDBCollectionThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string, collectionName string, updateThroughputParameters documentdb.ThroughputSettingsUpdateParameters) (result documentdb.MongoDBResourcesUpdateMongoDBCollectionThroughputFuture, err error) + UpdateMongoDBDatabaseThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string, updateThroughputParameters documentdb.ThroughputSettingsUpdateParameters) (result documentdb.MongoDBResourcesUpdateMongoDBDatabaseThroughputFuture, err error) +} + +var _ MongoDBResourcesClientAPI = (*documentdb.MongoDBResourcesClient)(nil) + +// TableResourcesClientAPI contains the set of methods on the TableResourcesClient type. +type TableResourcesClientAPI interface { + CreateUpdateTable(ctx context.Context, resourceGroupName string, accountName string, tableName string, createUpdateTableParameters documentdb.TableCreateUpdateParameters) (result documentdb.TableResourcesCreateUpdateTableFuture, err error) + DeleteTable(ctx context.Context, resourceGroupName string, accountName string, tableName string) (result documentdb.TableResourcesDeleteTableFuture, err error) + GetTable(ctx context.Context, resourceGroupName string, accountName string, tableName string) (result documentdb.TableGetResults, err error) + GetTableThroughput(ctx context.Context, resourceGroupName string, accountName string, tableName string) (result documentdb.ThroughputSettingsGetResults, err error) + ListTables(ctx context.Context, resourceGroupName string, accountName string) (result documentdb.TableListResult, err error) + MigrateTableToAutoscale(ctx context.Context, resourceGroupName string, accountName string, tableName string) (result documentdb.TableResourcesMigrateTableToAutoscaleFuture, err error) + MigrateTableToManualThroughput(ctx context.Context, resourceGroupName string, accountName string, tableName string) (result documentdb.TableResourcesMigrateTableToManualThroughputFuture, err error) + UpdateTableThroughput(ctx context.Context, resourceGroupName string, accountName string, tableName string, updateThroughputParameters documentdb.ThroughputSettingsUpdateParameters) (result documentdb.TableResourcesUpdateTableThroughputFuture, err error) +} + +var _ TableResourcesClientAPI = (*documentdb.TableResourcesClient)(nil) + +// CassandraResourcesClientAPI contains the set of methods on the CassandraResourcesClient type. +type CassandraResourcesClientAPI interface { + CreateUpdateCassandraKeyspace(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string, createUpdateCassandraKeyspaceParameters documentdb.CassandraKeyspaceCreateUpdateParameters) (result documentdb.CassandraResourcesCreateUpdateCassandraKeyspaceFuture, err error) + CreateUpdateCassandraTable(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string, tableName string, createUpdateCassandraTableParameters documentdb.CassandraTableCreateUpdateParameters) (result documentdb.CassandraResourcesCreateUpdateCassandraTableFuture, err error) + DeleteCassandraKeyspace(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string) (result documentdb.CassandraResourcesDeleteCassandraKeyspaceFuture, err error) + DeleteCassandraTable(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string, tableName string) (result documentdb.CassandraResourcesDeleteCassandraTableFuture, err error) + GetCassandraKeyspace(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string) (result documentdb.CassandraKeyspaceGetResults, err error) + GetCassandraKeyspaceThroughput(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string) (result documentdb.ThroughputSettingsGetResults, err error) + GetCassandraTable(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string, tableName string) (result documentdb.CassandraTableGetResults, err error) + GetCassandraTableThroughput(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string, tableName string) (result documentdb.ThroughputSettingsGetResults, err error) + ListCassandraKeyspaces(ctx context.Context, resourceGroupName string, accountName string) (result documentdb.CassandraKeyspaceListResult, err error) + ListCassandraTables(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string) (result documentdb.CassandraTableListResult, err error) + MigrateCassandraKeyspaceToAutoscale(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string) (result documentdb.CassandraResourcesMigrateCassandraKeyspaceToAutoscaleFuture, err error) + MigrateCassandraKeyspaceToManualThroughput(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string) (result documentdb.CassandraResourcesMigrateCassandraKeyspaceToManualThroughputFuture, err error) + MigrateCassandraTableToAutoscale(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string, tableName string) (result documentdb.CassandraResourcesMigrateCassandraTableToAutoscaleFuture, err error) + MigrateCassandraTableToManualThroughput(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string, tableName string) (result documentdb.CassandraResourcesMigrateCassandraTableToManualThroughputFuture, err error) + UpdateCassandraKeyspaceThroughput(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string, updateThroughputParameters documentdb.ThroughputSettingsUpdateParameters) (result documentdb.CassandraResourcesUpdateCassandraKeyspaceThroughputFuture, err error) + UpdateCassandraTableThroughput(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string, tableName string, updateThroughputParameters documentdb.ThroughputSettingsUpdateParameters) (result documentdb.CassandraResourcesUpdateCassandraTableThroughputFuture, err error) +} + +var _ CassandraResourcesClientAPI = (*documentdb.CassandraResourcesClient)(nil) + +// GremlinResourcesClientAPI contains the set of methods on the GremlinResourcesClient type. +type GremlinResourcesClientAPI interface { + CreateUpdateGremlinDatabase(ctx context.Context, resourceGroupName string, accountName string, databaseName string, createUpdateGremlinDatabaseParameters documentdb.GremlinDatabaseCreateUpdateParameters) (result documentdb.GremlinResourcesCreateUpdateGremlinDatabaseFuture, err error) + CreateUpdateGremlinGraph(ctx context.Context, resourceGroupName string, accountName string, databaseName string, graphName string, createUpdateGremlinGraphParameters documentdb.GremlinGraphCreateUpdateParameters) (result documentdb.GremlinResourcesCreateUpdateGremlinGraphFuture, err error) + DeleteGremlinDatabase(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result documentdb.GremlinResourcesDeleteGremlinDatabaseFuture, err error) + DeleteGremlinGraph(ctx context.Context, resourceGroupName string, accountName string, databaseName string, graphName string) (result documentdb.GremlinResourcesDeleteGremlinGraphFuture, err error) + GetGremlinDatabase(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result documentdb.GremlinDatabaseGetResults, err error) + GetGremlinDatabaseThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result documentdb.ThroughputSettingsGetResults, err error) + GetGremlinGraph(ctx context.Context, resourceGroupName string, accountName string, databaseName string, graphName string) (result documentdb.GremlinGraphGetResults, err error) + GetGremlinGraphThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string, graphName string) (result documentdb.ThroughputSettingsGetResults, err error) + ListGremlinDatabases(ctx context.Context, resourceGroupName string, accountName string) (result documentdb.GremlinDatabaseListResult, err error) + ListGremlinGraphs(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result documentdb.GremlinGraphListResult, err error) + MigrateGremlinDatabaseToAutoscale(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result documentdb.GremlinResourcesMigrateGremlinDatabaseToAutoscaleFuture, err error) + MigrateGremlinDatabaseToManualThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result documentdb.GremlinResourcesMigrateGremlinDatabaseToManualThroughputFuture, err error) + MigrateGremlinGraphToAutoscale(ctx context.Context, resourceGroupName string, accountName string, databaseName string, graphName string) (result documentdb.GremlinResourcesMigrateGremlinGraphToAutoscaleFuture, err error) + MigrateGremlinGraphToManualThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string, graphName string) (result documentdb.GremlinResourcesMigrateGremlinGraphToManualThroughputFuture, err error) + UpdateGremlinDatabaseThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string, updateThroughputParameters documentdb.ThroughputSettingsUpdateParameters) (result documentdb.GremlinResourcesUpdateGremlinDatabaseThroughputFuture, err error) + UpdateGremlinGraphThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string, graphName string, updateThroughputParameters documentdb.ThroughputSettingsUpdateParameters) (result documentdb.GremlinResourcesUpdateGremlinGraphThroughputFuture, err error) +} + +var _ GremlinResourcesClientAPI = (*documentdb.GremlinResourcesClient)(nil) + +// NotebookWorkspacesClientAPI contains the set of methods on the NotebookWorkspacesClient type. +type NotebookWorkspacesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, accountName string, notebookCreateUpdateParameters documentdb.NotebookWorkspaceCreateUpdateParameters) (result documentdb.NotebookWorkspacesCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, accountName string) (result documentdb.NotebookWorkspacesDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, accountName string) (result documentdb.NotebookWorkspace, err error) + ListByDatabaseAccount(ctx context.Context, resourceGroupName string, accountName string) (result documentdb.NotebookWorkspaceListResult, err error) + ListConnectionInfo(ctx context.Context, resourceGroupName string, accountName string) (result documentdb.NotebookWorkspaceConnectionInfoResult, err error) + RegenerateAuthToken(ctx context.Context, resourceGroupName string, accountName string) (result documentdb.NotebookWorkspacesRegenerateAuthTokenFuture, err error) + Start(ctx context.Context, resourceGroupName string, accountName string) (result documentdb.NotebookWorkspacesStartFuture, err error) +} + +var _ NotebookWorkspacesClientAPI = (*documentdb.NotebookWorkspacesClient)(nil) + +// PrivateEndpointConnectionsClientAPI contains the set of methods on the PrivateEndpointConnectionsClient type. +type PrivateEndpointConnectionsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, accountName string, privateEndpointConnectionName string, parameters documentdb.PrivateEndpointConnection) (result documentdb.PrivateEndpointConnectionsCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, accountName string, privateEndpointConnectionName string) (result documentdb.PrivateEndpointConnectionsDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, accountName string, privateEndpointConnectionName string) (result documentdb.PrivateEndpointConnection, err error) + ListByDatabaseAccount(ctx context.Context, resourceGroupName string, accountName string) (result documentdb.PrivateEndpointConnectionListResult, err error) +} + +var _ PrivateEndpointConnectionsClientAPI = (*documentdb.PrivateEndpointConnectionsClient)(nil) + +// PrivateLinkResourcesClientAPI contains the set of methods on the PrivateLinkResourcesClient type. +type PrivateLinkResourcesClientAPI interface { + Get(ctx context.Context, resourceGroupName string, accountName string, groupName string) (result documentdb.PrivateLinkResource, err error) + ListByDatabaseAccount(ctx context.Context, resourceGroupName string, accountName string) (result documentdb.PrivateLinkResourceListResult, err error) +} + +var _ PrivateLinkResourcesClientAPI = (*documentdb.PrivateLinkResourcesClient)(nil) + +// RestorableDatabaseAccountsClientAPI contains the set of methods on the RestorableDatabaseAccountsClient type. +type RestorableDatabaseAccountsClientAPI interface { + GetByLocation(ctx context.Context, location string, instanceID string) (result documentdb.RestorableDatabaseAccountGetResult, err error) + List(ctx context.Context) (result documentdb.RestorableDatabaseAccountsListResult, err error) + ListByLocation(ctx context.Context, location string) (result documentdb.RestorableDatabaseAccountsListResult, err error) +} + +var _ RestorableDatabaseAccountsClientAPI = (*documentdb.RestorableDatabaseAccountsClient)(nil) + +// RestorableSQLDatabasesClientAPI contains the set of methods on the RestorableSQLDatabasesClient type. +type RestorableSQLDatabasesClientAPI interface { + List(ctx context.Context, location string, instanceID string) (result documentdb.RestorableSQLDatabasesListResult, err error) +} + +var _ RestorableSQLDatabasesClientAPI = (*documentdb.RestorableSQLDatabasesClient)(nil) + +// RestorableSQLContainersClientAPI contains the set of methods on the RestorableSQLContainersClient type. +type RestorableSQLContainersClientAPI interface { + List(ctx context.Context, location string, instanceID string, restorableSQLDatabaseRid string, startTime string, endTime string) (result documentdb.RestorableSQLContainersListResult, err error) +} + +var _ RestorableSQLContainersClientAPI = (*documentdb.RestorableSQLContainersClient)(nil) + +// RestorableSQLResourcesClientAPI contains the set of methods on the RestorableSQLResourcesClient type. +type RestorableSQLResourcesClientAPI interface { + List(ctx context.Context, location string, instanceID string, restoreLocation string, restoreTimestampInUtc string) (result documentdb.RestorableSQLResourcesListResult, err error) +} + +var _ RestorableSQLResourcesClientAPI = (*documentdb.RestorableSQLResourcesClient)(nil) + +// RestorableMongodbDatabasesClientAPI contains the set of methods on the RestorableMongodbDatabasesClient type. +type RestorableMongodbDatabasesClientAPI interface { + List(ctx context.Context, location string, instanceID string) (result documentdb.RestorableMongodbDatabasesListResult, err error) +} + +var _ RestorableMongodbDatabasesClientAPI = (*documentdb.RestorableMongodbDatabasesClient)(nil) + +// RestorableMongodbCollectionsClientAPI contains the set of methods on the RestorableMongodbCollectionsClient type. +type RestorableMongodbCollectionsClientAPI interface { + List(ctx context.Context, location string, instanceID string, restorableMongodbDatabaseRid string) (result documentdb.RestorableMongodbCollectionsListResult, err error) +} + +var _ RestorableMongodbCollectionsClientAPI = (*documentdb.RestorableMongodbCollectionsClient)(nil) + +// RestorableMongodbResourcesClientAPI contains the set of methods on the RestorableMongodbResourcesClient type. +type RestorableMongodbResourcesClientAPI interface { + List(ctx context.Context, location string, instanceID string, restoreLocation string, restoreTimestampInUtc string) (result documentdb.RestorableMongodbResourcesListResult, err error) +} + +var _ RestorableMongodbResourcesClientAPI = (*documentdb.RestorableMongodbResourcesClient)(nil) diff --git a/services/cosmos-db/mgmt/2021-06-15/documentdb/enums.go b/services/cosmos-db/mgmt/2021-06-15/documentdb/enums.go new file mode 100644 index 000000000000..499df220099d --- /dev/null +++ b/services/cosmos-db/mgmt/2021-06-15/documentdb/enums.go @@ -0,0 +1,533 @@ +package documentdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// AnalyticalStorageSchemaType enumerates the values for analytical storage schema type. +type AnalyticalStorageSchemaType string + +const ( + // AnalyticalStorageSchemaTypeFullFidelity ... + AnalyticalStorageSchemaTypeFullFidelity AnalyticalStorageSchemaType = "FullFidelity" + // AnalyticalStorageSchemaTypeWellDefined ... + AnalyticalStorageSchemaTypeWellDefined AnalyticalStorageSchemaType = "WellDefined" +) + +// PossibleAnalyticalStorageSchemaTypeValues returns an array of possible values for the AnalyticalStorageSchemaType const type. +func PossibleAnalyticalStorageSchemaTypeValues() []AnalyticalStorageSchemaType { + return []AnalyticalStorageSchemaType{AnalyticalStorageSchemaTypeFullFidelity, AnalyticalStorageSchemaTypeWellDefined} +} + +// APIType enumerates the values for api type. +type APIType string + +const ( + // APITypeCassandra ... + APITypeCassandra APIType = "Cassandra" + // APITypeGremlin ... + APITypeGremlin APIType = "Gremlin" + // APITypeGremlinV2 ... + APITypeGremlinV2 APIType = "GremlinV2" + // APITypeMongoDB ... + APITypeMongoDB APIType = "MongoDB" + // APITypeSQL ... + APITypeSQL APIType = "Sql" + // APITypeTable ... + APITypeTable APIType = "Table" +) + +// PossibleAPITypeValues returns an array of possible values for the APIType const type. +func PossibleAPITypeValues() []APIType { + return []APIType{APITypeCassandra, APITypeGremlin, APITypeGremlinV2, APITypeMongoDB, APITypeSQL, APITypeTable} +} + +// BackupPolicyMigrationStatus enumerates the values for backup policy migration status. +type BackupPolicyMigrationStatus string + +const ( + // BackupPolicyMigrationStatusCompleted ... + BackupPolicyMigrationStatusCompleted BackupPolicyMigrationStatus = "Completed" + // BackupPolicyMigrationStatusFailed ... + BackupPolicyMigrationStatusFailed BackupPolicyMigrationStatus = "Failed" + // BackupPolicyMigrationStatusInProgress ... + BackupPolicyMigrationStatusInProgress BackupPolicyMigrationStatus = "InProgress" + // BackupPolicyMigrationStatusInvalid ... + BackupPolicyMigrationStatusInvalid BackupPolicyMigrationStatus = "Invalid" +) + +// PossibleBackupPolicyMigrationStatusValues returns an array of possible values for the BackupPolicyMigrationStatus const type. +func PossibleBackupPolicyMigrationStatusValues() []BackupPolicyMigrationStatus { + return []BackupPolicyMigrationStatus{BackupPolicyMigrationStatusCompleted, BackupPolicyMigrationStatusFailed, BackupPolicyMigrationStatusInProgress, BackupPolicyMigrationStatusInvalid} +} + +// BackupPolicyType enumerates the values for backup policy type. +type BackupPolicyType string + +const ( + // BackupPolicyTypeContinuous ... + BackupPolicyTypeContinuous BackupPolicyType = "Continuous" + // BackupPolicyTypePeriodic ... + BackupPolicyTypePeriodic BackupPolicyType = "Periodic" +) + +// PossibleBackupPolicyTypeValues returns an array of possible values for the BackupPolicyType const type. +func PossibleBackupPolicyTypeValues() []BackupPolicyType { + return []BackupPolicyType{BackupPolicyTypeContinuous, BackupPolicyTypePeriodic} +} + +// CompositePathSortOrder enumerates the values for composite path sort order. +type CompositePathSortOrder string + +const ( + // CompositePathSortOrderAscending ... + CompositePathSortOrderAscending CompositePathSortOrder = "ascending" + // CompositePathSortOrderDescending ... + CompositePathSortOrderDescending CompositePathSortOrder = "descending" +) + +// PossibleCompositePathSortOrderValues returns an array of possible values for the CompositePathSortOrder const type. +func PossibleCompositePathSortOrderValues() []CompositePathSortOrder { + return []CompositePathSortOrder{CompositePathSortOrderAscending, CompositePathSortOrderDescending} +} + +// ConflictResolutionMode enumerates the values for conflict resolution mode. +type ConflictResolutionMode string + +const ( + // ConflictResolutionModeCustom ... + ConflictResolutionModeCustom ConflictResolutionMode = "Custom" + // ConflictResolutionModeLastWriterWins ... + ConflictResolutionModeLastWriterWins ConflictResolutionMode = "LastWriterWins" +) + +// PossibleConflictResolutionModeValues returns an array of possible values for the ConflictResolutionMode const type. +func PossibleConflictResolutionModeValues() []ConflictResolutionMode { + return []ConflictResolutionMode{ConflictResolutionModeCustom, ConflictResolutionModeLastWriterWins} +} + +// ConnectorOffer enumerates the values for connector offer. +type ConnectorOffer string + +const ( + // ConnectorOfferSmall ... + ConnectorOfferSmall ConnectorOffer = "Small" +) + +// PossibleConnectorOfferValues returns an array of possible values for the ConnectorOffer const type. +func PossibleConnectorOfferValues() []ConnectorOffer { + return []ConnectorOffer{ConnectorOfferSmall} +} + +// CreatedByType enumerates the values for created by type. +type CreatedByType string + +const ( + // CreatedByTypeApplication ... + CreatedByTypeApplication CreatedByType = "Application" + // CreatedByTypeKey ... + CreatedByTypeKey CreatedByType = "Key" + // CreatedByTypeManagedIdentity ... + CreatedByTypeManagedIdentity CreatedByType = "ManagedIdentity" + // CreatedByTypeUser ... + CreatedByTypeUser CreatedByType = "User" +) + +// PossibleCreatedByTypeValues returns an array of possible values for the CreatedByType const type. +func PossibleCreatedByTypeValues() []CreatedByType { + return []CreatedByType{CreatedByTypeApplication, CreatedByTypeKey, CreatedByTypeManagedIdentity, CreatedByTypeUser} +} + +// CreateMode enumerates the values for create mode. +type CreateMode string + +const ( + // CreateModeDefault ... + CreateModeDefault CreateMode = "Default" + // CreateModeRestore ... + CreateModeRestore CreateMode = "Restore" +) + +// PossibleCreateModeValues returns an array of possible values for the CreateMode const type. +func PossibleCreateModeValues() []CreateMode { + return []CreateMode{CreateModeDefault, CreateModeRestore} +} + +// DatabaseAccountKind enumerates the values for database account kind. +type DatabaseAccountKind string + +const ( + // DatabaseAccountKindGlobalDocumentDB ... + DatabaseAccountKindGlobalDocumentDB DatabaseAccountKind = "GlobalDocumentDB" + // DatabaseAccountKindMongoDB ... + DatabaseAccountKindMongoDB DatabaseAccountKind = "MongoDB" + // DatabaseAccountKindParse ... + DatabaseAccountKindParse DatabaseAccountKind = "Parse" +) + +// PossibleDatabaseAccountKindValues returns an array of possible values for the DatabaseAccountKind const type. +func PossibleDatabaseAccountKindValues() []DatabaseAccountKind { + return []DatabaseAccountKind{DatabaseAccountKindGlobalDocumentDB, DatabaseAccountKindMongoDB, DatabaseAccountKindParse} +} + +// DatabaseAccountOfferType enumerates the values for database account offer type. +type DatabaseAccountOfferType string + +const ( + // DatabaseAccountOfferTypeStandard ... + DatabaseAccountOfferTypeStandard DatabaseAccountOfferType = "Standard" +) + +// PossibleDatabaseAccountOfferTypeValues returns an array of possible values for the DatabaseAccountOfferType const type. +func PossibleDatabaseAccountOfferTypeValues() []DatabaseAccountOfferType { + return []DatabaseAccountOfferType{DatabaseAccountOfferTypeStandard} +} + +// DataType enumerates the values for data type. +type DataType string + +const ( + // DataTypeLineString ... + DataTypeLineString DataType = "LineString" + // DataTypeMultiPolygon ... + DataTypeMultiPolygon DataType = "MultiPolygon" + // DataTypeNumber ... + DataTypeNumber DataType = "Number" + // DataTypePoint ... + DataTypePoint DataType = "Point" + // DataTypePolygon ... + DataTypePolygon DataType = "Polygon" + // DataTypeString ... + DataTypeString DataType = "String" +) + +// PossibleDataTypeValues returns an array of possible values for the DataType const type. +func PossibleDataTypeValues() []DataType { + return []DataType{DataTypeLineString, DataTypeMultiPolygon, DataTypeNumber, DataTypePoint, DataTypePolygon, DataTypeString} +} + +// DefaultConsistencyLevel enumerates the values for default consistency level. +type DefaultConsistencyLevel string + +const ( + // DefaultConsistencyLevelBoundedStaleness ... + DefaultConsistencyLevelBoundedStaleness DefaultConsistencyLevel = "BoundedStaleness" + // DefaultConsistencyLevelConsistentPrefix ... + DefaultConsistencyLevelConsistentPrefix DefaultConsistencyLevel = "ConsistentPrefix" + // DefaultConsistencyLevelEventual ... + DefaultConsistencyLevelEventual DefaultConsistencyLevel = "Eventual" + // DefaultConsistencyLevelSession ... + DefaultConsistencyLevelSession DefaultConsistencyLevel = "Session" + // DefaultConsistencyLevelStrong ... + DefaultConsistencyLevelStrong DefaultConsistencyLevel = "Strong" +) + +// PossibleDefaultConsistencyLevelValues returns an array of possible values for the DefaultConsistencyLevel const type. +func PossibleDefaultConsistencyLevelValues() []DefaultConsistencyLevel { + return []DefaultConsistencyLevel{DefaultConsistencyLevelBoundedStaleness, DefaultConsistencyLevelConsistentPrefix, DefaultConsistencyLevelEventual, DefaultConsistencyLevelSession, DefaultConsistencyLevelStrong} +} + +// IndexingMode enumerates the values for indexing mode. +type IndexingMode string + +const ( + // IndexingModeConsistent ... + IndexingModeConsistent IndexingMode = "consistent" + // IndexingModeLazy ... + IndexingModeLazy IndexingMode = "lazy" + // IndexingModeNone ... + IndexingModeNone IndexingMode = "none" +) + +// PossibleIndexingModeValues returns an array of possible values for the IndexingMode const type. +func PossibleIndexingModeValues() []IndexingMode { + return []IndexingMode{IndexingModeConsistent, IndexingModeLazy, IndexingModeNone} +} + +// IndexKind enumerates the values for index kind. +type IndexKind string + +const ( + // IndexKindHash ... + IndexKindHash IndexKind = "Hash" + // IndexKindRange ... + IndexKindRange IndexKind = "Range" + // IndexKindSpatial ... + IndexKindSpatial IndexKind = "Spatial" +) + +// PossibleIndexKindValues returns an array of possible values for the IndexKind const type. +func PossibleIndexKindValues() []IndexKind { + return []IndexKind{IndexKindHash, IndexKindRange, IndexKindSpatial} +} + +// KeyKind enumerates the values for key kind. +type KeyKind string + +const ( + // KeyKindPrimary ... + KeyKindPrimary KeyKind = "primary" + // KeyKindPrimaryReadonly ... + KeyKindPrimaryReadonly KeyKind = "primaryReadonly" + // KeyKindSecondary ... + KeyKindSecondary KeyKind = "secondary" + // KeyKindSecondaryReadonly ... + KeyKindSecondaryReadonly KeyKind = "secondaryReadonly" +) + +// PossibleKeyKindValues returns an array of possible values for the KeyKind const type. +func PossibleKeyKindValues() []KeyKind { + return []KeyKind{KeyKindPrimary, KeyKindPrimaryReadonly, KeyKindSecondary, KeyKindSecondaryReadonly} +} + +// NetworkACLBypass enumerates the values for network acl bypass. +type NetworkACLBypass string + +const ( + // NetworkACLBypassAzureServices ... + NetworkACLBypassAzureServices NetworkACLBypass = "AzureServices" + // NetworkACLBypassNone ... + NetworkACLBypassNone NetworkACLBypass = "None" +) + +// PossibleNetworkACLBypassValues returns an array of possible values for the NetworkACLBypass const type. +func PossibleNetworkACLBypassValues() []NetworkACLBypass { + return []NetworkACLBypass{NetworkACLBypassAzureServices, NetworkACLBypassNone} +} + +// OperationType enumerates the values for operation type. +type OperationType string + +const ( + // OperationTypeCreate ... + OperationTypeCreate OperationType = "Create" + // OperationTypeDelete ... + OperationTypeDelete OperationType = "Delete" + // OperationTypeReplace ... + OperationTypeReplace OperationType = "Replace" + // OperationTypeSystemOperation ... + OperationTypeSystemOperation OperationType = "SystemOperation" +) + +// PossibleOperationTypeValues returns an array of possible values for the OperationType const type. +func PossibleOperationTypeValues() []OperationType { + return []OperationType{OperationTypeCreate, OperationTypeDelete, OperationTypeReplace, OperationTypeSystemOperation} +} + +// PartitionKind enumerates the values for partition kind. +type PartitionKind string + +const ( + // PartitionKindHash ... + PartitionKindHash PartitionKind = "Hash" + // PartitionKindMultiHash ... + PartitionKindMultiHash PartitionKind = "MultiHash" + // PartitionKindRange ... + PartitionKindRange PartitionKind = "Range" +) + +// PossiblePartitionKindValues returns an array of possible values for the PartitionKind const type. +func PossiblePartitionKindValues() []PartitionKind { + return []PartitionKind{PartitionKindHash, PartitionKindMultiHash, PartitionKindRange} +} + +// PrimaryAggregationType enumerates the values for primary aggregation type. +type PrimaryAggregationType string + +const ( + // PrimaryAggregationTypeAverage ... + PrimaryAggregationTypeAverage PrimaryAggregationType = "Average" + // PrimaryAggregationTypeLast ... + PrimaryAggregationTypeLast PrimaryAggregationType = "Last" + // PrimaryAggregationTypeMaximum ... + PrimaryAggregationTypeMaximum PrimaryAggregationType = "Maximum" + // PrimaryAggregationTypeMinimum ... + PrimaryAggregationTypeMinimum PrimaryAggregationType = "Minimum" + // PrimaryAggregationTypeNone ... + PrimaryAggregationTypeNone PrimaryAggregationType = "None" + // PrimaryAggregationTypeTotal ... + PrimaryAggregationTypeTotal PrimaryAggregationType = "Total" +) + +// PossiblePrimaryAggregationTypeValues returns an array of possible values for the PrimaryAggregationType const type. +func PossiblePrimaryAggregationTypeValues() []PrimaryAggregationType { + return []PrimaryAggregationType{PrimaryAggregationTypeAverage, PrimaryAggregationTypeLast, PrimaryAggregationTypeMaximum, PrimaryAggregationTypeMinimum, PrimaryAggregationTypeNone, PrimaryAggregationTypeTotal} +} + +// PublicNetworkAccess enumerates the values for public network access. +type PublicNetworkAccess string + +const ( + // PublicNetworkAccessDisabled ... + PublicNetworkAccessDisabled PublicNetworkAccess = "Disabled" + // PublicNetworkAccessEnabled ... + PublicNetworkAccessEnabled PublicNetworkAccess = "Enabled" +) + +// PossiblePublicNetworkAccessValues returns an array of possible values for the PublicNetworkAccess const type. +func PossiblePublicNetworkAccessValues() []PublicNetworkAccess { + return []PublicNetworkAccess{PublicNetworkAccessDisabled, PublicNetworkAccessEnabled} +} + +// ResourceIdentityType enumerates the values for resource identity type. +type ResourceIdentityType string + +const ( + // ResourceIdentityTypeNone ... + ResourceIdentityTypeNone ResourceIdentityType = "None" + // ResourceIdentityTypeSystemAssigned ... + ResourceIdentityTypeSystemAssigned ResourceIdentityType = "SystemAssigned" + // ResourceIdentityTypeSystemAssignedUserAssigned ... + ResourceIdentityTypeSystemAssignedUserAssigned ResourceIdentityType = "SystemAssigned,UserAssigned" + // ResourceIdentityTypeUserAssigned ... + ResourceIdentityTypeUserAssigned ResourceIdentityType = "UserAssigned" +) + +// PossibleResourceIdentityTypeValues returns an array of possible values for the ResourceIdentityType const type. +func PossibleResourceIdentityTypeValues() []ResourceIdentityType { + return []ResourceIdentityType{ResourceIdentityTypeNone, ResourceIdentityTypeSystemAssigned, ResourceIdentityTypeSystemAssignedUserAssigned, ResourceIdentityTypeUserAssigned} +} + +// RestoreMode enumerates the values for restore mode. +type RestoreMode string + +const ( + // RestoreModePointInTime ... + RestoreModePointInTime RestoreMode = "PointInTime" +) + +// PossibleRestoreModeValues returns an array of possible values for the RestoreMode const type. +func PossibleRestoreModeValues() []RestoreMode { + return []RestoreMode{RestoreModePointInTime} +} + +// RoleDefinitionType enumerates the values for role definition type. +type RoleDefinitionType string + +const ( + // RoleDefinitionTypeBuiltInRole ... + RoleDefinitionTypeBuiltInRole RoleDefinitionType = "BuiltInRole" + // RoleDefinitionTypeCustomRole ... + RoleDefinitionTypeCustomRole RoleDefinitionType = "CustomRole" +) + +// PossibleRoleDefinitionTypeValues returns an array of possible values for the RoleDefinitionType const type. +func PossibleRoleDefinitionTypeValues() []RoleDefinitionType { + return []RoleDefinitionType{RoleDefinitionTypeBuiltInRole, RoleDefinitionTypeCustomRole} +} + +// ServerVersion enumerates the values for server version. +type ServerVersion string + +const ( + // ServerVersionFourFullStopZero ... + ServerVersionFourFullStopZero ServerVersion = "4.0" + // ServerVersionThreeFullStopSix ... + ServerVersionThreeFullStopSix ServerVersion = "3.6" + // ServerVersionThreeFullStopTwo ... + ServerVersionThreeFullStopTwo ServerVersion = "3.2" +) + +// PossibleServerVersionValues returns an array of possible values for the ServerVersion const type. +func PossibleServerVersionValues() []ServerVersion { + return []ServerVersion{ServerVersionFourFullStopZero, ServerVersionThreeFullStopSix, ServerVersionThreeFullStopTwo} +} + +// SpatialType enumerates the values for spatial type. +type SpatialType string + +const ( + // SpatialTypeLineString ... + SpatialTypeLineString SpatialType = "LineString" + // SpatialTypeMultiPolygon ... + SpatialTypeMultiPolygon SpatialType = "MultiPolygon" + // SpatialTypePoint ... + SpatialTypePoint SpatialType = "Point" + // SpatialTypePolygon ... + SpatialTypePolygon SpatialType = "Polygon" +) + +// PossibleSpatialTypeValues returns an array of possible values for the SpatialType const type. +func PossibleSpatialTypeValues() []SpatialType { + return []SpatialType{SpatialTypeLineString, SpatialTypeMultiPolygon, SpatialTypePoint, SpatialTypePolygon} +} + +// TriggerOperation enumerates the values for trigger operation. +type TriggerOperation string + +const ( + // TriggerOperationAll ... + TriggerOperationAll TriggerOperation = "All" + // TriggerOperationCreate ... + TriggerOperationCreate TriggerOperation = "Create" + // TriggerOperationDelete ... + TriggerOperationDelete TriggerOperation = "Delete" + // TriggerOperationReplace ... + TriggerOperationReplace TriggerOperation = "Replace" + // TriggerOperationUpdate ... + TriggerOperationUpdate TriggerOperation = "Update" +) + +// PossibleTriggerOperationValues returns an array of possible values for the TriggerOperation const type. +func PossibleTriggerOperationValues() []TriggerOperation { + return []TriggerOperation{TriggerOperationAll, TriggerOperationCreate, TriggerOperationDelete, TriggerOperationReplace, TriggerOperationUpdate} +} + +// TriggerType enumerates the values for trigger type. +type TriggerType string + +const ( + // TriggerTypePost ... + TriggerTypePost TriggerType = "Post" + // TriggerTypePre ... + TriggerTypePre TriggerType = "Pre" +) + +// PossibleTriggerTypeValues returns an array of possible values for the TriggerType const type. +func PossibleTriggerTypeValues() []TriggerType { + return []TriggerType{TriggerTypePost, TriggerTypePre} +} + +// Type enumerates the values for type. +type Type string + +const ( + // TypeBackupPolicy ... + TypeBackupPolicy Type = "BackupPolicy" + // TypeContinuous ... + TypeContinuous Type = "Continuous" + // TypePeriodic ... + TypePeriodic Type = "Periodic" +) + +// PossibleTypeValues returns an array of possible values for the Type const type. +func PossibleTypeValues() []Type { + return []Type{TypeBackupPolicy, TypeContinuous, TypePeriodic} +} + +// 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" + // UnitTypeMilliseconds ... + UnitTypeMilliseconds UnitType = "Milliseconds" + // 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, UnitTypeMilliseconds, UnitTypePercent, UnitTypeSeconds} +} diff --git a/services/cosmos-db/mgmt/2021-06-15/documentdb/gremlinresources.go b/services/cosmos-db/mgmt/2021-06-15/documentdb/gremlinresources.go new file mode 100644 index 000000000000..85a8a4060e2a --- /dev/null +++ b/services/cosmos-db/mgmt/2021-06-15/documentdb/gremlinresources.go @@ -0,0 +1,1567 @@ +package documentdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// GremlinResourcesClient is the client for the GremlinResources methods of the Documentdb service. +type GremlinResourcesClient struct { + BaseClient +} + +// NewGremlinResourcesClient creates an instance of the GremlinResourcesClient client. +func NewGremlinResourcesClient(subscriptionID string) GremlinResourcesClient { + return NewGremlinResourcesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewGremlinResourcesClientWithBaseURI creates an instance of the GremlinResourcesClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewGremlinResourcesClientWithBaseURI(baseURI string, subscriptionID string) GremlinResourcesClient { + return GremlinResourcesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateUpdateGremlinDatabase create or update an Azure Cosmos DB Gremlin database +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +// createUpdateGremlinDatabaseParameters - the parameters to provide for the current Gremlin database. +func (client GremlinResourcesClient) CreateUpdateGremlinDatabase(ctx context.Context, resourceGroupName string, accountName string, databaseName string, createUpdateGremlinDatabaseParameters GremlinDatabaseCreateUpdateParameters) (result GremlinResourcesCreateUpdateGremlinDatabaseFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GremlinResourcesClient.CreateUpdateGremlinDatabase") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}, + {TargetValue: createUpdateGremlinDatabaseParameters, + Constraints: []validation.Constraint{{Target: "createUpdateGremlinDatabaseParameters.GremlinDatabaseCreateUpdateProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "createUpdateGremlinDatabaseParameters.GremlinDatabaseCreateUpdateProperties.Resource", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "createUpdateGremlinDatabaseParameters.GremlinDatabaseCreateUpdateProperties.Resource.ID", Name: validation.Null, Rule: true, Chain: nil}}}, + }}}}}); err != nil { + return result, validation.NewError("documentdb.GremlinResourcesClient", "CreateUpdateGremlinDatabase", err.Error()) + } + + req, err := client.CreateUpdateGremlinDatabasePreparer(ctx, resourceGroupName, accountName, databaseName, createUpdateGremlinDatabaseParameters) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "CreateUpdateGremlinDatabase", nil, "Failure preparing request") + return + } + + result, err = client.CreateUpdateGremlinDatabaseSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "CreateUpdateGremlinDatabase", nil, "Failure sending request") + return + } + + return +} + +// CreateUpdateGremlinDatabasePreparer prepares the CreateUpdateGremlinDatabase request. +func (client GremlinResourcesClient) CreateUpdateGremlinDatabasePreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, createUpdateGremlinDatabaseParameters GremlinDatabaseCreateUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + 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.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}", pathParameters), + autorest.WithJSON(createUpdateGremlinDatabaseParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateUpdateGremlinDatabaseSender sends the CreateUpdateGremlinDatabase request. The method will close the +// http.Response Body if it receives an error. +func (client GremlinResourcesClient) CreateUpdateGremlinDatabaseSender(req *http.Request) (future GremlinResourcesCreateUpdateGremlinDatabaseFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateUpdateGremlinDatabaseResponder handles the response to the CreateUpdateGremlinDatabase request. The method always +// closes the http.Response Body. +func (client GremlinResourcesClient) CreateUpdateGremlinDatabaseResponder(resp *http.Response) (result GremlinDatabaseGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// CreateUpdateGremlinGraph create or update an Azure Cosmos DB Gremlin graph +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +// graphName - cosmos DB graph name. +// createUpdateGremlinGraphParameters - the parameters to provide for the current Gremlin graph. +func (client GremlinResourcesClient) CreateUpdateGremlinGraph(ctx context.Context, resourceGroupName string, accountName string, databaseName string, graphName string, createUpdateGremlinGraphParameters GremlinGraphCreateUpdateParameters) (result GremlinResourcesCreateUpdateGremlinGraphFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GremlinResourcesClient.CreateUpdateGremlinGraph") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}, + {TargetValue: createUpdateGremlinGraphParameters, + Constraints: []validation.Constraint{{Target: "createUpdateGremlinGraphParameters.GremlinGraphCreateUpdateProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "createUpdateGremlinGraphParameters.GremlinGraphCreateUpdateProperties.Resource", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "createUpdateGremlinGraphParameters.GremlinGraphCreateUpdateProperties.Resource.ID", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "createUpdateGremlinGraphParameters.GremlinGraphCreateUpdateProperties.Resource.PartitionKey", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "createUpdateGremlinGraphParameters.GremlinGraphCreateUpdateProperties.Resource.PartitionKey.Version", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "createUpdateGremlinGraphParameters.GremlinGraphCreateUpdateProperties.Resource.PartitionKey.Version", Name: validation.InclusiveMaximum, Rule: int64(2), Chain: nil}, + {Target: "createUpdateGremlinGraphParameters.GremlinGraphCreateUpdateProperties.Resource.PartitionKey.Version", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}, + }}, + }}, + }}, + }}}}}); err != nil { + return result, validation.NewError("documentdb.GremlinResourcesClient", "CreateUpdateGremlinGraph", err.Error()) + } + + req, err := client.CreateUpdateGremlinGraphPreparer(ctx, resourceGroupName, accountName, databaseName, graphName, createUpdateGremlinGraphParameters) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "CreateUpdateGremlinGraph", nil, "Failure preparing request") + return + } + + result, err = client.CreateUpdateGremlinGraphSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "CreateUpdateGremlinGraph", nil, "Failure sending request") + return + } + + return +} + +// CreateUpdateGremlinGraphPreparer prepares the CreateUpdateGremlinGraph request. +func (client GremlinResourcesClient) CreateUpdateGremlinGraphPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, graphName string, createUpdateGremlinGraphParameters GremlinGraphCreateUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "databaseName": autorest.Encode("path", databaseName), + "graphName": autorest.Encode("path", graphName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + 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.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs/{graphName}", pathParameters), + autorest.WithJSON(createUpdateGremlinGraphParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateUpdateGremlinGraphSender sends the CreateUpdateGremlinGraph request. The method will close the +// http.Response Body if it receives an error. +func (client GremlinResourcesClient) CreateUpdateGremlinGraphSender(req *http.Request) (future GremlinResourcesCreateUpdateGremlinGraphFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateUpdateGremlinGraphResponder handles the response to the CreateUpdateGremlinGraph request. The method always +// closes the http.Response Body. +func (client GremlinResourcesClient) CreateUpdateGremlinGraphResponder(resp *http.Response) (result GremlinGraphGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// DeleteGremlinDatabase deletes an existing Azure Cosmos DB Gremlin database. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +func (client GremlinResourcesClient) DeleteGremlinDatabase(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result GremlinResourcesDeleteGremlinDatabaseFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GremlinResourcesClient.DeleteGremlinDatabase") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.GremlinResourcesClient", "DeleteGremlinDatabase", err.Error()) + } + + req, err := client.DeleteGremlinDatabasePreparer(ctx, resourceGroupName, accountName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "DeleteGremlinDatabase", nil, "Failure preparing request") + return + } + + result, err = client.DeleteGremlinDatabaseSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "DeleteGremlinDatabase", nil, "Failure sending request") + return + } + + return +} + +// DeleteGremlinDatabasePreparer prepares the DeleteGremlinDatabase request. +func (client GremlinResourcesClient) DeleteGremlinDatabasePreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteGremlinDatabaseSender sends the DeleteGremlinDatabase request. The method will close the +// http.Response Body if it receives an error. +func (client GremlinResourcesClient) DeleteGremlinDatabaseSender(req *http.Request) (future GremlinResourcesDeleteGremlinDatabaseFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteGremlinDatabaseResponder handles the response to the DeleteGremlinDatabase request. The method always +// closes the http.Response Body. +func (client GremlinResourcesClient) DeleteGremlinDatabaseResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// DeleteGremlinGraph deletes an existing Azure Cosmos DB Gremlin graph. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +// graphName - cosmos DB graph name. +func (client GremlinResourcesClient) DeleteGremlinGraph(ctx context.Context, resourceGroupName string, accountName string, databaseName string, graphName string) (result GremlinResourcesDeleteGremlinGraphFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GremlinResourcesClient.DeleteGremlinGraph") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.GremlinResourcesClient", "DeleteGremlinGraph", err.Error()) + } + + req, err := client.DeleteGremlinGraphPreparer(ctx, resourceGroupName, accountName, databaseName, graphName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "DeleteGremlinGraph", nil, "Failure preparing request") + return + } + + result, err = client.DeleteGremlinGraphSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "DeleteGremlinGraph", nil, "Failure sending request") + return + } + + return +} + +// DeleteGremlinGraphPreparer prepares the DeleteGremlinGraph request. +func (client GremlinResourcesClient) DeleteGremlinGraphPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, graphName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "databaseName": autorest.Encode("path", databaseName), + "graphName": autorest.Encode("path", graphName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs/{graphName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteGremlinGraphSender sends the DeleteGremlinGraph request. The method will close the +// http.Response Body if it receives an error. +func (client GremlinResourcesClient) DeleteGremlinGraphSender(req *http.Request) (future GremlinResourcesDeleteGremlinGraphFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteGremlinGraphResponder handles the response to the DeleteGremlinGraph request. The method always +// closes the http.Response Body. +func (client GremlinResourcesClient) DeleteGremlinGraphResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// GetGremlinDatabase gets the Gremlin databases under an existing Azure Cosmos DB database account with the provided +// name. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +func (client GremlinResourcesClient) GetGremlinDatabase(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result GremlinDatabaseGetResults, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GremlinResourcesClient.GetGremlinDatabase") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.GremlinResourcesClient", "GetGremlinDatabase", err.Error()) + } + + req, err := client.GetGremlinDatabasePreparer(ctx, resourceGroupName, accountName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "GetGremlinDatabase", nil, "Failure preparing request") + return + } + + resp, err := client.GetGremlinDatabaseSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "GetGremlinDatabase", resp, "Failure sending request") + return + } + + result, err = client.GetGremlinDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "GetGremlinDatabase", resp, "Failure responding to request") + return + } + + return +} + +// GetGremlinDatabasePreparer prepares the GetGremlinDatabase request. +func (client GremlinResourcesClient) GetGremlinDatabasePreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetGremlinDatabaseSender sends the GetGremlinDatabase request. The method will close the +// http.Response Body if it receives an error. +func (client GremlinResourcesClient) GetGremlinDatabaseSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetGremlinDatabaseResponder handles the response to the GetGremlinDatabase request. The method always +// closes the http.Response Body. +func (client GremlinResourcesClient) GetGremlinDatabaseResponder(resp *http.Response) (result GremlinDatabaseGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetGremlinDatabaseThroughput gets the RUs per second of the Gremlin database under an existing Azure Cosmos DB +// database account with the provided name. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +func (client GremlinResourcesClient) GetGremlinDatabaseThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result ThroughputSettingsGetResults, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GremlinResourcesClient.GetGremlinDatabaseThroughput") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.GremlinResourcesClient", "GetGremlinDatabaseThroughput", err.Error()) + } + + req, err := client.GetGremlinDatabaseThroughputPreparer(ctx, resourceGroupName, accountName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "GetGremlinDatabaseThroughput", nil, "Failure preparing request") + return + } + + resp, err := client.GetGremlinDatabaseThroughputSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "GetGremlinDatabaseThroughput", resp, "Failure sending request") + return + } + + result, err = client.GetGremlinDatabaseThroughputResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "GetGremlinDatabaseThroughput", resp, "Failure responding to request") + return + } + + return +} + +// GetGremlinDatabaseThroughputPreparer prepares the GetGremlinDatabaseThroughput request. +func (client GremlinResourcesClient) GetGremlinDatabaseThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/throughputSettings/default", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetGremlinDatabaseThroughputSender sends the GetGremlinDatabaseThroughput request. The method will close the +// http.Response Body if it receives an error. +func (client GremlinResourcesClient) GetGremlinDatabaseThroughputSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetGremlinDatabaseThroughputResponder handles the response to the GetGremlinDatabaseThroughput request. The method always +// closes the http.Response Body. +func (client GremlinResourcesClient) GetGremlinDatabaseThroughputResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetGremlinGraph gets the Gremlin graph under an existing Azure Cosmos DB database account. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +// graphName - cosmos DB graph name. +func (client GremlinResourcesClient) GetGremlinGraph(ctx context.Context, resourceGroupName string, accountName string, databaseName string, graphName string) (result GremlinGraphGetResults, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GremlinResourcesClient.GetGremlinGraph") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.GremlinResourcesClient", "GetGremlinGraph", err.Error()) + } + + req, err := client.GetGremlinGraphPreparer(ctx, resourceGroupName, accountName, databaseName, graphName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "GetGremlinGraph", nil, "Failure preparing request") + return + } + + resp, err := client.GetGremlinGraphSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "GetGremlinGraph", resp, "Failure sending request") + return + } + + result, err = client.GetGremlinGraphResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "GetGremlinGraph", resp, "Failure responding to request") + return + } + + return +} + +// GetGremlinGraphPreparer prepares the GetGremlinGraph request. +func (client GremlinResourcesClient) GetGremlinGraphPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, graphName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "databaseName": autorest.Encode("path", databaseName), + "graphName": autorest.Encode("path", graphName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs/{graphName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetGremlinGraphSender sends the GetGremlinGraph request. The method will close the +// http.Response Body if it receives an error. +func (client GremlinResourcesClient) GetGremlinGraphSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetGremlinGraphResponder handles the response to the GetGremlinGraph request. The method always +// closes the http.Response Body. +func (client GremlinResourcesClient) GetGremlinGraphResponder(resp *http.Response) (result GremlinGraphGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetGremlinGraphThroughput gets the Gremlin graph throughput under an existing Azure Cosmos DB database account with +// the provided name. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +// graphName - cosmos DB graph name. +func (client GremlinResourcesClient) GetGremlinGraphThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string, graphName string) (result ThroughputSettingsGetResults, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GremlinResourcesClient.GetGremlinGraphThroughput") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.GremlinResourcesClient", "GetGremlinGraphThroughput", err.Error()) + } + + req, err := client.GetGremlinGraphThroughputPreparer(ctx, resourceGroupName, accountName, databaseName, graphName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "GetGremlinGraphThroughput", nil, "Failure preparing request") + return + } + + resp, err := client.GetGremlinGraphThroughputSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "GetGremlinGraphThroughput", resp, "Failure sending request") + return + } + + result, err = client.GetGremlinGraphThroughputResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "GetGremlinGraphThroughput", resp, "Failure responding to request") + return + } + + return +} + +// GetGremlinGraphThroughputPreparer prepares the GetGremlinGraphThroughput request. +func (client GremlinResourcesClient) GetGremlinGraphThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, graphName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "databaseName": autorest.Encode("path", databaseName), + "graphName": autorest.Encode("path", graphName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs/{graphName}/throughputSettings/default", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetGremlinGraphThroughputSender sends the GetGremlinGraphThroughput request. The method will close the +// http.Response Body if it receives an error. +func (client GremlinResourcesClient) GetGremlinGraphThroughputSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetGremlinGraphThroughputResponder handles the response to the GetGremlinGraphThroughput request. The method always +// closes the http.Response Body. +func (client GremlinResourcesClient) GetGremlinGraphThroughputResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListGremlinDatabases lists the Gremlin databases under an existing Azure Cosmos DB database account. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +func (client GremlinResourcesClient) ListGremlinDatabases(ctx context.Context, resourceGroupName string, accountName string) (result GremlinDatabaseListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GremlinResourcesClient.ListGremlinDatabases") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.GremlinResourcesClient", "ListGremlinDatabases", err.Error()) + } + + req, err := client.ListGremlinDatabasesPreparer(ctx, resourceGroupName, accountName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "ListGremlinDatabases", nil, "Failure preparing request") + return + } + + resp, err := client.ListGremlinDatabasesSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "ListGremlinDatabases", resp, "Failure sending request") + return + } + + result, err = client.ListGremlinDatabasesResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "ListGremlinDatabases", resp, "Failure responding to request") + return + } + + return +} + +// ListGremlinDatabasesPreparer prepares the ListGremlinDatabases request. +func (client GremlinResourcesClient) ListGremlinDatabasesPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListGremlinDatabasesSender sends the ListGremlinDatabases request. The method will close the +// http.Response Body if it receives an error. +func (client GremlinResourcesClient) ListGremlinDatabasesSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListGremlinDatabasesResponder handles the response to the ListGremlinDatabases request. The method always +// closes the http.Response Body. +func (client GremlinResourcesClient) ListGremlinDatabasesResponder(resp *http.Response) (result GremlinDatabaseListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListGremlinGraphs lists the Gremlin graph under an existing Azure Cosmos DB database account. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +func (client GremlinResourcesClient) ListGremlinGraphs(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result GremlinGraphListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GremlinResourcesClient.ListGremlinGraphs") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.GremlinResourcesClient", "ListGremlinGraphs", err.Error()) + } + + req, err := client.ListGremlinGraphsPreparer(ctx, resourceGroupName, accountName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "ListGremlinGraphs", nil, "Failure preparing request") + return + } + + resp, err := client.ListGremlinGraphsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "ListGremlinGraphs", resp, "Failure sending request") + return + } + + result, err = client.ListGremlinGraphsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "ListGremlinGraphs", resp, "Failure responding to request") + return + } + + return +} + +// ListGremlinGraphsPreparer prepares the ListGremlinGraphs request. +func (client GremlinResourcesClient) ListGremlinGraphsPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListGremlinGraphsSender sends the ListGremlinGraphs request. The method will close the +// http.Response Body if it receives an error. +func (client GremlinResourcesClient) ListGremlinGraphsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListGremlinGraphsResponder handles the response to the ListGremlinGraphs request. The method always +// closes the http.Response Body. +func (client GremlinResourcesClient) ListGremlinGraphsResponder(resp *http.Response) (result GremlinGraphListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// MigrateGremlinDatabaseToAutoscale migrate an Azure Cosmos DB Gremlin database from manual throughput to autoscale +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +func (client GremlinResourcesClient) MigrateGremlinDatabaseToAutoscale(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result GremlinResourcesMigrateGremlinDatabaseToAutoscaleFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GremlinResourcesClient.MigrateGremlinDatabaseToAutoscale") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.GremlinResourcesClient", "MigrateGremlinDatabaseToAutoscale", err.Error()) + } + + req, err := client.MigrateGremlinDatabaseToAutoscalePreparer(ctx, resourceGroupName, accountName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "MigrateGremlinDatabaseToAutoscale", nil, "Failure preparing request") + return + } + + result, err = client.MigrateGremlinDatabaseToAutoscaleSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "MigrateGremlinDatabaseToAutoscale", nil, "Failure sending request") + return + } + + return +} + +// MigrateGremlinDatabaseToAutoscalePreparer prepares the MigrateGremlinDatabaseToAutoscale request. +func (client GremlinResourcesClient) MigrateGremlinDatabaseToAutoscalePreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/throughputSettings/default/migrateToAutoscale", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// MigrateGremlinDatabaseToAutoscaleSender sends the MigrateGremlinDatabaseToAutoscale request. The method will close the +// http.Response Body if it receives an error. +func (client GremlinResourcesClient) MigrateGremlinDatabaseToAutoscaleSender(req *http.Request) (future GremlinResourcesMigrateGremlinDatabaseToAutoscaleFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// MigrateGremlinDatabaseToAutoscaleResponder handles the response to the MigrateGremlinDatabaseToAutoscale request. The method always +// closes the http.Response Body. +func (client GremlinResourcesClient) MigrateGremlinDatabaseToAutoscaleResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// MigrateGremlinDatabaseToManualThroughput migrate an Azure Cosmos DB Gremlin database from autoscale to manual +// throughput +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +func (client GremlinResourcesClient) MigrateGremlinDatabaseToManualThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result GremlinResourcesMigrateGremlinDatabaseToManualThroughputFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GremlinResourcesClient.MigrateGremlinDatabaseToManualThroughput") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.GremlinResourcesClient", "MigrateGremlinDatabaseToManualThroughput", err.Error()) + } + + req, err := client.MigrateGremlinDatabaseToManualThroughputPreparer(ctx, resourceGroupName, accountName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "MigrateGremlinDatabaseToManualThroughput", nil, "Failure preparing request") + return + } + + result, err = client.MigrateGremlinDatabaseToManualThroughputSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "MigrateGremlinDatabaseToManualThroughput", nil, "Failure sending request") + return + } + + return +} + +// MigrateGremlinDatabaseToManualThroughputPreparer prepares the MigrateGremlinDatabaseToManualThroughput request. +func (client GremlinResourcesClient) MigrateGremlinDatabaseToManualThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/throughputSettings/default/migrateToManualThroughput", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// MigrateGremlinDatabaseToManualThroughputSender sends the MigrateGremlinDatabaseToManualThroughput request. The method will close the +// http.Response Body if it receives an error. +func (client GremlinResourcesClient) MigrateGremlinDatabaseToManualThroughputSender(req *http.Request) (future GremlinResourcesMigrateGremlinDatabaseToManualThroughputFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// MigrateGremlinDatabaseToManualThroughputResponder handles the response to the MigrateGremlinDatabaseToManualThroughput request. The method always +// closes the http.Response Body. +func (client GremlinResourcesClient) MigrateGremlinDatabaseToManualThroughputResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// MigrateGremlinGraphToAutoscale migrate an Azure Cosmos DB Gremlin graph from manual throughput to autoscale +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +// graphName - cosmos DB graph name. +func (client GremlinResourcesClient) MigrateGremlinGraphToAutoscale(ctx context.Context, resourceGroupName string, accountName string, databaseName string, graphName string) (result GremlinResourcesMigrateGremlinGraphToAutoscaleFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GremlinResourcesClient.MigrateGremlinGraphToAutoscale") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.GremlinResourcesClient", "MigrateGremlinGraphToAutoscale", err.Error()) + } + + req, err := client.MigrateGremlinGraphToAutoscalePreparer(ctx, resourceGroupName, accountName, databaseName, graphName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "MigrateGremlinGraphToAutoscale", nil, "Failure preparing request") + return + } + + result, err = client.MigrateGremlinGraphToAutoscaleSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "MigrateGremlinGraphToAutoscale", nil, "Failure sending request") + return + } + + return +} + +// MigrateGremlinGraphToAutoscalePreparer prepares the MigrateGremlinGraphToAutoscale request. +func (client GremlinResourcesClient) MigrateGremlinGraphToAutoscalePreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, graphName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "databaseName": autorest.Encode("path", databaseName), + "graphName": autorest.Encode("path", graphName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs/{graphName}/throughputSettings/default/migrateToAutoscale", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// MigrateGremlinGraphToAutoscaleSender sends the MigrateGremlinGraphToAutoscale request. The method will close the +// http.Response Body if it receives an error. +func (client GremlinResourcesClient) MigrateGremlinGraphToAutoscaleSender(req *http.Request) (future GremlinResourcesMigrateGremlinGraphToAutoscaleFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// MigrateGremlinGraphToAutoscaleResponder handles the response to the MigrateGremlinGraphToAutoscale request. The method always +// closes the http.Response Body. +func (client GremlinResourcesClient) MigrateGremlinGraphToAutoscaleResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// MigrateGremlinGraphToManualThroughput migrate an Azure Cosmos DB Gremlin graph from autoscale to manual throughput +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +// graphName - cosmos DB graph name. +func (client GremlinResourcesClient) MigrateGremlinGraphToManualThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string, graphName string) (result GremlinResourcesMigrateGremlinGraphToManualThroughputFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GremlinResourcesClient.MigrateGremlinGraphToManualThroughput") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.GremlinResourcesClient", "MigrateGremlinGraphToManualThroughput", err.Error()) + } + + req, err := client.MigrateGremlinGraphToManualThroughputPreparer(ctx, resourceGroupName, accountName, databaseName, graphName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "MigrateGremlinGraphToManualThroughput", nil, "Failure preparing request") + return + } + + result, err = client.MigrateGremlinGraphToManualThroughputSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "MigrateGremlinGraphToManualThroughput", nil, "Failure sending request") + return + } + + return +} + +// MigrateGremlinGraphToManualThroughputPreparer prepares the MigrateGremlinGraphToManualThroughput request. +func (client GremlinResourcesClient) MigrateGremlinGraphToManualThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, graphName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "databaseName": autorest.Encode("path", databaseName), + "graphName": autorest.Encode("path", graphName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs/{graphName}/throughputSettings/default/migrateToManualThroughput", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// MigrateGremlinGraphToManualThroughputSender sends the MigrateGremlinGraphToManualThroughput request. The method will close the +// http.Response Body if it receives an error. +func (client GremlinResourcesClient) MigrateGremlinGraphToManualThroughputSender(req *http.Request) (future GremlinResourcesMigrateGremlinGraphToManualThroughputFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// MigrateGremlinGraphToManualThroughputResponder handles the response to the MigrateGremlinGraphToManualThroughput request. The method always +// closes the http.Response Body. +func (client GremlinResourcesClient) MigrateGremlinGraphToManualThroughputResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// UpdateGremlinDatabaseThroughput update RUs per second of an Azure Cosmos DB Gremlin database +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +// updateThroughputParameters - the RUs per second of the parameters to provide for the current Gremlin +// database. +func (client GremlinResourcesClient) UpdateGremlinDatabaseThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string, updateThroughputParameters ThroughputSettingsUpdateParameters) (result GremlinResourcesUpdateGremlinDatabaseThroughputFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GremlinResourcesClient.UpdateGremlinDatabaseThroughput") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}, + {TargetValue: updateThroughputParameters, + Constraints: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties.Resource", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties.Resource.AutoscaleSettings", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties.Resource.AutoscaleSettings.MaxThroughput", Name: validation.Null, Rule: true, Chain: nil}}}, + }}, + }}}}}); err != nil { + return result, validation.NewError("documentdb.GremlinResourcesClient", "UpdateGremlinDatabaseThroughput", err.Error()) + } + + req, err := client.UpdateGremlinDatabaseThroughputPreparer(ctx, resourceGroupName, accountName, databaseName, updateThroughputParameters) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "UpdateGremlinDatabaseThroughput", nil, "Failure preparing request") + return + } + + result, err = client.UpdateGremlinDatabaseThroughputSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "UpdateGremlinDatabaseThroughput", nil, "Failure sending request") + return + } + + return +} + +// UpdateGremlinDatabaseThroughputPreparer prepares the UpdateGremlinDatabaseThroughput request. +func (client GremlinResourcesClient) UpdateGremlinDatabaseThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, updateThroughputParameters ThroughputSettingsUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + 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.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/throughputSettings/default", pathParameters), + autorest.WithJSON(updateThroughputParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateGremlinDatabaseThroughputSender sends the UpdateGremlinDatabaseThroughput request. The method will close the +// http.Response Body if it receives an error. +func (client GremlinResourcesClient) UpdateGremlinDatabaseThroughputSender(req *http.Request) (future GremlinResourcesUpdateGremlinDatabaseThroughputFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// UpdateGremlinDatabaseThroughputResponder handles the response to the UpdateGremlinDatabaseThroughput request. The method always +// closes the http.Response Body. +func (client GremlinResourcesClient) UpdateGremlinDatabaseThroughputResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// UpdateGremlinGraphThroughput update RUs per second of an Azure Cosmos DB Gremlin graph +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +// graphName - cosmos DB graph name. +// updateThroughputParameters - the RUs per second of the parameters to provide for the current Gremlin graph. +func (client GremlinResourcesClient) UpdateGremlinGraphThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string, graphName string, updateThroughputParameters ThroughputSettingsUpdateParameters) (result GremlinResourcesUpdateGremlinGraphThroughputFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GremlinResourcesClient.UpdateGremlinGraphThroughput") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}, + {TargetValue: updateThroughputParameters, + Constraints: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties.Resource", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties.Resource.AutoscaleSettings", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties.Resource.AutoscaleSettings.MaxThroughput", Name: validation.Null, Rule: true, Chain: nil}}}, + }}, + }}}}}); err != nil { + return result, validation.NewError("documentdb.GremlinResourcesClient", "UpdateGremlinGraphThroughput", err.Error()) + } + + req, err := client.UpdateGremlinGraphThroughputPreparer(ctx, resourceGroupName, accountName, databaseName, graphName, updateThroughputParameters) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "UpdateGremlinGraphThroughput", nil, "Failure preparing request") + return + } + + result, err = client.UpdateGremlinGraphThroughputSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "UpdateGremlinGraphThroughput", nil, "Failure sending request") + return + } + + return +} + +// UpdateGremlinGraphThroughputPreparer prepares the UpdateGremlinGraphThroughput request. +func (client GremlinResourcesClient) UpdateGremlinGraphThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, graphName string, updateThroughputParameters ThroughputSettingsUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "databaseName": autorest.Encode("path", databaseName), + "graphName": autorest.Encode("path", graphName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + 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.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs/{graphName}/throughputSettings/default", pathParameters), + autorest.WithJSON(updateThroughputParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateGremlinGraphThroughputSender sends the UpdateGremlinGraphThroughput request. The method will close the +// http.Response Body if it receives an error. +func (client GremlinResourcesClient) UpdateGremlinGraphThroughputSender(req *http.Request) (future GremlinResourcesUpdateGremlinGraphThroughputFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// UpdateGremlinGraphThroughputResponder handles the response to the UpdateGremlinGraphThroughput request. The method always +// closes the http.Response Body. +func (client GremlinResourcesClient) UpdateGremlinGraphThroughputResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/cosmos-db/mgmt/2021-06-15/documentdb/models.go b/services/cosmos-db/mgmt/2021-06-15/documentdb/models.go new file mode 100644 index 000000000000..d5b8020025b3 --- /dev/null +++ b/services/cosmos-db/mgmt/2021-06-15/documentdb/models.go @@ -0,0 +1,10479 @@ +package documentdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "encoding/json" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/date" + "github.com/Azure/go-autorest/autorest/to" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// The package's fully qualified name. +const fqdn = "github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-06-15/documentdb" + +// AnalyticalStorageConfiguration analytical storage specific properties. +type AnalyticalStorageConfiguration struct { + // SchemaType - Possible values include: 'AnalyticalStorageSchemaTypeWellDefined', 'AnalyticalStorageSchemaTypeFullFidelity' + SchemaType AnalyticalStorageSchemaType `json:"schemaType,omitempty"` +} + +// APIProperties ... +type APIProperties struct { + // ServerVersion - Describes the ServerVersion of an a MongoDB account. Possible values include: 'ServerVersionThreeFullStopTwo', 'ServerVersionThreeFullStopSix', 'ServerVersionFourFullStopZero' + ServerVersion ServerVersion `json:"serverVersion,omitempty"` +} + +// ARMProxyResource the resource model definition for a ARM proxy resource. It will have everything other +// than required location and tags +type ARMProxyResource struct { + // ID - READ-ONLY; The unique resource identifier of the database account. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the database account. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of Azure resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ARMProxyResource. +func (apr ARMProxyResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ARMResourceProperties the core properties of ARM resources. +type ARMResourceProperties struct { + // ID - READ-ONLY; The unique resource identifier of the ARM resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the ARM resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of Azure resource. + Type *string `json:"type,omitempty"` + // Location - The location of the resource group to which the resource belongs. + Location *string `json:"location,omitempty"` + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for ARMResourceProperties. +func (arp ARMResourceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if arp.Location != nil { + objectMap["location"] = arp.Location + } + if arp.Tags != nil { + objectMap["tags"] = arp.Tags + } + return json.Marshal(objectMap) +} + +// AutoscaleSettings ... +type AutoscaleSettings struct { + // MaxThroughput - Represents maximum throughput, the resource can scale up to. + MaxThroughput *int32 `json:"maxThroughput,omitempty"` +} + +// AutoscaleSettingsResource cosmos DB provisioned throughput settings object +type AutoscaleSettingsResource struct { + // MaxThroughput - Represents maximum throughput container can scale up to. + MaxThroughput *int32 `json:"maxThroughput,omitempty"` + // AutoUpgradePolicy - Cosmos DB resource auto-upgrade policy + AutoUpgradePolicy *AutoUpgradePolicyResource `json:"autoUpgradePolicy,omitempty"` + // TargetMaxThroughput - READ-ONLY; Represents target maximum throughput container can scale up to once offer is no longer in pending state. + TargetMaxThroughput *int32 `json:"targetMaxThroughput,omitempty"` +} + +// MarshalJSON is the custom marshaler for AutoscaleSettingsResource. +func (asr AutoscaleSettingsResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if asr.MaxThroughput != nil { + objectMap["maxThroughput"] = asr.MaxThroughput + } + if asr.AutoUpgradePolicy != nil { + objectMap["autoUpgradePolicy"] = asr.AutoUpgradePolicy + } + return json.Marshal(objectMap) +} + +// AutoUpgradePolicyResource cosmos DB resource auto-upgrade policy +type AutoUpgradePolicyResource struct { + // ThroughputPolicy - Represents throughput policy which service must adhere to for auto-upgrade + ThroughputPolicy *ThroughputPolicyResource `json:"throughputPolicy,omitempty"` +} + +// AzureEntityResource the resource model definition for an Azure Resource Manager resource with an etag. +type AzureEntityResource struct { + // Etag - READ-ONLY; Resource Etag. + Etag *string `json:"etag,omitempty"` + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for AzureEntityResource. +func (aer AzureEntityResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// BackupInformation backup information of a resource. +type BackupInformation struct { + autorest.Response `json:"-"` + // ContinuousBackupInformation - Information about the status of continuous backups. + ContinuousBackupInformation *ContinuousBackupInformation `json:"continuousBackupInformation,omitempty"` +} + +// BasicBackupPolicy the object representing the policy for taking backups on an account. +type BasicBackupPolicy interface { + AsPeriodicModeBackupPolicy() (*PeriodicModeBackupPolicy, bool) + AsContinuousModeBackupPolicy() (*ContinuousModeBackupPolicy, bool) + AsBackupPolicy() (*BackupPolicy, bool) +} + +// BackupPolicy the object representing the policy for taking backups on an account. +type BackupPolicy struct { + // MigrationState - The object representing the state of the migration between the backup policies. + MigrationState *BackupPolicyMigrationState `json:"migrationState,omitempty"` + // Type - Possible values include: 'TypeBackupPolicy', 'TypePeriodic', 'TypeContinuous' + Type Type `json:"type,omitempty"` +} + +func unmarshalBasicBackupPolicy(body []byte) (BasicBackupPolicy, error) { + var m map[string]interface{} + err := json.Unmarshal(body, &m) + if err != nil { + return nil, err + } + + switch m["type"] { + case string(TypePeriodic): + var pmbp PeriodicModeBackupPolicy + err := json.Unmarshal(body, &pmbp) + return pmbp, err + case string(TypeContinuous): + var cmbp ContinuousModeBackupPolicy + err := json.Unmarshal(body, &cmbp) + return cmbp, err + default: + var bp BackupPolicy + err := json.Unmarshal(body, &bp) + return bp, err + } +} +func unmarshalBasicBackupPolicyArray(body []byte) ([]BasicBackupPolicy, error) { + var rawMessages []*json.RawMessage + err := json.Unmarshal(body, &rawMessages) + if err != nil { + return nil, err + } + + bpArray := make([]BasicBackupPolicy, len(rawMessages)) + + for index, rawMessage := range rawMessages { + bp, err := unmarshalBasicBackupPolicy(*rawMessage) + if err != nil { + return nil, err + } + bpArray[index] = bp + } + return bpArray, nil +} + +// MarshalJSON is the custom marshaler for BackupPolicy. +func (bp BackupPolicy) MarshalJSON() ([]byte, error) { + bp.Type = TypeBackupPolicy + objectMap := make(map[string]interface{}) + if bp.MigrationState != nil { + objectMap["migrationState"] = bp.MigrationState + } + if bp.Type != "" { + objectMap["type"] = bp.Type + } + return json.Marshal(objectMap) +} + +// AsPeriodicModeBackupPolicy is the BasicBackupPolicy implementation for BackupPolicy. +func (bp BackupPolicy) AsPeriodicModeBackupPolicy() (*PeriodicModeBackupPolicy, bool) { + return nil, false +} + +// AsContinuousModeBackupPolicy is the BasicBackupPolicy implementation for BackupPolicy. +func (bp BackupPolicy) AsContinuousModeBackupPolicy() (*ContinuousModeBackupPolicy, bool) { + return nil, false +} + +// AsBackupPolicy is the BasicBackupPolicy implementation for BackupPolicy. +func (bp BackupPolicy) AsBackupPolicy() (*BackupPolicy, bool) { + return &bp, true +} + +// AsBasicBackupPolicy is the BasicBackupPolicy implementation for BackupPolicy. +func (bp BackupPolicy) AsBasicBackupPolicy() (BasicBackupPolicy, bool) { + return &bp, true +} + +// BackupPolicyMigrationState the object representing the state of the migration between the backup +// policies. +type BackupPolicyMigrationState struct { + // Status - Describes the status of migration between backup policy types. Possible values include: 'BackupPolicyMigrationStatusInvalid', 'BackupPolicyMigrationStatusInProgress', 'BackupPolicyMigrationStatusCompleted', 'BackupPolicyMigrationStatusFailed' + Status BackupPolicyMigrationStatus `json:"status,omitempty"` + // TargetType - Describes the target backup policy type of the backup policy migration. Possible values include: 'BackupPolicyTypePeriodic', 'BackupPolicyTypeContinuous' + TargetType BackupPolicyType `json:"targetType,omitempty"` + // StartTime - Time at which the backup policy migration started (ISO-8601 format). + StartTime *date.Time `json:"startTime,omitempty"` +} + +// Capability cosmos DB capability object +type Capability struct { + // Name - Name of the Cosmos DB capability. For example, "name": "EnableCassandra". Current values also include "EnableTable" and "EnableGremlin". + Name *string `json:"name,omitempty"` +} + +// CassandraKeyspaceCreateUpdateParameters parameters to create and update Cosmos DB Cassandra keyspace. +type CassandraKeyspaceCreateUpdateParameters struct { + // CassandraKeyspaceCreateUpdateProperties - Properties to create and update Azure Cosmos DB Cassandra keyspace. + *CassandraKeyspaceCreateUpdateProperties `json:"properties,omitempty"` + // ID - READ-ONLY; The unique resource identifier of the ARM resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the ARM resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of Azure resource. + Type *string `json:"type,omitempty"` + // Location - The location of the resource group to which the resource belongs. + Location *string `json:"location,omitempty"` + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for CassandraKeyspaceCreateUpdateParameters. +func (ckcup CassandraKeyspaceCreateUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ckcup.CassandraKeyspaceCreateUpdateProperties != nil { + objectMap["properties"] = ckcup.CassandraKeyspaceCreateUpdateProperties + } + if ckcup.Location != nil { + objectMap["location"] = ckcup.Location + } + if ckcup.Tags != nil { + objectMap["tags"] = ckcup.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for CassandraKeyspaceCreateUpdateParameters struct. +func (ckcup *CassandraKeyspaceCreateUpdateParameters) UnmarshalJSON(body []byte) error { + 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 cassandraKeyspaceCreateUpdateProperties CassandraKeyspaceCreateUpdateProperties + err = json.Unmarshal(*v, &cassandraKeyspaceCreateUpdateProperties) + if err != nil { + return err + } + ckcup.CassandraKeyspaceCreateUpdateProperties = &cassandraKeyspaceCreateUpdateProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + ckcup.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ckcup.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ckcup.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + ckcup.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + ckcup.Tags = tags + } + } + } + + return nil +} + +// CassandraKeyspaceCreateUpdateProperties properties to create and update Azure Cosmos DB Cassandra +// keyspace. +type CassandraKeyspaceCreateUpdateProperties struct { + // Resource - The standard JSON format of a Cassandra keyspace + Resource *CassandraKeyspaceResource `json:"resource,omitempty"` + // Options - A key-value pair of options to be applied for the request. This corresponds to the headers sent with the request. + Options *CreateUpdateOptions `json:"options,omitempty"` +} + +// CassandraKeyspaceGetProperties the properties of an Azure Cosmos DB Cassandra keyspace +type CassandraKeyspaceGetProperties struct { + Resource *CassandraKeyspaceGetPropertiesResource `json:"resource,omitempty"` + Options *CassandraKeyspaceGetPropertiesOptions `json:"options,omitempty"` +} + +// CassandraKeyspaceGetPropertiesOptions ... +type CassandraKeyspaceGetPropertiesOptions struct { + // Throughput - Value of the Cosmos DB resource throughput or autoscaleSettings. Use the ThroughputSetting resource when retrieving offer details. + Throughput *int32 `json:"throughput,omitempty"` + // AutoscaleSettings - Specifies the Autoscale settings. + AutoscaleSettings *AutoscaleSettings `json:"autoscaleSettings,omitempty"` +} + +// CassandraKeyspaceGetPropertiesResource ... +type CassandraKeyspaceGetPropertiesResource struct { + // ID - Name of the Cosmos DB Cassandra keyspace + ID *string `json:"id,omitempty"` + // Rid - READ-ONLY; A system generated property. A unique identifier. + Rid *string `json:"_rid,omitempty"` + // Ts - READ-ONLY; A system generated property that denotes the last updated timestamp of the resource. + Ts *float64 `json:"_ts,omitempty"` + // Etag - READ-ONLY; A system generated property representing the resource etag required for optimistic concurrency control. + Etag *string `json:"_etag,omitempty"` +} + +// MarshalJSON is the custom marshaler for CassandraKeyspaceGetPropertiesResource. +func (ckgp CassandraKeyspaceGetPropertiesResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ckgp.ID != nil { + objectMap["id"] = ckgp.ID + } + return json.Marshal(objectMap) +} + +// CassandraKeyspaceGetResults an Azure Cosmos DB Cassandra keyspace. +type CassandraKeyspaceGetResults struct { + autorest.Response `json:"-"` + // CassandraKeyspaceGetProperties - The properties of an Azure Cosmos DB Cassandra keyspace + *CassandraKeyspaceGetProperties `json:"properties,omitempty"` + // ID - READ-ONLY; The unique resource identifier of the ARM resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the ARM resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of Azure resource. + Type *string `json:"type,omitempty"` + // Location - The location of the resource group to which the resource belongs. + Location *string `json:"location,omitempty"` + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for CassandraKeyspaceGetResults. +func (ckgr CassandraKeyspaceGetResults) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ckgr.CassandraKeyspaceGetProperties != nil { + objectMap["properties"] = ckgr.CassandraKeyspaceGetProperties + } + if ckgr.Location != nil { + objectMap["location"] = ckgr.Location + } + if ckgr.Tags != nil { + objectMap["tags"] = ckgr.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for CassandraKeyspaceGetResults struct. +func (ckgr *CassandraKeyspaceGetResults) UnmarshalJSON(body []byte) error { + 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 cassandraKeyspaceGetProperties CassandraKeyspaceGetProperties + err = json.Unmarshal(*v, &cassandraKeyspaceGetProperties) + if err != nil { + return err + } + ckgr.CassandraKeyspaceGetProperties = &cassandraKeyspaceGetProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + ckgr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ckgr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ckgr.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + ckgr.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + ckgr.Tags = tags + } + } + } + + return nil +} + +// CassandraKeyspaceListResult the List operation response, that contains the Cassandra keyspaces and their +// properties. +type CassandraKeyspaceListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; List of Cassandra keyspaces and their properties. + Value *[]CassandraKeyspaceGetResults `json:"value,omitempty"` +} + +// MarshalJSON is the custom marshaler for CassandraKeyspaceListResult. +func (cklr CassandraKeyspaceListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// CassandraKeyspaceResource cosmos DB Cassandra keyspace resource object +type CassandraKeyspaceResource struct { + // ID - Name of the Cosmos DB Cassandra keyspace + ID *string `json:"id,omitempty"` +} + +// CassandraPartitionKey cosmos DB Cassandra table partition key +type CassandraPartitionKey struct { + // Name - Name of the Cosmos DB Cassandra table partition key + Name *string `json:"name,omitempty"` +} + +// CassandraResourcesCreateUpdateCassandraKeyspaceFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type CassandraResourcesCreateUpdateCassandraKeyspaceFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(CassandraResourcesClient) (CassandraKeyspaceGetResults, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *CassandraResourcesCreateUpdateCassandraKeyspaceFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for CassandraResourcesCreateUpdateCassandraKeyspaceFuture.Result. +func (future *CassandraResourcesCreateUpdateCassandraKeyspaceFuture) result(client CassandraResourcesClient) (ckgr CassandraKeyspaceGetResults, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesCreateUpdateCassandraKeyspaceFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ckgr.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("documentdb.CassandraResourcesCreateUpdateCassandraKeyspaceFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if ckgr.Response.Response, err = future.GetResult(sender); err == nil && ckgr.Response.Response.StatusCode != http.StatusNoContent { + ckgr, err = client.CreateUpdateCassandraKeyspaceResponder(ckgr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesCreateUpdateCassandraKeyspaceFuture", "Result", ckgr.Response.Response, "Failure responding to request") + } + } + return +} + +// CassandraResourcesCreateUpdateCassandraTableFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type CassandraResourcesCreateUpdateCassandraTableFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(CassandraResourcesClient) (CassandraTableGetResults, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *CassandraResourcesCreateUpdateCassandraTableFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for CassandraResourcesCreateUpdateCassandraTableFuture.Result. +func (future *CassandraResourcesCreateUpdateCassandraTableFuture) result(client CassandraResourcesClient) (ctgr CassandraTableGetResults, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesCreateUpdateCassandraTableFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ctgr.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("documentdb.CassandraResourcesCreateUpdateCassandraTableFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if ctgr.Response.Response, err = future.GetResult(sender); err == nil && ctgr.Response.Response.StatusCode != http.StatusNoContent { + ctgr, err = client.CreateUpdateCassandraTableResponder(ctgr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesCreateUpdateCassandraTableFuture", "Result", ctgr.Response.Response, "Failure responding to request") + } + } + return +} + +// CassandraResourcesDeleteCassandraKeyspaceFuture an abstraction for monitoring and retrieving the results +// of a long-running operation. +type CassandraResourcesDeleteCassandraKeyspaceFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(CassandraResourcesClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *CassandraResourcesDeleteCassandraKeyspaceFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for CassandraResourcesDeleteCassandraKeyspaceFuture.Result. +func (future *CassandraResourcesDeleteCassandraKeyspaceFuture) result(client CassandraResourcesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesDeleteCassandraKeyspaceFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("documentdb.CassandraResourcesDeleteCassandraKeyspaceFuture") + return + } + ar.Response = future.Response() + return +} + +// CassandraResourcesDeleteCassandraTableFuture an abstraction for monitoring and retrieving the results of +// a long-running operation. +type CassandraResourcesDeleteCassandraTableFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(CassandraResourcesClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *CassandraResourcesDeleteCassandraTableFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for CassandraResourcesDeleteCassandraTableFuture.Result. +func (future *CassandraResourcesDeleteCassandraTableFuture) result(client CassandraResourcesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesDeleteCassandraTableFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("documentdb.CassandraResourcesDeleteCassandraTableFuture") + return + } + ar.Response = future.Response() + return +} + +// CassandraResourcesMigrateCassandraKeyspaceToAutoscaleFuture an abstraction for monitoring and retrieving +// the results of a long-running operation. +type CassandraResourcesMigrateCassandraKeyspaceToAutoscaleFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(CassandraResourcesClient) (ThroughputSettingsGetResults, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *CassandraResourcesMigrateCassandraKeyspaceToAutoscaleFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for CassandraResourcesMigrateCassandraKeyspaceToAutoscaleFuture.Result. +func (future *CassandraResourcesMigrateCassandraKeyspaceToAutoscaleFuture) result(client CassandraResourcesClient) (tsgr ThroughputSettingsGetResults, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesMigrateCassandraKeyspaceToAutoscaleFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + tsgr.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("documentdb.CassandraResourcesMigrateCassandraKeyspaceToAutoscaleFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if tsgr.Response.Response, err = future.GetResult(sender); err == nil && tsgr.Response.Response.StatusCode != http.StatusNoContent { + tsgr, err = client.MigrateCassandraKeyspaceToAutoscaleResponder(tsgr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesMigrateCassandraKeyspaceToAutoscaleFuture", "Result", tsgr.Response.Response, "Failure responding to request") + } + } + return +} + +// CassandraResourcesMigrateCassandraKeyspaceToManualThroughputFuture an abstraction for monitoring and +// retrieving the results of a long-running operation. +type CassandraResourcesMigrateCassandraKeyspaceToManualThroughputFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(CassandraResourcesClient) (ThroughputSettingsGetResults, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *CassandraResourcesMigrateCassandraKeyspaceToManualThroughputFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for CassandraResourcesMigrateCassandraKeyspaceToManualThroughputFuture.Result. +func (future *CassandraResourcesMigrateCassandraKeyspaceToManualThroughputFuture) result(client CassandraResourcesClient) (tsgr ThroughputSettingsGetResults, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesMigrateCassandraKeyspaceToManualThroughputFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + tsgr.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("documentdb.CassandraResourcesMigrateCassandraKeyspaceToManualThroughputFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if tsgr.Response.Response, err = future.GetResult(sender); err == nil && tsgr.Response.Response.StatusCode != http.StatusNoContent { + tsgr, err = client.MigrateCassandraKeyspaceToManualThroughputResponder(tsgr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesMigrateCassandraKeyspaceToManualThroughputFuture", "Result", tsgr.Response.Response, "Failure responding to request") + } + } + return +} + +// CassandraResourcesMigrateCassandraTableToAutoscaleFuture an abstraction for monitoring and retrieving +// the results of a long-running operation. +type CassandraResourcesMigrateCassandraTableToAutoscaleFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(CassandraResourcesClient) (ThroughputSettingsGetResults, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *CassandraResourcesMigrateCassandraTableToAutoscaleFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for CassandraResourcesMigrateCassandraTableToAutoscaleFuture.Result. +func (future *CassandraResourcesMigrateCassandraTableToAutoscaleFuture) result(client CassandraResourcesClient) (tsgr ThroughputSettingsGetResults, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesMigrateCassandraTableToAutoscaleFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + tsgr.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("documentdb.CassandraResourcesMigrateCassandraTableToAutoscaleFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if tsgr.Response.Response, err = future.GetResult(sender); err == nil && tsgr.Response.Response.StatusCode != http.StatusNoContent { + tsgr, err = client.MigrateCassandraTableToAutoscaleResponder(tsgr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesMigrateCassandraTableToAutoscaleFuture", "Result", tsgr.Response.Response, "Failure responding to request") + } + } + return +} + +// CassandraResourcesMigrateCassandraTableToManualThroughputFuture an abstraction for monitoring and +// retrieving the results of a long-running operation. +type CassandraResourcesMigrateCassandraTableToManualThroughputFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(CassandraResourcesClient) (ThroughputSettingsGetResults, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *CassandraResourcesMigrateCassandraTableToManualThroughputFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for CassandraResourcesMigrateCassandraTableToManualThroughputFuture.Result. +func (future *CassandraResourcesMigrateCassandraTableToManualThroughputFuture) result(client CassandraResourcesClient) (tsgr ThroughputSettingsGetResults, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesMigrateCassandraTableToManualThroughputFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + tsgr.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("documentdb.CassandraResourcesMigrateCassandraTableToManualThroughputFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if tsgr.Response.Response, err = future.GetResult(sender); err == nil && tsgr.Response.Response.StatusCode != http.StatusNoContent { + tsgr, err = client.MigrateCassandraTableToManualThroughputResponder(tsgr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesMigrateCassandraTableToManualThroughputFuture", "Result", tsgr.Response.Response, "Failure responding to request") + } + } + return +} + +// CassandraResourcesUpdateCassandraKeyspaceThroughputFuture an abstraction for monitoring and retrieving +// the results of a long-running operation. +type CassandraResourcesUpdateCassandraKeyspaceThroughputFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(CassandraResourcesClient) (ThroughputSettingsGetResults, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *CassandraResourcesUpdateCassandraKeyspaceThroughputFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for CassandraResourcesUpdateCassandraKeyspaceThroughputFuture.Result. +func (future *CassandraResourcesUpdateCassandraKeyspaceThroughputFuture) result(client CassandraResourcesClient) (tsgr ThroughputSettingsGetResults, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesUpdateCassandraKeyspaceThroughputFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + tsgr.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("documentdb.CassandraResourcesUpdateCassandraKeyspaceThroughputFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if tsgr.Response.Response, err = future.GetResult(sender); err == nil && tsgr.Response.Response.StatusCode != http.StatusNoContent { + tsgr, err = client.UpdateCassandraKeyspaceThroughputResponder(tsgr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesUpdateCassandraKeyspaceThroughputFuture", "Result", tsgr.Response.Response, "Failure responding to request") + } + } + return +} + +// CassandraResourcesUpdateCassandraTableThroughputFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type CassandraResourcesUpdateCassandraTableThroughputFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(CassandraResourcesClient) (ThroughputSettingsGetResults, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *CassandraResourcesUpdateCassandraTableThroughputFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for CassandraResourcesUpdateCassandraTableThroughputFuture.Result. +func (future *CassandraResourcesUpdateCassandraTableThroughputFuture) result(client CassandraResourcesClient) (tsgr ThroughputSettingsGetResults, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesUpdateCassandraTableThroughputFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + tsgr.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("documentdb.CassandraResourcesUpdateCassandraTableThroughputFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if tsgr.Response.Response, err = future.GetResult(sender); err == nil && tsgr.Response.Response.StatusCode != http.StatusNoContent { + tsgr, err = client.UpdateCassandraTableThroughputResponder(tsgr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesUpdateCassandraTableThroughputFuture", "Result", tsgr.Response.Response, "Failure responding to request") + } + } + return +} + +// CassandraSchema cosmos DB Cassandra table schema +type CassandraSchema struct { + // Columns - List of Cassandra table columns. + Columns *[]Column `json:"columns,omitempty"` + // PartitionKeys - List of partition key. + PartitionKeys *[]CassandraPartitionKey `json:"partitionKeys,omitempty"` + // ClusterKeys - List of cluster key. + ClusterKeys *[]ClusterKey `json:"clusterKeys,omitempty"` +} + +// CassandraTableCreateUpdateParameters parameters to create and update Cosmos DB Cassandra table. +type CassandraTableCreateUpdateParameters struct { + // CassandraTableCreateUpdateProperties - Properties to create and update Azure Cosmos DB Cassandra table. + *CassandraTableCreateUpdateProperties `json:"properties,omitempty"` + // ID - READ-ONLY; The unique resource identifier of the ARM resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the ARM resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of Azure resource. + Type *string `json:"type,omitempty"` + // Location - The location of the resource group to which the resource belongs. + Location *string `json:"location,omitempty"` + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for CassandraTableCreateUpdateParameters. +func (ctcup CassandraTableCreateUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ctcup.CassandraTableCreateUpdateProperties != nil { + objectMap["properties"] = ctcup.CassandraTableCreateUpdateProperties + } + if ctcup.Location != nil { + objectMap["location"] = ctcup.Location + } + if ctcup.Tags != nil { + objectMap["tags"] = ctcup.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for CassandraTableCreateUpdateParameters struct. +func (ctcup *CassandraTableCreateUpdateParameters) UnmarshalJSON(body []byte) error { + 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 cassandraTableCreateUpdateProperties CassandraTableCreateUpdateProperties + err = json.Unmarshal(*v, &cassandraTableCreateUpdateProperties) + if err != nil { + return err + } + ctcup.CassandraTableCreateUpdateProperties = &cassandraTableCreateUpdateProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + ctcup.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ctcup.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ctcup.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + ctcup.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + ctcup.Tags = tags + } + } + } + + return nil +} + +// CassandraTableCreateUpdateProperties properties to create and update Azure Cosmos DB Cassandra table. +type CassandraTableCreateUpdateProperties struct { + // Resource - The standard JSON format of a Cassandra table + Resource *CassandraTableResource `json:"resource,omitempty"` + // Options - A key-value pair of options to be applied for the request. This corresponds to the headers sent with the request. + Options *CreateUpdateOptions `json:"options,omitempty"` +} + +// CassandraTableGetProperties the properties of an Azure Cosmos DB Cassandra table +type CassandraTableGetProperties struct { + Resource *CassandraTableGetPropertiesResource `json:"resource,omitempty"` + Options *CassandraTableGetPropertiesOptions `json:"options,omitempty"` +} + +// CassandraTableGetPropertiesOptions ... +type CassandraTableGetPropertiesOptions struct { + // Throughput - Value of the Cosmos DB resource throughput or autoscaleSettings. Use the ThroughputSetting resource when retrieving offer details. + Throughput *int32 `json:"throughput,omitempty"` + // AutoscaleSettings - Specifies the Autoscale settings. + AutoscaleSettings *AutoscaleSettings `json:"autoscaleSettings,omitempty"` +} + +// CassandraTableGetPropertiesResource ... +type CassandraTableGetPropertiesResource struct { + // ID - Name of the Cosmos DB Cassandra table + ID *string `json:"id,omitempty"` + // DefaultTTL - Time to live of the Cosmos DB Cassandra table + DefaultTTL *int32 `json:"defaultTtl,omitempty"` + // Schema - Schema of the Cosmos DB Cassandra table + Schema *CassandraSchema `json:"schema,omitempty"` + // AnalyticalStorageTTL - Analytical TTL. + AnalyticalStorageTTL *int32 `json:"analyticalStorageTtl,omitempty"` + // Rid - READ-ONLY; A system generated property. A unique identifier. + Rid *string `json:"_rid,omitempty"` + // Ts - READ-ONLY; A system generated property that denotes the last updated timestamp of the resource. + Ts *float64 `json:"_ts,omitempty"` + // Etag - READ-ONLY; A system generated property representing the resource etag required for optimistic concurrency control. + Etag *string `json:"_etag,omitempty"` +} + +// MarshalJSON is the custom marshaler for CassandraTableGetPropertiesResource. +func (ctgp CassandraTableGetPropertiesResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ctgp.ID != nil { + objectMap["id"] = ctgp.ID + } + if ctgp.DefaultTTL != nil { + objectMap["defaultTtl"] = ctgp.DefaultTTL + } + if ctgp.Schema != nil { + objectMap["schema"] = ctgp.Schema + } + if ctgp.AnalyticalStorageTTL != nil { + objectMap["analyticalStorageTtl"] = ctgp.AnalyticalStorageTTL + } + return json.Marshal(objectMap) +} + +// CassandraTableGetResults an Azure Cosmos DB Cassandra table. +type CassandraTableGetResults struct { + autorest.Response `json:"-"` + // CassandraTableGetProperties - The properties of an Azure Cosmos DB Cassandra table + *CassandraTableGetProperties `json:"properties,omitempty"` + // ID - READ-ONLY; The unique resource identifier of the ARM resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the ARM resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of Azure resource. + Type *string `json:"type,omitempty"` + // Location - The location of the resource group to which the resource belongs. + Location *string `json:"location,omitempty"` + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for CassandraTableGetResults. +func (ctgr CassandraTableGetResults) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ctgr.CassandraTableGetProperties != nil { + objectMap["properties"] = ctgr.CassandraTableGetProperties + } + if ctgr.Location != nil { + objectMap["location"] = ctgr.Location + } + if ctgr.Tags != nil { + objectMap["tags"] = ctgr.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for CassandraTableGetResults struct. +func (ctgr *CassandraTableGetResults) UnmarshalJSON(body []byte) error { + 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 cassandraTableGetProperties CassandraTableGetProperties + err = json.Unmarshal(*v, &cassandraTableGetProperties) + if err != nil { + return err + } + ctgr.CassandraTableGetProperties = &cassandraTableGetProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + ctgr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ctgr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ctgr.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + ctgr.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + ctgr.Tags = tags + } + } + } + + return nil +} + +// CassandraTableListResult the List operation response, that contains the Cassandra tables and their +// properties. +type CassandraTableListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; List of Cassandra tables and their properties. + Value *[]CassandraTableGetResults `json:"value,omitempty"` +} + +// MarshalJSON is the custom marshaler for CassandraTableListResult. +func (ctlr CassandraTableListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// CassandraTableResource cosmos DB Cassandra table resource object +type CassandraTableResource struct { + // ID - Name of the Cosmos DB Cassandra table + ID *string `json:"id,omitempty"` + // DefaultTTL - Time to live of the Cosmos DB Cassandra table + DefaultTTL *int32 `json:"defaultTtl,omitempty"` + // Schema - Schema of the Cosmos DB Cassandra table + Schema *CassandraSchema `json:"schema,omitempty"` + // AnalyticalStorageTTL - Analytical TTL. + AnalyticalStorageTTL *int32 `json:"analyticalStorageTtl,omitempty"` +} + +// CloudError an error response from the service. +type CloudError struct { + Error *ErrorResponse `json:"error,omitempty"` +} + +// ClusterKey cosmos DB Cassandra table cluster key +type ClusterKey struct { + // Name - Name of the Cosmos DB Cassandra table cluster key + Name *string `json:"name,omitempty"` + // OrderBy - Order of the Cosmos DB Cassandra table cluster key, only support "Asc" and "Desc" + OrderBy *string `json:"orderBy,omitempty"` +} + +// Column cosmos DB Cassandra table column +type Column struct { + // Name - Name of the Cosmos DB Cassandra table column + Name *string `json:"name,omitempty"` + // Type - Type of the Cosmos DB Cassandra table column + Type *string `json:"type,omitempty"` +} + +// CompositePath ... +type CompositePath struct { + // Path - The path for which the indexing behavior applies to. Index paths typically start with root and end with wildcard (/path/*) + Path *string `json:"path,omitempty"` + // Order - Sort order for composite paths. Possible values include: 'CompositePathSortOrderAscending', 'CompositePathSortOrderDescending' + Order CompositePathSortOrder `json:"order,omitempty"` +} + +// ConflictResolutionPolicy the conflict resolution policy for the container. +type ConflictResolutionPolicy struct { + // Mode - Indicates the conflict resolution mode. Possible values include: 'ConflictResolutionModeLastWriterWins', 'ConflictResolutionModeCustom' + Mode ConflictResolutionMode `json:"mode,omitempty"` + // ConflictResolutionPath - The conflict resolution path in the case of LastWriterWins mode. + ConflictResolutionPath *string `json:"conflictResolutionPath,omitempty"` + // ConflictResolutionProcedure - The procedure to resolve conflicts in the case of custom mode. + ConflictResolutionProcedure *string `json:"conflictResolutionProcedure,omitempty"` +} + +// ConsistencyPolicy the consistency policy for the Cosmos DB database account. +type ConsistencyPolicy struct { + // DefaultConsistencyLevel - The default consistency level and configuration settings of the Cosmos DB account. Possible values include: 'DefaultConsistencyLevelEventual', 'DefaultConsistencyLevelSession', 'DefaultConsistencyLevelBoundedStaleness', 'DefaultConsistencyLevelStrong', 'DefaultConsistencyLevelConsistentPrefix' + DefaultConsistencyLevel DefaultConsistencyLevel `json:"defaultConsistencyLevel,omitempty"` + // MaxStalenessPrefix - When used with the Bounded Staleness consistency level, this value represents the number of stale requests tolerated. Accepted range for this value is 1 – 2,147,483,647. Required when defaultConsistencyPolicy is set to 'BoundedStaleness'. + MaxStalenessPrefix *int64 `json:"maxStalenessPrefix,omitempty"` + // MaxIntervalInSeconds - When used with the Bounded Staleness consistency level, this value represents the time amount of staleness (in seconds) tolerated. Accepted range for this value is 5 - 86400. Required when defaultConsistencyPolicy is set to 'BoundedStaleness'. + MaxIntervalInSeconds *int32 `json:"maxIntervalInSeconds,omitempty"` +} + +// ContainerPartitionKey the configuration of the partition key to be used for partitioning data into +// multiple partitions +type ContainerPartitionKey struct { + // Paths - List of paths using which data within the container can be partitioned + Paths *[]string `json:"paths,omitempty"` + // Kind - Indicates the kind of algorithm used for partitioning. For MultiHash, multiple partition keys (upto three maximum) are supported for container create. Possible values include: 'PartitionKindHash', 'PartitionKindRange', 'PartitionKindMultiHash' + Kind PartitionKind `json:"kind,omitempty"` + // Version - Indicates the version of the partition key definition + Version *int32 `json:"version,omitempty"` + // SystemKey - READ-ONLY; Indicates if the container is using a system generated partition key + SystemKey *bool `json:"systemKey,omitempty"` +} + +// MarshalJSON is the custom marshaler for ContainerPartitionKey. +func (cpk ContainerPartitionKey) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if cpk.Paths != nil { + objectMap["paths"] = cpk.Paths + } + if cpk.Kind != "" { + objectMap["kind"] = cpk.Kind + } + if cpk.Version != nil { + objectMap["version"] = cpk.Version + } + return json.Marshal(objectMap) +} + +// ContinuousBackupInformation information about the status of continuous backups. +type ContinuousBackupInformation struct { + // LatestRestorableTimestamp - The latest restorable timestamp for a resource. + LatestRestorableTimestamp *string `json:"latestRestorableTimestamp,omitempty"` +} + +// ContinuousBackupRestoreLocation properties of the regional restorable account. +type ContinuousBackupRestoreLocation struct { + // Location - The name of the continuous backup restore location. + Location *string `json:"location,omitempty"` +} + +// ContinuousModeBackupPolicy the object representing continuous mode backup policy. +type ContinuousModeBackupPolicy struct { + // MigrationState - The object representing the state of the migration between the backup policies. + MigrationState *BackupPolicyMigrationState `json:"migrationState,omitempty"` + // Type - Possible values include: 'TypeBackupPolicy', 'TypePeriodic', 'TypeContinuous' + Type Type `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ContinuousModeBackupPolicy. +func (cmbp ContinuousModeBackupPolicy) MarshalJSON() ([]byte, error) { + cmbp.Type = TypeContinuous + objectMap := make(map[string]interface{}) + if cmbp.MigrationState != nil { + objectMap["migrationState"] = cmbp.MigrationState + } + if cmbp.Type != "" { + objectMap["type"] = cmbp.Type + } + return json.Marshal(objectMap) +} + +// AsPeriodicModeBackupPolicy is the BasicBackupPolicy implementation for ContinuousModeBackupPolicy. +func (cmbp ContinuousModeBackupPolicy) AsPeriodicModeBackupPolicy() (*PeriodicModeBackupPolicy, bool) { + return nil, false +} + +// AsContinuousModeBackupPolicy is the BasicBackupPolicy implementation for ContinuousModeBackupPolicy. +func (cmbp ContinuousModeBackupPolicy) AsContinuousModeBackupPolicy() (*ContinuousModeBackupPolicy, bool) { + return &cmbp, true +} + +// AsBackupPolicy is the BasicBackupPolicy implementation for ContinuousModeBackupPolicy. +func (cmbp ContinuousModeBackupPolicy) AsBackupPolicy() (*BackupPolicy, bool) { + return nil, false +} + +// AsBasicBackupPolicy is the BasicBackupPolicy implementation for ContinuousModeBackupPolicy. +func (cmbp ContinuousModeBackupPolicy) AsBasicBackupPolicy() (BasicBackupPolicy, bool) { + return &cmbp, true +} + +// CorsPolicy the CORS policy for the Cosmos DB database account. +type CorsPolicy struct { + // AllowedOrigins - The origin domains that are permitted to make a request against the service via CORS. + AllowedOrigins *string `json:"allowedOrigins,omitempty"` + // AllowedMethods - The methods (HTTP request verbs) that the origin domain may use for a CORS request. + AllowedMethods *string `json:"allowedMethods,omitempty"` + // AllowedHeaders - The request headers that the origin domain may specify on the CORS request. + AllowedHeaders *string `json:"allowedHeaders,omitempty"` + // ExposedHeaders - The response headers that may be sent in the response to the CORS request and exposed by the browser to the request issuer. + ExposedHeaders *string `json:"exposedHeaders,omitempty"` + // MaxAgeInSeconds - The maximum amount time that a browser should cache the preflight OPTIONS request. + MaxAgeInSeconds *int64 `json:"maxAgeInSeconds,omitempty"` +} + +// CreateUpdateOptions createUpdateOptions are a list of key-value pairs that describe the resource. +// Supported keys are "If-Match", "If-None-Match", "Session-Token" and "Throughput" +type CreateUpdateOptions struct { + // Throughput - Request Units per second. For example, "throughput": 10000. + Throughput *int32 `json:"throughput,omitempty"` + // AutoscaleSettings - Specifies the Autoscale settings. + AutoscaleSettings *AutoscaleSettings `json:"autoscaleSettings,omitempty"` +} + +// DatabaseAccountConnectionString connection string for the Cosmos DB account +type DatabaseAccountConnectionString struct { + // ConnectionString - READ-ONLY; Value of the connection string + ConnectionString *string `json:"connectionString,omitempty"` + // Description - READ-ONLY; Description of the connection string + Description *string `json:"description,omitempty"` +} + +// MarshalJSON is the custom marshaler for DatabaseAccountConnectionString. +func (dacs DatabaseAccountConnectionString) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// DatabaseAccountCreateUpdateParameters parameters to create and update Cosmos DB database accounts. +type DatabaseAccountCreateUpdateParameters struct { + // Kind - Indicates the type of database account. This can only be set at database account creation. Possible values include: 'DatabaseAccountKindGlobalDocumentDB', 'DatabaseAccountKindMongoDB', 'DatabaseAccountKindParse' + Kind DatabaseAccountKind `json:"kind,omitempty"` + Identity *ManagedServiceIdentity `json:"identity,omitempty"` + *DatabaseAccountCreateUpdateProperties `json:"properties,omitempty"` + // ID - READ-ONLY; The unique resource identifier of the ARM resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the ARM resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of Azure resource. + Type *string `json:"type,omitempty"` + // Location - The location of the resource group to which the resource belongs. + Location *string `json:"location,omitempty"` + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for DatabaseAccountCreateUpdateParameters. +func (dacup DatabaseAccountCreateUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dacup.Kind != "" { + objectMap["kind"] = dacup.Kind + } + if dacup.Identity != nil { + objectMap["identity"] = dacup.Identity + } + if dacup.DatabaseAccountCreateUpdateProperties != nil { + objectMap["properties"] = dacup.DatabaseAccountCreateUpdateProperties + } + if dacup.Location != nil { + objectMap["location"] = dacup.Location + } + if dacup.Tags != nil { + objectMap["tags"] = dacup.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for DatabaseAccountCreateUpdateParameters struct. +func (dacup *DatabaseAccountCreateUpdateParameters) UnmarshalJSON(body []byte) error { + 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 DatabaseAccountKind + err = json.Unmarshal(*v, &kind) + if err != nil { + return err + } + dacup.Kind = kind + } + case "identity": + if v != nil { + var identity ManagedServiceIdentity + err = json.Unmarshal(*v, &identity) + if err != nil { + return err + } + dacup.Identity = &identity + } + case "properties": + if v != nil { + var databaseAccountCreateUpdateProperties DatabaseAccountCreateUpdateProperties + err = json.Unmarshal(*v, &databaseAccountCreateUpdateProperties) + if err != nil { + return err + } + dacup.DatabaseAccountCreateUpdateProperties = &databaseAccountCreateUpdateProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + dacup.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + dacup.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + dacup.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + dacup.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + dacup.Tags = tags + } + } + } + + return nil +} + +// DatabaseAccountCreateUpdateProperties properties to create and update Azure Cosmos DB database accounts. +type DatabaseAccountCreateUpdateProperties struct { + // ConsistencyPolicy - The consistency policy for the Cosmos DB account. + ConsistencyPolicy *ConsistencyPolicy `json:"consistencyPolicy,omitempty"` + // Locations - An array that contains the georeplication locations enabled for the Cosmos DB account. + Locations *[]Location `json:"locations,omitempty"` + // DatabaseAccountOfferType - The offer type for the database + DatabaseAccountOfferType *string `json:"databaseAccountOfferType,omitempty"` + // IPRules - List of IpRules. + IPRules *[]IPAddressOrRange `json:"ipRules,omitempty"` + // IsVirtualNetworkFilterEnabled - Flag to indicate whether to enable/disable Virtual Network ACL rules. + IsVirtualNetworkFilterEnabled *bool `json:"isVirtualNetworkFilterEnabled,omitempty"` + // EnableAutomaticFailover - Enables automatic failover of the write region in the rare event that the region is unavailable due to an outage. Automatic failover will result in a new write region for the account and is chosen based on the failover priorities configured for the account. + EnableAutomaticFailover *bool `json:"enableAutomaticFailover,omitempty"` + // Capabilities - List of Cosmos DB capabilities for the account + Capabilities *[]Capability `json:"capabilities,omitempty"` + // VirtualNetworkRules - List of Virtual Network ACL rules configured for the Cosmos DB account. + VirtualNetworkRules *[]VirtualNetworkRule `json:"virtualNetworkRules,omitempty"` + // EnableMultipleWriteLocations - Enables the account to write in multiple locations + EnableMultipleWriteLocations *bool `json:"enableMultipleWriteLocations,omitempty"` + // EnableCassandraConnector - Enables the cassandra connector on the Cosmos DB C* account + EnableCassandraConnector *bool `json:"enableCassandraConnector,omitempty"` + // ConnectorOffer - The cassandra connector offer type for the Cosmos DB database C* account. Possible values include: 'ConnectorOfferSmall' + ConnectorOffer ConnectorOffer `json:"connectorOffer,omitempty"` + // DisableKeyBasedMetadataWriteAccess - Disable write operations on metadata resources (databases, containers, throughput) via account keys + DisableKeyBasedMetadataWriteAccess *bool `json:"disableKeyBasedMetadataWriteAccess,omitempty"` + // KeyVaultKeyURI - The URI of the key vault + KeyVaultKeyURI *string `json:"keyVaultKeyUri,omitempty"` + // DefaultIdentity - The default identity for accessing key vault used in features like customer managed keys. The default identity needs to be explicitly set by the users. It can be "FirstPartyIdentity", "SystemAssignedIdentity" and more. + DefaultIdentity *string `json:"defaultIdentity,omitempty"` + // PublicNetworkAccess - Whether requests from Public Network are allowed. Possible values include: 'PublicNetworkAccessEnabled', 'PublicNetworkAccessDisabled' + PublicNetworkAccess PublicNetworkAccess `json:"publicNetworkAccess,omitempty"` + // EnableFreeTier - Flag to indicate whether Free Tier is enabled. + EnableFreeTier *bool `json:"enableFreeTier,omitempty"` + // APIProperties - API specific properties. Currently, supported only for MongoDB API. + APIProperties *APIProperties `json:"apiProperties,omitempty"` + // EnableAnalyticalStorage - Flag to indicate whether to enable storage analytics. + EnableAnalyticalStorage *bool `json:"enableAnalyticalStorage,omitempty"` + // AnalyticalStorageConfiguration - Analytical storage specific properties. + AnalyticalStorageConfiguration *AnalyticalStorageConfiguration `json:"analyticalStorageConfiguration,omitempty"` + // CreateMode - Enum to indicate the mode of account creation. Possible values include: 'CreateModeDefault', 'CreateModeRestore' + CreateMode CreateMode `json:"createMode,omitempty"` + // BackupPolicy - The object representing the policy for taking backups on an account. + BackupPolicy BasicBackupPolicy `json:"backupPolicy,omitempty"` + // Cors - The CORS policy for the Cosmos DB database account. + Cors *[]CorsPolicy `json:"cors,omitempty"` + // NetworkACLBypass - Indicates what services are allowed to bypass firewall checks. Possible values include: 'NetworkACLBypassNone', 'NetworkACLBypassAzureServices' + NetworkACLBypass NetworkACLBypass `json:"networkAclBypass,omitempty"` + // NetworkACLBypassResourceIds - An array that contains the Resource Ids for Network Acl Bypass for the Cosmos DB account. + NetworkACLBypassResourceIds *[]string `json:"networkAclBypassResourceIds,omitempty"` + // DisableLocalAuth - Opt-out of local authentication and ensure only MSI and AAD can be used exclusively for authentication. + DisableLocalAuth *bool `json:"disableLocalAuth,omitempty"` + // RestoreParameters - Parameters to indicate the information about the restore. + RestoreParameters *RestoreParameters `json:"restoreParameters,omitempty"` +} + +// UnmarshalJSON is the custom unmarshaler for DatabaseAccountCreateUpdateProperties struct. +func (dacup *DatabaseAccountCreateUpdateProperties) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "consistencyPolicy": + if v != nil { + var consistencyPolicy ConsistencyPolicy + err = json.Unmarshal(*v, &consistencyPolicy) + if err != nil { + return err + } + dacup.ConsistencyPolicy = &consistencyPolicy + } + case "locations": + if v != nil { + var locations []Location + err = json.Unmarshal(*v, &locations) + if err != nil { + return err + } + dacup.Locations = &locations + } + case "databaseAccountOfferType": + if v != nil { + var databaseAccountOfferType string + err = json.Unmarshal(*v, &databaseAccountOfferType) + if err != nil { + return err + } + dacup.DatabaseAccountOfferType = &databaseAccountOfferType + } + case "ipRules": + if v != nil { + var IPRules []IPAddressOrRange + err = json.Unmarshal(*v, &IPRules) + if err != nil { + return err + } + dacup.IPRules = &IPRules + } + case "isVirtualNetworkFilterEnabled": + if v != nil { + var isVirtualNetworkFilterEnabled bool + err = json.Unmarshal(*v, &isVirtualNetworkFilterEnabled) + if err != nil { + return err + } + dacup.IsVirtualNetworkFilterEnabled = &isVirtualNetworkFilterEnabled + } + case "enableAutomaticFailover": + if v != nil { + var enableAutomaticFailover bool + err = json.Unmarshal(*v, &enableAutomaticFailover) + if err != nil { + return err + } + dacup.EnableAutomaticFailover = &enableAutomaticFailover + } + case "capabilities": + if v != nil { + var capabilities []Capability + err = json.Unmarshal(*v, &capabilities) + if err != nil { + return err + } + dacup.Capabilities = &capabilities + } + case "virtualNetworkRules": + if v != nil { + var virtualNetworkRules []VirtualNetworkRule + err = json.Unmarshal(*v, &virtualNetworkRules) + if err != nil { + return err + } + dacup.VirtualNetworkRules = &virtualNetworkRules + } + case "enableMultipleWriteLocations": + if v != nil { + var enableMultipleWriteLocations bool + err = json.Unmarshal(*v, &enableMultipleWriteLocations) + if err != nil { + return err + } + dacup.EnableMultipleWriteLocations = &enableMultipleWriteLocations + } + case "enableCassandraConnector": + if v != nil { + var enableCassandraConnector bool + err = json.Unmarshal(*v, &enableCassandraConnector) + if err != nil { + return err + } + dacup.EnableCassandraConnector = &enableCassandraConnector + } + case "connectorOffer": + if v != nil { + var connectorOffer ConnectorOffer + err = json.Unmarshal(*v, &connectorOffer) + if err != nil { + return err + } + dacup.ConnectorOffer = connectorOffer + } + case "disableKeyBasedMetadataWriteAccess": + if v != nil { + var disableKeyBasedMetadataWriteAccess bool + err = json.Unmarshal(*v, &disableKeyBasedMetadataWriteAccess) + if err != nil { + return err + } + dacup.DisableKeyBasedMetadataWriteAccess = &disableKeyBasedMetadataWriteAccess + } + case "keyVaultKeyUri": + if v != nil { + var keyVaultKeyURI string + err = json.Unmarshal(*v, &keyVaultKeyURI) + if err != nil { + return err + } + dacup.KeyVaultKeyURI = &keyVaultKeyURI + } + case "defaultIdentity": + if v != nil { + var defaultIdentity string + err = json.Unmarshal(*v, &defaultIdentity) + if err != nil { + return err + } + dacup.DefaultIdentity = &defaultIdentity + } + case "publicNetworkAccess": + if v != nil { + var publicNetworkAccess PublicNetworkAccess + err = json.Unmarshal(*v, &publicNetworkAccess) + if err != nil { + return err + } + dacup.PublicNetworkAccess = publicNetworkAccess + } + case "enableFreeTier": + if v != nil { + var enableFreeTier bool + err = json.Unmarshal(*v, &enableFreeTier) + if err != nil { + return err + } + dacup.EnableFreeTier = &enableFreeTier + } + case "apiProperties": + if v != nil { + var APIProperties APIProperties + err = json.Unmarshal(*v, &APIProperties) + if err != nil { + return err + } + dacup.APIProperties = &APIProperties + } + case "enableAnalyticalStorage": + if v != nil { + var enableAnalyticalStorage bool + err = json.Unmarshal(*v, &enableAnalyticalStorage) + if err != nil { + return err + } + dacup.EnableAnalyticalStorage = &enableAnalyticalStorage + } + case "analyticalStorageConfiguration": + if v != nil { + var analyticalStorageConfiguration AnalyticalStorageConfiguration + err = json.Unmarshal(*v, &analyticalStorageConfiguration) + if err != nil { + return err + } + dacup.AnalyticalStorageConfiguration = &analyticalStorageConfiguration + } + case "createMode": + if v != nil { + var createMode CreateMode + err = json.Unmarshal(*v, &createMode) + if err != nil { + return err + } + dacup.CreateMode = createMode + } + case "backupPolicy": + if v != nil { + backupPolicy, err := unmarshalBasicBackupPolicy(*v) + if err != nil { + return err + } + dacup.BackupPolicy = backupPolicy + } + case "cors": + if v != nil { + var cors []CorsPolicy + err = json.Unmarshal(*v, &cors) + if err != nil { + return err + } + dacup.Cors = &cors + } + case "networkAclBypass": + if v != nil { + var networkACLBypass NetworkACLBypass + err = json.Unmarshal(*v, &networkACLBypass) + if err != nil { + return err + } + dacup.NetworkACLBypass = networkACLBypass + } + case "networkAclBypassResourceIds": + if v != nil { + var networkACLBypassResourceIds []string + err = json.Unmarshal(*v, &networkACLBypassResourceIds) + if err != nil { + return err + } + dacup.NetworkACLBypassResourceIds = &networkACLBypassResourceIds + } + case "disableLocalAuth": + if v != nil { + var disableLocalAuth bool + err = json.Unmarshal(*v, &disableLocalAuth) + if err != nil { + return err + } + dacup.DisableLocalAuth = &disableLocalAuth + } + case "restoreParameters": + if v != nil { + var restoreParameters RestoreParameters + err = json.Unmarshal(*v, &restoreParameters) + if err != nil { + return err + } + dacup.RestoreParameters = &restoreParameters + } + } + } + + return nil +} + +// DatabaseAccountGetProperties properties for the database account. +type DatabaseAccountGetProperties struct { + ProvisioningState *string `json:"provisioningState,omitempty"` + // DocumentEndpoint - READ-ONLY; The connection endpoint for the Cosmos DB database account. + DocumentEndpoint *string `json:"documentEndpoint,omitempty"` + // DatabaseAccountOfferType - READ-ONLY; The offer type for the Cosmos DB database account. Default value: Standard. Possible values include: 'DatabaseAccountOfferTypeStandard' + DatabaseAccountOfferType DatabaseAccountOfferType `json:"databaseAccountOfferType,omitempty"` + // IPRules - List of IpRules. + IPRules *[]IPAddressOrRange `json:"ipRules,omitempty"` + // IsVirtualNetworkFilterEnabled - Flag to indicate whether to enable/disable Virtual Network ACL rules. + IsVirtualNetworkFilterEnabled *bool `json:"isVirtualNetworkFilterEnabled,omitempty"` + // EnableAutomaticFailover - Enables automatic failover of the write region in the rare event that the region is unavailable due to an outage. Automatic failover will result in a new write region for the account and is chosen based on the failover priorities configured for the account. + EnableAutomaticFailover *bool `json:"enableAutomaticFailover,omitempty"` + // ConsistencyPolicy - The consistency policy for the Cosmos DB database account. + ConsistencyPolicy *ConsistencyPolicy `json:"consistencyPolicy,omitempty"` + // Capabilities - List of Cosmos DB capabilities for the account + Capabilities *[]Capability `json:"capabilities,omitempty"` + // WriteLocations - READ-ONLY; An array that contains the write location for the Cosmos DB account. + WriteLocations *[]Location `json:"writeLocations,omitempty"` + // ReadLocations - READ-ONLY; An array that contains of the read locations enabled for the Cosmos DB account. + ReadLocations *[]Location `json:"readLocations,omitempty"` + // Locations - READ-ONLY; An array that contains all of the locations enabled for the Cosmos DB account. + Locations *[]Location `json:"locations,omitempty"` + // FailoverPolicies - READ-ONLY; An array that contains the regions ordered by their failover priorities. + FailoverPolicies *[]FailoverPolicy `json:"failoverPolicies,omitempty"` + // VirtualNetworkRules - List of Virtual Network ACL rules configured for the Cosmos DB account. + VirtualNetworkRules *[]VirtualNetworkRule `json:"virtualNetworkRules,omitempty"` + // PrivateEndpointConnections - READ-ONLY; List of Private Endpoint Connections configured for the Cosmos DB account. + PrivateEndpointConnections *[]PrivateEndpointConnection `json:"privateEndpointConnections,omitempty"` + // EnableMultipleWriteLocations - Enables the account to write in multiple locations + EnableMultipleWriteLocations *bool `json:"enableMultipleWriteLocations,omitempty"` + // EnableCassandraConnector - Enables the cassandra connector on the Cosmos DB C* account + EnableCassandraConnector *bool `json:"enableCassandraConnector,omitempty"` + // ConnectorOffer - The cassandra connector offer type for the Cosmos DB database C* account. Possible values include: 'ConnectorOfferSmall' + ConnectorOffer ConnectorOffer `json:"connectorOffer,omitempty"` + // DisableKeyBasedMetadataWriteAccess - Disable write operations on metadata resources (databases, containers, throughput) via account keys + DisableKeyBasedMetadataWriteAccess *bool `json:"disableKeyBasedMetadataWriteAccess,omitempty"` + // KeyVaultKeyURI - The URI of the key vault + KeyVaultKeyURI *string `json:"keyVaultKeyUri,omitempty"` + // DefaultIdentity - The default identity for accessing key vault used in features like customer managed keys. The default identity needs to be explicitly set by the users. It can be "FirstPartyIdentity", "SystemAssignedIdentity" and more. + DefaultIdentity *string `json:"defaultIdentity,omitempty"` + // PublicNetworkAccess - Whether requests from Public Network are allowed. Possible values include: 'PublicNetworkAccessEnabled', 'PublicNetworkAccessDisabled' + PublicNetworkAccess PublicNetworkAccess `json:"publicNetworkAccess,omitempty"` + // EnableFreeTier - Flag to indicate whether Free Tier is enabled. + EnableFreeTier *bool `json:"enableFreeTier,omitempty"` + // APIProperties - API specific properties. + APIProperties *APIProperties `json:"apiProperties,omitempty"` + // EnableAnalyticalStorage - Flag to indicate whether to enable storage analytics. + EnableAnalyticalStorage *bool `json:"enableAnalyticalStorage,omitempty"` + // AnalyticalStorageConfiguration - Analytical storage specific properties. + AnalyticalStorageConfiguration *AnalyticalStorageConfiguration `json:"analyticalStorageConfiguration,omitempty"` + // InstanceID - READ-ONLY; A unique identifier assigned to the database account + InstanceID *string `json:"instanceId,omitempty"` + // CreateMode - Enum to indicate the mode of account creation. Possible values include: 'CreateModeDefault', 'CreateModeRestore' + CreateMode CreateMode `json:"createMode,omitempty"` + // RestoreParameters - Parameters to indicate the information about the restore. + RestoreParameters *RestoreParameters `json:"restoreParameters,omitempty"` + // BackupPolicy - The object representing the policy for taking backups on an account. + BackupPolicy BasicBackupPolicy `json:"backupPolicy,omitempty"` + // Cors - The CORS policy for the Cosmos DB database account. + Cors *[]CorsPolicy `json:"cors,omitempty"` + // NetworkACLBypass - Indicates what services are allowed to bypass firewall checks. Possible values include: 'NetworkACLBypassNone', 'NetworkACLBypassAzureServices' + NetworkACLBypass NetworkACLBypass `json:"networkAclBypass,omitempty"` + // NetworkACLBypassResourceIds - An array that contains the Resource Ids for Network Acl Bypass for the Cosmos DB account. + NetworkACLBypassResourceIds *[]string `json:"networkAclBypassResourceIds,omitempty"` + // DisableLocalAuth - Opt-out of local authentication and ensure only MSI and AAD can be used exclusively for authentication. + DisableLocalAuth *bool `json:"disableLocalAuth,omitempty"` +} + +// MarshalJSON is the custom marshaler for DatabaseAccountGetProperties. +func (dagp DatabaseAccountGetProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dagp.ProvisioningState != nil { + objectMap["provisioningState"] = dagp.ProvisioningState + } + if dagp.IPRules != nil { + objectMap["ipRules"] = dagp.IPRules + } + if dagp.IsVirtualNetworkFilterEnabled != nil { + objectMap["isVirtualNetworkFilterEnabled"] = dagp.IsVirtualNetworkFilterEnabled + } + if dagp.EnableAutomaticFailover != nil { + objectMap["enableAutomaticFailover"] = dagp.EnableAutomaticFailover + } + if dagp.ConsistencyPolicy != nil { + objectMap["consistencyPolicy"] = dagp.ConsistencyPolicy + } + if dagp.Capabilities != nil { + objectMap["capabilities"] = dagp.Capabilities + } + if dagp.VirtualNetworkRules != nil { + objectMap["virtualNetworkRules"] = dagp.VirtualNetworkRules + } + if dagp.EnableMultipleWriteLocations != nil { + objectMap["enableMultipleWriteLocations"] = dagp.EnableMultipleWriteLocations + } + if dagp.EnableCassandraConnector != nil { + objectMap["enableCassandraConnector"] = dagp.EnableCassandraConnector + } + if dagp.ConnectorOffer != "" { + objectMap["connectorOffer"] = dagp.ConnectorOffer + } + if dagp.DisableKeyBasedMetadataWriteAccess != nil { + objectMap["disableKeyBasedMetadataWriteAccess"] = dagp.DisableKeyBasedMetadataWriteAccess + } + if dagp.KeyVaultKeyURI != nil { + objectMap["keyVaultKeyUri"] = dagp.KeyVaultKeyURI + } + if dagp.DefaultIdentity != nil { + objectMap["defaultIdentity"] = dagp.DefaultIdentity + } + if dagp.PublicNetworkAccess != "" { + objectMap["publicNetworkAccess"] = dagp.PublicNetworkAccess + } + if dagp.EnableFreeTier != nil { + objectMap["enableFreeTier"] = dagp.EnableFreeTier + } + if dagp.APIProperties != nil { + objectMap["apiProperties"] = dagp.APIProperties + } + if dagp.EnableAnalyticalStorage != nil { + objectMap["enableAnalyticalStorage"] = dagp.EnableAnalyticalStorage + } + if dagp.AnalyticalStorageConfiguration != nil { + objectMap["analyticalStorageConfiguration"] = dagp.AnalyticalStorageConfiguration + } + if dagp.CreateMode != "" { + objectMap["createMode"] = dagp.CreateMode + } + if dagp.RestoreParameters != nil { + objectMap["restoreParameters"] = dagp.RestoreParameters + } + objectMap["backupPolicy"] = dagp.BackupPolicy + if dagp.Cors != nil { + objectMap["cors"] = dagp.Cors + } + if dagp.NetworkACLBypass != "" { + objectMap["networkAclBypass"] = dagp.NetworkACLBypass + } + if dagp.NetworkACLBypassResourceIds != nil { + objectMap["networkAclBypassResourceIds"] = dagp.NetworkACLBypassResourceIds + } + if dagp.DisableLocalAuth != nil { + objectMap["disableLocalAuth"] = dagp.DisableLocalAuth + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for DatabaseAccountGetProperties struct. +func (dagp *DatabaseAccountGetProperties) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "provisioningState": + if v != nil { + var provisioningState string + err = json.Unmarshal(*v, &provisioningState) + if err != nil { + return err + } + dagp.ProvisioningState = &provisioningState + } + case "documentEndpoint": + if v != nil { + var documentEndpoint string + err = json.Unmarshal(*v, &documentEndpoint) + if err != nil { + return err + } + dagp.DocumentEndpoint = &documentEndpoint + } + case "databaseAccountOfferType": + if v != nil { + var databaseAccountOfferType DatabaseAccountOfferType + err = json.Unmarshal(*v, &databaseAccountOfferType) + if err != nil { + return err + } + dagp.DatabaseAccountOfferType = databaseAccountOfferType + } + case "ipRules": + if v != nil { + var IPRules []IPAddressOrRange + err = json.Unmarshal(*v, &IPRules) + if err != nil { + return err + } + dagp.IPRules = &IPRules + } + case "isVirtualNetworkFilterEnabled": + if v != nil { + var isVirtualNetworkFilterEnabled bool + err = json.Unmarshal(*v, &isVirtualNetworkFilterEnabled) + if err != nil { + return err + } + dagp.IsVirtualNetworkFilterEnabled = &isVirtualNetworkFilterEnabled + } + case "enableAutomaticFailover": + if v != nil { + var enableAutomaticFailover bool + err = json.Unmarshal(*v, &enableAutomaticFailover) + if err != nil { + return err + } + dagp.EnableAutomaticFailover = &enableAutomaticFailover + } + case "consistencyPolicy": + if v != nil { + var consistencyPolicy ConsistencyPolicy + err = json.Unmarshal(*v, &consistencyPolicy) + if err != nil { + return err + } + dagp.ConsistencyPolicy = &consistencyPolicy + } + case "capabilities": + if v != nil { + var capabilities []Capability + err = json.Unmarshal(*v, &capabilities) + if err != nil { + return err + } + dagp.Capabilities = &capabilities + } + case "writeLocations": + if v != nil { + var writeLocations []Location + err = json.Unmarshal(*v, &writeLocations) + if err != nil { + return err + } + dagp.WriteLocations = &writeLocations + } + case "readLocations": + if v != nil { + var readLocations []Location + err = json.Unmarshal(*v, &readLocations) + if err != nil { + return err + } + dagp.ReadLocations = &readLocations + } + case "locations": + if v != nil { + var locations []Location + err = json.Unmarshal(*v, &locations) + if err != nil { + return err + } + dagp.Locations = &locations + } + case "failoverPolicies": + if v != nil { + var failoverPolicies []FailoverPolicy + err = json.Unmarshal(*v, &failoverPolicies) + if err != nil { + return err + } + dagp.FailoverPolicies = &failoverPolicies + } + case "virtualNetworkRules": + if v != nil { + var virtualNetworkRules []VirtualNetworkRule + err = json.Unmarshal(*v, &virtualNetworkRules) + if err != nil { + return err + } + dagp.VirtualNetworkRules = &virtualNetworkRules + } + case "privateEndpointConnections": + if v != nil { + var privateEndpointConnections []PrivateEndpointConnection + err = json.Unmarshal(*v, &privateEndpointConnections) + if err != nil { + return err + } + dagp.PrivateEndpointConnections = &privateEndpointConnections + } + case "enableMultipleWriteLocations": + if v != nil { + var enableMultipleWriteLocations bool + err = json.Unmarshal(*v, &enableMultipleWriteLocations) + if err != nil { + return err + } + dagp.EnableMultipleWriteLocations = &enableMultipleWriteLocations + } + case "enableCassandraConnector": + if v != nil { + var enableCassandraConnector bool + err = json.Unmarshal(*v, &enableCassandraConnector) + if err != nil { + return err + } + dagp.EnableCassandraConnector = &enableCassandraConnector + } + case "connectorOffer": + if v != nil { + var connectorOffer ConnectorOffer + err = json.Unmarshal(*v, &connectorOffer) + if err != nil { + return err + } + dagp.ConnectorOffer = connectorOffer + } + case "disableKeyBasedMetadataWriteAccess": + if v != nil { + var disableKeyBasedMetadataWriteAccess bool + err = json.Unmarshal(*v, &disableKeyBasedMetadataWriteAccess) + if err != nil { + return err + } + dagp.DisableKeyBasedMetadataWriteAccess = &disableKeyBasedMetadataWriteAccess + } + case "keyVaultKeyUri": + if v != nil { + var keyVaultKeyURI string + err = json.Unmarshal(*v, &keyVaultKeyURI) + if err != nil { + return err + } + dagp.KeyVaultKeyURI = &keyVaultKeyURI + } + case "defaultIdentity": + if v != nil { + var defaultIdentity string + err = json.Unmarshal(*v, &defaultIdentity) + if err != nil { + return err + } + dagp.DefaultIdentity = &defaultIdentity + } + case "publicNetworkAccess": + if v != nil { + var publicNetworkAccess PublicNetworkAccess + err = json.Unmarshal(*v, &publicNetworkAccess) + if err != nil { + return err + } + dagp.PublicNetworkAccess = publicNetworkAccess + } + case "enableFreeTier": + if v != nil { + var enableFreeTier bool + err = json.Unmarshal(*v, &enableFreeTier) + if err != nil { + return err + } + dagp.EnableFreeTier = &enableFreeTier + } + case "apiProperties": + if v != nil { + var APIProperties APIProperties + err = json.Unmarshal(*v, &APIProperties) + if err != nil { + return err + } + dagp.APIProperties = &APIProperties + } + case "enableAnalyticalStorage": + if v != nil { + var enableAnalyticalStorage bool + err = json.Unmarshal(*v, &enableAnalyticalStorage) + if err != nil { + return err + } + dagp.EnableAnalyticalStorage = &enableAnalyticalStorage + } + case "analyticalStorageConfiguration": + if v != nil { + var analyticalStorageConfiguration AnalyticalStorageConfiguration + err = json.Unmarshal(*v, &analyticalStorageConfiguration) + if err != nil { + return err + } + dagp.AnalyticalStorageConfiguration = &analyticalStorageConfiguration + } + case "instanceId": + if v != nil { + var instanceID string + err = json.Unmarshal(*v, &instanceID) + if err != nil { + return err + } + dagp.InstanceID = &instanceID + } + case "createMode": + if v != nil { + var createMode CreateMode + err = json.Unmarshal(*v, &createMode) + if err != nil { + return err + } + dagp.CreateMode = createMode + } + case "restoreParameters": + if v != nil { + var restoreParameters RestoreParameters + err = json.Unmarshal(*v, &restoreParameters) + if err != nil { + return err + } + dagp.RestoreParameters = &restoreParameters + } + case "backupPolicy": + if v != nil { + backupPolicy, err := unmarshalBasicBackupPolicy(*v) + if err != nil { + return err + } + dagp.BackupPolicy = backupPolicy + } + case "cors": + if v != nil { + var cors []CorsPolicy + err = json.Unmarshal(*v, &cors) + if err != nil { + return err + } + dagp.Cors = &cors + } + case "networkAclBypass": + if v != nil { + var networkACLBypass NetworkACLBypass + err = json.Unmarshal(*v, &networkACLBypass) + if err != nil { + return err + } + dagp.NetworkACLBypass = networkACLBypass + } + case "networkAclBypassResourceIds": + if v != nil { + var networkACLBypassResourceIds []string + err = json.Unmarshal(*v, &networkACLBypassResourceIds) + if err != nil { + return err + } + dagp.NetworkACLBypassResourceIds = &networkACLBypassResourceIds + } + case "disableLocalAuth": + if v != nil { + var disableLocalAuth bool + err = json.Unmarshal(*v, &disableLocalAuth) + if err != nil { + return err + } + dagp.DisableLocalAuth = &disableLocalAuth + } + } + } + + return nil +} + +// DatabaseAccountGetResults an Azure Cosmos DB database account. +type DatabaseAccountGetResults struct { + autorest.Response `json:"-"` + // Kind - Indicates the type of database account. This can only be set at database account creation. Possible values include: 'DatabaseAccountKindGlobalDocumentDB', 'DatabaseAccountKindMongoDB', 'DatabaseAccountKindParse' + Kind DatabaseAccountKind `json:"kind,omitempty"` + Identity *ManagedServiceIdentity `json:"identity,omitempty"` + *DatabaseAccountGetProperties `json:"properties,omitempty"` + // SystemData - READ-ONLY; The system meta data relating to this resource. + SystemData *SystemData `json:"systemData,omitempty"` + // ID - READ-ONLY; The unique resource identifier of the ARM resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the ARM resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of Azure resource. + Type *string `json:"type,omitempty"` + // Location - The location of the resource group to which the resource belongs. + Location *string `json:"location,omitempty"` + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for DatabaseAccountGetResults. +func (dagr DatabaseAccountGetResults) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dagr.Kind != "" { + objectMap["kind"] = dagr.Kind + } + if dagr.Identity != nil { + objectMap["identity"] = dagr.Identity + } + if dagr.DatabaseAccountGetProperties != nil { + objectMap["properties"] = dagr.DatabaseAccountGetProperties + } + if dagr.Location != nil { + objectMap["location"] = dagr.Location + } + if dagr.Tags != nil { + objectMap["tags"] = dagr.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for DatabaseAccountGetResults struct. +func (dagr *DatabaseAccountGetResults) UnmarshalJSON(body []byte) error { + 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 DatabaseAccountKind + err = json.Unmarshal(*v, &kind) + if err != nil { + return err + } + dagr.Kind = kind + } + case "identity": + if v != nil { + var identity ManagedServiceIdentity + err = json.Unmarshal(*v, &identity) + if err != nil { + return err + } + dagr.Identity = &identity + } + case "properties": + if v != nil { + var databaseAccountGetProperties DatabaseAccountGetProperties + err = json.Unmarshal(*v, &databaseAccountGetProperties) + if err != nil { + return err + } + dagr.DatabaseAccountGetProperties = &databaseAccountGetProperties + } + case "systemData": + if v != nil { + var systemData SystemData + err = json.Unmarshal(*v, &systemData) + if err != nil { + return err + } + dagr.SystemData = &systemData + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + dagr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + dagr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + dagr.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + dagr.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + dagr.Tags = tags + } + } + } + + return nil +} + +// DatabaseAccountListConnectionStringsResult the connection strings for the given database account. +type DatabaseAccountListConnectionStringsResult struct { + autorest.Response `json:"-"` + // ConnectionStrings - An array that contains the connection strings for the Cosmos DB account. + ConnectionStrings *[]DatabaseAccountConnectionString `json:"connectionStrings,omitempty"` +} + +// DatabaseAccountListKeysResult the access keys for the given database account. +type DatabaseAccountListKeysResult struct { + autorest.Response `json:"-"` + // PrimaryMasterKey - READ-ONLY; Base 64 encoded value of the primary read-write key. + PrimaryMasterKey *string `json:"primaryMasterKey,omitempty"` + // SecondaryMasterKey - READ-ONLY; Base 64 encoded value of the secondary read-write key. + SecondaryMasterKey *string `json:"secondaryMasterKey,omitempty"` + // PrimaryReadonlyMasterKey - READ-ONLY; Base 64 encoded value of the primary read-only key. + PrimaryReadonlyMasterKey *string `json:"primaryReadonlyMasterKey,omitempty"` + // SecondaryReadonlyMasterKey - READ-ONLY; Base 64 encoded value of the secondary read-only key. + SecondaryReadonlyMasterKey *string `json:"secondaryReadonlyMasterKey,omitempty"` +} + +// MarshalJSON is the custom marshaler for DatabaseAccountListKeysResult. +func (dalkr DatabaseAccountListKeysResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// DatabaseAccountListReadOnlyKeysResult the read-only access keys for the given database account. +type DatabaseAccountListReadOnlyKeysResult struct { + autorest.Response `json:"-"` + // PrimaryReadonlyMasterKey - READ-ONLY; Base 64 encoded value of the primary read-only key. + PrimaryReadonlyMasterKey *string `json:"primaryReadonlyMasterKey,omitempty"` + // SecondaryReadonlyMasterKey - READ-ONLY; Base 64 encoded value of the secondary read-only key. + SecondaryReadonlyMasterKey *string `json:"secondaryReadonlyMasterKey,omitempty"` +} + +// MarshalJSON is the custom marshaler for DatabaseAccountListReadOnlyKeysResult. +func (dalrokr DatabaseAccountListReadOnlyKeysResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// DatabaseAccountRegenerateKeyParameters parameters to regenerate the keys within the database account. +type DatabaseAccountRegenerateKeyParameters struct { + // KeyKind - The access key to regenerate. Possible values include: 'KeyKindPrimary', 'KeyKindSecondary', 'KeyKindPrimaryReadonly', 'KeyKindSecondaryReadonly' + KeyKind KeyKind `json:"keyKind,omitempty"` +} + +// DatabaseAccountsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type DatabaseAccountsCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(DatabaseAccountsClient) (DatabaseAccountGetResults, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *DatabaseAccountsCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for DatabaseAccountsCreateOrUpdateFuture.Result. +func (future *DatabaseAccountsCreateOrUpdateFuture) result(client DatabaseAccountsClient) (dagr DatabaseAccountGetResults, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + dagr.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("documentdb.DatabaseAccountsCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if dagr.Response.Response, err = future.GetResult(sender); err == nil && dagr.Response.Response.StatusCode != http.StatusNoContent { + dagr, err = client.CreateOrUpdateResponder(dagr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsCreateOrUpdateFuture", "Result", dagr.Response.Response, "Failure responding to request") + } + } + return +} + +// DatabaseAccountsDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type DatabaseAccountsDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(DatabaseAccountsClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *DatabaseAccountsDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for DatabaseAccountsDeleteFuture.Result. +func (future *DatabaseAccountsDeleteFuture) result(client DatabaseAccountsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("documentdb.DatabaseAccountsDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// DatabaseAccountsFailoverPriorityChangeFuture an abstraction for monitoring and retrieving the results of +// a long-running operation. +type DatabaseAccountsFailoverPriorityChangeFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(DatabaseAccountsClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *DatabaseAccountsFailoverPriorityChangeFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for DatabaseAccountsFailoverPriorityChangeFuture.Result. +func (future *DatabaseAccountsFailoverPriorityChangeFuture) result(client DatabaseAccountsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsFailoverPriorityChangeFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("documentdb.DatabaseAccountsFailoverPriorityChangeFuture") + return + } + ar.Response = future.Response() + return +} + +// DatabaseAccountsListResult the List operation response, that contains the database accounts and their +// properties. +type DatabaseAccountsListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; List of database account and their properties. + Value *[]DatabaseAccountGetResults `json:"value,omitempty"` +} + +// MarshalJSON is the custom marshaler for DatabaseAccountsListResult. +func (dalr DatabaseAccountsListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// DatabaseAccountsOfflineRegionFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type DatabaseAccountsOfflineRegionFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(DatabaseAccountsClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *DatabaseAccountsOfflineRegionFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for DatabaseAccountsOfflineRegionFuture.Result. +func (future *DatabaseAccountsOfflineRegionFuture) result(client DatabaseAccountsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsOfflineRegionFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("documentdb.DatabaseAccountsOfflineRegionFuture") + return + } + ar.Response = future.Response() + return +} + +// DatabaseAccountsOnlineRegionFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type DatabaseAccountsOnlineRegionFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(DatabaseAccountsClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *DatabaseAccountsOnlineRegionFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for DatabaseAccountsOnlineRegionFuture.Result. +func (future *DatabaseAccountsOnlineRegionFuture) result(client DatabaseAccountsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsOnlineRegionFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("documentdb.DatabaseAccountsOnlineRegionFuture") + return + } + ar.Response = future.Response() + return +} + +// DatabaseAccountsRegenerateKeyFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type DatabaseAccountsRegenerateKeyFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(DatabaseAccountsClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *DatabaseAccountsRegenerateKeyFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for DatabaseAccountsRegenerateKeyFuture.Result. +func (future *DatabaseAccountsRegenerateKeyFuture) result(client DatabaseAccountsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsRegenerateKeyFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("documentdb.DatabaseAccountsRegenerateKeyFuture") + return + } + ar.Response = future.Response() + return +} + +// DatabaseAccountsUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type DatabaseAccountsUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(DatabaseAccountsClient) (DatabaseAccountGetResults, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *DatabaseAccountsUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for DatabaseAccountsUpdateFuture.Result. +func (future *DatabaseAccountsUpdateFuture) result(client DatabaseAccountsClient) (dagr DatabaseAccountGetResults, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + dagr.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("documentdb.DatabaseAccountsUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if dagr.Response.Response, err = future.GetResult(sender); err == nil && dagr.Response.Response.StatusCode != http.StatusNoContent { + dagr, err = client.UpdateResponder(dagr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsUpdateFuture", "Result", dagr.Response.Response, "Failure responding to request") + } + } + return +} + +// DatabaseAccountUpdateParameters parameters for patching Azure Cosmos DB database account properties. +type DatabaseAccountUpdateParameters struct { + Tags map[string]*string `json:"tags"` + // Location - The location of the resource group to which the resource belongs. + Location *string `json:"location,omitempty"` + Identity *ManagedServiceIdentity `json:"identity,omitempty"` + *DatabaseAccountUpdateProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for DatabaseAccountUpdateParameters. +func (daup DatabaseAccountUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if daup.Tags != nil { + objectMap["tags"] = daup.Tags + } + if daup.Location != nil { + objectMap["location"] = daup.Location + } + if daup.Identity != nil { + objectMap["identity"] = daup.Identity + } + if daup.DatabaseAccountUpdateProperties != nil { + objectMap["properties"] = daup.DatabaseAccountUpdateProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for DatabaseAccountUpdateParameters struct. +func (daup *DatabaseAccountUpdateParameters) UnmarshalJSON(body []byte) error { + 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 + } + daup.Tags = tags + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + daup.Location = &location + } + case "identity": + if v != nil { + var identity ManagedServiceIdentity + err = json.Unmarshal(*v, &identity) + if err != nil { + return err + } + daup.Identity = &identity + } + case "properties": + if v != nil { + var databaseAccountUpdateProperties DatabaseAccountUpdateProperties + err = json.Unmarshal(*v, &databaseAccountUpdateProperties) + if err != nil { + return err + } + daup.DatabaseAccountUpdateProperties = &databaseAccountUpdateProperties + } + } + } + + return nil +} + +// DatabaseAccountUpdateProperties properties to update Azure Cosmos DB database accounts. +type DatabaseAccountUpdateProperties struct { + // ConsistencyPolicy - The consistency policy for the Cosmos DB account. + ConsistencyPolicy *ConsistencyPolicy `json:"consistencyPolicy,omitempty"` + // Locations - An array that contains the georeplication locations enabled for the Cosmos DB account. + Locations *[]Location `json:"locations,omitempty"` + // IPRules - List of IpRules. + IPRules *[]IPAddressOrRange `json:"ipRules,omitempty"` + // IsVirtualNetworkFilterEnabled - Flag to indicate whether to enable/disable Virtual Network ACL rules. + IsVirtualNetworkFilterEnabled *bool `json:"isVirtualNetworkFilterEnabled,omitempty"` + // EnableAutomaticFailover - Enables automatic failover of the write region in the rare event that the region is unavailable due to an outage. Automatic failover will result in a new write region for the account and is chosen based on the failover priorities configured for the account. + EnableAutomaticFailover *bool `json:"enableAutomaticFailover,omitempty"` + // Capabilities - List of Cosmos DB capabilities for the account + Capabilities *[]Capability `json:"capabilities,omitempty"` + // VirtualNetworkRules - List of Virtual Network ACL rules configured for the Cosmos DB account. + VirtualNetworkRules *[]VirtualNetworkRule `json:"virtualNetworkRules,omitempty"` + // EnableMultipleWriteLocations - Enables the account to write in multiple locations + EnableMultipleWriteLocations *bool `json:"enableMultipleWriteLocations,omitempty"` + // EnableCassandraConnector - Enables the cassandra connector on the Cosmos DB C* account + EnableCassandraConnector *bool `json:"enableCassandraConnector,omitempty"` + // ConnectorOffer - The cassandra connector offer type for the Cosmos DB database C* account. Possible values include: 'ConnectorOfferSmall' + ConnectorOffer ConnectorOffer `json:"connectorOffer,omitempty"` + // DisableKeyBasedMetadataWriteAccess - Disable write operations on metadata resources (databases, containers, throughput) via account keys + DisableKeyBasedMetadataWriteAccess *bool `json:"disableKeyBasedMetadataWriteAccess,omitempty"` + // KeyVaultKeyURI - The URI of the key vault + KeyVaultKeyURI *string `json:"keyVaultKeyUri,omitempty"` + // DefaultIdentity - The default identity for accessing key vault used in features like customer managed keys. The default identity needs to be explicitly set by the users. It can be "FirstPartyIdentity", "SystemAssignedIdentity" and more. + DefaultIdentity *string `json:"defaultIdentity,omitempty"` + // PublicNetworkAccess - Whether requests from Public Network are allowed. Possible values include: 'PublicNetworkAccessEnabled', 'PublicNetworkAccessDisabled' + PublicNetworkAccess PublicNetworkAccess `json:"publicNetworkAccess,omitempty"` + // EnableFreeTier - Flag to indicate whether Free Tier is enabled. + EnableFreeTier *bool `json:"enableFreeTier,omitempty"` + // APIProperties - API specific properties. Currently, supported only for MongoDB API. + APIProperties *APIProperties `json:"apiProperties,omitempty"` + // EnableAnalyticalStorage - Flag to indicate whether to enable storage analytics. + EnableAnalyticalStorage *bool `json:"enableAnalyticalStorage,omitempty"` + // AnalyticalStorageConfiguration - Analytical storage specific properties. + AnalyticalStorageConfiguration *AnalyticalStorageConfiguration `json:"analyticalStorageConfiguration,omitempty"` + // BackupPolicy - The object representing the policy for taking backups on an account. + BackupPolicy BasicBackupPolicy `json:"backupPolicy,omitempty"` + // Cors - The CORS policy for the Cosmos DB database account. + Cors *[]CorsPolicy `json:"cors,omitempty"` + // NetworkACLBypass - Indicates what services are allowed to bypass firewall checks. Possible values include: 'NetworkACLBypassNone', 'NetworkACLBypassAzureServices' + NetworkACLBypass NetworkACLBypass `json:"networkAclBypass,omitempty"` + // NetworkACLBypassResourceIds - An array that contains the Resource Ids for Network Acl Bypass for the Cosmos DB account. + NetworkACLBypassResourceIds *[]string `json:"networkAclBypassResourceIds,omitempty"` + // DisableLocalAuth - Opt-out of local authentication and ensure only MSI and AAD can be used exclusively for authentication. + DisableLocalAuth *bool `json:"disableLocalAuth,omitempty"` +} + +// UnmarshalJSON is the custom unmarshaler for DatabaseAccountUpdateProperties struct. +func (daup *DatabaseAccountUpdateProperties) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "consistencyPolicy": + if v != nil { + var consistencyPolicy ConsistencyPolicy + err = json.Unmarshal(*v, &consistencyPolicy) + if err != nil { + return err + } + daup.ConsistencyPolicy = &consistencyPolicy + } + case "locations": + if v != nil { + var locations []Location + err = json.Unmarshal(*v, &locations) + if err != nil { + return err + } + daup.Locations = &locations + } + case "ipRules": + if v != nil { + var IPRules []IPAddressOrRange + err = json.Unmarshal(*v, &IPRules) + if err != nil { + return err + } + daup.IPRules = &IPRules + } + case "isVirtualNetworkFilterEnabled": + if v != nil { + var isVirtualNetworkFilterEnabled bool + err = json.Unmarshal(*v, &isVirtualNetworkFilterEnabled) + if err != nil { + return err + } + daup.IsVirtualNetworkFilterEnabled = &isVirtualNetworkFilterEnabled + } + case "enableAutomaticFailover": + if v != nil { + var enableAutomaticFailover bool + err = json.Unmarshal(*v, &enableAutomaticFailover) + if err != nil { + return err + } + daup.EnableAutomaticFailover = &enableAutomaticFailover + } + case "capabilities": + if v != nil { + var capabilities []Capability + err = json.Unmarshal(*v, &capabilities) + if err != nil { + return err + } + daup.Capabilities = &capabilities + } + case "virtualNetworkRules": + if v != nil { + var virtualNetworkRules []VirtualNetworkRule + err = json.Unmarshal(*v, &virtualNetworkRules) + if err != nil { + return err + } + daup.VirtualNetworkRules = &virtualNetworkRules + } + case "enableMultipleWriteLocations": + if v != nil { + var enableMultipleWriteLocations bool + err = json.Unmarshal(*v, &enableMultipleWriteLocations) + if err != nil { + return err + } + daup.EnableMultipleWriteLocations = &enableMultipleWriteLocations + } + case "enableCassandraConnector": + if v != nil { + var enableCassandraConnector bool + err = json.Unmarshal(*v, &enableCassandraConnector) + if err != nil { + return err + } + daup.EnableCassandraConnector = &enableCassandraConnector + } + case "connectorOffer": + if v != nil { + var connectorOffer ConnectorOffer + err = json.Unmarshal(*v, &connectorOffer) + if err != nil { + return err + } + daup.ConnectorOffer = connectorOffer + } + case "disableKeyBasedMetadataWriteAccess": + if v != nil { + var disableKeyBasedMetadataWriteAccess bool + err = json.Unmarshal(*v, &disableKeyBasedMetadataWriteAccess) + if err != nil { + return err + } + daup.DisableKeyBasedMetadataWriteAccess = &disableKeyBasedMetadataWriteAccess + } + case "keyVaultKeyUri": + if v != nil { + var keyVaultKeyURI string + err = json.Unmarshal(*v, &keyVaultKeyURI) + if err != nil { + return err + } + daup.KeyVaultKeyURI = &keyVaultKeyURI + } + case "defaultIdentity": + if v != nil { + var defaultIdentity string + err = json.Unmarshal(*v, &defaultIdentity) + if err != nil { + return err + } + daup.DefaultIdentity = &defaultIdentity + } + case "publicNetworkAccess": + if v != nil { + var publicNetworkAccess PublicNetworkAccess + err = json.Unmarshal(*v, &publicNetworkAccess) + if err != nil { + return err + } + daup.PublicNetworkAccess = publicNetworkAccess + } + case "enableFreeTier": + if v != nil { + var enableFreeTier bool + err = json.Unmarshal(*v, &enableFreeTier) + if err != nil { + return err + } + daup.EnableFreeTier = &enableFreeTier + } + case "apiProperties": + if v != nil { + var APIProperties APIProperties + err = json.Unmarshal(*v, &APIProperties) + if err != nil { + return err + } + daup.APIProperties = &APIProperties + } + case "enableAnalyticalStorage": + if v != nil { + var enableAnalyticalStorage bool + err = json.Unmarshal(*v, &enableAnalyticalStorage) + if err != nil { + return err + } + daup.EnableAnalyticalStorage = &enableAnalyticalStorage + } + case "analyticalStorageConfiguration": + if v != nil { + var analyticalStorageConfiguration AnalyticalStorageConfiguration + err = json.Unmarshal(*v, &analyticalStorageConfiguration) + if err != nil { + return err + } + daup.AnalyticalStorageConfiguration = &analyticalStorageConfiguration + } + case "backupPolicy": + if v != nil { + backupPolicy, err := unmarshalBasicBackupPolicy(*v) + if err != nil { + return err + } + daup.BackupPolicy = backupPolicy + } + case "cors": + if v != nil { + var cors []CorsPolicy + err = json.Unmarshal(*v, &cors) + if err != nil { + return err + } + daup.Cors = &cors + } + case "networkAclBypass": + if v != nil { + var networkACLBypass NetworkACLBypass + err = json.Unmarshal(*v, &networkACLBypass) + if err != nil { + return err + } + daup.NetworkACLBypass = networkACLBypass + } + case "networkAclBypassResourceIds": + if v != nil { + var networkACLBypassResourceIds []string + err = json.Unmarshal(*v, &networkACLBypassResourceIds) + if err != nil { + return err + } + daup.NetworkACLBypassResourceIds = &networkACLBypassResourceIds + } + case "disableLocalAuth": + if v != nil { + var disableLocalAuth bool + err = json.Unmarshal(*v, &disableLocalAuth) + if err != nil { + return err + } + daup.DisableLocalAuth = &disableLocalAuth + } + } + } + + return nil +} + +// DatabaseRestoreResource specific Databases to restore. +type DatabaseRestoreResource struct { + // DatabaseName - The name of the database available for restore. + DatabaseName *string `json:"databaseName,omitempty"` + // CollectionNames - The names of the collections available for restore. + CollectionNames *[]string `json:"collectionNames,omitempty"` +} + +// ErrorResponse error Response. +type ErrorResponse struct { + // Code - Error code. + Code *string `json:"code,omitempty"` + // Message - Error message indicating why the operation failed. + Message *string `json:"message,omitempty"` +} + +// ExcludedPath ... +type ExcludedPath struct { + // Path - The path for which the indexing behavior applies to. Index paths typically start with root and end with wildcard (/path/*) + Path *string `json:"path,omitempty"` +} + +// ExtendedResourceProperties the system generated resource properties associated with SQL databases, SQL +// containers, Gremlin databases and Gremlin graphs. +type ExtendedResourceProperties struct { + // Rid - READ-ONLY; A system generated property. A unique identifier. + Rid *string `json:"_rid,omitempty"` + // Ts - READ-ONLY; A system generated property that denotes the last updated timestamp of the resource. + Ts *float64 `json:"_ts,omitempty"` + // Etag - READ-ONLY; A system generated property representing the resource etag required for optimistic concurrency control. + Etag *string `json:"_etag,omitempty"` +} + +// MarshalJSON is the custom marshaler for ExtendedResourceProperties. +func (erp ExtendedResourceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// FailoverPolicies the list of new failover policies for the failover priority change. +type FailoverPolicies struct { + // FailoverPolicies - List of failover policies. + FailoverPolicies *[]FailoverPolicy `json:"failoverPolicies,omitempty"` +} + +// FailoverPolicy the failover policy for a given region of a database account. +type FailoverPolicy struct { + // ID - READ-ONLY; The unique identifier of the region in which the database account replicates to. Example: <accountName>-<locationName>. + ID *string `json:"id,omitempty"` + // LocationName - The name of the region in which the database account exists. + LocationName *string `json:"locationName,omitempty"` + // FailoverPriority - The failover priority of the region. A failover priority of 0 indicates a write region. The maximum value for a failover priority = (total number of regions - 1). Failover priority values must be unique for each of the regions in which the database account exists. + FailoverPriority *int32 `json:"failoverPriority,omitempty"` +} + +// MarshalJSON is the custom marshaler for FailoverPolicy. +func (fp FailoverPolicy) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if fp.LocationName != nil { + objectMap["locationName"] = fp.LocationName + } + if fp.FailoverPriority != nil { + objectMap["failoverPriority"] = fp.FailoverPriority + } + return json.Marshal(objectMap) +} + +// GremlinDatabaseCreateUpdateParameters parameters to create and update Cosmos DB Gremlin database. +type GremlinDatabaseCreateUpdateParameters struct { + // GremlinDatabaseCreateUpdateProperties - Properties to create and update Azure Cosmos DB Gremlin database. + *GremlinDatabaseCreateUpdateProperties `json:"properties,omitempty"` + // ID - READ-ONLY; The unique resource identifier of the ARM resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the ARM resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of Azure resource. + Type *string `json:"type,omitempty"` + // Location - The location of the resource group to which the resource belongs. + Location *string `json:"location,omitempty"` + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for GremlinDatabaseCreateUpdateParameters. +func (gdcup GremlinDatabaseCreateUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if gdcup.GremlinDatabaseCreateUpdateProperties != nil { + objectMap["properties"] = gdcup.GremlinDatabaseCreateUpdateProperties + } + if gdcup.Location != nil { + objectMap["location"] = gdcup.Location + } + if gdcup.Tags != nil { + objectMap["tags"] = gdcup.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for GremlinDatabaseCreateUpdateParameters struct. +func (gdcup *GremlinDatabaseCreateUpdateParameters) UnmarshalJSON(body []byte) error { + 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 gremlinDatabaseCreateUpdateProperties GremlinDatabaseCreateUpdateProperties + err = json.Unmarshal(*v, &gremlinDatabaseCreateUpdateProperties) + if err != nil { + return err + } + gdcup.GremlinDatabaseCreateUpdateProperties = &gremlinDatabaseCreateUpdateProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + gdcup.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + gdcup.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + gdcup.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + gdcup.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + gdcup.Tags = tags + } + } + } + + return nil +} + +// GremlinDatabaseCreateUpdateProperties properties to create and update Azure Cosmos DB Gremlin database. +type GremlinDatabaseCreateUpdateProperties struct { + // Resource - The standard JSON format of a Gremlin database + Resource *GremlinDatabaseResource `json:"resource,omitempty"` + // Options - A key-value pair of options to be applied for the request. This corresponds to the headers sent with the request. + Options *CreateUpdateOptions `json:"options,omitempty"` +} + +// GremlinDatabaseGetProperties the properties of an Azure Cosmos DB SQL database +type GremlinDatabaseGetProperties struct { + Resource *GremlinDatabaseGetPropertiesResource `json:"resource,omitempty"` + Options *GremlinDatabaseGetPropertiesOptions `json:"options,omitempty"` +} + +// GremlinDatabaseGetPropertiesOptions ... +type GremlinDatabaseGetPropertiesOptions struct { + // Throughput - Value of the Cosmos DB resource throughput or autoscaleSettings. Use the ThroughputSetting resource when retrieving offer details. + Throughput *int32 `json:"throughput,omitempty"` + // AutoscaleSettings - Specifies the Autoscale settings. + AutoscaleSettings *AutoscaleSettings `json:"autoscaleSettings,omitempty"` +} + +// GremlinDatabaseGetPropertiesResource ... +type GremlinDatabaseGetPropertiesResource struct { + // ID - Name of the Cosmos DB Gremlin database + ID *string `json:"id,omitempty"` + // Rid - READ-ONLY; A system generated property. A unique identifier. + Rid *string `json:"_rid,omitempty"` + // Ts - READ-ONLY; A system generated property that denotes the last updated timestamp of the resource. + Ts *float64 `json:"_ts,omitempty"` + // Etag - READ-ONLY; A system generated property representing the resource etag required for optimistic concurrency control. + Etag *string `json:"_etag,omitempty"` +} + +// MarshalJSON is the custom marshaler for GremlinDatabaseGetPropertiesResource. +func (gdgp GremlinDatabaseGetPropertiesResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if gdgp.ID != nil { + objectMap["id"] = gdgp.ID + } + return json.Marshal(objectMap) +} + +// GremlinDatabaseGetResults an Azure Cosmos DB Gremlin database. +type GremlinDatabaseGetResults struct { + autorest.Response `json:"-"` + // GremlinDatabaseGetProperties - The properties of an Azure Cosmos DB SQL database + *GremlinDatabaseGetProperties `json:"properties,omitempty"` + // ID - READ-ONLY; The unique resource identifier of the ARM resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the ARM resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of Azure resource. + Type *string `json:"type,omitempty"` + // Location - The location of the resource group to which the resource belongs. + Location *string `json:"location,omitempty"` + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for GremlinDatabaseGetResults. +func (gdgr GremlinDatabaseGetResults) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if gdgr.GremlinDatabaseGetProperties != nil { + objectMap["properties"] = gdgr.GremlinDatabaseGetProperties + } + if gdgr.Location != nil { + objectMap["location"] = gdgr.Location + } + if gdgr.Tags != nil { + objectMap["tags"] = gdgr.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for GremlinDatabaseGetResults struct. +func (gdgr *GremlinDatabaseGetResults) UnmarshalJSON(body []byte) error { + 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 gremlinDatabaseGetProperties GremlinDatabaseGetProperties + err = json.Unmarshal(*v, &gremlinDatabaseGetProperties) + if err != nil { + return err + } + gdgr.GremlinDatabaseGetProperties = &gremlinDatabaseGetProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + gdgr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + gdgr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + gdgr.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + gdgr.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + gdgr.Tags = tags + } + } + } + + return nil +} + +// GremlinDatabaseListResult the List operation response, that contains the Gremlin databases and their +// properties. +type GremlinDatabaseListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; List of Gremlin databases and their properties. + Value *[]GremlinDatabaseGetResults `json:"value,omitempty"` +} + +// MarshalJSON is the custom marshaler for GremlinDatabaseListResult. +func (gdlr GremlinDatabaseListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// GremlinDatabaseResource cosmos DB Gremlin database resource object +type GremlinDatabaseResource struct { + // ID - Name of the Cosmos DB Gremlin database + ID *string `json:"id,omitempty"` +} + +// GremlinGraphCreateUpdateParameters parameters to create and update Cosmos DB Gremlin graph. +type GremlinGraphCreateUpdateParameters struct { + // GremlinGraphCreateUpdateProperties - Properties to create and update Azure Cosmos DB Gremlin graph. + *GremlinGraphCreateUpdateProperties `json:"properties,omitempty"` + // ID - READ-ONLY; The unique resource identifier of the ARM resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the ARM resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of Azure resource. + Type *string `json:"type,omitempty"` + // Location - The location of the resource group to which the resource belongs. + Location *string `json:"location,omitempty"` + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for GremlinGraphCreateUpdateParameters. +func (ggcup GremlinGraphCreateUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ggcup.GremlinGraphCreateUpdateProperties != nil { + objectMap["properties"] = ggcup.GremlinGraphCreateUpdateProperties + } + if ggcup.Location != nil { + objectMap["location"] = ggcup.Location + } + if ggcup.Tags != nil { + objectMap["tags"] = ggcup.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for GremlinGraphCreateUpdateParameters struct. +func (ggcup *GremlinGraphCreateUpdateParameters) UnmarshalJSON(body []byte) error { + 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 gremlinGraphCreateUpdateProperties GremlinGraphCreateUpdateProperties + err = json.Unmarshal(*v, &gremlinGraphCreateUpdateProperties) + if err != nil { + return err + } + ggcup.GremlinGraphCreateUpdateProperties = &gremlinGraphCreateUpdateProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + ggcup.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ggcup.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ggcup.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + ggcup.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + ggcup.Tags = tags + } + } + } + + return nil +} + +// GremlinGraphCreateUpdateProperties properties to create and update Azure Cosmos DB Gremlin graph. +type GremlinGraphCreateUpdateProperties struct { + // Resource - The standard JSON format of a Gremlin graph + Resource *GremlinGraphResource `json:"resource,omitempty"` + // Options - A key-value pair of options to be applied for the request. This corresponds to the headers sent with the request. + Options *CreateUpdateOptions `json:"options,omitempty"` +} + +// GremlinGraphGetProperties the properties of an Azure Cosmos DB Gremlin graph +type GremlinGraphGetProperties struct { + Resource *GremlinGraphGetPropertiesResource `json:"resource,omitempty"` + Options *GremlinGraphGetPropertiesOptions `json:"options,omitempty"` +} + +// GremlinGraphGetPropertiesOptions ... +type GremlinGraphGetPropertiesOptions struct { + // Throughput - Value of the Cosmos DB resource throughput or autoscaleSettings. Use the ThroughputSetting resource when retrieving offer details. + Throughput *int32 `json:"throughput,omitempty"` + // AutoscaleSettings - Specifies the Autoscale settings. + AutoscaleSettings *AutoscaleSettings `json:"autoscaleSettings,omitempty"` +} + +// GremlinGraphGetPropertiesResource ... +type GremlinGraphGetPropertiesResource struct { + // ID - Name of the Cosmos DB Gremlin graph + ID *string `json:"id,omitempty"` + // IndexingPolicy - The configuration of the indexing policy. By default, the indexing is automatic for all document paths within the graph + IndexingPolicy *IndexingPolicy `json:"indexingPolicy,omitempty"` + // PartitionKey - The configuration of the partition key to be used for partitioning data into multiple partitions + PartitionKey *ContainerPartitionKey `json:"partitionKey,omitempty"` + // DefaultTTL - Default time to live + DefaultTTL *int32 `json:"defaultTtl,omitempty"` + // UniqueKeyPolicy - The unique key policy configuration for specifying uniqueness constraints on documents in the collection in the Azure Cosmos DB service. + UniqueKeyPolicy *UniqueKeyPolicy `json:"uniqueKeyPolicy,omitempty"` + // ConflictResolutionPolicy - The conflict resolution policy for the graph. + ConflictResolutionPolicy *ConflictResolutionPolicy `json:"conflictResolutionPolicy,omitempty"` + // Rid - READ-ONLY; A system generated property. A unique identifier. + Rid *string `json:"_rid,omitempty"` + // Ts - READ-ONLY; A system generated property that denotes the last updated timestamp of the resource. + Ts *float64 `json:"_ts,omitempty"` + // Etag - READ-ONLY; A system generated property representing the resource etag required for optimistic concurrency control. + Etag *string `json:"_etag,omitempty"` +} + +// MarshalJSON is the custom marshaler for GremlinGraphGetPropertiesResource. +func (gggp GremlinGraphGetPropertiesResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if gggp.ID != nil { + objectMap["id"] = gggp.ID + } + if gggp.IndexingPolicy != nil { + objectMap["indexingPolicy"] = gggp.IndexingPolicy + } + if gggp.PartitionKey != nil { + objectMap["partitionKey"] = gggp.PartitionKey + } + if gggp.DefaultTTL != nil { + objectMap["defaultTtl"] = gggp.DefaultTTL + } + if gggp.UniqueKeyPolicy != nil { + objectMap["uniqueKeyPolicy"] = gggp.UniqueKeyPolicy + } + if gggp.ConflictResolutionPolicy != nil { + objectMap["conflictResolutionPolicy"] = gggp.ConflictResolutionPolicy + } + return json.Marshal(objectMap) +} + +// GremlinGraphGetResults an Azure Cosmos DB Gremlin graph. +type GremlinGraphGetResults struct { + autorest.Response `json:"-"` + // GremlinGraphGetProperties - The properties of an Azure Cosmos DB Gremlin graph + *GremlinGraphGetProperties `json:"properties,omitempty"` + // ID - READ-ONLY; The unique resource identifier of the ARM resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the ARM resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of Azure resource. + Type *string `json:"type,omitempty"` + // Location - The location of the resource group to which the resource belongs. + Location *string `json:"location,omitempty"` + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for GremlinGraphGetResults. +func (gggr GremlinGraphGetResults) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if gggr.GremlinGraphGetProperties != nil { + objectMap["properties"] = gggr.GremlinGraphGetProperties + } + if gggr.Location != nil { + objectMap["location"] = gggr.Location + } + if gggr.Tags != nil { + objectMap["tags"] = gggr.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for GremlinGraphGetResults struct. +func (gggr *GremlinGraphGetResults) UnmarshalJSON(body []byte) error { + 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 gremlinGraphGetProperties GremlinGraphGetProperties + err = json.Unmarshal(*v, &gremlinGraphGetProperties) + if err != nil { + return err + } + gggr.GremlinGraphGetProperties = &gremlinGraphGetProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + gggr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + gggr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + gggr.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + gggr.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + gggr.Tags = tags + } + } + } + + return nil +} + +// GremlinGraphListResult the List operation response, that contains the graphs and their properties. +type GremlinGraphListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; List of graphs and their properties. + Value *[]GremlinGraphGetResults `json:"value,omitempty"` +} + +// MarshalJSON is the custom marshaler for GremlinGraphListResult. +func (gglr GremlinGraphListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// GremlinGraphResource cosmos DB Gremlin graph resource object +type GremlinGraphResource struct { + // ID - Name of the Cosmos DB Gremlin graph + ID *string `json:"id,omitempty"` + // IndexingPolicy - The configuration of the indexing policy. By default, the indexing is automatic for all document paths within the graph + IndexingPolicy *IndexingPolicy `json:"indexingPolicy,omitempty"` + // PartitionKey - The configuration of the partition key to be used for partitioning data into multiple partitions + PartitionKey *ContainerPartitionKey `json:"partitionKey,omitempty"` + // DefaultTTL - Default time to live + DefaultTTL *int32 `json:"defaultTtl,omitempty"` + // UniqueKeyPolicy - The unique key policy configuration for specifying uniqueness constraints on documents in the collection in the Azure Cosmos DB service. + UniqueKeyPolicy *UniqueKeyPolicy `json:"uniqueKeyPolicy,omitempty"` + // ConflictResolutionPolicy - The conflict resolution policy for the graph. + ConflictResolutionPolicy *ConflictResolutionPolicy `json:"conflictResolutionPolicy,omitempty"` +} + +// GremlinResourcesCreateUpdateGremlinDatabaseFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type GremlinResourcesCreateUpdateGremlinDatabaseFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(GremlinResourcesClient) (GremlinDatabaseGetResults, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *GremlinResourcesCreateUpdateGremlinDatabaseFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for GremlinResourcesCreateUpdateGremlinDatabaseFuture.Result. +func (future *GremlinResourcesCreateUpdateGremlinDatabaseFuture) result(client GremlinResourcesClient) (gdgr GremlinDatabaseGetResults, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesCreateUpdateGremlinDatabaseFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + gdgr.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("documentdb.GremlinResourcesCreateUpdateGremlinDatabaseFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if gdgr.Response.Response, err = future.GetResult(sender); err == nil && gdgr.Response.Response.StatusCode != http.StatusNoContent { + gdgr, err = client.CreateUpdateGremlinDatabaseResponder(gdgr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesCreateUpdateGremlinDatabaseFuture", "Result", gdgr.Response.Response, "Failure responding to request") + } + } + return +} + +// GremlinResourcesCreateUpdateGremlinGraphFuture an abstraction for monitoring and retrieving the results +// of a long-running operation. +type GremlinResourcesCreateUpdateGremlinGraphFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(GremlinResourcesClient) (GremlinGraphGetResults, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *GremlinResourcesCreateUpdateGremlinGraphFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for GremlinResourcesCreateUpdateGremlinGraphFuture.Result. +func (future *GremlinResourcesCreateUpdateGremlinGraphFuture) result(client GremlinResourcesClient) (gggr GremlinGraphGetResults, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesCreateUpdateGremlinGraphFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + gggr.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("documentdb.GremlinResourcesCreateUpdateGremlinGraphFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if gggr.Response.Response, err = future.GetResult(sender); err == nil && gggr.Response.Response.StatusCode != http.StatusNoContent { + gggr, err = client.CreateUpdateGremlinGraphResponder(gggr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesCreateUpdateGremlinGraphFuture", "Result", gggr.Response.Response, "Failure responding to request") + } + } + return +} + +// GremlinResourcesDeleteGremlinDatabaseFuture an abstraction for monitoring and retrieving the results of +// a long-running operation. +type GremlinResourcesDeleteGremlinDatabaseFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(GremlinResourcesClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *GremlinResourcesDeleteGremlinDatabaseFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for GremlinResourcesDeleteGremlinDatabaseFuture.Result. +func (future *GremlinResourcesDeleteGremlinDatabaseFuture) result(client GremlinResourcesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesDeleteGremlinDatabaseFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("documentdb.GremlinResourcesDeleteGremlinDatabaseFuture") + return + } + ar.Response = future.Response() + return +} + +// GremlinResourcesDeleteGremlinGraphFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type GremlinResourcesDeleteGremlinGraphFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(GremlinResourcesClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *GremlinResourcesDeleteGremlinGraphFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for GremlinResourcesDeleteGremlinGraphFuture.Result. +func (future *GremlinResourcesDeleteGremlinGraphFuture) result(client GremlinResourcesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesDeleteGremlinGraphFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("documentdb.GremlinResourcesDeleteGremlinGraphFuture") + return + } + ar.Response = future.Response() + return +} + +// GremlinResourcesMigrateGremlinDatabaseToAutoscaleFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type GremlinResourcesMigrateGremlinDatabaseToAutoscaleFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(GremlinResourcesClient) (ThroughputSettingsGetResults, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *GremlinResourcesMigrateGremlinDatabaseToAutoscaleFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for GremlinResourcesMigrateGremlinDatabaseToAutoscaleFuture.Result. +func (future *GremlinResourcesMigrateGremlinDatabaseToAutoscaleFuture) result(client GremlinResourcesClient) (tsgr ThroughputSettingsGetResults, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesMigrateGremlinDatabaseToAutoscaleFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + tsgr.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("documentdb.GremlinResourcesMigrateGremlinDatabaseToAutoscaleFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if tsgr.Response.Response, err = future.GetResult(sender); err == nil && tsgr.Response.Response.StatusCode != http.StatusNoContent { + tsgr, err = client.MigrateGremlinDatabaseToAutoscaleResponder(tsgr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesMigrateGremlinDatabaseToAutoscaleFuture", "Result", tsgr.Response.Response, "Failure responding to request") + } + } + return +} + +// GremlinResourcesMigrateGremlinDatabaseToManualThroughputFuture an abstraction for monitoring and +// retrieving the results of a long-running operation. +type GremlinResourcesMigrateGremlinDatabaseToManualThroughputFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(GremlinResourcesClient) (ThroughputSettingsGetResults, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *GremlinResourcesMigrateGremlinDatabaseToManualThroughputFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for GremlinResourcesMigrateGremlinDatabaseToManualThroughputFuture.Result. +func (future *GremlinResourcesMigrateGremlinDatabaseToManualThroughputFuture) result(client GremlinResourcesClient) (tsgr ThroughputSettingsGetResults, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesMigrateGremlinDatabaseToManualThroughputFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + tsgr.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("documentdb.GremlinResourcesMigrateGremlinDatabaseToManualThroughputFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if tsgr.Response.Response, err = future.GetResult(sender); err == nil && tsgr.Response.Response.StatusCode != http.StatusNoContent { + tsgr, err = client.MigrateGremlinDatabaseToManualThroughputResponder(tsgr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesMigrateGremlinDatabaseToManualThroughputFuture", "Result", tsgr.Response.Response, "Failure responding to request") + } + } + return +} + +// GremlinResourcesMigrateGremlinGraphToAutoscaleFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type GremlinResourcesMigrateGremlinGraphToAutoscaleFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(GremlinResourcesClient) (ThroughputSettingsGetResults, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *GremlinResourcesMigrateGremlinGraphToAutoscaleFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for GremlinResourcesMigrateGremlinGraphToAutoscaleFuture.Result. +func (future *GremlinResourcesMigrateGremlinGraphToAutoscaleFuture) result(client GremlinResourcesClient) (tsgr ThroughputSettingsGetResults, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesMigrateGremlinGraphToAutoscaleFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + tsgr.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("documentdb.GremlinResourcesMigrateGremlinGraphToAutoscaleFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if tsgr.Response.Response, err = future.GetResult(sender); err == nil && tsgr.Response.Response.StatusCode != http.StatusNoContent { + tsgr, err = client.MigrateGremlinGraphToAutoscaleResponder(tsgr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesMigrateGremlinGraphToAutoscaleFuture", "Result", tsgr.Response.Response, "Failure responding to request") + } + } + return +} + +// GremlinResourcesMigrateGremlinGraphToManualThroughputFuture an abstraction for monitoring and retrieving +// the results of a long-running operation. +type GremlinResourcesMigrateGremlinGraphToManualThroughputFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(GremlinResourcesClient) (ThroughputSettingsGetResults, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *GremlinResourcesMigrateGremlinGraphToManualThroughputFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for GremlinResourcesMigrateGremlinGraphToManualThroughputFuture.Result. +func (future *GremlinResourcesMigrateGremlinGraphToManualThroughputFuture) result(client GremlinResourcesClient) (tsgr ThroughputSettingsGetResults, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesMigrateGremlinGraphToManualThroughputFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + tsgr.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("documentdb.GremlinResourcesMigrateGremlinGraphToManualThroughputFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if tsgr.Response.Response, err = future.GetResult(sender); err == nil && tsgr.Response.Response.StatusCode != http.StatusNoContent { + tsgr, err = client.MigrateGremlinGraphToManualThroughputResponder(tsgr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesMigrateGremlinGraphToManualThroughputFuture", "Result", tsgr.Response.Response, "Failure responding to request") + } + } + return +} + +// GremlinResourcesUpdateGremlinDatabaseThroughputFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type GremlinResourcesUpdateGremlinDatabaseThroughputFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(GremlinResourcesClient) (ThroughputSettingsGetResults, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *GremlinResourcesUpdateGremlinDatabaseThroughputFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for GremlinResourcesUpdateGremlinDatabaseThroughputFuture.Result. +func (future *GremlinResourcesUpdateGremlinDatabaseThroughputFuture) result(client GremlinResourcesClient) (tsgr ThroughputSettingsGetResults, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesUpdateGremlinDatabaseThroughputFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + tsgr.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("documentdb.GremlinResourcesUpdateGremlinDatabaseThroughputFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if tsgr.Response.Response, err = future.GetResult(sender); err == nil && tsgr.Response.Response.StatusCode != http.StatusNoContent { + tsgr, err = client.UpdateGremlinDatabaseThroughputResponder(tsgr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesUpdateGremlinDatabaseThroughputFuture", "Result", tsgr.Response.Response, "Failure responding to request") + } + } + return +} + +// GremlinResourcesUpdateGremlinGraphThroughputFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type GremlinResourcesUpdateGremlinGraphThroughputFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(GremlinResourcesClient) (ThroughputSettingsGetResults, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *GremlinResourcesUpdateGremlinGraphThroughputFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for GremlinResourcesUpdateGremlinGraphThroughputFuture.Result. +func (future *GremlinResourcesUpdateGremlinGraphThroughputFuture) result(client GremlinResourcesClient) (tsgr ThroughputSettingsGetResults, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesUpdateGremlinGraphThroughputFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + tsgr.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("documentdb.GremlinResourcesUpdateGremlinGraphThroughputFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if tsgr.Response.Response, err = future.GetResult(sender); err == nil && tsgr.Response.Response.StatusCode != http.StatusNoContent { + tsgr, err = client.UpdateGremlinGraphThroughputResponder(tsgr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesUpdateGremlinGraphThroughputFuture", "Result", tsgr.Response.Response, "Failure responding to request") + } + } + return +} + +// IncludedPath the paths that are included in indexing +type IncludedPath struct { + // Path - The path for which the indexing behavior applies to. Index paths typically start with root and end with wildcard (/path/*) + Path *string `json:"path,omitempty"` + // Indexes - List of indexes for this path + Indexes *[]Indexes `json:"indexes,omitempty"` +} + +// Indexes the indexes for the path. +type Indexes struct { + // DataType - The datatype for which the indexing behavior is applied to. Possible values include: 'DataTypeString', 'DataTypeNumber', 'DataTypePoint', 'DataTypePolygon', 'DataTypeLineString', 'DataTypeMultiPolygon' + DataType DataType `json:"dataType,omitempty"` + // Precision - The precision of the index. -1 is maximum precision. + Precision *int32 `json:"precision,omitempty"` + // Kind - Indicates the type of index. Possible values include: 'IndexKindHash', 'IndexKindRange', 'IndexKindSpatial' + Kind IndexKind `json:"kind,omitempty"` +} + +// IndexingPolicy cosmos DB indexing policy +type IndexingPolicy struct { + // Automatic - Indicates if the indexing policy is automatic + Automatic *bool `json:"automatic,omitempty"` + // IndexingMode - Indicates the indexing mode. Possible values include: 'IndexingModeConsistent', 'IndexingModeLazy', 'IndexingModeNone' + IndexingMode IndexingMode `json:"indexingMode,omitempty"` + // IncludedPaths - List of paths to include in the indexing + IncludedPaths *[]IncludedPath `json:"includedPaths,omitempty"` + // ExcludedPaths - List of paths to exclude from indexing + ExcludedPaths *[]ExcludedPath `json:"excludedPaths,omitempty"` + // CompositeIndexes - List of composite path list + CompositeIndexes *[][]CompositePath `json:"compositeIndexes,omitempty"` + // SpatialIndexes - List of spatial specifics + SpatialIndexes *[]SpatialSpec `json:"spatialIndexes,omitempty"` +} + +// IPAddressOrRange ipAddressOrRange object +type IPAddressOrRange struct { + // IPAddressOrRange - A single IPv4 address or a single IPv4 address range in CIDR format. Provided IPs must be well-formatted and cannot be contained in one of the following ranges: 10.0.0.0/8, 100.64.0.0/10, 172.16.0.0/12, 192.168.0.0/16, since these are not enforceable by the IP address filter. Example of valid inputs: “23.40.210.245” or “23.40.210.0/8”. + IPAddressOrRange *string `json:"ipAddressOrRange,omitempty"` +} + +// Location a region in which the Azure Cosmos DB database account is deployed. +type Location struct { + // ID - READ-ONLY; The unique identifier of the region within the database account. Example: <accountName>-<locationName>. + ID *string `json:"id,omitempty"` + // LocationName - The name of the region. + LocationName *string `json:"locationName,omitempty"` + // DocumentEndpoint - READ-ONLY; The connection endpoint for the specific region. Example: https://<accountName>-<locationName>.documents.azure.com:443/ + DocumentEndpoint *string `json:"documentEndpoint,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` + // FailoverPriority - The failover priority of the region. A failover priority of 0 indicates a write region. The maximum value for a failover priority = (total number of regions - 1). Failover priority values must be unique for each of the regions in which the database account exists. + FailoverPriority *int32 `json:"failoverPriority,omitempty"` + // IsZoneRedundant - Flag to indicate whether or not this region is an AvailabilityZone region + IsZoneRedundant *bool `json:"isZoneRedundant,omitempty"` +} + +// MarshalJSON is the custom marshaler for Location. +func (l Location) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if l.LocationName != nil { + objectMap["locationName"] = l.LocationName + } + if l.ProvisioningState != nil { + objectMap["provisioningState"] = l.ProvisioningState + } + if l.FailoverPriority != nil { + objectMap["failoverPriority"] = l.FailoverPriority + } + if l.IsZoneRedundant != nil { + objectMap["isZoneRedundant"] = l.IsZoneRedundant + } + return json.Marshal(objectMap) +} + +// ManagedServiceIdentity identity for the resource. +type ManagedServiceIdentity struct { + // PrincipalID - READ-ONLY; The principal id of the system assigned identity. This property will only be provided for a system assigned identity. + PrincipalID *string `json:"principalId,omitempty"` + // TenantID - READ-ONLY; The tenant id of the system assigned identity. This property will only be provided for a system assigned identity. + TenantID *string `json:"tenantId,omitempty"` + // Type - The type of identity used for the resource. The type 'SystemAssigned,UserAssigned' includes both an implicitly created identity and a set of user assigned identities. The type 'None' will remove any identities from the service. Possible values include: 'ResourceIdentityTypeSystemAssigned', 'ResourceIdentityTypeUserAssigned', 'ResourceIdentityTypeSystemAssignedUserAssigned', 'ResourceIdentityTypeNone' + Type ResourceIdentityType `json:"type,omitempty"` + // UserAssignedIdentities - The list of user identities associated with resource. The user identity dictionary key references will be ARM resource ids in the form: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. + UserAssignedIdentities map[string]*ManagedServiceIdentityUserAssignedIdentitiesValue `json:"userAssignedIdentities"` +} + +// MarshalJSON is the custom marshaler for ManagedServiceIdentity. +func (msi ManagedServiceIdentity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if msi.Type != "" { + objectMap["type"] = msi.Type + } + if msi.UserAssignedIdentities != nil { + objectMap["userAssignedIdentities"] = msi.UserAssignedIdentities + } + return json.Marshal(objectMap) +} + +// ManagedServiceIdentityUserAssignedIdentitiesValue ... +type ManagedServiceIdentityUserAssignedIdentitiesValue struct { + // PrincipalID - READ-ONLY; The principal id of user assigned identity. + PrincipalID *string `json:"principalId,omitempty"` + // ClientID - READ-ONLY; The client id of user assigned identity. + ClientID *string `json:"clientId,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedServiceIdentityUserAssignedIdentitiesValue. +func (msiAiv ManagedServiceIdentityUserAssignedIdentitiesValue) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// Metric metric data +type Metric struct { + // StartTime - READ-ONLY; The start time for the metric (ISO-8601 format). + StartTime *date.Time `json:"startTime,omitempty"` + // EndTime - READ-ONLY; The end time for the metric (ISO-8601 format). + EndTime *date.Time `json:"endTime,omitempty"` + // TimeGrain - READ-ONLY; The time grain 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', 'UnitTypeMilliseconds' + Unit UnitType `json:"unit,omitempty"` + // Name - READ-ONLY; The name information for the metric. + Name *MetricName `json:"name,omitempty"` + // MetricValues - READ-ONLY; The metric values for the specified time window and timestep. + MetricValues *[]MetricValue `json:"metricValues,omitempty"` +} + +// MarshalJSON is the custom marshaler for Metric. +func (mVar Metric) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mVar.Unit != "" { + objectMap["unit"] = mVar.Unit + } + return json.Marshal(objectMap) +} + +// MetricAvailability the availability of the metric. +type MetricAvailability struct { + // TimeGrain - READ-ONLY; The time grain to be used to summarize the metric values. + TimeGrain *string `json:"timeGrain,omitempty"` + // Retention - READ-ONLY; The retention for the metric values. + Retention *string `json:"retention,omitempty"` +} + +// MarshalJSON is the custom marshaler for MetricAvailability. +func (ma MetricAvailability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// MetricDefinition the definition of a metric. +type MetricDefinition struct { + // MetricAvailabilities - READ-ONLY; The list of metric availabilities for the account. + MetricAvailabilities *[]MetricAvailability `json:"metricAvailabilities,omitempty"` + // PrimaryAggregationType - READ-ONLY; The primary aggregation type of the metric. Possible values include: 'PrimaryAggregationTypeNone', 'PrimaryAggregationTypeAverage', 'PrimaryAggregationTypeTotal', 'PrimaryAggregationTypeMinimum', 'PrimaryAggregationTypeMaximum', 'PrimaryAggregationTypeLast' + PrimaryAggregationType PrimaryAggregationType `json:"primaryAggregationType,omitempty"` + // Unit - The unit of the metric. Possible values include: 'UnitTypeCount', 'UnitTypeBytes', 'UnitTypeSeconds', 'UnitTypePercent', 'UnitTypeCountPerSecond', 'UnitTypeBytesPerSecond', 'UnitTypeMilliseconds' + Unit UnitType `json:"unit,omitempty"` + // ResourceURI - READ-ONLY; The resource uri of the database. + ResourceURI *string `json:"resourceUri,omitempty"` + // Name - READ-ONLY; The name information for the metric. + Name *MetricName `json:"name,omitempty"` +} + +// MarshalJSON is the custom marshaler for MetricDefinition. +func (md MetricDefinition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if md.Unit != "" { + objectMap["unit"] = md.Unit + } + return json.Marshal(objectMap) +} + +// MetricDefinitionsListResult the response to a list metric definitions request. +type MetricDefinitionsListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; The list of metric definitions for the account. + Value *[]MetricDefinition `json:"value,omitempty"` +} + +// MarshalJSON is the custom marshaler for MetricDefinitionsListResult. +func (mdlr MetricDefinitionsListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// MetricListResult the response to a list metrics request. +type MetricListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; The list of metrics for the account. + Value *[]Metric `json:"value,omitempty"` +} + +// MarshalJSON is the custom marshaler for MetricListResult. +func (mlr MetricListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// MetricName a metric name. +type MetricName struct { + // Value - READ-ONLY; The name of the metric. + Value *string `json:"value,omitempty"` + // LocalizedValue - READ-ONLY; The friendly name of the metric. + LocalizedValue *string `json:"localizedValue,omitempty"` +} + +// MarshalJSON is the custom marshaler for MetricName. +func (mn MetricName) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// MetricValue represents metrics values. +type MetricValue struct { + // Count - READ-ONLY; The number of values for the metric. + Count *float64 `json:"_count,omitempty"` + // Average - READ-ONLY; The average value of the metric. + Average *float64 `json:"average,omitempty"` + // Maximum - READ-ONLY; The max value of the metric. + Maximum *float64 `json:"maximum,omitempty"` + // Minimum - READ-ONLY; The min value of the metric. + Minimum *float64 `json:"minimum,omitempty"` + // Timestamp - READ-ONLY; The metric timestamp (ISO-8601 format). + Timestamp *date.Time `json:"timestamp,omitempty"` + // Total - READ-ONLY; The total value of the metric. + Total *float64 `json:"total,omitempty"` +} + +// MarshalJSON is the custom marshaler for MetricValue. +func (mv MetricValue) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// MongoDBCollectionCreateUpdateParameters parameters to create and update Cosmos DB MongoDB collection. +type MongoDBCollectionCreateUpdateParameters struct { + // MongoDBCollectionCreateUpdateProperties - Properties to create and update Azure Cosmos DB MongoDB collection. + *MongoDBCollectionCreateUpdateProperties `json:"properties,omitempty"` + // ID - READ-ONLY; The unique resource identifier of the ARM resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the ARM resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of Azure resource. + Type *string `json:"type,omitempty"` + // Location - The location of the resource group to which the resource belongs. + Location *string `json:"location,omitempty"` + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for MongoDBCollectionCreateUpdateParameters. +func (mdccup MongoDBCollectionCreateUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mdccup.MongoDBCollectionCreateUpdateProperties != nil { + objectMap["properties"] = mdccup.MongoDBCollectionCreateUpdateProperties + } + if mdccup.Location != nil { + objectMap["location"] = mdccup.Location + } + if mdccup.Tags != nil { + objectMap["tags"] = mdccup.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for MongoDBCollectionCreateUpdateParameters struct. +func (mdccup *MongoDBCollectionCreateUpdateParameters) UnmarshalJSON(body []byte) error { + 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 mongoDBCollectionCreateUpdateProperties MongoDBCollectionCreateUpdateProperties + err = json.Unmarshal(*v, &mongoDBCollectionCreateUpdateProperties) + if err != nil { + return err + } + mdccup.MongoDBCollectionCreateUpdateProperties = &mongoDBCollectionCreateUpdateProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + mdccup.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + mdccup.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + mdccup.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + mdccup.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + mdccup.Tags = tags + } + } + } + + return nil +} + +// MongoDBCollectionCreateUpdateProperties properties to create and update Azure Cosmos DB MongoDB +// collection. +type MongoDBCollectionCreateUpdateProperties struct { + // Resource - The standard JSON format of a MongoDB collection + Resource *MongoDBCollectionResource `json:"resource,omitempty"` + // Options - A key-value pair of options to be applied for the request. This corresponds to the headers sent with the request. + Options *CreateUpdateOptions `json:"options,omitempty"` +} + +// MongoDBCollectionGetProperties the properties of an Azure Cosmos DB MongoDB collection +type MongoDBCollectionGetProperties struct { + Resource *MongoDBCollectionGetPropertiesResource `json:"resource,omitempty"` + Options *MongoDBCollectionGetPropertiesOptions `json:"options,omitempty"` +} + +// MongoDBCollectionGetPropertiesOptions ... +type MongoDBCollectionGetPropertiesOptions struct { + // Throughput - Value of the Cosmos DB resource throughput or autoscaleSettings. Use the ThroughputSetting resource when retrieving offer details. + Throughput *int32 `json:"throughput,omitempty"` + // AutoscaleSettings - Specifies the Autoscale settings. + AutoscaleSettings *AutoscaleSettings `json:"autoscaleSettings,omitempty"` +} + +// MongoDBCollectionGetPropertiesResource ... +type MongoDBCollectionGetPropertiesResource struct { + // ID - Name of the Cosmos DB MongoDB collection + ID *string `json:"id,omitempty"` + // ShardKey - A key-value pair of shard keys to be applied for the request. + ShardKey map[string]*string `json:"shardKey"` + // Indexes - List of index keys + Indexes *[]MongoIndex `json:"indexes,omitempty"` + // AnalyticalStorageTTL - Analytical TTL. + AnalyticalStorageTTL *int32 `json:"analyticalStorageTtl,omitempty"` + // Rid - READ-ONLY; A system generated property. A unique identifier. + Rid *string `json:"_rid,omitempty"` + // Ts - READ-ONLY; A system generated property that denotes the last updated timestamp of the resource. + Ts *float64 `json:"_ts,omitempty"` + // Etag - READ-ONLY; A system generated property representing the resource etag required for optimistic concurrency control. + Etag *string `json:"_etag,omitempty"` +} + +// MarshalJSON is the custom marshaler for MongoDBCollectionGetPropertiesResource. +func (mdcgp MongoDBCollectionGetPropertiesResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mdcgp.ID != nil { + objectMap["id"] = mdcgp.ID + } + if mdcgp.ShardKey != nil { + objectMap["shardKey"] = mdcgp.ShardKey + } + if mdcgp.Indexes != nil { + objectMap["indexes"] = mdcgp.Indexes + } + if mdcgp.AnalyticalStorageTTL != nil { + objectMap["analyticalStorageTtl"] = mdcgp.AnalyticalStorageTTL + } + return json.Marshal(objectMap) +} + +// MongoDBCollectionGetResults an Azure Cosmos DB MongoDB collection. +type MongoDBCollectionGetResults struct { + autorest.Response `json:"-"` + // MongoDBCollectionGetProperties - The properties of an Azure Cosmos DB MongoDB collection + *MongoDBCollectionGetProperties `json:"properties,omitempty"` + // ID - READ-ONLY; The unique resource identifier of the ARM resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the ARM resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of Azure resource. + Type *string `json:"type,omitempty"` + // Location - The location of the resource group to which the resource belongs. + Location *string `json:"location,omitempty"` + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for MongoDBCollectionGetResults. +func (mdcgr MongoDBCollectionGetResults) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mdcgr.MongoDBCollectionGetProperties != nil { + objectMap["properties"] = mdcgr.MongoDBCollectionGetProperties + } + if mdcgr.Location != nil { + objectMap["location"] = mdcgr.Location + } + if mdcgr.Tags != nil { + objectMap["tags"] = mdcgr.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for MongoDBCollectionGetResults struct. +func (mdcgr *MongoDBCollectionGetResults) UnmarshalJSON(body []byte) error { + 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 mongoDBCollectionGetProperties MongoDBCollectionGetProperties + err = json.Unmarshal(*v, &mongoDBCollectionGetProperties) + if err != nil { + return err + } + mdcgr.MongoDBCollectionGetProperties = &mongoDBCollectionGetProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + mdcgr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + mdcgr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + mdcgr.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + mdcgr.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + mdcgr.Tags = tags + } + } + } + + return nil +} + +// MongoDBCollectionListResult the List operation response, that contains the MongoDB collections and their +// properties. +type MongoDBCollectionListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; List of MongoDB collections and their properties. + Value *[]MongoDBCollectionGetResults `json:"value,omitempty"` +} + +// MarshalJSON is the custom marshaler for MongoDBCollectionListResult. +func (mdclr MongoDBCollectionListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// MongoDBCollectionResource cosmos DB MongoDB collection resource object +type MongoDBCollectionResource struct { + // ID - Name of the Cosmos DB MongoDB collection + ID *string `json:"id,omitempty"` + // ShardKey - A key-value pair of shard keys to be applied for the request. + ShardKey map[string]*string `json:"shardKey"` + // Indexes - List of index keys + Indexes *[]MongoIndex `json:"indexes,omitempty"` + // AnalyticalStorageTTL - Analytical TTL. + AnalyticalStorageTTL *int32 `json:"analyticalStorageTtl,omitempty"` +} + +// MarshalJSON is the custom marshaler for MongoDBCollectionResource. +func (mdcr MongoDBCollectionResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mdcr.ID != nil { + objectMap["id"] = mdcr.ID + } + if mdcr.ShardKey != nil { + objectMap["shardKey"] = mdcr.ShardKey + } + if mdcr.Indexes != nil { + objectMap["indexes"] = mdcr.Indexes + } + if mdcr.AnalyticalStorageTTL != nil { + objectMap["analyticalStorageTtl"] = mdcr.AnalyticalStorageTTL + } + return json.Marshal(objectMap) +} + +// MongoDBDatabaseCreateUpdateParameters parameters to create and update Cosmos DB MongoDB database. +type MongoDBDatabaseCreateUpdateParameters struct { + // MongoDBDatabaseCreateUpdateProperties - Properties to create and update Azure Cosmos DB MongoDB database. + *MongoDBDatabaseCreateUpdateProperties `json:"properties,omitempty"` + // ID - READ-ONLY; The unique resource identifier of the ARM resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the ARM resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of Azure resource. + Type *string `json:"type,omitempty"` + // Location - The location of the resource group to which the resource belongs. + Location *string `json:"location,omitempty"` + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for MongoDBDatabaseCreateUpdateParameters. +func (mddcup MongoDBDatabaseCreateUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mddcup.MongoDBDatabaseCreateUpdateProperties != nil { + objectMap["properties"] = mddcup.MongoDBDatabaseCreateUpdateProperties + } + if mddcup.Location != nil { + objectMap["location"] = mddcup.Location + } + if mddcup.Tags != nil { + objectMap["tags"] = mddcup.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for MongoDBDatabaseCreateUpdateParameters struct. +func (mddcup *MongoDBDatabaseCreateUpdateParameters) UnmarshalJSON(body []byte) error { + 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 mongoDBDatabaseCreateUpdateProperties MongoDBDatabaseCreateUpdateProperties + err = json.Unmarshal(*v, &mongoDBDatabaseCreateUpdateProperties) + if err != nil { + return err + } + mddcup.MongoDBDatabaseCreateUpdateProperties = &mongoDBDatabaseCreateUpdateProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + mddcup.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + mddcup.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + mddcup.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + mddcup.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + mddcup.Tags = tags + } + } + } + + return nil +} + +// MongoDBDatabaseCreateUpdateProperties properties to create and update Azure Cosmos DB MongoDB database. +type MongoDBDatabaseCreateUpdateProperties struct { + // Resource - The standard JSON format of a MongoDB database + Resource *MongoDBDatabaseResource `json:"resource,omitempty"` + // Options - A key-value pair of options to be applied for the request. This corresponds to the headers sent with the request. + Options *CreateUpdateOptions `json:"options,omitempty"` +} + +// MongoDBDatabaseGetProperties the properties of an Azure Cosmos DB MongoDB database +type MongoDBDatabaseGetProperties struct { + Resource *MongoDBDatabaseGetPropertiesResource `json:"resource,omitempty"` + Options *MongoDBDatabaseGetPropertiesOptions `json:"options,omitempty"` +} + +// MongoDBDatabaseGetPropertiesOptions ... +type MongoDBDatabaseGetPropertiesOptions struct { + // Throughput - Value of the Cosmos DB resource throughput or autoscaleSettings. Use the ThroughputSetting resource when retrieving offer details. + Throughput *int32 `json:"throughput,omitempty"` + // AutoscaleSettings - Specifies the Autoscale settings. + AutoscaleSettings *AutoscaleSettings `json:"autoscaleSettings,omitempty"` +} + +// MongoDBDatabaseGetPropertiesResource ... +type MongoDBDatabaseGetPropertiesResource struct { + // ID - Name of the Cosmos DB MongoDB database + ID *string `json:"id,omitempty"` + // Rid - READ-ONLY; A system generated property. A unique identifier. + Rid *string `json:"_rid,omitempty"` + // Ts - READ-ONLY; A system generated property that denotes the last updated timestamp of the resource. + Ts *float64 `json:"_ts,omitempty"` + // Etag - READ-ONLY; A system generated property representing the resource etag required for optimistic concurrency control. + Etag *string `json:"_etag,omitempty"` +} + +// MarshalJSON is the custom marshaler for MongoDBDatabaseGetPropertiesResource. +func (mddgp MongoDBDatabaseGetPropertiesResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mddgp.ID != nil { + objectMap["id"] = mddgp.ID + } + return json.Marshal(objectMap) +} + +// MongoDBDatabaseGetResults an Azure Cosmos DB MongoDB database. +type MongoDBDatabaseGetResults struct { + autorest.Response `json:"-"` + // MongoDBDatabaseGetProperties - The properties of an Azure Cosmos DB MongoDB database + *MongoDBDatabaseGetProperties `json:"properties,omitempty"` + // ID - READ-ONLY; The unique resource identifier of the ARM resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the ARM resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of Azure resource. + Type *string `json:"type,omitempty"` + // Location - The location of the resource group to which the resource belongs. + Location *string `json:"location,omitempty"` + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for MongoDBDatabaseGetResults. +func (mddgr MongoDBDatabaseGetResults) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mddgr.MongoDBDatabaseGetProperties != nil { + objectMap["properties"] = mddgr.MongoDBDatabaseGetProperties + } + if mddgr.Location != nil { + objectMap["location"] = mddgr.Location + } + if mddgr.Tags != nil { + objectMap["tags"] = mddgr.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for MongoDBDatabaseGetResults struct. +func (mddgr *MongoDBDatabaseGetResults) UnmarshalJSON(body []byte) error { + 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 mongoDBDatabaseGetProperties MongoDBDatabaseGetProperties + err = json.Unmarshal(*v, &mongoDBDatabaseGetProperties) + if err != nil { + return err + } + mddgr.MongoDBDatabaseGetProperties = &mongoDBDatabaseGetProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + mddgr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + mddgr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + mddgr.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + mddgr.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + mddgr.Tags = tags + } + } + } + + return nil +} + +// MongoDBDatabaseListResult the List operation response, that contains the MongoDB databases and their +// properties. +type MongoDBDatabaseListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; List of MongoDB databases and their properties. + Value *[]MongoDBDatabaseGetResults `json:"value,omitempty"` +} + +// MarshalJSON is the custom marshaler for MongoDBDatabaseListResult. +func (mddlr MongoDBDatabaseListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// MongoDBDatabaseResource cosmos DB MongoDB database resource object +type MongoDBDatabaseResource struct { + // ID - Name of the Cosmos DB MongoDB database + ID *string `json:"id,omitempty"` +} + +// MongoDBResourcesCreateUpdateMongoDBCollectionFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type MongoDBResourcesCreateUpdateMongoDBCollectionFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(MongoDBResourcesClient) (MongoDBCollectionGetResults, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *MongoDBResourcesCreateUpdateMongoDBCollectionFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for MongoDBResourcesCreateUpdateMongoDBCollectionFuture.Result. +func (future *MongoDBResourcesCreateUpdateMongoDBCollectionFuture) result(client MongoDBResourcesClient) (mdcgr MongoDBCollectionGetResults, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesCreateUpdateMongoDBCollectionFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + mdcgr.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("documentdb.MongoDBResourcesCreateUpdateMongoDBCollectionFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if mdcgr.Response.Response, err = future.GetResult(sender); err == nil && mdcgr.Response.Response.StatusCode != http.StatusNoContent { + mdcgr, err = client.CreateUpdateMongoDBCollectionResponder(mdcgr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesCreateUpdateMongoDBCollectionFuture", "Result", mdcgr.Response.Response, "Failure responding to request") + } + } + return +} + +// MongoDBResourcesCreateUpdateMongoDBDatabaseFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type MongoDBResourcesCreateUpdateMongoDBDatabaseFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(MongoDBResourcesClient) (MongoDBDatabaseGetResults, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *MongoDBResourcesCreateUpdateMongoDBDatabaseFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for MongoDBResourcesCreateUpdateMongoDBDatabaseFuture.Result. +func (future *MongoDBResourcesCreateUpdateMongoDBDatabaseFuture) result(client MongoDBResourcesClient) (mddgr MongoDBDatabaseGetResults, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesCreateUpdateMongoDBDatabaseFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + mddgr.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("documentdb.MongoDBResourcesCreateUpdateMongoDBDatabaseFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if mddgr.Response.Response, err = future.GetResult(sender); err == nil && mddgr.Response.Response.StatusCode != http.StatusNoContent { + mddgr, err = client.CreateUpdateMongoDBDatabaseResponder(mddgr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesCreateUpdateMongoDBDatabaseFuture", "Result", mddgr.Response.Response, "Failure responding to request") + } + } + return +} + +// MongoDBResourcesDeleteMongoDBCollectionFuture an abstraction for monitoring and retrieving the results +// of a long-running operation. +type MongoDBResourcesDeleteMongoDBCollectionFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(MongoDBResourcesClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *MongoDBResourcesDeleteMongoDBCollectionFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for MongoDBResourcesDeleteMongoDBCollectionFuture.Result. +func (future *MongoDBResourcesDeleteMongoDBCollectionFuture) result(client MongoDBResourcesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesDeleteMongoDBCollectionFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("documentdb.MongoDBResourcesDeleteMongoDBCollectionFuture") + return + } + ar.Response = future.Response() + return +} + +// MongoDBResourcesDeleteMongoDBDatabaseFuture an abstraction for monitoring and retrieving the results of +// a long-running operation. +type MongoDBResourcesDeleteMongoDBDatabaseFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(MongoDBResourcesClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *MongoDBResourcesDeleteMongoDBDatabaseFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for MongoDBResourcesDeleteMongoDBDatabaseFuture.Result. +func (future *MongoDBResourcesDeleteMongoDBDatabaseFuture) result(client MongoDBResourcesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesDeleteMongoDBDatabaseFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("documentdb.MongoDBResourcesDeleteMongoDBDatabaseFuture") + return + } + ar.Response = future.Response() + return +} + +// MongoDBResourcesMigrateMongoDBCollectionToAutoscaleFuture an abstraction for monitoring and retrieving +// the results of a long-running operation. +type MongoDBResourcesMigrateMongoDBCollectionToAutoscaleFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(MongoDBResourcesClient) (ThroughputSettingsGetResults, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *MongoDBResourcesMigrateMongoDBCollectionToAutoscaleFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for MongoDBResourcesMigrateMongoDBCollectionToAutoscaleFuture.Result. +func (future *MongoDBResourcesMigrateMongoDBCollectionToAutoscaleFuture) result(client MongoDBResourcesClient) (tsgr ThroughputSettingsGetResults, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesMigrateMongoDBCollectionToAutoscaleFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + tsgr.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("documentdb.MongoDBResourcesMigrateMongoDBCollectionToAutoscaleFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if tsgr.Response.Response, err = future.GetResult(sender); err == nil && tsgr.Response.Response.StatusCode != http.StatusNoContent { + tsgr, err = client.MigrateMongoDBCollectionToAutoscaleResponder(tsgr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesMigrateMongoDBCollectionToAutoscaleFuture", "Result", tsgr.Response.Response, "Failure responding to request") + } + } + return +} + +// MongoDBResourcesMigrateMongoDBCollectionToManualThroughputFuture an abstraction for monitoring and +// retrieving the results of a long-running operation. +type MongoDBResourcesMigrateMongoDBCollectionToManualThroughputFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(MongoDBResourcesClient) (ThroughputSettingsGetResults, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *MongoDBResourcesMigrateMongoDBCollectionToManualThroughputFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for MongoDBResourcesMigrateMongoDBCollectionToManualThroughputFuture.Result. +func (future *MongoDBResourcesMigrateMongoDBCollectionToManualThroughputFuture) result(client MongoDBResourcesClient) (tsgr ThroughputSettingsGetResults, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesMigrateMongoDBCollectionToManualThroughputFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + tsgr.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("documentdb.MongoDBResourcesMigrateMongoDBCollectionToManualThroughputFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if tsgr.Response.Response, err = future.GetResult(sender); err == nil && tsgr.Response.Response.StatusCode != http.StatusNoContent { + tsgr, err = client.MigrateMongoDBCollectionToManualThroughputResponder(tsgr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesMigrateMongoDBCollectionToManualThroughputFuture", "Result", tsgr.Response.Response, "Failure responding to request") + } + } + return +} + +// MongoDBResourcesMigrateMongoDBDatabaseToAutoscaleFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type MongoDBResourcesMigrateMongoDBDatabaseToAutoscaleFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(MongoDBResourcesClient) (ThroughputSettingsGetResults, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *MongoDBResourcesMigrateMongoDBDatabaseToAutoscaleFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for MongoDBResourcesMigrateMongoDBDatabaseToAutoscaleFuture.Result. +func (future *MongoDBResourcesMigrateMongoDBDatabaseToAutoscaleFuture) result(client MongoDBResourcesClient) (tsgr ThroughputSettingsGetResults, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesMigrateMongoDBDatabaseToAutoscaleFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + tsgr.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("documentdb.MongoDBResourcesMigrateMongoDBDatabaseToAutoscaleFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if tsgr.Response.Response, err = future.GetResult(sender); err == nil && tsgr.Response.Response.StatusCode != http.StatusNoContent { + tsgr, err = client.MigrateMongoDBDatabaseToAutoscaleResponder(tsgr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesMigrateMongoDBDatabaseToAutoscaleFuture", "Result", tsgr.Response.Response, "Failure responding to request") + } + } + return +} + +// MongoDBResourcesMigrateMongoDBDatabaseToManualThroughputFuture an abstraction for monitoring and +// retrieving the results of a long-running operation. +type MongoDBResourcesMigrateMongoDBDatabaseToManualThroughputFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(MongoDBResourcesClient) (ThroughputSettingsGetResults, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *MongoDBResourcesMigrateMongoDBDatabaseToManualThroughputFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for MongoDBResourcesMigrateMongoDBDatabaseToManualThroughputFuture.Result. +func (future *MongoDBResourcesMigrateMongoDBDatabaseToManualThroughputFuture) result(client MongoDBResourcesClient) (tsgr ThroughputSettingsGetResults, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesMigrateMongoDBDatabaseToManualThroughputFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + tsgr.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("documentdb.MongoDBResourcesMigrateMongoDBDatabaseToManualThroughputFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if tsgr.Response.Response, err = future.GetResult(sender); err == nil && tsgr.Response.Response.StatusCode != http.StatusNoContent { + tsgr, err = client.MigrateMongoDBDatabaseToManualThroughputResponder(tsgr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesMigrateMongoDBDatabaseToManualThroughputFuture", "Result", tsgr.Response.Response, "Failure responding to request") + } + } + return +} + +// MongoDBResourcesUpdateMongoDBCollectionThroughputFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type MongoDBResourcesUpdateMongoDBCollectionThroughputFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(MongoDBResourcesClient) (ThroughputSettingsGetResults, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *MongoDBResourcesUpdateMongoDBCollectionThroughputFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for MongoDBResourcesUpdateMongoDBCollectionThroughputFuture.Result. +func (future *MongoDBResourcesUpdateMongoDBCollectionThroughputFuture) result(client MongoDBResourcesClient) (tsgr ThroughputSettingsGetResults, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesUpdateMongoDBCollectionThroughputFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + tsgr.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("documentdb.MongoDBResourcesUpdateMongoDBCollectionThroughputFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if tsgr.Response.Response, err = future.GetResult(sender); err == nil && tsgr.Response.Response.StatusCode != http.StatusNoContent { + tsgr, err = client.UpdateMongoDBCollectionThroughputResponder(tsgr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesUpdateMongoDBCollectionThroughputFuture", "Result", tsgr.Response.Response, "Failure responding to request") + } + } + return +} + +// MongoDBResourcesUpdateMongoDBDatabaseThroughputFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type MongoDBResourcesUpdateMongoDBDatabaseThroughputFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(MongoDBResourcesClient) (ThroughputSettingsGetResults, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *MongoDBResourcesUpdateMongoDBDatabaseThroughputFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for MongoDBResourcesUpdateMongoDBDatabaseThroughputFuture.Result. +func (future *MongoDBResourcesUpdateMongoDBDatabaseThroughputFuture) result(client MongoDBResourcesClient) (tsgr ThroughputSettingsGetResults, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesUpdateMongoDBDatabaseThroughputFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + tsgr.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("documentdb.MongoDBResourcesUpdateMongoDBDatabaseThroughputFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if tsgr.Response.Response, err = future.GetResult(sender); err == nil && tsgr.Response.Response.StatusCode != http.StatusNoContent { + tsgr, err = client.UpdateMongoDBDatabaseThroughputResponder(tsgr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesUpdateMongoDBDatabaseThroughputFuture", "Result", tsgr.Response.Response, "Failure responding to request") + } + } + return +} + +// MongoIndex cosmos DB MongoDB collection index key +type MongoIndex struct { + // Key - Cosmos DB MongoDB collection index keys + Key *MongoIndexKeys `json:"key,omitempty"` + // Options - Cosmos DB MongoDB collection index key options + Options *MongoIndexOptions `json:"options,omitempty"` +} + +// MongoIndexKeys cosmos DB MongoDB collection resource object +type MongoIndexKeys struct { + // Keys - List of keys for each MongoDB collection in the Azure Cosmos DB service + Keys *[]string `json:"keys,omitempty"` +} + +// MongoIndexOptions cosmos DB MongoDB collection index options +type MongoIndexOptions struct { + // ExpireAfterSeconds - Expire after seconds + ExpireAfterSeconds *int32 `json:"expireAfterSeconds,omitempty"` + // Unique - Is unique or not + Unique *bool `json:"unique,omitempty"` +} + +// NotebookWorkspace a notebook workspace resource +type NotebookWorkspace struct { + autorest.Response `json:"-"` + // NotebookWorkspaceProperties - Resource properties. + *NotebookWorkspaceProperties `json:"properties,omitempty"` + // ID - READ-ONLY; The unique resource identifier of the database account. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the database account. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of Azure resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for NotebookWorkspace. +func (nw NotebookWorkspace) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if nw.NotebookWorkspaceProperties != nil { + objectMap["properties"] = nw.NotebookWorkspaceProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for NotebookWorkspace struct. +func (nw *NotebookWorkspace) UnmarshalJSON(body []byte) error { + 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 notebookWorkspaceProperties NotebookWorkspaceProperties + err = json.Unmarshal(*v, ¬ebookWorkspaceProperties) + if err != nil { + return err + } + nw.NotebookWorkspaceProperties = ¬ebookWorkspaceProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + nw.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + nw.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + nw.Type = &typeVar + } + } + } + + return nil +} + +// NotebookWorkspaceConnectionInfoResult the connection info for the given notebook workspace +type NotebookWorkspaceConnectionInfoResult struct { + autorest.Response `json:"-"` + // AuthToken - READ-ONLY; Specifies auth token used for connecting to Notebook server (uses token-based auth). + AuthToken *string `json:"authToken,omitempty"` + // NotebookServerEndpoint - READ-ONLY; Specifies the endpoint of Notebook server. + NotebookServerEndpoint *string `json:"notebookServerEndpoint,omitempty"` +} + +// MarshalJSON is the custom marshaler for NotebookWorkspaceConnectionInfoResult. +func (nwcir NotebookWorkspaceConnectionInfoResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// NotebookWorkspaceCreateUpdateParameters parameters to create a notebook workspace resource +type NotebookWorkspaceCreateUpdateParameters struct { + // ID - READ-ONLY; The unique resource identifier of the database account. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the database account. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of Azure resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for NotebookWorkspaceCreateUpdateParameters. +func (nwcup NotebookWorkspaceCreateUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// NotebookWorkspaceListResult a list of notebook workspace resources +type NotebookWorkspaceListResult struct { + autorest.Response `json:"-"` + // Value - Array of notebook workspace resources + Value *[]NotebookWorkspace `json:"value,omitempty"` +} + +// NotebookWorkspaceProperties properties of a notebook workspace resource. +type NotebookWorkspaceProperties struct { + // NotebookServerEndpoint - READ-ONLY; Specifies the endpoint of Notebook server. + NotebookServerEndpoint *string `json:"notebookServerEndpoint,omitempty"` + // Status - READ-ONLY; Status of the notebook workspace. Possible values are: Creating, Online, Deleting, Failed, Updating. + Status *string `json:"status,omitempty"` +} + +// MarshalJSON is the custom marshaler for NotebookWorkspaceProperties. +func (nwp NotebookWorkspaceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// NotebookWorkspacesCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type NotebookWorkspacesCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(NotebookWorkspacesClient) (NotebookWorkspace, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *NotebookWorkspacesCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for NotebookWorkspacesCreateOrUpdateFuture.Result. +func (future *NotebookWorkspacesCreateOrUpdateFuture) result(client NotebookWorkspacesClient) (nw NotebookWorkspace, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + nw.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("documentdb.NotebookWorkspacesCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if nw.Response.Response, err = future.GetResult(sender); err == nil && nw.Response.Response.StatusCode != http.StatusNoContent { + nw, err = client.CreateOrUpdateResponder(nw.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesCreateOrUpdateFuture", "Result", nw.Response.Response, "Failure responding to request") + } + } + return +} + +// NotebookWorkspacesDeleteFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type NotebookWorkspacesDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(NotebookWorkspacesClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *NotebookWorkspacesDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for NotebookWorkspacesDeleteFuture.Result. +func (future *NotebookWorkspacesDeleteFuture) result(client NotebookWorkspacesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("documentdb.NotebookWorkspacesDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// NotebookWorkspacesRegenerateAuthTokenFuture an abstraction for monitoring and retrieving the results of +// a long-running operation. +type NotebookWorkspacesRegenerateAuthTokenFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(NotebookWorkspacesClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *NotebookWorkspacesRegenerateAuthTokenFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for NotebookWorkspacesRegenerateAuthTokenFuture.Result. +func (future *NotebookWorkspacesRegenerateAuthTokenFuture) result(client NotebookWorkspacesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesRegenerateAuthTokenFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("documentdb.NotebookWorkspacesRegenerateAuthTokenFuture") + return + } + ar.Response = future.Response() + return +} + +// NotebookWorkspacesStartFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type NotebookWorkspacesStartFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(NotebookWorkspacesClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *NotebookWorkspacesStartFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for NotebookWorkspacesStartFuture.Result. +func (future *NotebookWorkspacesStartFuture) result(client NotebookWorkspacesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesStartFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("documentdb.NotebookWorkspacesStartFuture") + return + } + ar.Response = future.Response() + return +} + +// Operation REST API operation +type Operation struct { + // Name - Operation name: {provider}/{resource}/{operation} + Name *string `json:"name,omitempty"` + // Display - The object that represents the operation. + Display *OperationDisplay `json:"display,omitempty"` +} + +// OperationDisplay the object that represents the operation. +type OperationDisplay struct { + // Provider - Service provider: Microsoft.ResourceProvider + Provider *string `json:"Provider,omitempty"` + // Resource - Resource on which the operation is performed: Profile, endpoint, etc. + Resource *string `json:"Resource,omitempty"` + // Operation - Operation type: Read, write, delete, etc. + Operation *string `json:"Operation,omitempty"` + // Description - Description of operation + Description *string `json:"Description,omitempty"` +} + +// OperationListResult result of the request to list Resource Provider operations. It contains a list of +// operations and a URL link to get the next set of results. +type OperationListResult struct { + autorest.Response `json:"-"` + // Value - List of operations supported by the Resource Provider. + Value *[]Operation `json:"value,omitempty"` + // NextLink - URL to get the next set of operation list results if there are any. + NextLink *string `json:"nextLink,omitempty"` +} + +// OperationListResultIterator provides access to a complete listing of Operation values. +type OperationListResultIterator struct { + i int + page OperationListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *OperationListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *OperationListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter OperationListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter OperationListResultIterator) Response() OperationListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter OperationListResultIterator) Value() Operation { + if !iter.page.NotDone() { + return Operation{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the OperationListResultIterator type. +func NewOperationListResultIterator(page OperationListResultPage) OperationListResultIterator { + return OperationListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (olr OperationListResult) IsEmpty() bool { + return olr.Value == nil || len(*olr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (olr OperationListResult) hasNextLink() bool { + return olr.NextLink != nil && len(*olr.NextLink) != 0 +} + +// operationListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (olr OperationListResult) operationListResultPreparer(ctx context.Context) (*http.Request, error) { + if !olr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(olr.NextLink))) +} + +// OperationListResultPage contains a page of Operation values. +type OperationListResultPage struct { + fn func(context.Context, OperationListResult) (OperationListResult, error) + olr OperationListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *OperationListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.olr) + if err != nil { + return err + } + page.olr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *OperationListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page OperationListResultPage) NotDone() bool { + return !page.olr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page OperationListResultPage) Response() OperationListResult { + return page.olr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page OperationListResultPage) Values() []Operation { + if page.olr.IsEmpty() { + return nil + } + return *page.olr.Value +} + +// Creates a new instance of the OperationListResultPage type. +func NewOperationListResultPage(cur OperationListResult, getNextPage func(context.Context, OperationListResult) (OperationListResult, error)) OperationListResultPage { + return OperationListResultPage{ + fn: getNextPage, + olr: cur, + } +} + +// OptionsResource cosmos DB options resource object +type OptionsResource struct { + // Throughput - Value of the Cosmos DB resource throughput or autoscaleSettings. Use the ThroughputSetting resource when retrieving offer details. + Throughput *int32 `json:"throughput,omitempty"` + // AutoscaleSettings - Specifies the Autoscale settings. + AutoscaleSettings *AutoscaleSettings `json:"autoscaleSettings,omitempty"` +} + +// PartitionMetric the metric values for a single partition. +type PartitionMetric struct { + // PartitionID - READ-ONLY; The partition id (GUID identifier) of the metric values. + PartitionID *string `json:"partitionId,omitempty"` + // PartitionKeyRangeID - READ-ONLY; The partition key range id (integer identifier) of the metric values. + PartitionKeyRangeID *string `json:"partitionKeyRangeId,omitempty"` + // StartTime - READ-ONLY; The start time for the metric (ISO-8601 format). + StartTime *date.Time `json:"startTime,omitempty"` + // EndTime - READ-ONLY; The end time for the metric (ISO-8601 format). + EndTime *date.Time `json:"endTime,omitempty"` + // TimeGrain - READ-ONLY; The time grain 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', 'UnitTypeMilliseconds' + Unit UnitType `json:"unit,omitempty"` + // Name - READ-ONLY; The name information for the metric. + Name *MetricName `json:"name,omitempty"` + // MetricValues - READ-ONLY; The metric values for the specified time window and timestep. + MetricValues *[]MetricValue `json:"metricValues,omitempty"` +} + +// MarshalJSON is the custom marshaler for PartitionMetric. +func (pm PartitionMetric) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if pm.Unit != "" { + objectMap["unit"] = pm.Unit + } + return json.Marshal(objectMap) +} + +// PartitionMetricListResult the response to a list partition metrics request. +type PartitionMetricListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; The list of partition-level metrics for the account. + Value *[]PartitionMetric `json:"value,omitempty"` +} + +// MarshalJSON is the custom marshaler for PartitionMetricListResult. +func (pmlr PartitionMetricListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// PartitionUsage the partition level usage data for a usage request. +type PartitionUsage struct { + // PartitionID - READ-ONLY; The partition id (GUID identifier) of the usages. + PartitionID *string `json:"partitionId,omitempty"` + // PartitionKeyRangeID - READ-ONLY; The partition key range id (integer identifier) of the usages. + PartitionKeyRangeID *string `json:"partitionKeyRangeId,omitempty"` + // Unit - The unit of the metric. Possible values include: 'UnitTypeCount', 'UnitTypeBytes', 'UnitTypeSeconds', 'UnitTypePercent', 'UnitTypeCountPerSecond', 'UnitTypeBytesPerSecond', 'UnitTypeMilliseconds' + Unit UnitType `json:"unit,omitempty"` + // Name - READ-ONLY; The name information for the metric. + Name *MetricName `json:"name,omitempty"` + // QuotaPeriod - READ-ONLY; The quota period used to summarize the usage values. + QuotaPeriod *string `json:"quotaPeriod,omitempty"` + // Limit - READ-ONLY; Maximum value for this metric + Limit *int64 `json:"limit,omitempty"` + // CurrentValue - READ-ONLY; Current value for this metric + CurrentValue *int64 `json:"currentValue,omitempty"` +} + +// MarshalJSON is the custom marshaler for PartitionUsage. +func (pu PartitionUsage) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if pu.Unit != "" { + objectMap["unit"] = pu.Unit + } + return json.Marshal(objectMap) +} + +// PartitionUsagesResult the response to a list partition level usage request. +type PartitionUsagesResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; The list of partition-level usages for the database. A usage is a point in time metric + Value *[]PartitionUsage `json:"value,omitempty"` +} + +// MarshalJSON is the custom marshaler for PartitionUsagesResult. +func (pur PartitionUsagesResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// PercentileMetric percentile Metric data +type PercentileMetric struct { + // StartTime - READ-ONLY; The start time for the metric (ISO-8601 format). + StartTime *date.Time `json:"startTime,omitempty"` + // EndTime - READ-ONLY; The end time for the metric (ISO-8601 format). + EndTime *date.Time `json:"endTime,omitempty"` + // TimeGrain - READ-ONLY; The time grain 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', 'UnitTypeMilliseconds' + Unit UnitType `json:"unit,omitempty"` + // Name - READ-ONLY; The name information for the metric. + Name *MetricName `json:"name,omitempty"` + // MetricValues - READ-ONLY; The percentile metric values for the specified time window and timestep. + MetricValues *[]PercentileMetricValue `json:"metricValues,omitempty"` +} + +// MarshalJSON is the custom marshaler for PercentileMetric. +func (pm PercentileMetric) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if pm.Unit != "" { + objectMap["unit"] = pm.Unit + } + return json.Marshal(objectMap) +} + +// PercentileMetricListResult the response to a list percentile metrics request. +type PercentileMetricListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; The list of percentile metrics for the account. + Value *[]PercentileMetric `json:"value,omitempty"` +} + +// MarshalJSON is the custom marshaler for PercentileMetricListResult. +func (pmlr PercentileMetricListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// PercentileMetricValue represents percentile metrics values. +type PercentileMetricValue struct { + // P10 - READ-ONLY; The 10th percentile value for the metric. + P10 *float64 `json:"P10,omitempty"` + // P25 - READ-ONLY; The 25th percentile value for the metric. + P25 *float64 `json:"P25,omitempty"` + // P50 - READ-ONLY; The 50th percentile value for the metric. + P50 *float64 `json:"P50,omitempty"` + // P75 - READ-ONLY; The 75th percentile value for the metric. + P75 *float64 `json:"P75,omitempty"` + // P90 - READ-ONLY; The 90th percentile value for the metric. + P90 *float64 `json:"P90,omitempty"` + // P95 - READ-ONLY; The 95th percentile value for the metric. + P95 *float64 `json:"P95,omitempty"` + // P99 - READ-ONLY; The 99th percentile value for the metric. + P99 *float64 `json:"P99,omitempty"` + // Count - READ-ONLY; The number of values for the metric. + Count *float64 `json:"_count,omitempty"` + // Average - READ-ONLY; The average value of the metric. + Average *float64 `json:"average,omitempty"` + // Maximum - READ-ONLY; The max value of the metric. + Maximum *float64 `json:"maximum,omitempty"` + // Minimum - READ-ONLY; The min value of the metric. + Minimum *float64 `json:"minimum,omitempty"` + // Timestamp - READ-ONLY; The metric timestamp (ISO-8601 format). + Timestamp *date.Time `json:"timestamp,omitempty"` + // Total - READ-ONLY; The total value of the metric. + Total *float64 `json:"total,omitempty"` +} + +// MarshalJSON is the custom marshaler for PercentileMetricValue. +func (pmv PercentileMetricValue) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// PeriodicModeBackupPolicy the object representing periodic mode backup policy. +type PeriodicModeBackupPolicy struct { + // PeriodicModeProperties - Configuration values for periodic mode backup + PeriodicModeProperties *PeriodicModeProperties `json:"periodicModeProperties,omitempty"` + // MigrationState - The object representing the state of the migration between the backup policies. + MigrationState *BackupPolicyMigrationState `json:"migrationState,omitempty"` + // Type - Possible values include: 'TypeBackupPolicy', 'TypePeriodic', 'TypeContinuous' + Type Type `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for PeriodicModeBackupPolicy. +func (pmbp PeriodicModeBackupPolicy) MarshalJSON() ([]byte, error) { + pmbp.Type = TypePeriodic + objectMap := make(map[string]interface{}) + if pmbp.PeriodicModeProperties != nil { + objectMap["periodicModeProperties"] = pmbp.PeriodicModeProperties + } + if pmbp.MigrationState != nil { + objectMap["migrationState"] = pmbp.MigrationState + } + if pmbp.Type != "" { + objectMap["type"] = pmbp.Type + } + return json.Marshal(objectMap) +} + +// AsPeriodicModeBackupPolicy is the BasicBackupPolicy implementation for PeriodicModeBackupPolicy. +func (pmbp PeriodicModeBackupPolicy) AsPeriodicModeBackupPolicy() (*PeriodicModeBackupPolicy, bool) { + return &pmbp, true +} + +// AsContinuousModeBackupPolicy is the BasicBackupPolicy implementation for PeriodicModeBackupPolicy. +func (pmbp PeriodicModeBackupPolicy) AsContinuousModeBackupPolicy() (*ContinuousModeBackupPolicy, bool) { + return nil, false +} + +// AsBackupPolicy is the BasicBackupPolicy implementation for PeriodicModeBackupPolicy. +func (pmbp PeriodicModeBackupPolicy) AsBackupPolicy() (*BackupPolicy, bool) { + return nil, false +} + +// AsBasicBackupPolicy is the BasicBackupPolicy implementation for PeriodicModeBackupPolicy. +func (pmbp PeriodicModeBackupPolicy) AsBasicBackupPolicy() (BasicBackupPolicy, bool) { + return &pmbp, true +} + +// PeriodicModeProperties configuration values for periodic mode backup +type PeriodicModeProperties struct { + // BackupIntervalInMinutes - An integer representing the interval in minutes between two backups + BackupIntervalInMinutes *int32 `json:"backupIntervalInMinutes,omitempty"` + // BackupRetentionIntervalInHours - An integer representing the time (in hours) that each backup is retained + BackupRetentionIntervalInHours *int32 `json:"backupRetentionIntervalInHours,omitempty"` +} + +// Permission the set of data plane operations permitted through this Role Definition. +type Permission struct { + // DataActions - An array of data actions that are allowed. + DataActions *[]string `json:"dataActions,omitempty"` + // NotDataActions - An array of data actions that are denied. + NotDataActions *[]string `json:"notDataActions,omitempty"` +} + +// PrivateEndpointConnection a private endpoint connection +type PrivateEndpointConnection struct { + autorest.Response `json:"-"` + // PrivateEndpointConnectionProperties - Resource properties. + *PrivateEndpointConnectionProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for PrivateEndpointConnection. +func (pec PrivateEndpointConnection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if pec.PrivateEndpointConnectionProperties != nil { + objectMap["properties"] = pec.PrivateEndpointConnectionProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for PrivateEndpointConnection struct. +func (pec *PrivateEndpointConnection) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var privateEndpointConnectionProperties PrivateEndpointConnectionProperties + err = json.Unmarshal(*v, &privateEndpointConnectionProperties) + if err != nil { + return err + } + pec.PrivateEndpointConnectionProperties = &privateEndpointConnectionProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + pec.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + pec.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + pec.Type = &typeVar + } + } + } + + return nil +} + +// PrivateEndpointConnectionListResult a list of private endpoint connections +type PrivateEndpointConnectionListResult struct { + autorest.Response `json:"-"` + // Value - Array of private endpoint connections + Value *[]PrivateEndpointConnection `json:"value,omitempty"` +} + +// PrivateEndpointConnectionProperties properties of a private endpoint connection. +type PrivateEndpointConnectionProperties struct { + // PrivateEndpoint - Private endpoint which the connection belongs to. + PrivateEndpoint *PrivateEndpointProperty `json:"privateEndpoint,omitempty"` + // PrivateLinkServiceConnectionState - Connection State of the Private Endpoint Connection. + PrivateLinkServiceConnectionState *PrivateLinkServiceConnectionStateProperty `json:"privateLinkServiceConnectionState,omitempty"` + // GroupID - Group id of the private endpoint. + GroupID *string `json:"groupId,omitempty"` + // ProvisioningState - Provisioning state of the private endpoint. + ProvisioningState *string `json:"provisioningState,omitempty"` +} + +// PrivateEndpointConnectionsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results +// of a long-running operation. +type PrivateEndpointConnectionsCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(PrivateEndpointConnectionsClient) (PrivateEndpointConnection, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *PrivateEndpointConnectionsCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for PrivateEndpointConnectionsCreateOrUpdateFuture.Result. +func (future *PrivateEndpointConnectionsCreateOrUpdateFuture) result(client PrivateEndpointConnectionsClient) (pec PrivateEndpointConnection, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.PrivateEndpointConnectionsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + pec.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("documentdb.PrivateEndpointConnectionsCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if pec.Response.Response, err = future.GetResult(sender); err == nil && pec.Response.Response.StatusCode != http.StatusNoContent { + pec, err = client.CreateOrUpdateResponder(pec.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.PrivateEndpointConnectionsCreateOrUpdateFuture", "Result", pec.Response.Response, "Failure responding to request") + } + } + return +} + +// PrivateEndpointConnectionsDeleteFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type PrivateEndpointConnectionsDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(PrivateEndpointConnectionsClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *PrivateEndpointConnectionsDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for PrivateEndpointConnectionsDeleteFuture.Result. +func (future *PrivateEndpointConnectionsDeleteFuture) result(client PrivateEndpointConnectionsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.PrivateEndpointConnectionsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("documentdb.PrivateEndpointConnectionsDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// PrivateEndpointProperty private endpoint which the connection belongs to. +type PrivateEndpointProperty struct { + // ID - Resource id of the private endpoint. + ID *string `json:"id,omitempty"` +} + +// PrivateLinkResource a private link resource +type PrivateLinkResource struct { + autorest.Response `json:"-"` + // PrivateLinkResourceProperties - Resource properties. + *PrivateLinkResourceProperties `json:"properties,omitempty"` + // ID - READ-ONLY; The unique resource identifier of the database account. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the database account. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of Azure resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for PrivateLinkResource. +func (plr PrivateLinkResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if plr.PrivateLinkResourceProperties != nil { + objectMap["properties"] = plr.PrivateLinkResourceProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for PrivateLinkResource struct. +func (plr *PrivateLinkResource) UnmarshalJSON(body []byte) error { + 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 privateLinkResourceProperties PrivateLinkResourceProperties + err = json.Unmarshal(*v, &privateLinkResourceProperties) + if err != nil { + return err + } + plr.PrivateLinkResourceProperties = &privateLinkResourceProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + plr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + plr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + plr.Type = &typeVar + } + } + } + + return nil +} + +// PrivateLinkResourceListResult a list of private link resources +type PrivateLinkResourceListResult struct { + autorest.Response `json:"-"` + // Value - Array of private link resources + Value *[]PrivateLinkResource `json:"value,omitempty"` +} + +// PrivateLinkResourceProperties properties of a private link resource. +type PrivateLinkResourceProperties struct { + // GroupID - READ-ONLY; The private link resource group id. + GroupID *string `json:"groupId,omitempty"` + // RequiredMembers - READ-ONLY; The private link resource required member names. + RequiredMembers *[]string `json:"requiredMembers,omitempty"` + // RequiredZoneNames - READ-ONLY; The private link resource required zone names. + RequiredZoneNames *[]string `json:"requiredZoneNames,omitempty"` +} + +// MarshalJSON is the custom marshaler for PrivateLinkResourceProperties. +func (plrp PrivateLinkResourceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// PrivateLinkServiceConnectionStateProperty connection State of the Private Endpoint Connection. +type PrivateLinkServiceConnectionStateProperty struct { + // Status - The private link service connection status. + Status *string `json:"status,omitempty"` + // Description - The private link service connection description. + Description *string `json:"description,omitempty"` + // ActionsRequired - READ-ONLY; Any action that is required beyond basic workflow (approve/ reject/ disconnect) + ActionsRequired *string `json:"actionsRequired,omitempty"` +} + +// MarshalJSON is the custom marshaler for PrivateLinkServiceConnectionStateProperty. +func (plscsp PrivateLinkServiceConnectionStateProperty) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if plscsp.Status != nil { + objectMap["status"] = plscsp.Status + } + if plscsp.Description != nil { + objectMap["description"] = plscsp.Description + } + return json.Marshal(objectMap) +} + +// ProxyResource the resource model definition for a Azure Resource Manager proxy resource. It will not +// have tags and a location +type ProxyResource struct { + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ProxyResource. +func (pr ProxyResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// RegionForOnlineOffline cosmos DB region to online or offline. +type RegionForOnlineOffline struct { + // Region - Cosmos DB region, with spaces between words and each word capitalized. + Region *string `json:"region,omitempty"` +} + +// Resource common fields that are returned in the response for all Azure Resource Manager resources +type Resource struct { + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Resource. +func (r Resource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// RestorableDatabaseAccountGetResult a Azure Cosmos DB restorable database account. +type RestorableDatabaseAccountGetResult struct { + autorest.Response `json:"-"` + // RestorableDatabaseAccountProperties - The properties of a restorable database account. + *RestorableDatabaseAccountProperties `json:"properties,omitempty"` + // ID - READ-ONLY; The unique resource identifier of the ARM resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the ARM resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of Azure resource. + Type *string `json:"type,omitempty"` + // Location - The location of the resource group to which the resource belongs. + Location *string `json:"location,omitempty"` +} + +// MarshalJSON is the custom marshaler for RestorableDatabaseAccountGetResult. +func (rdagr RestorableDatabaseAccountGetResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rdagr.RestorableDatabaseAccountProperties != nil { + objectMap["properties"] = rdagr.RestorableDatabaseAccountProperties + } + if rdagr.Location != nil { + objectMap["location"] = rdagr.Location + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for RestorableDatabaseAccountGetResult struct. +func (rdagr *RestorableDatabaseAccountGetResult) UnmarshalJSON(body []byte) error { + 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 restorableDatabaseAccountProperties RestorableDatabaseAccountProperties + err = json.Unmarshal(*v, &restorableDatabaseAccountProperties) + if err != nil { + return err + } + rdagr.RestorableDatabaseAccountProperties = &restorableDatabaseAccountProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + rdagr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + rdagr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + rdagr.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + rdagr.Location = &location + } + } + } + + return nil +} + +// RestorableDatabaseAccountProperties the properties of a restorable database account. +type RestorableDatabaseAccountProperties struct { + // AccountName - The name of the global database account + AccountName *string `json:"accountName,omitempty"` + // CreationTime - The creation time of the restorable database account (ISO-8601 format). + CreationTime *date.Time `json:"creationTime,omitempty"` + // DeletionTime - The time at which the restorable database account has been deleted (ISO-8601 format). + DeletionTime *date.Time `json:"deletionTime,omitempty"` + // APIType - READ-ONLY; The API type of the restorable database account. Possible values include: 'APITypeMongoDB', 'APITypeGremlin', 'APITypeCassandra', 'APITypeTable', 'APITypeSQL', 'APITypeGremlinV2' + APIType APIType `json:"apiType,omitempty"` + // RestorableLocations - READ-ONLY; List of regions where the of the database account can be restored from. + RestorableLocations *[]RestorableLocationResource `json:"restorableLocations,omitempty"` +} + +// MarshalJSON is the custom marshaler for RestorableDatabaseAccountProperties. +func (rdap RestorableDatabaseAccountProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rdap.AccountName != nil { + objectMap["accountName"] = rdap.AccountName + } + if rdap.CreationTime != nil { + objectMap["creationTime"] = rdap.CreationTime + } + if rdap.DeletionTime != nil { + objectMap["deletionTime"] = rdap.DeletionTime + } + return json.Marshal(objectMap) +} + +// RestorableDatabaseAccountsListResult the List operation response, that contains the restorable database +// accounts and their properties. +type RestorableDatabaseAccountsListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; List of restorable database accounts and their properties. + Value *[]RestorableDatabaseAccountGetResult `json:"value,omitempty"` +} + +// MarshalJSON is the custom marshaler for RestorableDatabaseAccountsListResult. +func (rdalr RestorableDatabaseAccountsListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// RestorableLocationResource properties of the regional restorable account. +type RestorableLocationResource struct { + // LocationName - READ-ONLY; The location of the regional restorable account. + LocationName *string `json:"locationName,omitempty"` + // RegionalDatabaseAccountInstanceID - READ-ONLY; The instance id of the regional restorable account. + RegionalDatabaseAccountInstanceID *string `json:"regionalDatabaseAccountInstanceId,omitempty"` + // CreationTime - READ-ONLY; The creation time of the regional restorable database account (ISO-8601 format). + CreationTime *date.Time `json:"creationTime,omitempty"` + // DeletionTime - READ-ONLY; The time at which the regional restorable database account has been deleted (ISO-8601 format). + DeletionTime *date.Time `json:"deletionTime,omitempty"` +} + +// MarshalJSON is the custom marshaler for RestorableLocationResource. +func (rlr RestorableLocationResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// RestorableMongodbCollectionGetResult an Azure Cosmos DB MongoDB collection event +type RestorableMongodbCollectionGetResult struct { + // RestorableMongodbCollectionProperties - The properties of a MongoDB collection event. + *RestorableMongodbCollectionProperties `json:"properties,omitempty"` + // ID - READ-ONLY; The unique resource Identifier of the ARM resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the ARM resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of Azure resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for RestorableMongodbCollectionGetResult. +func (rmcgr RestorableMongodbCollectionGetResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rmcgr.RestorableMongodbCollectionProperties != nil { + objectMap["properties"] = rmcgr.RestorableMongodbCollectionProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for RestorableMongodbCollectionGetResult struct. +func (rmcgr *RestorableMongodbCollectionGetResult) UnmarshalJSON(body []byte) error { + 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 restorableMongodbCollectionProperties RestorableMongodbCollectionProperties + err = json.Unmarshal(*v, &restorableMongodbCollectionProperties) + if err != nil { + return err + } + rmcgr.RestorableMongodbCollectionProperties = &restorableMongodbCollectionProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + rmcgr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + rmcgr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + rmcgr.Type = &typeVar + } + } + } + + return nil +} + +// RestorableMongodbCollectionProperties the properties of an Azure Cosmos DB MongoDB collection event +type RestorableMongodbCollectionProperties struct { + // Resource - The resource of an Azure Cosmos DB MongoDB collection event + Resource *RestorableMongodbCollectionPropertiesResource `json:"resource,omitempty"` +} + +// RestorableMongodbCollectionPropertiesResource the resource of an Azure Cosmos DB MongoDB collection +// event +type RestorableMongodbCollectionPropertiesResource struct { + // Rid - READ-ONLY; A system generated property. A unique identifier. + Rid *string `json:"_rid,omitempty"` + // OperationType - READ-ONLY; The operation type of this collection event. Possible values include: 'OperationTypeCreate', 'OperationTypeReplace', 'OperationTypeDelete', 'OperationTypeSystemOperation' + OperationType OperationType `json:"operationType,omitempty"` + // EventTimestamp - READ-ONLY; The time when this collection event happened. + EventTimestamp *string `json:"eventTimestamp,omitempty"` + // OwnerID - READ-ONLY; The name of this MongoDB collection. + OwnerID *string `json:"ownerId,omitempty"` + // OwnerResourceID - READ-ONLY; The resource ID of this MongoDB collection. + OwnerResourceID *string `json:"ownerResourceId,omitempty"` +} + +// MarshalJSON is the custom marshaler for RestorableMongodbCollectionPropertiesResource. +func (rmcp RestorableMongodbCollectionPropertiesResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// RestorableMongodbCollectionsListResult the List operation response, that contains the MongoDB collection +// events and their properties. +type RestorableMongodbCollectionsListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; List of MongoDB collection events and their properties. + Value *[]RestorableMongodbCollectionGetResult `json:"value,omitempty"` +} + +// MarshalJSON is the custom marshaler for RestorableMongodbCollectionsListResult. +func (rmclr RestorableMongodbCollectionsListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// RestorableMongodbDatabaseGetResult an Azure Cosmos DB MongoDB database event +type RestorableMongodbDatabaseGetResult struct { + // RestorableMongodbDatabaseProperties - The properties of a MongoDB database event. + *RestorableMongodbDatabaseProperties `json:"properties,omitempty"` + // ID - READ-ONLY; The unique resource Identifier of the ARM resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the ARM resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of Azure resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for RestorableMongodbDatabaseGetResult. +func (rmdgr RestorableMongodbDatabaseGetResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rmdgr.RestorableMongodbDatabaseProperties != nil { + objectMap["properties"] = rmdgr.RestorableMongodbDatabaseProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for RestorableMongodbDatabaseGetResult struct. +func (rmdgr *RestorableMongodbDatabaseGetResult) UnmarshalJSON(body []byte) error { + 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 restorableMongodbDatabaseProperties RestorableMongodbDatabaseProperties + err = json.Unmarshal(*v, &restorableMongodbDatabaseProperties) + if err != nil { + return err + } + rmdgr.RestorableMongodbDatabaseProperties = &restorableMongodbDatabaseProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + rmdgr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + rmdgr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + rmdgr.Type = &typeVar + } + } + } + + return nil +} + +// RestorableMongodbDatabaseProperties the properties of an Azure Cosmos DB MongoDB database event +type RestorableMongodbDatabaseProperties struct { + // Resource - The resource of an Azure Cosmos DB MongoDB database event + Resource *RestorableMongodbDatabasePropertiesResource `json:"resource,omitempty"` +} + +// RestorableMongodbDatabasePropertiesResource the resource of an Azure Cosmos DB MongoDB database event +type RestorableMongodbDatabasePropertiesResource struct { + // Rid - READ-ONLY; A system generated property. A unique identifier. + Rid *string `json:"_rid,omitempty"` + // OperationType - READ-ONLY; The operation type of this database event. Possible values include: 'OperationTypeCreate', 'OperationTypeReplace', 'OperationTypeDelete', 'OperationTypeSystemOperation' + OperationType OperationType `json:"operationType,omitempty"` + // EventTimestamp - READ-ONLY; The time when this database event happened. + EventTimestamp *string `json:"eventTimestamp,omitempty"` + // OwnerID - READ-ONLY; The name of this MongoDB database. + OwnerID *string `json:"ownerId,omitempty"` + // OwnerResourceID - READ-ONLY; The resource ID of this MongoDB database. + OwnerResourceID *string `json:"ownerResourceId,omitempty"` +} + +// MarshalJSON is the custom marshaler for RestorableMongodbDatabasePropertiesResource. +func (rmdp RestorableMongodbDatabasePropertiesResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// RestorableMongodbDatabasesListResult the List operation response, that contains the MongoDB database +// events and their properties. +type RestorableMongodbDatabasesListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; List of MongoDB database events and their properties. + Value *[]RestorableMongodbDatabaseGetResult `json:"value,omitempty"` +} + +// MarshalJSON is the custom marshaler for RestorableMongodbDatabasesListResult. +func (rmdlr RestorableMongodbDatabasesListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// RestorableMongodbResourcesListResult the List operation response, that contains the restorable MongoDB +// resources. +type RestorableMongodbResourcesListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; List of restorable MongoDB resources, including the database and collection names. + Value *[]DatabaseRestoreResource `json:"value,omitempty"` +} + +// MarshalJSON is the custom marshaler for RestorableMongodbResourcesListResult. +func (rmrlr RestorableMongodbResourcesListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// RestorableSQLContainerGetResult an Azure Cosmos DB SQL container event +type RestorableSQLContainerGetResult struct { + // RestorableSQLContainerProperties - The properties of a SQL container event. + *RestorableSQLContainerProperties `json:"properties,omitempty"` + // ID - READ-ONLY; The unique resource Identifier of the ARM resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the ARM resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of Azure resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for RestorableSQLContainerGetResult. +func (rscgr RestorableSQLContainerGetResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rscgr.RestorableSQLContainerProperties != nil { + objectMap["properties"] = rscgr.RestorableSQLContainerProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for RestorableSQLContainerGetResult struct. +func (rscgr *RestorableSQLContainerGetResult) UnmarshalJSON(body []byte) error { + 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 restorableSQLContainerProperties RestorableSQLContainerProperties + err = json.Unmarshal(*v, &restorableSQLContainerProperties) + if err != nil { + return err + } + rscgr.RestorableSQLContainerProperties = &restorableSQLContainerProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + rscgr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + rscgr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + rscgr.Type = &typeVar + } + } + } + + return nil +} + +// RestorableSQLContainerProperties the properties of an Azure Cosmos DB SQL container event +type RestorableSQLContainerProperties struct { + // Resource - The resource of an Azure Cosmos DB SQL container event + Resource *RestorableSQLContainerPropertiesResource `json:"resource,omitempty"` +} + +// RestorableSQLContainerPropertiesResource the resource of an Azure Cosmos DB SQL container event +type RestorableSQLContainerPropertiesResource struct { + // Rid - READ-ONLY; A system generated property. A unique identifier. + Rid *string `json:"_rid,omitempty"` + // OperationType - READ-ONLY; The operation type of this container event. Possible values include: 'OperationTypeCreate', 'OperationTypeReplace', 'OperationTypeDelete', 'OperationTypeSystemOperation' + OperationType OperationType `json:"operationType,omitempty"` + // EventTimestamp - READ-ONLY; The when this container event happened. + EventTimestamp *string `json:"eventTimestamp,omitempty"` + // OwnerID - READ-ONLY; The name of this SQL container. + OwnerID *string `json:"ownerId,omitempty"` + // OwnerResourceID - READ-ONLY; The resource ID of this SQL container. + OwnerResourceID *string `json:"ownerResourceId,omitempty"` + // Container - Cosmos DB SQL container resource object + Container *RestorableSQLContainerPropertiesResourceContainer `json:"container,omitempty"` +} + +// MarshalJSON is the custom marshaler for RestorableSQLContainerPropertiesResource. +func (rscp RestorableSQLContainerPropertiesResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rscp.Container != nil { + objectMap["container"] = rscp.Container + } + return json.Marshal(objectMap) +} + +// RestorableSQLContainerPropertiesResourceContainer cosmos DB SQL container resource object +type RestorableSQLContainerPropertiesResourceContainer struct { + // ID - Name of the Cosmos DB SQL container + ID *string `json:"id,omitempty"` + // IndexingPolicy - The configuration of the indexing policy. By default, the indexing is automatic for all document paths within the container + IndexingPolicy *IndexingPolicy `json:"indexingPolicy,omitempty"` + // PartitionKey - The configuration of the partition key to be used for partitioning data into multiple partitions + PartitionKey *ContainerPartitionKey `json:"partitionKey,omitempty"` + // DefaultTTL - Default time to live + DefaultTTL *int32 `json:"defaultTtl,omitempty"` + // UniqueKeyPolicy - The unique key policy configuration for specifying uniqueness constraints on documents in the collection in the Azure Cosmos DB service. + UniqueKeyPolicy *UniqueKeyPolicy `json:"uniqueKeyPolicy,omitempty"` + // ConflictResolutionPolicy - The conflict resolution policy for the container. + ConflictResolutionPolicy *ConflictResolutionPolicy `json:"conflictResolutionPolicy,omitempty"` + // AnalyticalStorageTTL - Analytical TTL. + AnalyticalStorageTTL *int64 `json:"analyticalStorageTtl,omitempty"` + // Rid - READ-ONLY; A system generated property. A unique identifier. + Rid *string `json:"_rid,omitempty"` + // Ts - READ-ONLY; A system generated property that denotes the last updated timestamp of the resource. + Ts *float64 `json:"_ts,omitempty"` + // Etag - READ-ONLY; A system generated property representing the resource etag required for optimistic concurrency control. + Etag *string `json:"_etag,omitempty"` + // Self - READ-ONLY; A system generated property that specifies the addressable path of the container resource. + Self *string `json:"_self,omitempty"` +} + +// MarshalJSON is the custom marshaler for RestorableSQLContainerPropertiesResourceContainer. +func (rscp RestorableSQLContainerPropertiesResourceContainer) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rscp.ID != nil { + objectMap["id"] = rscp.ID + } + if rscp.IndexingPolicy != nil { + objectMap["indexingPolicy"] = rscp.IndexingPolicy + } + if rscp.PartitionKey != nil { + objectMap["partitionKey"] = rscp.PartitionKey + } + if rscp.DefaultTTL != nil { + objectMap["defaultTtl"] = rscp.DefaultTTL + } + if rscp.UniqueKeyPolicy != nil { + objectMap["uniqueKeyPolicy"] = rscp.UniqueKeyPolicy + } + if rscp.ConflictResolutionPolicy != nil { + objectMap["conflictResolutionPolicy"] = rscp.ConflictResolutionPolicy + } + if rscp.AnalyticalStorageTTL != nil { + objectMap["analyticalStorageTtl"] = rscp.AnalyticalStorageTTL + } + return json.Marshal(objectMap) +} + +// RestorableSQLContainersListResult the List operation response, that contains the SQL container events +// and their properties. +type RestorableSQLContainersListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; List of SQL container events and their properties. + Value *[]RestorableSQLContainerGetResult `json:"value,omitempty"` +} + +// MarshalJSON is the custom marshaler for RestorableSQLContainersListResult. +func (rsclr RestorableSQLContainersListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// RestorableSQLDatabaseGetResult an Azure Cosmos DB SQL database event +type RestorableSQLDatabaseGetResult struct { + // RestorableSQLDatabaseProperties - The properties of a SQL database event. + *RestorableSQLDatabaseProperties `json:"properties,omitempty"` + // ID - READ-ONLY; The unique resource Identifier of the ARM resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the ARM resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of Azure resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for RestorableSQLDatabaseGetResult. +func (rsdgr RestorableSQLDatabaseGetResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rsdgr.RestorableSQLDatabaseProperties != nil { + objectMap["properties"] = rsdgr.RestorableSQLDatabaseProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for RestorableSQLDatabaseGetResult struct. +func (rsdgr *RestorableSQLDatabaseGetResult) UnmarshalJSON(body []byte) error { + 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 restorableSQLDatabaseProperties RestorableSQLDatabaseProperties + err = json.Unmarshal(*v, &restorableSQLDatabaseProperties) + if err != nil { + return err + } + rsdgr.RestorableSQLDatabaseProperties = &restorableSQLDatabaseProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + rsdgr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + rsdgr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + rsdgr.Type = &typeVar + } + } + } + + return nil +} + +// RestorableSQLDatabaseProperties the properties of an Azure Cosmos DB SQL database event +type RestorableSQLDatabaseProperties struct { + // Resource - The resource of an Azure Cosmos DB SQL database event + Resource *RestorableSQLDatabasePropertiesResource `json:"resource,omitempty"` +} + +// RestorableSQLDatabasePropertiesResource the resource of an Azure Cosmos DB SQL database event +type RestorableSQLDatabasePropertiesResource struct { + // Rid - READ-ONLY; A system generated property. A unique identifier. + Rid *string `json:"_rid,omitempty"` + // OperationType - READ-ONLY; The operation type of this database event. Possible values include: 'OperationTypeCreate', 'OperationTypeReplace', 'OperationTypeDelete', 'OperationTypeSystemOperation' + OperationType OperationType `json:"operationType,omitempty"` + // EventTimestamp - READ-ONLY; The time when this database event happened. + EventTimestamp *string `json:"eventTimestamp,omitempty"` + // OwnerID - READ-ONLY; The name of the SQL database. + OwnerID *string `json:"ownerId,omitempty"` + // OwnerResourceID - READ-ONLY; The resource ID of the SQL database. + OwnerResourceID *string `json:"ownerResourceId,omitempty"` + // Database - Cosmos DB SQL database resource object + Database *RestorableSQLDatabasePropertiesResourceDatabase `json:"database,omitempty"` +} + +// MarshalJSON is the custom marshaler for RestorableSQLDatabasePropertiesResource. +func (rsdp RestorableSQLDatabasePropertiesResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rsdp.Database != nil { + objectMap["database"] = rsdp.Database + } + return json.Marshal(objectMap) +} + +// RestorableSQLDatabasePropertiesResourceDatabase cosmos DB SQL database resource object +type RestorableSQLDatabasePropertiesResourceDatabase struct { + // ID - Name of the Cosmos DB SQL database + ID *string `json:"id,omitempty"` + // Rid - READ-ONLY; A system generated property. A unique identifier. + Rid *string `json:"_rid,omitempty"` + // Ts - READ-ONLY; A system generated property that denotes the last updated timestamp of the resource. + Ts *float64 `json:"_ts,omitempty"` + // Etag - READ-ONLY; A system generated property representing the resource etag required for optimistic concurrency control. + Etag *string `json:"_etag,omitempty"` + // Colls - READ-ONLY; A system generated property that specified the addressable path of the collections resource. + Colls *string `json:"_colls,omitempty"` + // Users - READ-ONLY; A system generated property that specifies the addressable path of the users resource. + Users *string `json:"_users,omitempty"` + // Self - READ-ONLY; A system generated property that specifies the addressable path of the database resource. + Self *string `json:"_self,omitempty"` +} + +// MarshalJSON is the custom marshaler for RestorableSQLDatabasePropertiesResourceDatabase. +func (rsdp RestorableSQLDatabasePropertiesResourceDatabase) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rsdp.ID != nil { + objectMap["id"] = rsdp.ID + } + return json.Marshal(objectMap) +} + +// RestorableSQLDatabasesListResult the List operation response, that contains the SQL database events and +// their properties. +type RestorableSQLDatabasesListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; List of SQL database events and their properties. + Value *[]RestorableSQLDatabaseGetResult `json:"value,omitempty"` +} + +// MarshalJSON is the custom marshaler for RestorableSQLDatabasesListResult. +func (rsdlr RestorableSQLDatabasesListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// RestorableSQLResourcesListResult the List operation response, that contains the restorable SQL +// resources. +type RestorableSQLResourcesListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; List of restorable SQL resources, including the database and collection names. + Value *[]DatabaseRestoreResource `json:"value,omitempty"` +} + +// MarshalJSON is the custom marshaler for RestorableSQLResourcesListResult. +func (rsrlr RestorableSQLResourcesListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// RestoreParameters parameters to indicate the information about the restore. +type RestoreParameters struct { + // RestoreMode - Describes the mode of the restore. Possible values include: 'RestoreModePointInTime' + RestoreMode RestoreMode `json:"restoreMode,omitempty"` + // RestoreSource - The id of the restorable database account from which the restore has to be initiated. For example: /subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{restorableDatabaseAccountName} + RestoreSource *string `json:"restoreSource,omitempty"` + // RestoreTimestampInUtc - Time to which the account has to be restored (ISO-8601 format). + RestoreTimestampInUtc *date.Time `json:"restoreTimestampInUtc,omitempty"` + // DatabasesToRestore - List of specific databases available for restore. + DatabasesToRestore *[]DatabaseRestoreResource `json:"databasesToRestore,omitempty"` +} + +// SpatialSpec ... +type SpatialSpec struct { + // Path - The path for which the indexing behavior applies to. Index paths typically start with root and end with wildcard (/path/*) + Path *string `json:"path,omitempty"` + // Types - List of path's spatial type + Types *[]SpatialType `json:"types,omitempty"` +} + +// SQLContainerCreateUpdateParameters parameters to create and update Cosmos DB container. +type SQLContainerCreateUpdateParameters struct { + // SQLContainerCreateUpdateProperties - Properties to create and update Azure Cosmos DB container. + *SQLContainerCreateUpdateProperties `json:"properties,omitempty"` + // ID - READ-ONLY; The unique resource identifier of the ARM resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the ARM resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of Azure resource. + Type *string `json:"type,omitempty"` + // Location - The location of the resource group to which the resource belongs. + Location *string `json:"location,omitempty"` + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for SQLContainerCreateUpdateParameters. +func (sccup SQLContainerCreateUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sccup.SQLContainerCreateUpdateProperties != nil { + objectMap["properties"] = sccup.SQLContainerCreateUpdateProperties + } + if sccup.Location != nil { + objectMap["location"] = sccup.Location + } + if sccup.Tags != nil { + objectMap["tags"] = sccup.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for SQLContainerCreateUpdateParameters struct. +func (sccup *SQLContainerCreateUpdateParameters) UnmarshalJSON(body []byte) error { + 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 SQLContainerCreateUpdateProperties SQLContainerCreateUpdateProperties + err = json.Unmarshal(*v, &SQLContainerCreateUpdateProperties) + if err != nil { + return err + } + sccup.SQLContainerCreateUpdateProperties = &SQLContainerCreateUpdateProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + sccup.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + sccup.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + sccup.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + sccup.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + sccup.Tags = tags + } + } + } + + return nil +} + +// SQLContainerCreateUpdateProperties properties to create and update Azure Cosmos DB container. +type SQLContainerCreateUpdateProperties struct { + // Resource - The standard JSON format of a container + Resource *SQLContainerResource `json:"resource,omitempty"` + // Options - A key-value pair of options to be applied for the request. This corresponds to the headers sent with the request. + Options *CreateUpdateOptions `json:"options,omitempty"` +} + +// SQLContainerGetProperties the properties of an Azure Cosmos DB container +type SQLContainerGetProperties struct { + Resource *SQLContainerGetPropertiesResource `json:"resource,omitempty"` + Options *SQLContainerGetPropertiesOptions `json:"options,omitempty"` +} + +// SQLContainerGetPropertiesOptions ... +type SQLContainerGetPropertiesOptions struct { + // Throughput - Value of the Cosmos DB resource throughput or autoscaleSettings. Use the ThroughputSetting resource when retrieving offer details. + Throughput *int32 `json:"throughput,omitempty"` + // AutoscaleSettings - Specifies the Autoscale settings. + AutoscaleSettings *AutoscaleSettings `json:"autoscaleSettings,omitempty"` +} + +// SQLContainerGetPropertiesResource ... +type SQLContainerGetPropertiesResource struct { + // ID - Name of the Cosmos DB SQL container + ID *string `json:"id,omitempty"` + // IndexingPolicy - The configuration of the indexing policy. By default, the indexing is automatic for all document paths within the container + IndexingPolicy *IndexingPolicy `json:"indexingPolicy,omitempty"` + // PartitionKey - The configuration of the partition key to be used for partitioning data into multiple partitions + PartitionKey *ContainerPartitionKey `json:"partitionKey,omitempty"` + // DefaultTTL - Default time to live + DefaultTTL *int32 `json:"defaultTtl,omitempty"` + // UniqueKeyPolicy - The unique key policy configuration for specifying uniqueness constraints on documents in the collection in the Azure Cosmos DB service. + UniqueKeyPolicy *UniqueKeyPolicy `json:"uniqueKeyPolicy,omitempty"` + // ConflictResolutionPolicy - The conflict resolution policy for the container. + ConflictResolutionPolicy *ConflictResolutionPolicy `json:"conflictResolutionPolicy,omitempty"` + // AnalyticalStorageTTL - Analytical TTL. + AnalyticalStorageTTL *int64 `json:"analyticalStorageTtl,omitempty"` + // Rid - READ-ONLY; A system generated property. A unique identifier. + Rid *string `json:"_rid,omitempty"` + // Ts - READ-ONLY; A system generated property that denotes the last updated timestamp of the resource. + Ts *float64 `json:"_ts,omitempty"` + // Etag - READ-ONLY; A system generated property representing the resource etag required for optimistic concurrency control. + Etag *string `json:"_etag,omitempty"` +} + +// MarshalJSON is the custom marshaler for SQLContainerGetPropertiesResource. +func (scgp SQLContainerGetPropertiesResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if scgp.ID != nil { + objectMap["id"] = scgp.ID + } + if scgp.IndexingPolicy != nil { + objectMap["indexingPolicy"] = scgp.IndexingPolicy + } + if scgp.PartitionKey != nil { + objectMap["partitionKey"] = scgp.PartitionKey + } + if scgp.DefaultTTL != nil { + objectMap["defaultTtl"] = scgp.DefaultTTL + } + if scgp.UniqueKeyPolicy != nil { + objectMap["uniqueKeyPolicy"] = scgp.UniqueKeyPolicy + } + if scgp.ConflictResolutionPolicy != nil { + objectMap["conflictResolutionPolicy"] = scgp.ConflictResolutionPolicy + } + if scgp.AnalyticalStorageTTL != nil { + objectMap["analyticalStorageTtl"] = scgp.AnalyticalStorageTTL + } + return json.Marshal(objectMap) +} + +// SQLContainerGetResults an Azure Cosmos DB container. +type SQLContainerGetResults struct { + autorest.Response `json:"-"` + // SQLContainerGetProperties - The properties of an Azure Cosmos DB container + *SQLContainerGetProperties `json:"properties,omitempty"` + // ID - READ-ONLY; The unique resource identifier of the ARM resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the ARM resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of Azure resource. + Type *string `json:"type,omitempty"` + // Location - The location of the resource group to which the resource belongs. + Location *string `json:"location,omitempty"` + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for SQLContainerGetResults. +func (scgr SQLContainerGetResults) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if scgr.SQLContainerGetProperties != nil { + objectMap["properties"] = scgr.SQLContainerGetProperties + } + if scgr.Location != nil { + objectMap["location"] = scgr.Location + } + if scgr.Tags != nil { + objectMap["tags"] = scgr.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for SQLContainerGetResults struct. +func (scgr *SQLContainerGetResults) UnmarshalJSON(body []byte) error { + 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 SQLContainerGetProperties SQLContainerGetProperties + err = json.Unmarshal(*v, &SQLContainerGetProperties) + if err != nil { + return err + } + scgr.SQLContainerGetProperties = &SQLContainerGetProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + scgr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + scgr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + scgr.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + scgr.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + scgr.Tags = tags + } + } + } + + return nil +} + +// SQLContainerListResult the List operation response, that contains the containers and their properties. +type SQLContainerListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; List of containers and their properties. + Value *[]SQLContainerGetResults `json:"value,omitempty"` +} + +// MarshalJSON is the custom marshaler for SQLContainerListResult. +func (sclr SQLContainerListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// SQLContainerResource cosmos DB SQL container resource object +type SQLContainerResource struct { + // ID - Name of the Cosmos DB SQL container + ID *string `json:"id,omitempty"` + // IndexingPolicy - The configuration of the indexing policy. By default, the indexing is automatic for all document paths within the container + IndexingPolicy *IndexingPolicy `json:"indexingPolicy,omitempty"` + // PartitionKey - The configuration of the partition key to be used for partitioning data into multiple partitions + PartitionKey *ContainerPartitionKey `json:"partitionKey,omitempty"` + // DefaultTTL - Default time to live + DefaultTTL *int32 `json:"defaultTtl,omitempty"` + // UniqueKeyPolicy - The unique key policy configuration for specifying uniqueness constraints on documents in the collection in the Azure Cosmos DB service. + UniqueKeyPolicy *UniqueKeyPolicy `json:"uniqueKeyPolicy,omitempty"` + // ConflictResolutionPolicy - The conflict resolution policy for the container. + ConflictResolutionPolicy *ConflictResolutionPolicy `json:"conflictResolutionPolicy,omitempty"` + // AnalyticalStorageTTL - Analytical TTL. + AnalyticalStorageTTL *int64 `json:"analyticalStorageTtl,omitempty"` +} + +// SQLDatabaseCreateUpdateParameters parameters to create and update Cosmos DB SQL database. +type SQLDatabaseCreateUpdateParameters struct { + // SQLDatabaseCreateUpdateProperties - Properties to create and update Azure Cosmos DB SQL database. + *SQLDatabaseCreateUpdateProperties `json:"properties,omitempty"` + // ID - READ-ONLY; The unique resource identifier of the ARM resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the ARM resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of Azure resource. + Type *string `json:"type,omitempty"` + // Location - The location of the resource group to which the resource belongs. + Location *string `json:"location,omitempty"` + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for SQLDatabaseCreateUpdateParameters. +func (sdcup SQLDatabaseCreateUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sdcup.SQLDatabaseCreateUpdateProperties != nil { + objectMap["properties"] = sdcup.SQLDatabaseCreateUpdateProperties + } + if sdcup.Location != nil { + objectMap["location"] = sdcup.Location + } + if sdcup.Tags != nil { + objectMap["tags"] = sdcup.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for SQLDatabaseCreateUpdateParameters struct. +func (sdcup *SQLDatabaseCreateUpdateParameters) UnmarshalJSON(body []byte) error { + 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 SQLDatabaseCreateUpdateProperties SQLDatabaseCreateUpdateProperties + err = json.Unmarshal(*v, &SQLDatabaseCreateUpdateProperties) + if err != nil { + return err + } + sdcup.SQLDatabaseCreateUpdateProperties = &SQLDatabaseCreateUpdateProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + sdcup.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + sdcup.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + sdcup.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + sdcup.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + sdcup.Tags = tags + } + } + } + + return nil +} + +// SQLDatabaseCreateUpdateProperties properties to create and update Azure Cosmos DB SQL database. +type SQLDatabaseCreateUpdateProperties struct { + // Resource - The standard JSON format of a SQL database + Resource *SQLDatabaseResource `json:"resource,omitempty"` + // Options - A key-value pair of options to be applied for the request. This corresponds to the headers sent with the request. + Options *CreateUpdateOptions `json:"options,omitempty"` +} + +// SQLDatabaseGetProperties the properties of an Azure Cosmos DB SQL database +type SQLDatabaseGetProperties struct { + Resource *SQLDatabaseGetPropertiesResource `json:"resource,omitempty"` + Options *SQLDatabaseGetPropertiesOptions `json:"options,omitempty"` +} + +// SQLDatabaseGetPropertiesOptions ... +type SQLDatabaseGetPropertiesOptions struct { + // Throughput - Value of the Cosmos DB resource throughput or autoscaleSettings. Use the ThroughputSetting resource when retrieving offer details. + Throughput *int32 `json:"throughput,omitempty"` + // AutoscaleSettings - Specifies the Autoscale settings. + AutoscaleSettings *AutoscaleSettings `json:"autoscaleSettings,omitempty"` +} + +// SQLDatabaseGetPropertiesResource ... +type SQLDatabaseGetPropertiesResource struct { + // ID - Name of the Cosmos DB SQL database + ID *string `json:"id,omitempty"` + // Rid - READ-ONLY; A system generated property. A unique identifier. + Rid *string `json:"_rid,omitempty"` + // Ts - READ-ONLY; A system generated property that denotes the last updated timestamp of the resource. + Ts *float64 `json:"_ts,omitempty"` + // Etag - READ-ONLY; A system generated property representing the resource etag required for optimistic concurrency control. + Etag *string `json:"_etag,omitempty"` + // Colls - A system generated property that specified the addressable path of the collections resource. + Colls *string `json:"_colls,omitempty"` + // Users - A system generated property that specifies the addressable path of the users resource. + Users *string `json:"_users,omitempty"` +} + +// MarshalJSON is the custom marshaler for SQLDatabaseGetPropertiesResource. +func (sdgp SQLDatabaseGetPropertiesResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sdgp.ID != nil { + objectMap["id"] = sdgp.ID + } + if sdgp.Colls != nil { + objectMap["_colls"] = sdgp.Colls + } + if sdgp.Users != nil { + objectMap["_users"] = sdgp.Users + } + return json.Marshal(objectMap) +} + +// SQLDatabaseGetResults an Azure Cosmos DB SQL database. +type SQLDatabaseGetResults struct { + autorest.Response `json:"-"` + // SQLDatabaseGetProperties - The properties of an Azure Cosmos DB SQL database + *SQLDatabaseGetProperties `json:"properties,omitempty"` + // ID - READ-ONLY; The unique resource identifier of the ARM resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the ARM resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of Azure resource. + Type *string `json:"type,omitempty"` + // Location - The location of the resource group to which the resource belongs. + Location *string `json:"location,omitempty"` + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for SQLDatabaseGetResults. +func (sdgr SQLDatabaseGetResults) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sdgr.SQLDatabaseGetProperties != nil { + objectMap["properties"] = sdgr.SQLDatabaseGetProperties + } + if sdgr.Location != nil { + objectMap["location"] = sdgr.Location + } + if sdgr.Tags != nil { + objectMap["tags"] = sdgr.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for SQLDatabaseGetResults struct. +func (sdgr *SQLDatabaseGetResults) UnmarshalJSON(body []byte) error { + 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 SQLDatabaseGetProperties SQLDatabaseGetProperties + err = json.Unmarshal(*v, &SQLDatabaseGetProperties) + if err != nil { + return err + } + sdgr.SQLDatabaseGetProperties = &SQLDatabaseGetProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + sdgr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + sdgr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + sdgr.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + sdgr.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + sdgr.Tags = tags + } + } + } + + return nil +} + +// SQLDatabaseListResult the List operation response, that contains the SQL databases and their properties. +type SQLDatabaseListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; List of SQL databases and their properties. + Value *[]SQLDatabaseGetResults `json:"value,omitempty"` +} + +// MarshalJSON is the custom marshaler for SQLDatabaseListResult. +func (sdlr SQLDatabaseListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// SQLDatabaseResource cosmos DB SQL database resource object +type SQLDatabaseResource struct { + // ID - Name of the Cosmos DB SQL database + ID *string `json:"id,omitempty"` +} + +// SQLResourcesCreateUpdateSQLContainerFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type SQLResourcesCreateUpdateSQLContainerFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(SQLResourcesClient) (SQLContainerGetResults, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *SQLResourcesCreateUpdateSQLContainerFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for SQLResourcesCreateUpdateSQLContainerFuture.Result. +func (future *SQLResourcesCreateUpdateSQLContainerFuture) result(client SQLResourcesClient) (scgr SQLContainerGetResults, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesCreateUpdateSQLContainerFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + scgr.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("documentdb.SQLResourcesCreateUpdateSQLContainerFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if scgr.Response.Response, err = future.GetResult(sender); err == nil && scgr.Response.Response.StatusCode != http.StatusNoContent { + scgr, err = client.CreateUpdateSQLContainerResponder(scgr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesCreateUpdateSQLContainerFuture", "Result", scgr.Response.Response, "Failure responding to request") + } + } + return +} + +// SQLResourcesCreateUpdateSQLDatabaseFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type SQLResourcesCreateUpdateSQLDatabaseFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(SQLResourcesClient) (SQLDatabaseGetResults, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *SQLResourcesCreateUpdateSQLDatabaseFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for SQLResourcesCreateUpdateSQLDatabaseFuture.Result. +func (future *SQLResourcesCreateUpdateSQLDatabaseFuture) result(client SQLResourcesClient) (sdgr SQLDatabaseGetResults, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesCreateUpdateSQLDatabaseFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + sdgr.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("documentdb.SQLResourcesCreateUpdateSQLDatabaseFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if sdgr.Response.Response, err = future.GetResult(sender); err == nil && sdgr.Response.Response.StatusCode != http.StatusNoContent { + sdgr, err = client.CreateUpdateSQLDatabaseResponder(sdgr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesCreateUpdateSQLDatabaseFuture", "Result", sdgr.Response.Response, "Failure responding to request") + } + } + return +} + +// SQLResourcesCreateUpdateSQLRoleAssignmentFuture an abstraction for monitoring and retrieving the results +// of a long-running operation. +type SQLResourcesCreateUpdateSQLRoleAssignmentFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(SQLResourcesClient) (SQLRoleAssignmentGetResults, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *SQLResourcesCreateUpdateSQLRoleAssignmentFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for SQLResourcesCreateUpdateSQLRoleAssignmentFuture.Result. +func (future *SQLResourcesCreateUpdateSQLRoleAssignmentFuture) result(client SQLResourcesClient) (sragr SQLRoleAssignmentGetResults, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesCreateUpdateSQLRoleAssignmentFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + sragr.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("documentdb.SQLResourcesCreateUpdateSQLRoleAssignmentFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if sragr.Response.Response, err = future.GetResult(sender); err == nil && sragr.Response.Response.StatusCode != http.StatusNoContent { + sragr, err = client.CreateUpdateSQLRoleAssignmentResponder(sragr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesCreateUpdateSQLRoleAssignmentFuture", "Result", sragr.Response.Response, "Failure responding to request") + } + } + return +} + +// SQLResourcesCreateUpdateSQLRoleDefinitionFuture an abstraction for monitoring and retrieving the results +// of a long-running operation. +type SQLResourcesCreateUpdateSQLRoleDefinitionFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(SQLResourcesClient) (SQLRoleDefinitionGetResults, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *SQLResourcesCreateUpdateSQLRoleDefinitionFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for SQLResourcesCreateUpdateSQLRoleDefinitionFuture.Result. +func (future *SQLResourcesCreateUpdateSQLRoleDefinitionFuture) result(client SQLResourcesClient) (srdgr SQLRoleDefinitionGetResults, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesCreateUpdateSQLRoleDefinitionFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + srdgr.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("documentdb.SQLResourcesCreateUpdateSQLRoleDefinitionFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if srdgr.Response.Response, err = future.GetResult(sender); err == nil && srdgr.Response.Response.StatusCode != http.StatusNoContent { + srdgr, err = client.CreateUpdateSQLRoleDefinitionResponder(srdgr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesCreateUpdateSQLRoleDefinitionFuture", "Result", srdgr.Response.Response, "Failure responding to request") + } + } + return +} + +// SQLResourcesCreateUpdateSQLStoredProcedureFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type SQLResourcesCreateUpdateSQLStoredProcedureFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(SQLResourcesClient) (SQLStoredProcedureGetResults, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *SQLResourcesCreateUpdateSQLStoredProcedureFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for SQLResourcesCreateUpdateSQLStoredProcedureFuture.Result. +func (future *SQLResourcesCreateUpdateSQLStoredProcedureFuture) result(client SQLResourcesClient) (sspgr SQLStoredProcedureGetResults, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesCreateUpdateSQLStoredProcedureFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + sspgr.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("documentdb.SQLResourcesCreateUpdateSQLStoredProcedureFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if sspgr.Response.Response, err = future.GetResult(sender); err == nil && sspgr.Response.Response.StatusCode != http.StatusNoContent { + sspgr, err = client.CreateUpdateSQLStoredProcedureResponder(sspgr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesCreateUpdateSQLStoredProcedureFuture", "Result", sspgr.Response.Response, "Failure responding to request") + } + } + return +} + +// SQLResourcesCreateUpdateSQLTriggerFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type SQLResourcesCreateUpdateSQLTriggerFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(SQLResourcesClient) (SQLTriggerGetResults, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *SQLResourcesCreateUpdateSQLTriggerFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for SQLResourcesCreateUpdateSQLTriggerFuture.Result. +func (future *SQLResourcesCreateUpdateSQLTriggerFuture) result(client SQLResourcesClient) (stgr SQLTriggerGetResults, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesCreateUpdateSQLTriggerFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + stgr.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("documentdb.SQLResourcesCreateUpdateSQLTriggerFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if stgr.Response.Response, err = future.GetResult(sender); err == nil && stgr.Response.Response.StatusCode != http.StatusNoContent { + stgr, err = client.CreateUpdateSQLTriggerResponder(stgr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesCreateUpdateSQLTriggerFuture", "Result", stgr.Response.Response, "Failure responding to request") + } + } + return +} + +// SQLResourcesCreateUpdateSQLUserDefinedFunctionFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type SQLResourcesCreateUpdateSQLUserDefinedFunctionFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(SQLResourcesClient) (SQLUserDefinedFunctionGetResults, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *SQLResourcesCreateUpdateSQLUserDefinedFunctionFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for SQLResourcesCreateUpdateSQLUserDefinedFunctionFuture.Result. +func (future *SQLResourcesCreateUpdateSQLUserDefinedFunctionFuture) result(client SQLResourcesClient) (sudfgr SQLUserDefinedFunctionGetResults, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesCreateUpdateSQLUserDefinedFunctionFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + sudfgr.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("documentdb.SQLResourcesCreateUpdateSQLUserDefinedFunctionFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if sudfgr.Response.Response, err = future.GetResult(sender); err == nil && sudfgr.Response.Response.StatusCode != http.StatusNoContent { + sudfgr, err = client.CreateUpdateSQLUserDefinedFunctionResponder(sudfgr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesCreateUpdateSQLUserDefinedFunctionFuture", "Result", sudfgr.Response.Response, "Failure responding to request") + } + } + return +} + +// SQLResourcesDeleteSQLContainerFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type SQLResourcesDeleteSQLContainerFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(SQLResourcesClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *SQLResourcesDeleteSQLContainerFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for SQLResourcesDeleteSQLContainerFuture.Result. +func (future *SQLResourcesDeleteSQLContainerFuture) result(client SQLResourcesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesDeleteSQLContainerFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("documentdb.SQLResourcesDeleteSQLContainerFuture") + return + } + ar.Response = future.Response() + return +} + +// SQLResourcesDeleteSQLDatabaseFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type SQLResourcesDeleteSQLDatabaseFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(SQLResourcesClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *SQLResourcesDeleteSQLDatabaseFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for SQLResourcesDeleteSQLDatabaseFuture.Result. +func (future *SQLResourcesDeleteSQLDatabaseFuture) result(client SQLResourcesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesDeleteSQLDatabaseFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("documentdb.SQLResourcesDeleteSQLDatabaseFuture") + return + } + ar.Response = future.Response() + return +} + +// SQLResourcesDeleteSQLRoleAssignmentFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type SQLResourcesDeleteSQLRoleAssignmentFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(SQLResourcesClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *SQLResourcesDeleteSQLRoleAssignmentFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for SQLResourcesDeleteSQLRoleAssignmentFuture.Result. +func (future *SQLResourcesDeleteSQLRoleAssignmentFuture) result(client SQLResourcesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesDeleteSQLRoleAssignmentFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("documentdb.SQLResourcesDeleteSQLRoleAssignmentFuture") + return + } + ar.Response = future.Response() + return +} + +// SQLResourcesDeleteSQLRoleDefinitionFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type SQLResourcesDeleteSQLRoleDefinitionFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(SQLResourcesClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *SQLResourcesDeleteSQLRoleDefinitionFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for SQLResourcesDeleteSQLRoleDefinitionFuture.Result. +func (future *SQLResourcesDeleteSQLRoleDefinitionFuture) result(client SQLResourcesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesDeleteSQLRoleDefinitionFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("documentdb.SQLResourcesDeleteSQLRoleDefinitionFuture") + return + } + ar.Response = future.Response() + return +} + +// SQLResourcesDeleteSQLStoredProcedureFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type SQLResourcesDeleteSQLStoredProcedureFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(SQLResourcesClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *SQLResourcesDeleteSQLStoredProcedureFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for SQLResourcesDeleteSQLStoredProcedureFuture.Result. +func (future *SQLResourcesDeleteSQLStoredProcedureFuture) result(client SQLResourcesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesDeleteSQLStoredProcedureFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("documentdb.SQLResourcesDeleteSQLStoredProcedureFuture") + return + } + ar.Response = future.Response() + return +} + +// SQLResourcesDeleteSQLTriggerFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type SQLResourcesDeleteSQLTriggerFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(SQLResourcesClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *SQLResourcesDeleteSQLTriggerFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for SQLResourcesDeleteSQLTriggerFuture.Result. +func (future *SQLResourcesDeleteSQLTriggerFuture) result(client SQLResourcesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesDeleteSQLTriggerFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("documentdb.SQLResourcesDeleteSQLTriggerFuture") + return + } + ar.Response = future.Response() + return +} + +// SQLResourcesDeleteSQLUserDefinedFunctionFuture an abstraction for monitoring and retrieving the results +// of a long-running operation. +type SQLResourcesDeleteSQLUserDefinedFunctionFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(SQLResourcesClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *SQLResourcesDeleteSQLUserDefinedFunctionFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for SQLResourcesDeleteSQLUserDefinedFunctionFuture.Result. +func (future *SQLResourcesDeleteSQLUserDefinedFunctionFuture) result(client SQLResourcesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesDeleteSQLUserDefinedFunctionFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("documentdb.SQLResourcesDeleteSQLUserDefinedFunctionFuture") + return + } + ar.Response = future.Response() + return +} + +// SQLResourcesMigrateSQLContainerToAutoscaleFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type SQLResourcesMigrateSQLContainerToAutoscaleFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(SQLResourcesClient) (ThroughputSettingsGetResults, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *SQLResourcesMigrateSQLContainerToAutoscaleFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for SQLResourcesMigrateSQLContainerToAutoscaleFuture.Result. +func (future *SQLResourcesMigrateSQLContainerToAutoscaleFuture) result(client SQLResourcesClient) (tsgr ThroughputSettingsGetResults, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesMigrateSQLContainerToAutoscaleFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + tsgr.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("documentdb.SQLResourcesMigrateSQLContainerToAutoscaleFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if tsgr.Response.Response, err = future.GetResult(sender); err == nil && tsgr.Response.Response.StatusCode != http.StatusNoContent { + tsgr, err = client.MigrateSQLContainerToAutoscaleResponder(tsgr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesMigrateSQLContainerToAutoscaleFuture", "Result", tsgr.Response.Response, "Failure responding to request") + } + } + return +} + +// SQLResourcesMigrateSQLContainerToManualThroughputFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type SQLResourcesMigrateSQLContainerToManualThroughputFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(SQLResourcesClient) (ThroughputSettingsGetResults, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *SQLResourcesMigrateSQLContainerToManualThroughputFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for SQLResourcesMigrateSQLContainerToManualThroughputFuture.Result. +func (future *SQLResourcesMigrateSQLContainerToManualThroughputFuture) result(client SQLResourcesClient) (tsgr ThroughputSettingsGetResults, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesMigrateSQLContainerToManualThroughputFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + tsgr.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("documentdb.SQLResourcesMigrateSQLContainerToManualThroughputFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if tsgr.Response.Response, err = future.GetResult(sender); err == nil && tsgr.Response.Response.StatusCode != http.StatusNoContent { + tsgr, err = client.MigrateSQLContainerToManualThroughputResponder(tsgr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesMigrateSQLContainerToManualThroughputFuture", "Result", tsgr.Response.Response, "Failure responding to request") + } + } + return +} + +// SQLResourcesMigrateSQLDatabaseToAutoscaleFuture an abstraction for monitoring and retrieving the results +// of a long-running operation. +type SQLResourcesMigrateSQLDatabaseToAutoscaleFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(SQLResourcesClient) (ThroughputSettingsGetResults, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *SQLResourcesMigrateSQLDatabaseToAutoscaleFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for SQLResourcesMigrateSQLDatabaseToAutoscaleFuture.Result. +func (future *SQLResourcesMigrateSQLDatabaseToAutoscaleFuture) result(client SQLResourcesClient) (tsgr ThroughputSettingsGetResults, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesMigrateSQLDatabaseToAutoscaleFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + tsgr.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("documentdb.SQLResourcesMigrateSQLDatabaseToAutoscaleFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if tsgr.Response.Response, err = future.GetResult(sender); err == nil && tsgr.Response.Response.StatusCode != http.StatusNoContent { + tsgr, err = client.MigrateSQLDatabaseToAutoscaleResponder(tsgr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesMigrateSQLDatabaseToAutoscaleFuture", "Result", tsgr.Response.Response, "Failure responding to request") + } + } + return +} + +// SQLResourcesMigrateSQLDatabaseToManualThroughputFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type SQLResourcesMigrateSQLDatabaseToManualThroughputFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(SQLResourcesClient) (ThroughputSettingsGetResults, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *SQLResourcesMigrateSQLDatabaseToManualThroughputFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for SQLResourcesMigrateSQLDatabaseToManualThroughputFuture.Result. +func (future *SQLResourcesMigrateSQLDatabaseToManualThroughputFuture) result(client SQLResourcesClient) (tsgr ThroughputSettingsGetResults, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesMigrateSQLDatabaseToManualThroughputFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + tsgr.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("documentdb.SQLResourcesMigrateSQLDatabaseToManualThroughputFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if tsgr.Response.Response, err = future.GetResult(sender); err == nil && tsgr.Response.Response.StatusCode != http.StatusNoContent { + tsgr, err = client.MigrateSQLDatabaseToManualThroughputResponder(tsgr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesMigrateSQLDatabaseToManualThroughputFuture", "Result", tsgr.Response.Response, "Failure responding to request") + } + } + return +} + +// SQLResourcesRetrieveContinuousBackupInformationFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type SQLResourcesRetrieveContinuousBackupInformationFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(SQLResourcesClient) (BackupInformation, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *SQLResourcesRetrieveContinuousBackupInformationFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for SQLResourcesRetrieveContinuousBackupInformationFuture.Result. +func (future *SQLResourcesRetrieveContinuousBackupInformationFuture) result(client SQLResourcesClient) (bi BackupInformation, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesRetrieveContinuousBackupInformationFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + bi.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("documentdb.SQLResourcesRetrieveContinuousBackupInformationFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if bi.Response.Response, err = future.GetResult(sender); err == nil && bi.Response.Response.StatusCode != http.StatusNoContent { + bi, err = client.RetrieveContinuousBackupInformationResponder(bi.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesRetrieveContinuousBackupInformationFuture", "Result", bi.Response.Response, "Failure responding to request") + } + } + return +} + +// SQLResourcesUpdateSQLContainerThroughputFuture an abstraction for monitoring and retrieving the results +// of a long-running operation. +type SQLResourcesUpdateSQLContainerThroughputFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(SQLResourcesClient) (ThroughputSettingsGetResults, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *SQLResourcesUpdateSQLContainerThroughputFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for SQLResourcesUpdateSQLContainerThroughputFuture.Result. +func (future *SQLResourcesUpdateSQLContainerThroughputFuture) result(client SQLResourcesClient) (tsgr ThroughputSettingsGetResults, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesUpdateSQLContainerThroughputFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + tsgr.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("documentdb.SQLResourcesUpdateSQLContainerThroughputFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if tsgr.Response.Response, err = future.GetResult(sender); err == nil && tsgr.Response.Response.StatusCode != http.StatusNoContent { + tsgr, err = client.UpdateSQLContainerThroughputResponder(tsgr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesUpdateSQLContainerThroughputFuture", "Result", tsgr.Response.Response, "Failure responding to request") + } + } + return +} + +// SQLResourcesUpdateSQLDatabaseThroughputFuture an abstraction for monitoring and retrieving the results +// of a long-running operation. +type SQLResourcesUpdateSQLDatabaseThroughputFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(SQLResourcesClient) (ThroughputSettingsGetResults, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *SQLResourcesUpdateSQLDatabaseThroughputFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for SQLResourcesUpdateSQLDatabaseThroughputFuture.Result. +func (future *SQLResourcesUpdateSQLDatabaseThroughputFuture) result(client SQLResourcesClient) (tsgr ThroughputSettingsGetResults, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesUpdateSQLDatabaseThroughputFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + tsgr.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("documentdb.SQLResourcesUpdateSQLDatabaseThroughputFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if tsgr.Response.Response, err = future.GetResult(sender); err == nil && tsgr.Response.Response.StatusCode != http.StatusNoContent { + tsgr, err = client.UpdateSQLDatabaseThroughputResponder(tsgr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesUpdateSQLDatabaseThroughputFuture", "Result", tsgr.Response.Response, "Failure responding to request") + } + } + return +} + +// SQLRoleAssignmentCreateUpdateParameters parameters to create and update an Azure Cosmos DB SQL Role +// Assignment. +type SQLRoleAssignmentCreateUpdateParameters struct { + // SQLRoleAssignmentResource - Properties to create and update an Azure Cosmos DB SQL Role Assignment. + *SQLRoleAssignmentResource `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for SQLRoleAssignmentCreateUpdateParameters. +func (sracup SQLRoleAssignmentCreateUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sracup.SQLRoleAssignmentResource != nil { + objectMap["properties"] = sracup.SQLRoleAssignmentResource + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for SQLRoleAssignmentCreateUpdateParameters struct. +func (sracup *SQLRoleAssignmentCreateUpdateParameters) UnmarshalJSON(body []byte) error { + 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 SQLRoleAssignmentResource SQLRoleAssignmentResource + err = json.Unmarshal(*v, &SQLRoleAssignmentResource) + if err != nil { + return err + } + sracup.SQLRoleAssignmentResource = &SQLRoleAssignmentResource + } + } + } + + return nil +} + +// SQLRoleAssignmentGetResults an Azure Cosmos DB Role Assignment +type SQLRoleAssignmentGetResults struct { + autorest.Response `json:"-"` + // SQLRoleAssignmentResource - Properties related to the Role Assignment. + *SQLRoleAssignmentResource `json:"properties,omitempty"` + // ID - READ-ONLY; The unique resource identifier of the database account. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the database account. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of Azure resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for SQLRoleAssignmentGetResults. +func (sragr SQLRoleAssignmentGetResults) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sragr.SQLRoleAssignmentResource != nil { + objectMap["properties"] = sragr.SQLRoleAssignmentResource + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for SQLRoleAssignmentGetResults struct. +func (sragr *SQLRoleAssignmentGetResults) UnmarshalJSON(body []byte) error { + 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 SQLRoleAssignmentResource SQLRoleAssignmentResource + err = json.Unmarshal(*v, &SQLRoleAssignmentResource) + if err != nil { + return err + } + sragr.SQLRoleAssignmentResource = &SQLRoleAssignmentResource + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + sragr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + sragr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + sragr.Type = &typeVar + } + } + } + + return nil +} + +// SQLRoleAssignmentListResult the relevant Role Assignments. +type SQLRoleAssignmentListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; List of Role Assignments and their properties + Value *[]SQLRoleAssignmentGetResults `json:"value,omitempty"` +} + +// MarshalJSON is the custom marshaler for SQLRoleAssignmentListResult. +func (sralr SQLRoleAssignmentListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// SQLRoleAssignmentResource azure Cosmos DB SQL Role Assignment resource object. +type SQLRoleAssignmentResource struct { + // RoleDefinitionID - The unique identifier for the associated Role Definition. + RoleDefinitionID *string `json:"roleDefinitionId,omitempty"` + // Scope - The data plane resource path for which access is being granted through this Role Assignment. + Scope *string `json:"scope,omitempty"` + // PrincipalID - The unique identifier for the associated AAD principal in the AAD graph to which access is being granted through this Role Assignment. Tenant ID for the principal is inferred using the tenant associated with the subscription. + PrincipalID *string `json:"principalId,omitempty"` +} + +// SQLRoleDefinitionCreateUpdateParameters parameters to create and update an Azure Cosmos DB SQL Role +// Definition. +type SQLRoleDefinitionCreateUpdateParameters struct { + // SQLRoleDefinitionResource - Properties to create and update an Azure Cosmos DB SQL Role Definition. + *SQLRoleDefinitionResource `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for SQLRoleDefinitionCreateUpdateParameters. +func (srdcup SQLRoleDefinitionCreateUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if srdcup.SQLRoleDefinitionResource != nil { + objectMap["properties"] = srdcup.SQLRoleDefinitionResource + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for SQLRoleDefinitionCreateUpdateParameters struct. +func (srdcup *SQLRoleDefinitionCreateUpdateParameters) UnmarshalJSON(body []byte) error { + 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 SQLRoleDefinitionResource SQLRoleDefinitionResource + err = json.Unmarshal(*v, &SQLRoleDefinitionResource) + if err != nil { + return err + } + srdcup.SQLRoleDefinitionResource = &SQLRoleDefinitionResource + } + } + } + + return nil +} + +// SQLRoleDefinitionGetResults an Azure Cosmos DB SQL Role Definition. +type SQLRoleDefinitionGetResults struct { + autorest.Response `json:"-"` + // SQLRoleDefinitionResource - Properties related to the Role Definition. + *SQLRoleDefinitionResource `json:"properties,omitempty"` + // ID - READ-ONLY; The unique resource identifier of the database account. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the database account. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of Azure resource. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for SQLRoleDefinitionGetResults. +func (srdgr SQLRoleDefinitionGetResults) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if srdgr.SQLRoleDefinitionResource != nil { + objectMap["properties"] = srdgr.SQLRoleDefinitionResource + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for SQLRoleDefinitionGetResults struct. +func (srdgr *SQLRoleDefinitionGetResults) UnmarshalJSON(body []byte) error { + 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 SQLRoleDefinitionResource SQLRoleDefinitionResource + err = json.Unmarshal(*v, &SQLRoleDefinitionResource) + if err != nil { + return err + } + srdgr.SQLRoleDefinitionResource = &SQLRoleDefinitionResource + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + srdgr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + srdgr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + srdgr.Type = &typeVar + } + } + } + + return nil +} + +// SQLRoleDefinitionListResult the relevant Role Definitions. +type SQLRoleDefinitionListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; List of Role Definitions and their properties. + Value *[]SQLRoleDefinitionGetResults `json:"value,omitempty"` +} + +// MarshalJSON is the custom marshaler for SQLRoleDefinitionListResult. +func (srdlr SQLRoleDefinitionListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// SQLRoleDefinitionResource azure Cosmos DB SQL Role Definition resource object. +type SQLRoleDefinitionResource struct { + // RoleName - A user-friendly name for the Role Definition. Must be unique for the database account. + RoleName *string `json:"roleName,omitempty"` + // Type - Indicates whether the Role Definition was built-in or user created. Possible values include: 'RoleDefinitionTypeBuiltInRole', 'RoleDefinitionTypeCustomRole' + Type RoleDefinitionType `json:"type,omitempty"` + // AssignableScopes - A set of fully qualified Scopes at or below which Role Assignments may be created using this Role Definition. This will allow application of this Role Definition on the entire database account or any underlying Database / Collection. Must have at least one element. Scopes higher than Database account are not enforceable as assignable Scopes. Note that resources referenced in assignable Scopes need not exist. + AssignableScopes *[]string `json:"assignableScopes,omitempty"` + // Permissions - The set of operations allowed through this Role Definition. + Permissions *[]Permission `json:"permissions,omitempty"` +} + +// SQLStoredProcedureCreateUpdateParameters parameters to create and update Cosmos DB storedProcedure. +type SQLStoredProcedureCreateUpdateParameters struct { + // SQLStoredProcedureCreateUpdateProperties - Properties to create and update Azure Cosmos DB storedProcedure. + *SQLStoredProcedureCreateUpdateProperties `json:"properties,omitempty"` + // ID - READ-ONLY; The unique resource identifier of the ARM resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the ARM resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of Azure resource. + Type *string `json:"type,omitempty"` + // Location - The location of the resource group to which the resource belongs. + Location *string `json:"location,omitempty"` + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for SQLStoredProcedureCreateUpdateParameters. +func (sspcup SQLStoredProcedureCreateUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sspcup.SQLStoredProcedureCreateUpdateProperties != nil { + objectMap["properties"] = sspcup.SQLStoredProcedureCreateUpdateProperties + } + if sspcup.Location != nil { + objectMap["location"] = sspcup.Location + } + if sspcup.Tags != nil { + objectMap["tags"] = sspcup.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for SQLStoredProcedureCreateUpdateParameters struct. +func (sspcup *SQLStoredProcedureCreateUpdateParameters) UnmarshalJSON(body []byte) error { + 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 SQLStoredProcedureCreateUpdateProperties SQLStoredProcedureCreateUpdateProperties + err = json.Unmarshal(*v, &SQLStoredProcedureCreateUpdateProperties) + if err != nil { + return err + } + sspcup.SQLStoredProcedureCreateUpdateProperties = &SQLStoredProcedureCreateUpdateProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + sspcup.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + sspcup.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + sspcup.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + sspcup.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + sspcup.Tags = tags + } + } + } + + return nil +} + +// SQLStoredProcedureCreateUpdateProperties properties to create and update Azure Cosmos DB +// storedProcedure. +type SQLStoredProcedureCreateUpdateProperties struct { + // Resource - The standard JSON format of a storedProcedure + Resource *SQLStoredProcedureResource `json:"resource,omitempty"` + // Options - A key-value pair of options to be applied for the request. This corresponds to the headers sent with the request. + Options *CreateUpdateOptions `json:"options,omitempty"` +} + +// SQLStoredProcedureGetProperties the properties of an Azure Cosmos DB StoredProcedure +type SQLStoredProcedureGetProperties struct { + Resource *SQLStoredProcedureGetPropertiesResource `json:"resource,omitempty"` +} + +// SQLStoredProcedureGetPropertiesResource ... +type SQLStoredProcedureGetPropertiesResource struct { + // ID - Name of the Cosmos DB SQL storedProcedure + ID *string `json:"id,omitempty"` + // Body - Body of the Stored Procedure + Body *string `json:"body,omitempty"` + // Rid - READ-ONLY; A system generated property. A unique identifier. + Rid *string `json:"_rid,omitempty"` + // Ts - READ-ONLY; A system generated property that denotes the last updated timestamp of the resource. + Ts *float64 `json:"_ts,omitempty"` + // Etag - READ-ONLY; A system generated property representing the resource etag required for optimistic concurrency control. + Etag *string `json:"_etag,omitempty"` +} + +// MarshalJSON is the custom marshaler for SQLStoredProcedureGetPropertiesResource. +func (sspgp SQLStoredProcedureGetPropertiesResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sspgp.ID != nil { + objectMap["id"] = sspgp.ID + } + if sspgp.Body != nil { + objectMap["body"] = sspgp.Body + } + return json.Marshal(objectMap) +} + +// SQLStoredProcedureGetResults an Azure Cosmos DB storedProcedure. +type SQLStoredProcedureGetResults struct { + autorest.Response `json:"-"` + // SQLStoredProcedureGetProperties - The properties of an Azure Cosmos DB storedProcedure + *SQLStoredProcedureGetProperties `json:"properties,omitempty"` + // ID - READ-ONLY; The unique resource identifier of the ARM resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the ARM resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of Azure resource. + Type *string `json:"type,omitempty"` + // Location - The location of the resource group to which the resource belongs. + Location *string `json:"location,omitempty"` + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for SQLStoredProcedureGetResults. +func (sspgr SQLStoredProcedureGetResults) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sspgr.SQLStoredProcedureGetProperties != nil { + objectMap["properties"] = sspgr.SQLStoredProcedureGetProperties + } + if sspgr.Location != nil { + objectMap["location"] = sspgr.Location + } + if sspgr.Tags != nil { + objectMap["tags"] = sspgr.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for SQLStoredProcedureGetResults struct. +func (sspgr *SQLStoredProcedureGetResults) UnmarshalJSON(body []byte) error { + 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 SQLStoredProcedureGetProperties SQLStoredProcedureGetProperties + err = json.Unmarshal(*v, &SQLStoredProcedureGetProperties) + if err != nil { + return err + } + sspgr.SQLStoredProcedureGetProperties = &SQLStoredProcedureGetProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + sspgr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + sspgr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + sspgr.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + sspgr.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + sspgr.Tags = tags + } + } + } + + return nil +} + +// SQLStoredProcedureListResult the List operation response, that contains the storedProcedures and their +// properties. +type SQLStoredProcedureListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; List of storedProcedures and their properties. + Value *[]SQLStoredProcedureGetResults `json:"value,omitempty"` +} + +// MarshalJSON is the custom marshaler for SQLStoredProcedureListResult. +func (ssplr SQLStoredProcedureListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// SQLStoredProcedureResource cosmos DB SQL storedProcedure resource object +type SQLStoredProcedureResource struct { + // ID - Name of the Cosmos DB SQL storedProcedure + ID *string `json:"id,omitempty"` + // Body - Body of the Stored Procedure + Body *string `json:"body,omitempty"` +} + +// SQLTriggerCreateUpdateParameters parameters to create and update Cosmos DB trigger. +type SQLTriggerCreateUpdateParameters struct { + // SQLTriggerCreateUpdateProperties - Properties to create and update Azure Cosmos DB trigger. + *SQLTriggerCreateUpdateProperties `json:"properties,omitempty"` + // ID - READ-ONLY; The unique resource identifier of the ARM resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the ARM resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of Azure resource. + Type *string `json:"type,omitempty"` + // Location - The location of the resource group to which the resource belongs. + Location *string `json:"location,omitempty"` + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for SQLTriggerCreateUpdateParameters. +func (stcup SQLTriggerCreateUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if stcup.SQLTriggerCreateUpdateProperties != nil { + objectMap["properties"] = stcup.SQLTriggerCreateUpdateProperties + } + if stcup.Location != nil { + objectMap["location"] = stcup.Location + } + if stcup.Tags != nil { + objectMap["tags"] = stcup.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for SQLTriggerCreateUpdateParameters struct. +func (stcup *SQLTriggerCreateUpdateParameters) UnmarshalJSON(body []byte) error { + 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 SQLTriggerCreateUpdateProperties SQLTriggerCreateUpdateProperties + err = json.Unmarshal(*v, &SQLTriggerCreateUpdateProperties) + if err != nil { + return err + } + stcup.SQLTriggerCreateUpdateProperties = &SQLTriggerCreateUpdateProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + stcup.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + stcup.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + stcup.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + stcup.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + stcup.Tags = tags + } + } + } + + return nil +} + +// SQLTriggerCreateUpdateProperties properties to create and update Azure Cosmos DB trigger. +type SQLTriggerCreateUpdateProperties struct { + // Resource - The standard JSON format of a trigger + Resource *SQLTriggerResource `json:"resource,omitempty"` + // Options - A key-value pair of options to be applied for the request. This corresponds to the headers sent with the request. + Options *CreateUpdateOptions `json:"options,omitempty"` +} + +// SQLTriggerGetProperties the properties of an Azure Cosmos DB trigger +type SQLTriggerGetProperties struct { + Resource *SQLTriggerGetPropertiesResource `json:"resource,omitempty"` +} + +// SQLTriggerGetPropertiesResource ... +type SQLTriggerGetPropertiesResource struct { + // ID - Name of the Cosmos DB SQL trigger + ID *string `json:"id,omitempty"` + // Body - Body of the Trigger + Body *string `json:"body,omitempty"` + // TriggerType - Type of the Trigger. Possible values include: 'TriggerTypePre', 'TriggerTypePost' + TriggerType TriggerType `json:"triggerType,omitempty"` + // TriggerOperation - The operation the trigger is associated with. Possible values include: 'TriggerOperationAll', 'TriggerOperationCreate', 'TriggerOperationUpdate', 'TriggerOperationDelete', 'TriggerOperationReplace' + TriggerOperation TriggerOperation `json:"triggerOperation,omitempty"` + // Rid - READ-ONLY; A system generated property. A unique identifier. + Rid *string `json:"_rid,omitempty"` + // Ts - READ-ONLY; A system generated property that denotes the last updated timestamp of the resource. + Ts *float64 `json:"_ts,omitempty"` + // Etag - READ-ONLY; A system generated property representing the resource etag required for optimistic concurrency control. + Etag *string `json:"_etag,omitempty"` +} + +// MarshalJSON is the custom marshaler for SQLTriggerGetPropertiesResource. +func (stgp SQLTriggerGetPropertiesResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if stgp.ID != nil { + objectMap["id"] = stgp.ID + } + if stgp.Body != nil { + objectMap["body"] = stgp.Body + } + if stgp.TriggerType != "" { + objectMap["triggerType"] = stgp.TriggerType + } + if stgp.TriggerOperation != "" { + objectMap["triggerOperation"] = stgp.TriggerOperation + } + return json.Marshal(objectMap) +} + +// SQLTriggerGetResults an Azure Cosmos DB trigger. +type SQLTriggerGetResults struct { + autorest.Response `json:"-"` + // SQLTriggerGetProperties - The properties of an Azure Cosmos DB trigger + *SQLTriggerGetProperties `json:"properties,omitempty"` + // ID - READ-ONLY; The unique resource identifier of the ARM resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the ARM resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of Azure resource. + Type *string `json:"type,omitempty"` + // Location - The location of the resource group to which the resource belongs. + Location *string `json:"location,omitempty"` + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for SQLTriggerGetResults. +func (stgr SQLTriggerGetResults) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if stgr.SQLTriggerGetProperties != nil { + objectMap["properties"] = stgr.SQLTriggerGetProperties + } + if stgr.Location != nil { + objectMap["location"] = stgr.Location + } + if stgr.Tags != nil { + objectMap["tags"] = stgr.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for SQLTriggerGetResults struct. +func (stgr *SQLTriggerGetResults) UnmarshalJSON(body []byte) error { + 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 SQLTriggerGetProperties SQLTriggerGetProperties + err = json.Unmarshal(*v, &SQLTriggerGetProperties) + if err != nil { + return err + } + stgr.SQLTriggerGetProperties = &SQLTriggerGetProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + stgr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + stgr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + stgr.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + stgr.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + stgr.Tags = tags + } + } + } + + return nil +} + +// SQLTriggerListResult the List operation response, that contains the triggers and their properties. +type SQLTriggerListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; List of triggers and their properties. + Value *[]SQLTriggerGetResults `json:"value,omitempty"` +} + +// MarshalJSON is the custom marshaler for SQLTriggerListResult. +func (stlr SQLTriggerListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// SQLTriggerResource cosmos DB SQL trigger resource object +type SQLTriggerResource struct { + // ID - Name of the Cosmos DB SQL trigger + ID *string `json:"id,omitempty"` + // Body - Body of the Trigger + Body *string `json:"body,omitempty"` + // TriggerType - Type of the Trigger. Possible values include: 'TriggerTypePre', 'TriggerTypePost' + TriggerType TriggerType `json:"triggerType,omitempty"` + // TriggerOperation - The operation the trigger is associated with. Possible values include: 'TriggerOperationAll', 'TriggerOperationCreate', 'TriggerOperationUpdate', 'TriggerOperationDelete', 'TriggerOperationReplace' + TriggerOperation TriggerOperation `json:"triggerOperation,omitempty"` +} + +// SQLUserDefinedFunctionCreateUpdateParameters parameters to create and update Cosmos DB +// userDefinedFunction. +type SQLUserDefinedFunctionCreateUpdateParameters struct { + // SQLUserDefinedFunctionCreateUpdateProperties - Properties to create and update Azure Cosmos DB userDefinedFunction. + *SQLUserDefinedFunctionCreateUpdateProperties `json:"properties,omitempty"` + // ID - READ-ONLY; The unique resource identifier of the ARM resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the ARM resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of Azure resource. + Type *string `json:"type,omitempty"` + // Location - The location of the resource group to which the resource belongs. + Location *string `json:"location,omitempty"` + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for SQLUserDefinedFunctionCreateUpdateParameters. +func (sudfcup SQLUserDefinedFunctionCreateUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sudfcup.SQLUserDefinedFunctionCreateUpdateProperties != nil { + objectMap["properties"] = sudfcup.SQLUserDefinedFunctionCreateUpdateProperties + } + if sudfcup.Location != nil { + objectMap["location"] = sudfcup.Location + } + if sudfcup.Tags != nil { + objectMap["tags"] = sudfcup.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for SQLUserDefinedFunctionCreateUpdateParameters struct. +func (sudfcup *SQLUserDefinedFunctionCreateUpdateParameters) UnmarshalJSON(body []byte) error { + 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 SQLUserDefinedFunctionCreateUpdateProperties SQLUserDefinedFunctionCreateUpdateProperties + err = json.Unmarshal(*v, &SQLUserDefinedFunctionCreateUpdateProperties) + if err != nil { + return err + } + sudfcup.SQLUserDefinedFunctionCreateUpdateProperties = &SQLUserDefinedFunctionCreateUpdateProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + sudfcup.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + sudfcup.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + sudfcup.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + sudfcup.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + sudfcup.Tags = tags + } + } + } + + return nil +} + +// SQLUserDefinedFunctionCreateUpdateProperties properties to create and update Azure Cosmos DB +// userDefinedFunction. +type SQLUserDefinedFunctionCreateUpdateProperties struct { + // Resource - The standard JSON format of a userDefinedFunction + Resource *SQLUserDefinedFunctionResource `json:"resource,omitempty"` + // Options - A key-value pair of options to be applied for the request. This corresponds to the headers sent with the request. + Options *CreateUpdateOptions `json:"options,omitempty"` +} + +// SQLUserDefinedFunctionGetProperties the properties of an Azure Cosmos DB userDefinedFunction +type SQLUserDefinedFunctionGetProperties struct { + Resource *SQLUserDefinedFunctionGetPropertiesResource `json:"resource,omitempty"` +} + +// SQLUserDefinedFunctionGetPropertiesResource ... +type SQLUserDefinedFunctionGetPropertiesResource struct { + // ID - Name of the Cosmos DB SQL userDefinedFunction + ID *string `json:"id,omitempty"` + // Body - Body of the User Defined Function + Body *string `json:"body,omitempty"` + // Rid - READ-ONLY; A system generated property. A unique identifier. + Rid *string `json:"_rid,omitempty"` + // Ts - READ-ONLY; A system generated property that denotes the last updated timestamp of the resource. + Ts *float64 `json:"_ts,omitempty"` + // Etag - READ-ONLY; A system generated property representing the resource etag required for optimistic concurrency control. + Etag *string `json:"_etag,omitempty"` +} + +// MarshalJSON is the custom marshaler for SQLUserDefinedFunctionGetPropertiesResource. +func (sudfgp SQLUserDefinedFunctionGetPropertiesResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sudfgp.ID != nil { + objectMap["id"] = sudfgp.ID + } + if sudfgp.Body != nil { + objectMap["body"] = sudfgp.Body + } + return json.Marshal(objectMap) +} + +// SQLUserDefinedFunctionGetResults an Azure Cosmos DB userDefinedFunction. +type SQLUserDefinedFunctionGetResults struct { + autorest.Response `json:"-"` + // SQLUserDefinedFunctionGetProperties - The properties of an Azure Cosmos DB userDefinedFunction + *SQLUserDefinedFunctionGetProperties `json:"properties,omitempty"` + // ID - READ-ONLY; The unique resource identifier of the ARM resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the ARM resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of Azure resource. + Type *string `json:"type,omitempty"` + // Location - The location of the resource group to which the resource belongs. + Location *string `json:"location,omitempty"` + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for SQLUserDefinedFunctionGetResults. +func (sudfgr SQLUserDefinedFunctionGetResults) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sudfgr.SQLUserDefinedFunctionGetProperties != nil { + objectMap["properties"] = sudfgr.SQLUserDefinedFunctionGetProperties + } + if sudfgr.Location != nil { + objectMap["location"] = sudfgr.Location + } + if sudfgr.Tags != nil { + objectMap["tags"] = sudfgr.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for SQLUserDefinedFunctionGetResults struct. +func (sudfgr *SQLUserDefinedFunctionGetResults) UnmarshalJSON(body []byte) error { + 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 SQLUserDefinedFunctionGetProperties SQLUserDefinedFunctionGetProperties + err = json.Unmarshal(*v, &SQLUserDefinedFunctionGetProperties) + if err != nil { + return err + } + sudfgr.SQLUserDefinedFunctionGetProperties = &SQLUserDefinedFunctionGetProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + sudfgr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + sudfgr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + sudfgr.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + sudfgr.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + sudfgr.Tags = tags + } + } + } + + return nil +} + +// SQLUserDefinedFunctionListResult the List operation response, that contains the userDefinedFunctions and +// their properties. +type SQLUserDefinedFunctionListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; List of userDefinedFunctions and their properties. + Value *[]SQLUserDefinedFunctionGetResults `json:"value,omitempty"` +} + +// MarshalJSON is the custom marshaler for SQLUserDefinedFunctionListResult. +func (sudflr SQLUserDefinedFunctionListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// SQLUserDefinedFunctionResource cosmos DB SQL userDefinedFunction resource object +type SQLUserDefinedFunctionResource struct { + // ID - Name of the Cosmos DB SQL userDefinedFunction + ID *string `json:"id,omitempty"` + // Body - Body of the User Defined Function + Body *string `json:"body,omitempty"` +} + +// SystemData metadata pertaining to creation and last modification of the resource. +type SystemData struct { + // CreatedBy - The identity that created the resource. + CreatedBy *string `json:"createdBy,omitempty"` + // CreatedByType - The type of identity that created the resource. Possible values include: 'CreatedByTypeUser', 'CreatedByTypeApplication', 'CreatedByTypeManagedIdentity', 'CreatedByTypeKey' + CreatedByType CreatedByType `json:"createdByType,omitempty"` + // CreatedAt - The timestamp of resource creation (UTC). + CreatedAt *date.Time `json:"createdAt,omitempty"` + // LastModifiedBy - The identity that last modified the resource. + LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + // LastModifiedByType - The type of identity that last modified the resource. Possible values include: 'CreatedByTypeUser', 'CreatedByTypeApplication', 'CreatedByTypeManagedIdentity', 'CreatedByTypeKey' + LastModifiedByType CreatedByType `json:"lastModifiedByType,omitempty"` + // LastModifiedAt - The timestamp of resource last modification (UTC) + LastModifiedAt *date.Time `json:"lastModifiedAt,omitempty"` +} + +// TableCreateUpdateParameters parameters to create and update Cosmos DB Table. +type TableCreateUpdateParameters struct { + // TableCreateUpdateProperties - Properties to create and update Azure Cosmos DB Table. + *TableCreateUpdateProperties `json:"properties,omitempty"` + // ID - READ-ONLY; The unique resource identifier of the ARM resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the ARM resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of Azure resource. + Type *string `json:"type,omitempty"` + // Location - The location of the resource group to which the resource belongs. + Location *string `json:"location,omitempty"` + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for TableCreateUpdateParameters. +func (tcup TableCreateUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if tcup.TableCreateUpdateProperties != nil { + objectMap["properties"] = tcup.TableCreateUpdateProperties + } + if tcup.Location != nil { + objectMap["location"] = tcup.Location + } + if tcup.Tags != nil { + objectMap["tags"] = tcup.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for TableCreateUpdateParameters struct. +func (tcup *TableCreateUpdateParameters) UnmarshalJSON(body []byte) error { + 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 tableCreateUpdateProperties TableCreateUpdateProperties + err = json.Unmarshal(*v, &tableCreateUpdateProperties) + if err != nil { + return err + } + tcup.TableCreateUpdateProperties = &tableCreateUpdateProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + tcup.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + tcup.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + tcup.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + tcup.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + tcup.Tags = tags + } + } + } + + return nil +} + +// TableCreateUpdateProperties properties to create and update Azure Cosmos DB Table. +type TableCreateUpdateProperties struct { + // Resource - The standard JSON format of a Table + Resource *TableResource `json:"resource,omitempty"` + // Options - A key-value pair of options to be applied for the request. This corresponds to the headers sent with the request. + Options *CreateUpdateOptions `json:"options,omitempty"` +} + +// TableGetProperties the properties of an Azure Cosmos Table +type TableGetProperties struct { + Resource *TableGetPropertiesResource `json:"resource,omitempty"` + Options *TableGetPropertiesOptions `json:"options,omitempty"` +} + +// TableGetPropertiesOptions ... +type TableGetPropertiesOptions struct { + // Throughput - Value of the Cosmos DB resource throughput or autoscaleSettings. Use the ThroughputSetting resource when retrieving offer details. + Throughput *int32 `json:"throughput,omitempty"` + // AutoscaleSettings - Specifies the Autoscale settings. + AutoscaleSettings *AutoscaleSettings `json:"autoscaleSettings,omitempty"` +} + +// TableGetPropertiesResource ... +type TableGetPropertiesResource struct { + // ID - Name of the Cosmos DB table + ID *string `json:"id,omitempty"` + // Rid - READ-ONLY; A system generated property. A unique identifier. + Rid *string `json:"_rid,omitempty"` + // Ts - READ-ONLY; A system generated property that denotes the last updated timestamp of the resource. + Ts *float64 `json:"_ts,omitempty"` + // Etag - READ-ONLY; A system generated property representing the resource etag required for optimistic concurrency control. + Etag *string `json:"_etag,omitempty"` +} + +// MarshalJSON is the custom marshaler for TableGetPropertiesResource. +func (tgp TableGetPropertiesResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if tgp.ID != nil { + objectMap["id"] = tgp.ID + } + return json.Marshal(objectMap) +} + +// TableGetResults an Azure Cosmos DB Table. +type TableGetResults struct { + autorest.Response `json:"-"` + // TableGetProperties - The properties of an Azure Cosmos DB Table + *TableGetProperties `json:"properties,omitempty"` + // ID - READ-ONLY; The unique resource identifier of the ARM resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the ARM resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of Azure resource. + Type *string `json:"type,omitempty"` + // Location - The location of the resource group to which the resource belongs. + Location *string `json:"location,omitempty"` + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for TableGetResults. +func (tgr TableGetResults) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if tgr.TableGetProperties != nil { + objectMap["properties"] = tgr.TableGetProperties + } + if tgr.Location != nil { + objectMap["location"] = tgr.Location + } + if tgr.Tags != nil { + objectMap["tags"] = tgr.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for TableGetResults struct. +func (tgr *TableGetResults) UnmarshalJSON(body []byte) error { + 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 tableGetProperties TableGetProperties + err = json.Unmarshal(*v, &tableGetProperties) + if err != nil { + return err + } + tgr.TableGetProperties = &tableGetProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + tgr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + tgr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + tgr.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + tgr.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + tgr.Tags = tags + } + } + } + + return nil +} + +// TableListResult the List operation response, that contains the Table and their properties. +type TableListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; List of Table and their properties. + Value *[]TableGetResults `json:"value,omitempty"` +} + +// MarshalJSON is the custom marshaler for TableListResult. +func (tlr TableListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// TableResource cosmos DB table resource object +type TableResource struct { + // ID - Name of the Cosmos DB table + ID *string `json:"id,omitempty"` +} + +// TableResourcesCreateUpdateTableFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type TableResourcesCreateUpdateTableFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(TableResourcesClient) (TableGetResults, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *TableResourcesCreateUpdateTableFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for TableResourcesCreateUpdateTableFuture.Result. +func (future *TableResourcesCreateUpdateTableFuture) result(client TableResourcesClient) (tgr TableGetResults, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.TableResourcesCreateUpdateTableFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + tgr.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("documentdb.TableResourcesCreateUpdateTableFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if tgr.Response.Response, err = future.GetResult(sender); err == nil && tgr.Response.Response.StatusCode != http.StatusNoContent { + tgr, err = client.CreateUpdateTableResponder(tgr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.TableResourcesCreateUpdateTableFuture", "Result", tgr.Response.Response, "Failure responding to request") + } + } + return +} + +// TableResourcesDeleteTableFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type TableResourcesDeleteTableFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(TableResourcesClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *TableResourcesDeleteTableFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for TableResourcesDeleteTableFuture.Result. +func (future *TableResourcesDeleteTableFuture) result(client TableResourcesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.TableResourcesDeleteTableFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("documentdb.TableResourcesDeleteTableFuture") + return + } + ar.Response = future.Response() + return +} + +// TableResourcesMigrateTableToAutoscaleFuture an abstraction for monitoring and retrieving the results of +// a long-running operation. +type TableResourcesMigrateTableToAutoscaleFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(TableResourcesClient) (ThroughputSettingsGetResults, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *TableResourcesMigrateTableToAutoscaleFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for TableResourcesMigrateTableToAutoscaleFuture.Result. +func (future *TableResourcesMigrateTableToAutoscaleFuture) result(client TableResourcesClient) (tsgr ThroughputSettingsGetResults, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.TableResourcesMigrateTableToAutoscaleFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + tsgr.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("documentdb.TableResourcesMigrateTableToAutoscaleFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if tsgr.Response.Response, err = future.GetResult(sender); err == nil && tsgr.Response.Response.StatusCode != http.StatusNoContent { + tsgr, err = client.MigrateTableToAutoscaleResponder(tsgr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.TableResourcesMigrateTableToAutoscaleFuture", "Result", tsgr.Response.Response, "Failure responding to request") + } + } + return +} + +// TableResourcesMigrateTableToManualThroughputFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type TableResourcesMigrateTableToManualThroughputFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(TableResourcesClient) (ThroughputSettingsGetResults, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *TableResourcesMigrateTableToManualThroughputFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for TableResourcesMigrateTableToManualThroughputFuture.Result. +func (future *TableResourcesMigrateTableToManualThroughputFuture) result(client TableResourcesClient) (tsgr ThroughputSettingsGetResults, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.TableResourcesMigrateTableToManualThroughputFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + tsgr.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("documentdb.TableResourcesMigrateTableToManualThroughputFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if tsgr.Response.Response, err = future.GetResult(sender); err == nil && tsgr.Response.Response.StatusCode != http.StatusNoContent { + tsgr, err = client.MigrateTableToManualThroughputResponder(tsgr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.TableResourcesMigrateTableToManualThroughputFuture", "Result", tsgr.Response.Response, "Failure responding to request") + } + } + return +} + +// TableResourcesUpdateTableThroughputFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type TableResourcesUpdateTableThroughputFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(TableResourcesClient) (ThroughputSettingsGetResults, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *TableResourcesUpdateTableThroughputFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for TableResourcesUpdateTableThroughputFuture.Result. +func (future *TableResourcesUpdateTableThroughputFuture) result(client TableResourcesClient) (tsgr ThroughputSettingsGetResults, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.TableResourcesUpdateTableThroughputFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + tsgr.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("documentdb.TableResourcesUpdateTableThroughputFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if tsgr.Response.Response, err = future.GetResult(sender); err == nil && tsgr.Response.Response.StatusCode != http.StatusNoContent { + tsgr, err = client.UpdateTableThroughputResponder(tsgr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.TableResourcesUpdateTableThroughputFuture", "Result", tsgr.Response.Response, "Failure responding to request") + } + } + return +} + +// ThroughputPolicyResource cosmos DB resource throughput policy +type ThroughputPolicyResource struct { + // IsEnabled - Determines whether the ThroughputPolicy is active or not + IsEnabled *bool `json:"isEnabled,omitempty"` + // IncrementPercent - Represents the percentage by which throughput can increase every time throughput policy kicks in. + IncrementPercent *int32 `json:"incrementPercent,omitempty"` +} + +// ThroughputSettingsGetProperties the properties of an Azure Cosmos DB resource throughput +type ThroughputSettingsGetProperties struct { + Resource *ThroughputSettingsGetPropertiesResource `json:"resource,omitempty"` +} + +// ThroughputSettingsGetPropertiesResource ... +type ThroughputSettingsGetPropertiesResource struct { + // Throughput - Value of the Cosmos DB resource throughput. Either throughput is required or autoscaleSettings is required, but not both. + Throughput *int32 `json:"throughput,omitempty"` + // AutoscaleSettings - Cosmos DB resource for autoscale settings. Either throughput is required or autoscaleSettings is required, but not both. + AutoscaleSettings *AutoscaleSettingsResource `json:"autoscaleSettings,omitempty"` + // MinimumThroughput - READ-ONLY; The minimum throughput of the resource + MinimumThroughput *string `json:"minimumThroughput,omitempty"` + // OfferReplacePending - READ-ONLY; The throughput replace is pending + OfferReplacePending *string `json:"offerReplacePending,omitempty"` + // Rid - READ-ONLY; A system generated property. A unique identifier. + Rid *string `json:"_rid,omitempty"` + // Ts - READ-ONLY; A system generated property that denotes the last updated timestamp of the resource. + Ts *float64 `json:"_ts,omitempty"` + // Etag - READ-ONLY; A system generated property representing the resource etag required for optimistic concurrency control. + Etag *string `json:"_etag,omitempty"` +} + +// MarshalJSON is the custom marshaler for ThroughputSettingsGetPropertiesResource. +func (tsgp ThroughputSettingsGetPropertiesResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if tsgp.Throughput != nil { + objectMap["throughput"] = tsgp.Throughput + } + if tsgp.AutoscaleSettings != nil { + objectMap["autoscaleSettings"] = tsgp.AutoscaleSettings + } + return json.Marshal(objectMap) +} + +// ThroughputSettingsGetResults an Azure Cosmos DB resource throughput. +type ThroughputSettingsGetResults struct { + autorest.Response `json:"-"` + // ThroughputSettingsGetProperties - The properties of an Azure Cosmos DB resource throughput + *ThroughputSettingsGetProperties `json:"properties,omitempty"` + // ID - READ-ONLY; The unique resource identifier of the ARM resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the ARM resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of Azure resource. + Type *string `json:"type,omitempty"` + // Location - The location of the resource group to which the resource belongs. + Location *string `json:"location,omitempty"` + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for ThroughputSettingsGetResults. +func (tsgr ThroughputSettingsGetResults) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if tsgr.ThroughputSettingsGetProperties != nil { + objectMap["properties"] = tsgr.ThroughputSettingsGetProperties + } + if tsgr.Location != nil { + objectMap["location"] = tsgr.Location + } + if tsgr.Tags != nil { + objectMap["tags"] = tsgr.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ThroughputSettingsGetResults struct. +func (tsgr *ThroughputSettingsGetResults) UnmarshalJSON(body []byte) error { + 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 throughputSettingsGetProperties ThroughputSettingsGetProperties + err = json.Unmarshal(*v, &throughputSettingsGetProperties) + if err != nil { + return err + } + tsgr.ThroughputSettingsGetProperties = &throughputSettingsGetProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + tsgr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + tsgr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + tsgr.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + tsgr.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + tsgr.Tags = tags + } + } + } + + return nil +} + +// ThroughputSettingsResource cosmos DB resource throughput object. Either throughput is required or +// autoscaleSettings is required, but not both. +type ThroughputSettingsResource struct { + // Throughput - Value of the Cosmos DB resource throughput. Either throughput is required or autoscaleSettings is required, but not both. + Throughput *int32 `json:"throughput,omitempty"` + // AutoscaleSettings - Cosmos DB resource for autoscale settings. Either throughput is required or autoscaleSettings is required, but not both. + AutoscaleSettings *AutoscaleSettingsResource `json:"autoscaleSettings,omitempty"` + // MinimumThroughput - READ-ONLY; The minimum throughput of the resource + MinimumThroughput *string `json:"minimumThroughput,omitempty"` + // OfferReplacePending - READ-ONLY; The throughput replace is pending + OfferReplacePending *string `json:"offerReplacePending,omitempty"` +} + +// MarshalJSON is the custom marshaler for ThroughputSettingsResource. +func (tsr ThroughputSettingsResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if tsr.Throughput != nil { + objectMap["throughput"] = tsr.Throughput + } + if tsr.AutoscaleSettings != nil { + objectMap["autoscaleSettings"] = tsr.AutoscaleSettings + } + return json.Marshal(objectMap) +} + +// ThroughputSettingsUpdateParameters parameters to update Cosmos DB resource throughput. +type ThroughputSettingsUpdateParameters struct { + // ThroughputSettingsUpdateProperties - Properties to update Azure Cosmos DB resource throughput. + *ThroughputSettingsUpdateProperties `json:"properties,omitempty"` + // ID - READ-ONLY; The unique resource identifier of the ARM resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the ARM resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of Azure resource. + Type *string `json:"type,omitempty"` + // Location - The location of the resource group to which the resource belongs. + Location *string `json:"location,omitempty"` + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for ThroughputSettingsUpdateParameters. +func (tsup ThroughputSettingsUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if tsup.ThroughputSettingsUpdateProperties != nil { + objectMap["properties"] = tsup.ThroughputSettingsUpdateProperties + } + if tsup.Location != nil { + objectMap["location"] = tsup.Location + } + if tsup.Tags != nil { + objectMap["tags"] = tsup.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ThroughputSettingsUpdateParameters struct. +func (tsup *ThroughputSettingsUpdateParameters) UnmarshalJSON(body []byte) error { + 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 throughputSettingsUpdateProperties ThroughputSettingsUpdateProperties + err = json.Unmarshal(*v, &throughputSettingsUpdateProperties) + if err != nil { + return err + } + tsup.ThroughputSettingsUpdateProperties = &throughputSettingsUpdateProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + tsup.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + tsup.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + tsup.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + tsup.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + tsup.Tags = tags + } + } + } + + return nil +} + +// ThroughputSettingsUpdateProperties properties to update Azure Cosmos DB resource throughput. +type ThroughputSettingsUpdateProperties struct { + // Resource - The standard JSON format of a resource throughput + Resource *ThroughputSettingsResource `json:"resource,omitempty"` +} + +// TrackedResource the resource model definition for an Azure Resource Manager tracked top level resource +// which has 'tags' and a 'location' +type TrackedResource struct { + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // Location - The geo-location where the resource lives + Location *string `json:"location,omitempty"` + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + 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 + } + return json.Marshal(objectMap) +} + +// UniqueKey the unique key on that enforces uniqueness constraint on documents in the collection in the +// Azure Cosmos DB service. +type UniqueKey struct { + // Paths - List of paths must be unique for each document in the Azure Cosmos DB service + Paths *[]string `json:"paths,omitempty"` +} + +// UniqueKeyPolicy the unique key policy configuration for specifying uniqueness constraints on documents +// in the collection in the Azure Cosmos DB service. +type UniqueKeyPolicy struct { + // UniqueKeys - List of unique keys on that enforces uniqueness constraint on documents in the collection in the Azure Cosmos DB service. + UniqueKeys *[]UniqueKey `json:"uniqueKeys,omitempty"` +} + +// Usage the usage data for a usage request. +type Usage struct { + // Unit - The unit of the metric. Possible values include: 'UnitTypeCount', 'UnitTypeBytes', 'UnitTypeSeconds', 'UnitTypePercent', 'UnitTypeCountPerSecond', 'UnitTypeBytesPerSecond', 'UnitTypeMilliseconds' + Unit UnitType `json:"unit,omitempty"` + // Name - READ-ONLY; The name information for the metric. + Name *MetricName `json:"name,omitempty"` + // QuotaPeriod - READ-ONLY; The quota period used to summarize the usage values. + QuotaPeriod *string `json:"quotaPeriod,omitempty"` + // Limit - READ-ONLY; Maximum value for this metric + Limit *int64 `json:"limit,omitempty"` + // CurrentValue - READ-ONLY; Current value for this metric + CurrentValue *int64 `json:"currentValue,omitempty"` +} + +// MarshalJSON is the custom marshaler for Usage. +func (u Usage) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if u.Unit != "" { + objectMap["unit"] = u.Unit + } + return json.Marshal(objectMap) +} + +// UsagesResult the response to a list usage request. +type UsagesResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; The list of usages for the database. A usage is a point in time metric + Value *[]Usage `json:"value,omitempty"` +} + +// MarshalJSON is the custom marshaler for UsagesResult. +func (ur UsagesResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// VirtualNetworkRule virtual Network ACL Rule object +type VirtualNetworkRule struct { + // ID - Resource ID of a subnet, for example: /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{virtualNetworkName}/subnets/{subnetName}. + ID *string `json:"id,omitempty"` + // IgnoreMissingVNetServiceEndpoint - Create firewall rule before the virtual network has vnet service endpoint enabled. + IgnoreMissingVNetServiceEndpoint *bool `json:"ignoreMissingVNetServiceEndpoint,omitempty"` +} diff --git a/services/cosmos-db/mgmt/2021-06-15/documentdb/mongodbresources.go b/services/cosmos-db/mgmt/2021-06-15/documentdb/mongodbresources.go new file mode 100644 index 000000000000..50df9032ac6b --- /dev/null +++ b/services/cosmos-db/mgmt/2021-06-15/documentdb/mongodbresources.go @@ -0,0 +1,1563 @@ +package documentdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// MongoDBResourcesClient is the client for the MongoDBResources methods of the Documentdb service. +type MongoDBResourcesClient struct { + BaseClient +} + +// NewMongoDBResourcesClient creates an instance of the MongoDBResourcesClient client. +func NewMongoDBResourcesClient(subscriptionID string) MongoDBResourcesClient { + return NewMongoDBResourcesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewMongoDBResourcesClientWithBaseURI creates an instance of the MongoDBResourcesClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewMongoDBResourcesClientWithBaseURI(baseURI string, subscriptionID string) MongoDBResourcesClient { + return MongoDBResourcesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateUpdateMongoDBCollection create or update an Azure Cosmos DB MongoDB Collection +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +// collectionName - cosmos DB collection name. +// createUpdateMongoDBCollectionParameters - the parameters to provide for the current MongoDB Collection. +func (client MongoDBResourcesClient) CreateUpdateMongoDBCollection(ctx context.Context, resourceGroupName string, accountName string, databaseName string, collectionName string, createUpdateMongoDBCollectionParameters MongoDBCollectionCreateUpdateParameters) (result MongoDBResourcesCreateUpdateMongoDBCollectionFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MongoDBResourcesClient.CreateUpdateMongoDBCollection") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}, + {TargetValue: createUpdateMongoDBCollectionParameters, + Constraints: []validation.Constraint{{Target: "createUpdateMongoDBCollectionParameters.MongoDBCollectionCreateUpdateProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "createUpdateMongoDBCollectionParameters.MongoDBCollectionCreateUpdateProperties.Resource", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "createUpdateMongoDBCollectionParameters.MongoDBCollectionCreateUpdateProperties.Resource.ID", Name: validation.Null, Rule: true, Chain: nil}}}, + }}}}}); err != nil { + return result, validation.NewError("documentdb.MongoDBResourcesClient", "CreateUpdateMongoDBCollection", err.Error()) + } + + req, err := client.CreateUpdateMongoDBCollectionPreparer(ctx, resourceGroupName, accountName, databaseName, collectionName, createUpdateMongoDBCollectionParameters) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "CreateUpdateMongoDBCollection", nil, "Failure preparing request") + return + } + + result, err = client.CreateUpdateMongoDBCollectionSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "CreateUpdateMongoDBCollection", nil, "Failure sending request") + return + } + + return +} + +// CreateUpdateMongoDBCollectionPreparer prepares the CreateUpdateMongoDBCollection request. +func (client MongoDBResourcesClient) CreateUpdateMongoDBCollectionPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, collectionName string, createUpdateMongoDBCollectionParameters MongoDBCollectionCreateUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "collectionName": autorest.Encode("path", collectionName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + 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.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}", pathParameters), + autorest.WithJSON(createUpdateMongoDBCollectionParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateUpdateMongoDBCollectionSender sends the CreateUpdateMongoDBCollection request. The method will close the +// http.Response Body if it receives an error. +func (client MongoDBResourcesClient) CreateUpdateMongoDBCollectionSender(req *http.Request) (future MongoDBResourcesCreateUpdateMongoDBCollectionFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateUpdateMongoDBCollectionResponder handles the response to the CreateUpdateMongoDBCollection request. The method always +// closes the http.Response Body. +func (client MongoDBResourcesClient) CreateUpdateMongoDBCollectionResponder(resp *http.Response) (result MongoDBCollectionGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// CreateUpdateMongoDBDatabase create or updates Azure Cosmos DB MongoDB database +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +// createUpdateMongoDBDatabaseParameters - the parameters to provide for the current MongoDB database. +func (client MongoDBResourcesClient) CreateUpdateMongoDBDatabase(ctx context.Context, resourceGroupName string, accountName string, databaseName string, createUpdateMongoDBDatabaseParameters MongoDBDatabaseCreateUpdateParameters) (result MongoDBResourcesCreateUpdateMongoDBDatabaseFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MongoDBResourcesClient.CreateUpdateMongoDBDatabase") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}, + {TargetValue: createUpdateMongoDBDatabaseParameters, + Constraints: []validation.Constraint{{Target: "createUpdateMongoDBDatabaseParameters.MongoDBDatabaseCreateUpdateProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "createUpdateMongoDBDatabaseParameters.MongoDBDatabaseCreateUpdateProperties.Resource", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "createUpdateMongoDBDatabaseParameters.MongoDBDatabaseCreateUpdateProperties.Resource.ID", Name: validation.Null, Rule: true, Chain: nil}}}, + }}}}}); err != nil { + return result, validation.NewError("documentdb.MongoDBResourcesClient", "CreateUpdateMongoDBDatabase", err.Error()) + } + + req, err := client.CreateUpdateMongoDBDatabasePreparer(ctx, resourceGroupName, accountName, databaseName, createUpdateMongoDBDatabaseParameters) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "CreateUpdateMongoDBDatabase", nil, "Failure preparing request") + return + } + + result, err = client.CreateUpdateMongoDBDatabaseSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "CreateUpdateMongoDBDatabase", nil, "Failure sending request") + return + } + + return +} + +// CreateUpdateMongoDBDatabasePreparer prepares the CreateUpdateMongoDBDatabase request. +func (client MongoDBResourcesClient) CreateUpdateMongoDBDatabasePreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, createUpdateMongoDBDatabaseParameters MongoDBDatabaseCreateUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + 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.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}", pathParameters), + autorest.WithJSON(createUpdateMongoDBDatabaseParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateUpdateMongoDBDatabaseSender sends the CreateUpdateMongoDBDatabase request. The method will close the +// http.Response Body if it receives an error. +func (client MongoDBResourcesClient) CreateUpdateMongoDBDatabaseSender(req *http.Request) (future MongoDBResourcesCreateUpdateMongoDBDatabaseFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateUpdateMongoDBDatabaseResponder handles the response to the CreateUpdateMongoDBDatabase request. The method always +// closes the http.Response Body. +func (client MongoDBResourcesClient) CreateUpdateMongoDBDatabaseResponder(resp *http.Response) (result MongoDBDatabaseGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// DeleteMongoDBCollection deletes an existing Azure Cosmos DB MongoDB Collection. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +// collectionName - cosmos DB collection name. +func (client MongoDBResourcesClient) DeleteMongoDBCollection(ctx context.Context, resourceGroupName string, accountName string, databaseName string, collectionName string) (result MongoDBResourcesDeleteMongoDBCollectionFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MongoDBResourcesClient.DeleteMongoDBCollection") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.MongoDBResourcesClient", "DeleteMongoDBCollection", err.Error()) + } + + req, err := client.DeleteMongoDBCollectionPreparer(ctx, resourceGroupName, accountName, databaseName, collectionName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "DeleteMongoDBCollection", nil, "Failure preparing request") + return + } + + result, err = client.DeleteMongoDBCollectionSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "DeleteMongoDBCollection", nil, "Failure sending request") + return + } + + return +} + +// DeleteMongoDBCollectionPreparer prepares the DeleteMongoDBCollection request. +func (client MongoDBResourcesClient) DeleteMongoDBCollectionPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, collectionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "collectionName": autorest.Encode("path", collectionName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteMongoDBCollectionSender sends the DeleteMongoDBCollection request. The method will close the +// http.Response Body if it receives an error. +func (client MongoDBResourcesClient) DeleteMongoDBCollectionSender(req *http.Request) (future MongoDBResourcesDeleteMongoDBCollectionFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteMongoDBCollectionResponder handles the response to the DeleteMongoDBCollection request. The method always +// closes the http.Response Body. +func (client MongoDBResourcesClient) DeleteMongoDBCollectionResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// DeleteMongoDBDatabase deletes an existing Azure Cosmos DB MongoDB database. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +func (client MongoDBResourcesClient) DeleteMongoDBDatabase(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result MongoDBResourcesDeleteMongoDBDatabaseFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MongoDBResourcesClient.DeleteMongoDBDatabase") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.MongoDBResourcesClient", "DeleteMongoDBDatabase", err.Error()) + } + + req, err := client.DeleteMongoDBDatabasePreparer(ctx, resourceGroupName, accountName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "DeleteMongoDBDatabase", nil, "Failure preparing request") + return + } + + result, err = client.DeleteMongoDBDatabaseSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "DeleteMongoDBDatabase", nil, "Failure sending request") + return + } + + return +} + +// DeleteMongoDBDatabasePreparer prepares the DeleteMongoDBDatabase request. +func (client MongoDBResourcesClient) DeleteMongoDBDatabasePreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteMongoDBDatabaseSender sends the DeleteMongoDBDatabase request. The method will close the +// http.Response Body if it receives an error. +func (client MongoDBResourcesClient) DeleteMongoDBDatabaseSender(req *http.Request) (future MongoDBResourcesDeleteMongoDBDatabaseFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteMongoDBDatabaseResponder handles the response to the DeleteMongoDBDatabase request. The method always +// closes the http.Response Body. +func (client MongoDBResourcesClient) DeleteMongoDBDatabaseResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// GetMongoDBCollection gets the MongoDB collection under an existing Azure Cosmos DB database account. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +// collectionName - cosmos DB collection name. +func (client MongoDBResourcesClient) GetMongoDBCollection(ctx context.Context, resourceGroupName string, accountName string, databaseName string, collectionName string) (result MongoDBCollectionGetResults, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MongoDBResourcesClient.GetMongoDBCollection") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.MongoDBResourcesClient", "GetMongoDBCollection", err.Error()) + } + + req, err := client.GetMongoDBCollectionPreparer(ctx, resourceGroupName, accountName, databaseName, collectionName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "GetMongoDBCollection", nil, "Failure preparing request") + return + } + + resp, err := client.GetMongoDBCollectionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "GetMongoDBCollection", resp, "Failure sending request") + return + } + + result, err = client.GetMongoDBCollectionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "GetMongoDBCollection", resp, "Failure responding to request") + return + } + + return +} + +// GetMongoDBCollectionPreparer prepares the GetMongoDBCollection request. +func (client MongoDBResourcesClient) GetMongoDBCollectionPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, collectionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "collectionName": autorest.Encode("path", collectionName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetMongoDBCollectionSender sends the GetMongoDBCollection request. The method will close the +// http.Response Body if it receives an error. +func (client MongoDBResourcesClient) GetMongoDBCollectionSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetMongoDBCollectionResponder handles the response to the GetMongoDBCollection request. The method always +// closes the http.Response Body. +func (client MongoDBResourcesClient) GetMongoDBCollectionResponder(resp *http.Response) (result MongoDBCollectionGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetMongoDBCollectionThroughput gets the RUs per second of the MongoDB collection under an existing Azure Cosmos DB +// database account with the provided name. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +// collectionName - cosmos DB collection name. +func (client MongoDBResourcesClient) GetMongoDBCollectionThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string, collectionName string) (result ThroughputSettingsGetResults, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MongoDBResourcesClient.GetMongoDBCollectionThroughput") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.MongoDBResourcesClient", "GetMongoDBCollectionThroughput", err.Error()) + } + + req, err := client.GetMongoDBCollectionThroughputPreparer(ctx, resourceGroupName, accountName, databaseName, collectionName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "GetMongoDBCollectionThroughput", nil, "Failure preparing request") + return + } + + resp, err := client.GetMongoDBCollectionThroughputSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "GetMongoDBCollectionThroughput", resp, "Failure sending request") + return + } + + result, err = client.GetMongoDBCollectionThroughputResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "GetMongoDBCollectionThroughput", resp, "Failure responding to request") + return + } + + return +} + +// GetMongoDBCollectionThroughputPreparer prepares the GetMongoDBCollectionThroughput request. +func (client MongoDBResourcesClient) GetMongoDBCollectionThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, collectionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "collectionName": autorest.Encode("path", collectionName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}/throughputSettings/default", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetMongoDBCollectionThroughputSender sends the GetMongoDBCollectionThroughput request. The method will close the +// http.Response Body if it receives an error. +func (client MongoDBResourcesClient) GetMongoDBCollectionThroughputSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetMongoDBCollectionThroughputResponder handles the response to the GetMongoDBCollectionThroughput request. The method always +// closes the http.Response Body. +func (client MongoDBResourcesClient) GetMongoDBCollectionThroughputResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetMongoDBDatabase gets the MongoDB databases under an existing Azure Cosmos DB database account with the provided +// name. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +func (client MongoDBResourcesClient) GetMongoDBDatabase(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result MongoDBDatabaseGetResults, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MongoDBResourcesClient.GetMongoDBDatabase") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.MongoDBResourcesClient", "GetMongoDBDatabase", err.Error()) + } + + req, err := client.GetMongoDBDatabasePreparer(ctx, resourceGroupName, accountName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "GetMongoDBDatabase", nil, "Failure preparing request") + return + } + + resp, err := client.GetMongoDBDatabaseSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "GetMongoDBDatabase", resp, "Failure sending request") + return + } + + result, err = client.GetMongoDBDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "GetMongoDBDatabase", resp, "Failure responding to request") + return + } + + return +} + +// GetMongoDBDatabasePreparer prepares the GetMongoDBDatabase request. +func (client MongoDBResourcesClient) GetMongoDBDatabasePreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetMongoDBDatabaseSender sends the GetMongoDBDatabase request. The method will close the +// http.Response Body if it receives an error. +func (client MongoDBResourcesClient) GetMongoDBDatabaseSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetMongoDBDatabaseResponder handles the response to the GetMongoDBDatabase request. The method always +// closes the http.Response Body. +func (client MongoDBResourcesClient) GetMongoDBDatabaseResponder(resp *http.Response) (result MongoDBDatabaseGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetMongoDBDatabaseThroughput gets the RUs per second of the MongoDB database under an existing Azure Cosmos DB +// database account with the provided name. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +func (client MongoDBResourcesClient) GetMongoDBDatabaseThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result ThroughputSettingsGetResults, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MongoDBResourcesClient.GetMongoDBDatabaseThroughput") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.MongoDBResourcesClient", "GetMongoDBDatabaseThroughput", err.Error()) + } + + req, err := client.GetMongoDBDatabaseThroughputPreparer(ctx, resourceGroupName, accountName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "GetMongoDBDatabaseThroughput", nil, "Failure preparing request") + return + } + + resp, err := client.GetMongoDBDatabaseThroughputSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "GetMongoDBDatabaseThroughput", resp, "Failure sending request") + return + } + + result, err = client.GetMongoDBDatabaseThroughputResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "GetMongoDBDatabaseThroughput", resp, "Failure responding to request") + return + } + + return +} + +// GetMongoDBDatabaseThroughputPreparer prepares the GetMongoDBDatabaseThroughput request. +func (client MongoDBResourcesClient) GetMongoDBDatabaseThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/throughputSettings/default", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetMongoDBDatabaseThroughputSender sends the GetMongoDBDatabaseThroughput request. The method will close the +// http.Response Body if it receives an error. +func (client MongoDBResourcesClient) GetMongoDBDatabaseThroughputSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetMongoDBDatabaseThroughputResponder handles the response to the GetMongoDBDatabaseThroughput request. The method always +// closes the http.Response Body. +func (client MongoDBResourcesClient) GetMongoDBDatabaseThroughputResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListMongoDBCollections lists the MongoDB collection under an existing Azure Cosmos DB database account. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +func (client MongoDBResourcesClient) ListMongoDBCollections(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result MongoDBCollectionListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MongoDBResourcesClient.ListMongoDBCollections") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.MongoDBResourcesClient", "ListMongoDBCollections", err.Error()) + } + + req, err := client.ListMongoDBCollectionsPreparer(ctx, resourceGroupName, accountName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "ListMongoDBCollections", nil, "Failure preparing request") + return + } + + resp, err := client.ListMongoDBCollectionsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "ListMongoDBCollections", resp, "Failure sending request") + return + } + + result, err = client.ListMongoDBCollectionsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "ListMongoDBCollections", resp, "Failure responding to request") + return + } + + return +} + +// ListMongoDBCollectionsPreparer prepares the ListMongoDBCollections request. +func (client MongoDBResourcesClient) ListMongoDBCollectionsPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListMongoDBCollectionsSender sends the ListMongoDBCollections request. The method will close the +// http.Response Body if it receives an error. +func (client MongoDBResourcesClient) ListMongoDBCollectionsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListMongoDBCollectionsResponder handles the response to the ListMongoDBCollections request. The method always +// closes the http.Response Body. +func (client MongoDBResourcesClient) ListMongoDBCollectionsResponder(resp *http.Response) (result MongoDBCollectionListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListMongoDBDatabases lists the MongoDB databases under an existing Azure Cosmos DB database account. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +func (client MongoDBResourcesClient) ListMongoDBDatabases(ctx context.Context, resourceGroupName string, accountName string) (result MongoDBDatabaseListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MongoDBResourcesClient.ListMongoDBDatabases") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.MongoDBResourcesClient", "ListMongoDBDatabases", err.Error()) + } + + req, err := client.ListMongoDBDatabasesPreparer(ctx, resourceGroupName, accountName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "ListMongoDBDatabases", nil, "Failure preparing request") + return + } + + resp, err := client.ListMongoDBDatabasesSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "ListMongoDBDatabases", resp, "Failure sending request") + return + } + + result, err = client.ListMongoDBDatabasesResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "ListMongoDBDatabases", resp, "Failure responding to request") + return + } + + return +} + +// ListMongoDBDatabasesPreparer prepares the ListMongoDBDatabases request. +func (client MongoDBResourcesClient) ListMongoDBDatabasesPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListMongoDBDatabasesSender sends the ListMongoDBDatabases request. The method will close the +// http.Response Body if it receives an error. +func (client MongoDBResourcesClient) ListMongoDBDatabasesSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListMongoDBDatabasesResponder handles the response to the ListMongoDBDatabases request. The method always +// closes the http.Response Body. +func (client MongoDBResourcesClient) ListMongoDBDatabasesResponder(resp *http.Response) (result MongoDBDatabaseListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// MigrateMongoDBCollectionToAutoscale migrate an Azure Cosmos DB MongoDB collection from manual throughput to +// autoscale +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +// collectionName - cosmos DB collection name. +func (client MongoDBResourcesClient) MigrateMongoDBCollectionToAutoscale(ctx context.Context, resourceGroupName string, accountName string, databaseName string, collectionName string) (result MongoDBResourcesMigrateMongoDBCollectionToAutoscaleFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MongoDBResourcesClient.MigrateMongoDBCollectionToAutoscale") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.MongoDBResourcesClient", "MigrateMongoDBCollectionToAutoscale", err.Error()) + } + + req, err := client.MigrateMongoDBCollectionToAutoscalePreparer(ctx, resourceGroupName, accountName, databaseName, collectionName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "MigrateMongoDBCollectionToAutoscale", nil, "Failure preparing request") + return + } + + result, err = client.MigrateMongoDBCollectionToAutoscaleSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "MigrateMongoDBCollectionToAutoscale", nil, "Failure sending request") + return + } + + return +} + +// MigrateMongoDBCollectionToAutoscalePreparer prepares the MigrateMongoDBCollectionToAutoscale request. +func (client MongoDBResourcesClient) MigrateMongoDBCollectionToAutoscalePreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, collectionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "collectionName": autorest.Encode("path", collectionName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}/throughputSettings/default/migrateToAutoscale", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// MigrateMongoDBCollectionToAutoscaleSender sends the MigrateMongoDBCollectionToAutoscale request. The method will close the +// http.Response Body if it receives an error. +func (client MongoDBResourcesClient) MigrateMongoDBCollectionToAutoscaleSender(req *http.Request) (future MongoDBResourcesMigrateMongoDBCollectionToAutoscaleFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// MigrateMongoDBCollectionToAutoscaleResponder handles the response to the MigrateMongoDBCollectionToAutoscale request. The method always +// closes the http.Response Body. +func (client MongoDBResourcesClient) MigrateMongoDBCollectionToAutoscaleResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// MigrateMongoDBCollectionToManualThroughput migrate an Azure Cosmos DB MongoDB collection from autoscale to manual +// throughput +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +// collectionName - cosmos DB collection name. +func (client MongoDBResourcesClient) MigrateMongoDBCollectionToManualThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string, collectionName string) (result MongoDBResourcesMigrateMongoDBCollectionToManualThroughputFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MongoDBResourcesClient.MigrateMongoDBCollectionToManualThroughput") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.MongoDBResourcesClient", "MigrateMongoDBCollectionToManualThroughput", err.Error()) + } + + req, err := client.MigrateMongoDBCollectionToManualThroughputPreparer(ctx, resourceGroupName, accountName, databaseName, collectionName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "MigrateMongoDBCollectionToManualThroughput", nil, "Failure preparing request") + return + } + + result, err = client.MigrateMongoDBCollectionToManualThroughputSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "MigrateMongoDBCollectionToManualThroughput", nil, "Failure sending request") + return + } + + return +} + +// MigrateMongoDBCollectionToManualThroughputPreparer prepares the MigrateMongoDBCollectionToManualThroughput request. +func (client MongoDBResourcesClient) MigrateMongoDBCollectionToManualThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, collectionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "collectionName": autorest.Encode("path", collectionName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}/throughputSettings/default/migrateToManualThroughput", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// MigrateMongoDBCollectionToManualThroughputSender sends the MigrateMongoDBCollectionToManualThroughput request. The method will close the +// http.Response Body if it receives an error. +func (client MongoDBResourcesClient) MigrateMongoDBCollectionToManualThroughputSender(req *http.Request) (future MongoDBResourcesMigrateMongoDBCollectionToManualThroughputFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// MigrateMongoDBCollectionToManualThroughputResponder handles the response to the MigrateMongoDBCollectionToManualThroughput request. The method always +// closes the http.Response Body. +func (client MongoDBResourcesClient) MigrateMongoDBCollectionToManualThroughputResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// MigrateMongoDBDatabaseToAutoscale migrate an Azure Cosmos DB MongoDB database from manual throughput to autoscale +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +func (client MongoDBResourcesClient) MigrateMongoDBDatabaseToAutoscale(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result MongoDBResourcesMigrateMongoDBDatabaseToAutoscaleFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MongoDBResourcesClient.MigrateMongoDBDatabaseToAutoscale") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.MongoDBResourcesClient", "MigrateMongoDBDatabaseToAutoscale", err.Error()) + } + + req, err := client.MigrateMongoDBDatabaseToAutoscalePreparer(ctx, resourceGroupName, accountName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "MigrateMongoDBDatabaseToAutoscale", nil, "Failure preparing request") + return + } + + result, err = client.MigrateMongoDBDatabaseToAutoscaleSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "MigrateMongoDBDatabaseToAutoscale", nil, "Failure sending request") + return + } + + return +} + +// MigrateMongoDBDatabaseToAutoscalePreparer prepares the MigrateMongoDBDatabaseToAutoscale request. +func (client MongoDBResourcesClient) MigrateMongoDBDatabaseToAutoscalePreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/throughputSettings/default/migrateToAutoscale", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// MigrateMongoDBDatabaseToAutoscaleSender sends the MigrateMongoDBDatabaseToAutoscale request. The method will close the +// http.Response Body if it receives an error. +func (client MongoDBResourcesClient) MigrateMongoDBDatabaseToAutoscaleSender(req *http.Request) (future MongoDBResourcesMigrateMongoDBDatabaseToAutoscaleFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// MigrateMongoDBDatabaseToAutoscaleResponder handles the response to the MigrateMongoDBDatabaseToAutoscale request. The method always +// closes the http.Response Body. +func (client MongoDBResourcesClient) MigrateMongoDBDatabaseToAutoscaleResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// MigrateMongoDBDatabaseToManualThroughput migrate an Azure Cosmos DB MongoDB database from autoscale to manual +// throughput +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +func (client MongoDBResourcesClient) MigrateMongoDBDatabaseToManualThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result MongoDBResourcesMigrateMongoDBDatabaseToManualThroughputFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MongoDBResourcesClient.MigrateMongoDBDatabaseToManualThroughput") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.MongoDBResourcesClient", "MigrateMongoDBDatabaseToManualThroughput", err.Error()) + } + + req, err := client.MigrateMongoDBDatabaseToManualThroughputPreparer(ctx, resourceGroupName, accountName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "MigrateMongoDBDatabaseToManualThroughput", nil, "Failure preparing request") + return + } + + result, err = client.MigrateMongoDBDatabaseToManualThroughputSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "MigrateMongoDBDatabaseToManualThroughput", nil, "Failure sending request") + return + } + + return +} + +// MigrateMongoDBDatabaseToManualThroughputPreparer prepares the MigrateMongoDBDatabaseToManualThroughput request. +func (client MongoDBResourcesClient) MigrateMongoDBDatabaseToManualThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/throughputSettings/default/migrateToManualThroughput", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// MigrateMongoDBDatabaseToManualThroughputSender sends the MigrateMongoDBDatabaseToManualThroughput request. The method will close the +// http.Response Body if it receives an error. +func (client MongoDBResourcesClient) MigrateMongoDBDatabaseToManualThroughputSender(req *http.Request) (future MongoDBResourcesMigrateMongoDBDatabaseToManualThroughputFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// MigrateMongoDBDatabaseToManualThroughputResponder handles the response to the MigrateMongoDBDatabaseToManualThroughput request. The method always +// closes the http.Response Body. +func (client MongoDBResourcesClient) MigrateMongoDBDatabaseToManualThroughputResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// UpdateMongoDBCollectionThroughput update the RUs per second of an Azure Cosmos DB MongoDB collection +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +// collectionName - cosmos DB collection name. +// updateThroughputParameters - the RUs per second of the parameters to provide for the current MongoDB +// collection. +func (client MongoDBResourcesClient) UpdateMongoDBCollectionThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string, collectionName string, updateThroughputParameters ThroughputSettingsUpdateParameters) (result MongoDBResourcesUpdateMongoDBCollectionThroughputFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MongoDBResourcesClient.UpdateMongoDBCollectionThroughput") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}, + {TargetValue: updateThroughputParameters, + Constraints: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties.Resource", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties.Resource.AutoscaleSettings", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties.Resource.AutoscaleSettings.MaxThroughput", Name: validation.Null, Rule: true, Chain: nil}}}, + }}, + }}}}}); err != nil { + return result, validation.NewError("documentdb.MongoDBResourcesClient", "UpdateMongoDBCollectionThroughput", err.Error()) + } + + req, err := client.UpdateMongoDBCollectionThroughputPreparer(ctx, resourceGroupName, accountName, databaseName, collectionName, updateThroughputParameters) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "UpdateMongoDBCollectionThroughput", nil, "Failure preparing request") + return + } + + result, err = client.UpdateMongoDBCollectionThroughputSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "UpdateMongoDBCollectionThroughput", nil, "Failure sending request") + return + } + + return +} + +// UpdateMongoDBCollectionThroughputPreparer prepares the UpdateMongoDBCollectionThroughput request. +func (client MongoDBResourcesClient) UpdateMongoDBCollectionThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, collectionName string, updateThroughputParameters ThroughputSettingsUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "collectionName": autorest.Encode("path", collectionName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + 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.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}/throughputSettings/default", pathParameters), + autorest.WithJSON(updateThroughputParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateMongoDBCollectionThroughputSender sends the UpdateMongoDBCollectionThroughput request. The method will close the +// http.Response Body if it receives an error. +func (client MongoDBResourcesClient) UpdateMongoDBCollectionThroughputSender(req *http.Request) (future MongoDBResourcesUpdateMongoDBCollectionThroughputFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// UpdateMongoDBCollectionThroughputResponder handles the response to the UpdateMongoDBCollectionThroughput request. The method always +// closes the http.Response Body. +func (client MongoDBResourcesClient) UpdateMongoDBCollectionThroughputResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// UpdateMongoDBDatabaseThroughput update RUs per second of the an Azure Cosmos DB MongoDB database +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +// updateThroughputParameters - the RUs per second of the parameters to provide for the current MongoDB +// database. +func (client MongoDBResourcesClient) UpdateMongoDBDatabaseThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string, updateThroughputParameters ThroughputSettingsUpdateParameters) (result MongoDBResourcesUpdateMongoDBDatabaseThroughputFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MongoDBResourcesClient.UpdateMongoDBDatabaseThroughput") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}, + {TargetValue: updateThroughputParameters, + Constraints: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties.Resource", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties.Resource.AutoscaleSettings", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties.Resource.AutoscaleSettings.MaxThroughput", Name: validation.Null, Rule: true, Chain: nil}}}, + }}, + }}}}}); err != nil { + return result, validation.NewError("documentdb.MongoDBResourcesClient", "UpdateMongoDBDatabaseThroughput", err.Error()) + } + + req, err := client.UpdateMongoDBDatabaseThroughputPreparer(ctx, resourceGroupName, accountName, databaseName, updateThroughputParameters) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "UpdateMongoDBDatabaseThroughput", nil, "Failure preparing request") + return + } + + result, err = client.UpdateMongoDBDatabaseThroughputSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "UpdateMongoDBDatabaseThroughput", nil, "Failure sending request") + return + } + + return +} + +// UpdateMongoDBDatabaseThroughputPreparer prepares the UpdateMongoDBDatabaseThroughput request. +func (client MongoDBResourcesClient) UpdateMongoDBDatabaseThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, updateThroughputParameters ThroughputSettingsUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + 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.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/throughputSettings/default", pathParameters), + autorest.WithJSON(updateThroughputParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateMongoDBDatabaseThroughputSender sends the UpdateMongoDBDatabaseThroughput request. The method will close the +// http.Response Body if it receives an error. +func (client MongoDBResourcesClient) UpdateMongoDBDatabaseThroughputSender(req *http.Request) (future MongoDBResourcesUpdateMongoDBDatabaseThroughputFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// UpdateMongoDBDatabaseThroughputResponder handles the response to the UpdateMongoDBDatabaseThroughput request. The method always +// closes the http.Response Body. +func (client MongoDBResourcesClient) UpdateMongoDBDatabaseThroughputResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/cosmos-db/mgmt/2021-06-15/documentdb/notebookworkspaces.go b/services/cosmos-db/mgmt/2021-06-15/documentdb/notebookworkspaces.go new file mode 100644 index 000000000000..21466bc077d5 --- /dev/null +++ b/services/cosmos-db/mgmt/2021-06-15/documentdb/notebookworkspaces.go @@ -0,0 +1,670 @@ +package documentdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// NotebookWorkspacesClient is the client for the NotebookWorkspaces methods of the Documentdb service. +type NotebookWorkspacesClient struct { + BaseClient +} + +// NewNotebookWorkspacesClient creates an instance of the NotebookWorkspacesClient client. +func NewNotebookWorkspacesClient(subscriptionID string) NotebookWorkspacesClient { + return NewNotebookWorkspacesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewNotebookWorkspacesClientWithBaseURI creates an instance of the NotebookWorkspacesClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewNotebookWorkspacesClientWithBaseURI(baseURI string, subscriptionID string) NotebookWorkspacesClient { + return NotebookWorkspacesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates the notebook workspace for a Cosmos DB account. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// notebookCreateUpdateParameters - the notebook workspace to create for the current database account. +func (client NotebookWorkspacesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, accountName string, notebookCreateUpdateParameters NotebookWorkspaceCreateUpdateParameters) (result NotebookWorkspacesCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/NotebookWorkspacesClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.NotebookWorkspacesClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, accountName, notebookCreateUpdateParameters) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesClient", "CreateOrUpdate", nil, "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client NotebookWorkspacesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, accountName string, notebookCreateUpdateParameters NotebookWorkspaceCreateUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "notebookWorkspaceName": autorest.Encode("path", "default"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + 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.DocumentDB/databaseAccounts/{accountName}/notebookWorkspaces/{notebookWorkspaceName}", pathParameters), + autorest.WithJSON(notebookCreateUpdateParameters), + 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 NotebookWorkspacesClient) CreateOrUpdateSender(req *http.Request) (future NotebookWorkspacesCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client NotebookWorkspacesClient) CreateOrUpdateResponder(resp *http.Response) (result NotebookWorkspace, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes the notebook workspace for a Cosmos DB account. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +func (client NotebookWorkspacesClient) Delete(ctx context.Context, resourceGroupName string, accountName string) (result NotebookWorkspacesDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/NotebookWorkspacesClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.NotebookWorkspacesClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, accountName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesClient", "Delete", nil, "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client NotebookWorkspacesClient) DeletePreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "notebookWorkspaceName": autorest.Encode("path", "default"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/notebookWorkspaces/{notebookWorkspaceName}", 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 NotebookWorkspacesClient) DeleteSender(req *http.Request) (future NotebookWorkspacesDeleteFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client NotebookWorkspacesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets the notebook workspace for a Cosmos DB account. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +func (client NotebookWorkspacesClient) Get(ctx context.Context, resourceGroupName string, accountName string) (result NotebookWorkspace, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/NotebookWorkspacesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.NotebookWorkspacesClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, accountName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client NotebookWorkspacesClient) GetPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "notebookWorkspaceName": autorest.Encode("path", "default"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/notebookWorkspaces/{notebookWorkspaceName}", 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 NotebookWorkspacesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client NotebookWorkspacesClient) GetResponder(resp *http.Response) (result NotebookWorkspace, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByDatabaseAccount gets the notebook workspace resources of an existing Cosmos DB account. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +func (client NotebookWorkspacesClient) ListByDatabaseAccount(ctx context.Context, resourceGroupName string, accountName string) (result NotebookWorkspaceListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/NotebookWorkspacesClient.ListByDatabaseAccount") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.NotebookWorkspacesClient", "ListByDatabaseAccount", err.Error()) + } + + req, err := client.ListByDatabaseAccountPreparer(ctx, resourceGroupName, accountName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesClient", "ListByDatabaseAccount", nil, "Failure preparing request") + return + } + + resp, err := client.ListByDatabaseAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesClient", "ListByDatabaseAccount", resp, "Failure sending request") + return + } + + result, err = client.ListByDatabaseAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesClient", "ListByDatabaseAccount", resp, "Failure responding to request") + return + } + + return +} + +// ListByDatabaseAccountPreparer prepares the ListByDatabaseAccount request. +func (client NotebookWorkspacesClient) ListByDatabaseAccountPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/notebookWorkspaces", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByDatabaseAccountSender sends the ListByDatabaseAccount request. The method will close the +// http.Response Body if it receives an error. +func (client NotebookWorkspacesClient) ListByDatabaseAccountSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByDatabaseAccountResponder handles the response to the ListByDatabaseAccount request. The method always +// closes the http.Response Body. +func (client NotebookWorkspacesClient) ListByDatabaseAccountResponder(resp *http.Response) (result NotebookWorkspaceListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListConnectionInfo retrieves the connection info for the notebook workspace +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +func (client NotebookWorkspacesClient) ListConnectionInfo(ctx context.Context, resourceGroupName string, accountName string) (result NotebookWorkspaceConnectionInfoResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/NotebookWorkspacesClient.ListConnectionInfo") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.NotebookWorkspacesClient", "ListConnectionInfo", err.Error()) + } + + req, err := client.ListConnectionInfoPreparer(ctx, resourceGroupName, accountName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesClient", "ListConnectionInfo", nil, "Failure preparing request") + return + } + + resp, err := client.ListConnectionInfoSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesClient", "ListConnectionInfo", resp, "Failure sending request") + return + } + + result, err = client.ListConnectionInfoResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesClient", "ListConnectionInfo", resp, "Failure responding to request") + return + } + + return +} + +// ListConnectionInfoPreparer prepares the ListConnectionInfo request. +func (client NotebookWorkspacesClient) ListConnectionInfoPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "notebookWorkspaceName": autorest.Encode("path", "default"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/notebookWorkspaces/{notebookWorkspaceName}/listConnectionInfo", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListConnectionInfoSender sends the ListConnectionInfo request. The method will close the +// http.Response Body if it receives an error. +func (client NotebookWorkspacesClient) ListConnectionInfoSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListConnectionInfoResponder handles the response to the ListConnectionInfo request. The method always +// closes the http.Response Body. +func (client NotebookWorkspacesClient) ListConnectionInfoResponder(resp *http.Response) (result NotebookWorkspaceConnectionInfoResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// RegenerateAuthToken regenerates the auth token for the notebook workspace +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +func (client NotebookWorkspacesClient) RegenerateAuthToken(ctx context.Context, resourceGroupName string, accountName string) (result NotebookWorkspacesRegenerateAuthTokenFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/NotebookWorkspacesClient.RegenerateAuthToken") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.NotebookWorkspacesClient", "RegenerateAuthToken", err.Error()) + } + + req, err := client.RegenerateAuthTokenPreparer(ctx, resourceGroupName, accountName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesClient", "RegenerateAuthToken", nil, "Failure preparing request") + return + } + + result, err = client.RegenerateAuthTokenSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesClient", "RegenerateAuthToken", nil, "Failure sending request") + return + } + + return +} + +// RegenerateAuthTokenPreparer prepares the RegenerateAuthToken request. +func (client NotebookWorkspacesClient) RegenerateAuthTokenPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "notebookWorkspaceName": autorest.Encode("path", "default"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/notebookWorkspaces/{notebookWorkspaceName}/regenerateAuthToken", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// RegenerateAuthTokenSender sends the RegenerateAuthToken request. The method will close the +// http.Response Body if it receives an error. +func (client NotebookWorkspacesClient) RegenerateAuthTokenSender(req *http.Request) (future NotebookWorkspacesRegenerateAuthTokenFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// RegenerateAuthTokenResponder handles the response to the RegenerateAuthToken request. The method always +// closes the http.Response Body. +func (client NotebookWorkspacesClient) RegenerateAuthTokenResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + +// Start starts the notebook workspace +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +func (client NotebookWorkspacesClient) Start(ctx context.Context, resourceGroupName string, accountName string) (result NotebookWorkspacesStartFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/NotebookWorkspacesClient.Start") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.NotebookWorkspacesClient", "Start", err.Error()) + } + + req, err := client.StartPreparer(ctx, resourceGroupName, accountName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesClient", "Start", nil, "Failure preparing request") + return + } + + result, err = client.StartSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesClient", "Start", nil, "Failure sending request") + return + } + + return +} + +// StartPreparer prepares the Start request. +func (client NotebookWorkspacesClient) StartPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "notebookWorkspaceName": autorest.Encode("path", "default"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/notebookWorkspaces/{notebookWorkspaceName}/start", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// StartSender sends the Start request. The method will close the +// http.Response Body if it receives an error. +func (client NotebookWorkspacesClient) StartSender(req *http.Request) (future NotebookWorkspacesStartFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// StartResponder handles the response to the Start request. The method always +// closes the http.Response Body. +func (client NotebookWorkspacesClient) StartResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} diff --git a/services/cosmos-db/mgmt/2021-06-15/documentdb/operations.go b/services/cosmos-db/mgmt/2021-06-15/documentdb/operations.go new file mode 100644 index 000000000000..46f18a0efdfd --- /dev/null +++ b/services/cosmos-db/mgmt/2021-06-15/documentdb/operations.go @@ -0,0 +1,140 @@ +package documentdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// OperationsClient is the client for the Operations methods of the Documentdb service. +type OperationsClient struct { + BaseClient +} + +// NewOperationsClient creates an instance of the OperationsClient client. +func NewOperationsClient(subscriptionID string) OperationsClient { + return NewOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewOperationsClientWithBaseURI creates an instance of the OperationsClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient { + return OperationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List lists all of the available Cosmos DB Resource Provider operations. +func (client OperationsClient) List(ctx context.Context) (result OperationListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List") + defer func() { + sc := -1 + if result.olr.Response.Response != nil { + sc = result.olr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.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, "documentdb.OperationsClient", "List", resp, "Failure sending request") + return + } + + result.olr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.OperationsClient", "List", resp, "Failure responding to request") + return + } + if result.olr.hasNextLink() && result.olr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client OperationsClient) ListPreparer(ctx context.Context) (*http.Request, error) { + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.DocumentDB/operations"), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client OperationsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client OperationsClient) ListResponder(resp *http.Response) (result OperationListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client OperationsClient) listNextResults(ctx context.Context, lastResults OperationListResult) (result OperationListResult, err error) { + req, err := lastResults.operationListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "documentdb.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, "documentdb.OperationsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.OperationsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client OperationsClient) ListComplete(ctx context.Context) (result OperationListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx) + return +} diff --git a/services/cosmos-db/mgmt/2021-06-15/documentdb/partitionkeyrangeid.go b/services/cosmos-db/mgmt/2021-06-15/documentdb/partitionkeyrangeid.go new file mode 100644 index 000000000000..4581fde9671e --- /dev/null +++ b/services/cosmos-db/mgmt/2021-06-15/documentdb/partitionkeyrangeid.go @@ -0,0 +1,132 @@ +package documentdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// PartitionKeyRangeIDClient is the client for the PartitionKeyRangeID methods of the Documentdb service. +type PartitionKeyRangeIDClient struct { + BaseClient +} + +// NewPartitionKeyRangeIDClient creates an instance of the PartitionKeyRangeIDClient client. +func NewPartitionKeyRangeIDClient(subscriptionID string) PartitionKeyRangeIDClient { + return NewPartitionKeyRangeIDClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewPartitionKeyRangeIDClientWithBaseURI creates an instance of the PartitionKeyRangeIDClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewPartitionKeyRangeIDClientWithBaseURI(baseURI string, subscriptionID string) PartitionKeyRangeIDClient { + return PartitionKeyRangeIDClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListMetrics retrieves the metrics determined by the given filter for the given partition key range id. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseRid - cosmos DB database rid. +// collectionRid - cosmos DB collection rid. +// partitionKeyRangeID - partition Key Range Id for which to get data. +// filter - an OData filter expression that describes a subset of metrics to return. The parameters that can be +// filtered are name.value (name of the metric, can have an or of multiple names), startTime, endTime, and +// timeGrain. The supported operator is eq. +func (client PartitionKeyRangeIDClient) ListMetrics(ctx context.Context, resourceGroupName string, accountName string, databaseRid string, collectionRid string, partitionKeyRangeID string, filter string) (result PartitionMetricListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PartitionKeyRangeIDClient.ListMetrics") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.PartitionKeyRangeIDClient", "ListMetrics", err.Error()) + } + + req, err := client.ListMetricsPreparer(ctx, resourceGroupName, accountName, databaseRid, collectionRid, partitionKeyRangeID, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.PartitionKeyRangeIDClient", "ListMetrics", nil, "Failure preparing request") + return + } + + resp, err := client.ListMetricsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.PartitionKeyRangeIDClient", "ListMetrics", resp, "Failure sending request") + return + } + + result, err = client.ListMetricsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.PartitionKeyRangeIDClient", "ListMetrics", resp, "Failure responding to request") + return + } + + return +} + +// ListMetricsPreparer prepares the ListMetrics request. +func (client PartitionKeyRangeIDClient) ListMetricsPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseRid string, collectionRid string, partitionKeyRangeID string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "collectionRid": autorest.Encode("path", collectionRid), + "databaseRid": autorest.Encode("path", databaseRid), + "partitionKeyRangeId": autorest.Encode("path", partitionKeyRangeID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + 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.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/collections/{collectionRid}/partitionKeyRangeId/{partitionKeyRangeId}/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 PartitionKeyRangeIDClient) ListMetricsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListMetricsResponder handles the response to the ListMetrics request. The method always +// closes the http.Response Body. +func (client PartitionKeyRangeIDClient) ListMetricsResponder(resp *http.Response) (result PartitionMetricListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/cosmos-db/mgmt/2021-06-15/documentdb/partitionkeyrangeidregion.go b/services/cosmos-db/mgmt/2021-06-15/documentdb/partitionkeyrangeidregion.go new file mode 100644 index 000000000000..212e734187cf --- /dev/null +++ b/services/cosmos-db/mgmt/2021-06-15/documentdb/partitionkeyrangeidregion.go @@ -0,0 +1,134 @@ +package documentdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// PartitionKeyRangeIDRegionClient is the client for the PartitionKeyRangeIDRegion methods of the Documentdb service. +type PartitionKeyRangeIDRegionClient struct { + BaseClient +} + +// NewPartitionKeyRangeIDRegionClient creates an instance of the PartitionKeyRangeIDRegionClient client. +func NewPartitionKeyRangeIDRegionClient(subscriptionID string) PartitionKeyRangeIDRegionClient { + return NewPartitionKeyRangeIDRegionClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewPartitionKeyRangeIDRegionClientWithBaseURI creates an instance of the PartitionKeyRangeIDRegionClient client +// using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign +// clouds, Azure stack). +func NewPartitionKeyRangeIDRegionClientWithBaseURI(baseURI string, subscriptionID string) PartitionKeyRangeIDRegionClient { + return PartitionKeyRangeIDRegionClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListMetrics retrieves the metrics determined by the given filter for the given partition key range id and region. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// region - cosmos DB region, with spaces between words and each word capitalized. +// databaseRid - cosmos DB database rid. +// collectionRid - cosmos DB collection rid. +// partitionKeyRangeID - partition Key Range Id for which to get data. +// filter - an OData filter expression that describes a subset of metrics to return. The parameters that can be +// filtered are name.value (name of the metric, can have an or of multiple names), startTime, endTime, and +// timeGrain. The supported operator is eq. +func (client PartitionKeyRangeIDRegionClient) ListMetrics(ctx context.Context, resourceGroupName string, accountName string, region string, databaseRid string, collectionRid string, partitionKeyRangeID string, filter string) (result PartitionMetricListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PartitionKeyRangeIDRegionClient.ListMetrics") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.PartitionKeyRangeIDRegionClient", "ListMetrics", err.Error()) + } + + req, err := client.ListMetricsPreparer(ctx, resourceGroupName, accountName, region, databaseRid, collectionRid, partitionKeyRangeID, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.PartitionKeyRangeIDRegionClient", "ListMetrics", nil, "Failure preparing request") + return + } + + resp, err := client.ListMetricsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.PartitionKeyRangeIDRegionClient", "ListMetrics", resp, "Failure sending request") + return + } + + result, err = client.ListMetricsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.PartitionKeyRangeIDRegionClient", "ListMetrics", resp, "Failure responding to request") + return + } + + return +} + +// ListMetricsPreparer prepares the ListMetrics request. +func (client PartitionKeyRangeIDRegionClient) ListMetricsPreparer(ctx context.Context, resourceGroupName string, accountName string, region string, databaseRid string, collectionRid string, partitionKeyRangeID string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "collectionRid": autorest.Encode("path", collectionRid), + "databaseRid": autorest.Encode("path", databaseRid), + "partitionKeyRangeId": autorest.Encode("path", partitionKeyRangeID), + "region": autorest.Encode("path", region), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + 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.DocumentDB/databaseAccounts/{accountName}/region/{region}/databases/{databaseRid}/collections/{collectionRid}/partitionKeyRangeId/{partitionKeyRangeId}/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 PartitionKeyRangeIDRegionClient) ListMetricsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListMetricsResponder handles the response to the ListMetrics request. The method always +// closes the http.Response Body. +func (client PartitionKeyRangeIDRegionClient) ListMetricsResponder(resp *http.Response) (result PartitionMetricListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/cosmos-db/mgmt/2021-06-15/documentdb/percentile.go b/services/cosmos-db/mgmt/2021-06-15/documentdb/percentile.go new file mode 100644 index 000000000000..930b4fcf780a --- /dev/null +++ b/services/cosmos-db/mgmt/2021-06-15/documentdb/percentile.go @@ -0,0 +1,126 @@ +package documentdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// PercentileClient is the client for the Percentile methods of the Documentdb service. +type PercentileClient struct { + BaseClient +} + +// NewPercentileClient creates an instance of the PercentileClient client. +func NewPercentileClient(subscriptionID string) PercentileClient { + return NewPercentileClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewPercentileClientWithBaseURI creates an instance of the PercentileClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewPercentileClientWithBaseURI(baseURI string, subscriptionID string) PercentileClient { + return PercentileClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListMetrics retrieves the metrics determined by the given filter for the given database account. This url is only +// for PBS and Replication Latency data +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// filter - an OData filter expression that describes a subset of metrics to return. The parameters that can be +// filtered are name.value (name of the metric, can have an or of multiple names), startTime, endTime, and +// timeGrain. The supported operator is eq. +func (client PercentileClient) ListMetrics(ctx context.Context, resourceGroupName string, accountName string, filter string) (result PercentileMetricListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PercentileClient.ListMetrics") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.PercentileClient", "ListMetrics", err.Error()) + } + + req, err := client.ListMetricsPreparer(ctx, resourceGroupName, accountName, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.PercentileClient", "ListMetrics", nil, "Failure preparing request") + return + } + + resp, err := client.ListMetricsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.PercentileClient", "ListMetrics", resp, "Failure sending request") + return + } + + result, err = client.ListMetricsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.PercentileClient", "ListMetrics", resp, "Failure responding to request") + return + } + + return +} + +// ListMetricsPreparer prepares the ListMetrics request. +func (client PercentileClient) ListMetricsPreparer(ctx context.Context, resourceGroupName string, accountName string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + 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.DocumentDB/databaseAccounts/{accountName}/percentile/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 PercentileClient) ListMetricsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListMetricsResponder handles the response to the ListMetrics request. The method always +// closes the http.Response Body. +func (client PercentileClient) ListMetricsResponder(resp *http.Response) (result PercentileMetricListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/cosmos-db/mgmt/2021-06-15/documentdb/percentilesourcetarget.go b/services/cosmos-db/mgmt/2021-06-15/documentdb/percentilesourcetarget.go new file mode 100644 index 000000000000..432604d66002 --- /dev/null +++ b/services/cosmos-db/mgmt/2021-06-15/documentdb/percentilesourcetarget.go @@ -0,0 +1,133 @@ +package documentdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// PercentileSourceTargetClient is the client for the PercentileSourceTarget methods of the Documentdb service. +type PercentileSourceTargetClient struct { + BaseClient +} + +// NewPercentileSourceTargetClient creates an instance of the PercentileSourceTargetClient client. +func NewPercentileSourceTargetClient(subscriptionID string) PercentileSourceTargetClient { + return NewPercentileSourceTargetClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewPercentileSourceTargetClientWithBaseURI creates an instance of the PercentileSourceTargetClient client using a +// custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, +// Azure stack). +func NewPercentileSourceTargetClientWithBaseURI(baseURI string, subscriptionID string) PercentileSourceTargetClient { + return PercentileSourceTargetClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListMetrics retrieves the metrics determined by the given filter for the given account, source and target region. +// This url is only for PBS and Replication Latency data +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// sourceRegion - source region from which data is written. Cosmos DB region, with spaces between words and +// each word capitalized. +// targetRegion - target region to which data is written. Cosmos DB region, with spaces between words and each +// word capitalized. +// filter - an OData filter expression that describes a subset of metrics to return. The parameters that can be +// filtered are name.value (name of the metric, can have an or of multiple names), startTime, endTime, and +// timeGrain. The supported operator is eq. +func (client PercentileSourceTargetClient) ListMetrics(ctx context.Context, resourceGroupName string, accountName string, sourceRegion string, targetRegion string, filter string) (result PercentileMetricListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PercentileSourceTargetClient.ListMetrics") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.PercentileSourceTargetClient", "ListMetrics", err.Error()) + } + + req, err := client.ListMetricsPreparer(ctx, resourceGroupName, accountName, sourceRegion, targetRegion, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.PercentileSourceTargetClient", "ListMetrics", nil, "Failure preparing request") + return + } + + resp, err := client.ListMetricsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.PercentileSourceTargetClient", "ListMetrics", resp, "Failure sending request") + return + } + + result, err = client.ListMetricsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.PercentileSourceTargetClient", "ListMetrics", resp, "Failure responding to request") + return + } + + return +} + +// ListMetricsPreparer prepares the ListMetrics request. +func (client PercentileSourceTargetClient) ListMetricsPreparer(ctx context.Context, resourceGroupName string, accountName string, sourceRegion string, targetRegion string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "sourceRegion": autorest.Encode("path", sourceRegion), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "targetRegion": autorest.Encode("path", targetRegion), + } + + const APIVersion = "2021-06-15" + 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.DocumentDB/databaseAccounts/{accountName}/sourceRegion/{sourceRegion}/targetRegion/{targetRegion}/percentile/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 PercentileSourceTargetClient) ListMetricsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListMetricsResponder handles the response to the ListMetrics request. The method always +// closes the http.Response Body. +func (client PercentileSourceTargetClient) ListMetricsResponder(resp *http.Response) (result PercentileMetricListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/cosmos-db/mgmt/2021-06-15/documentdb/percentiletarget.go b/services/cosmos-db/mgmt/2021-06-15/documentdb/percentiletarget.go new file mode 100644 index 000000000000..49b1a67c32d3 --- /dev/null +++ b/services/cosmos-db/mgmt/2021-06-15/documentdb/percentiletarget.go @@ -0,0 +1,130 @@ +package documentdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// PercentileTargetClient is the client for the PercentileTarget methods of the Documentdb service. +type PercentileTargetClient struct { + BaseClient +} + +// NewPercentileTargetClient creates an instance of the PercentileTargetClient client. +func NewPercentileTargetClient(subscriptionID string) PercentileTargetClient { + return NewPercentileTargetClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewPercentileTargetClientWithBaseURI creates an instance of the PercentileTargetClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewPercentileTargetClientWithBaseURI(baseURI string, subscriptionID string) PercentileTargetClient { + return PercentileTargetClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListMetrics retrieves the metrics determined by the given filter for the given account target region. This url is +// only for PBS and Replication Latency data +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// targetRegion - target region to which data is written. Cosmos DB region, with spaces between words and each +// word capitalized. +// filter - an OData filter expression that describes a subset of metrics to return. The parameters that can be +// filtered are name.value (name of the metric, can have an or of multiple names), startTime, endTime, and +// timeGrain. The supported operator is eq. +func (client PercentileTargetClient) ListMetrics(ctx context.Context, resourceGroupName string, accountName string, targetRegion string, filter string) (result PercentileMetricListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PercentileTargetClient.ListMetrics") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.PercentileTargetClient", "ListMetrics", err.Error()) + } + + req, err := client.ListMetricsPreparer(ctx, resourceGroupName, accountName, targetRegion, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.PercentileTargetClient", "ListMetrics", nil, "Failure preparing request") + return + } + + resp, err := client.ListMetricsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.PercentileTargetClient", "ListMetrics", resp, "Failure sending request") + return + } + + result, err = client.ListMetricsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.PercentileTargetClient", "ListMetrics", resp, "Failure responding to request") + return + } + + return +} + +// ListMetricsPreparer prepares the ListMetrics request. +func (client PercentileTargetClient) ListMetricsPreparer(ctx context.Context, resourceGroupName string, accountName string, targetRegion string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "targetRegion": autorest.Encode("path", targetRegion), + } + + const APIVersion = "2021-06-15" + 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.DocumentDB/databaseAccounts/{accountName}/targetRegion/{targetRegion}/percentile/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 PercentileTargetClient) ListMetricsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListMetricsResponder handles the response to the ListMetrics request. The method always +// closes the http.Response Body. +func (client PercentileTargetClient) ListMetricsResponder(resp *http.Response) (result PercentileMetricListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/cosmos-db/mgmt/2021-06-15/documentdb/privateendpointconnections.go b/services/cosmos-db/mgmt/2021-06-15/documentdb/privateendpointconnections.go new file mode 100644 index 000000000000..fc8743092ea6 --- /dev/null +++ b/services/cosmos-db/mgmt/2021-06-15/documentdb/privateendpointconnections.go @@ -0,0 +1,400 @@ +package documentdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// PrivateEndpointConnectionsClient is the client for the PrivateEndpointConnections methods of the Documentdb service. +type PrivateEndpointConnectionsClient struct { + BaseClient +} + +// NewPrivateEndpointConnectionsClient creates an instance of the PrivateEndpointConnectionsClient client. +func NewPrivateEndpointConnectionsClient(subscriptionID string) PrivateEndpointConnectionsClient { + return NewPrivateEndpointConnectionsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewPrivateEndpointConnectionsClientWithBaseURI creates an instance of the PrivateEndpointConnectionsClient client +// using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign +// clouds, Azure stack). +func NewPrivateEndpointConnectionsClientWithBaseURI(baseURI string, subscriptionID string) PrivateEndpointConnectionsClient { + return PrivateEndpointConnectionsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate approve or reject a private endpoint connection with a given name. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// privateEndpointConnectionName - the name of the private endpoint connection. +func (client PrivateEndpointConnectionsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, accountName string, privateEndpointConnectionName string, parameters PrivateEndpointConnection) (result PrivateEndpointConnectionsCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.PrivateEndpointConnectionsClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, accountName, privateEndpointConnectionName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.PrivateEndpointConnectionsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.PrivateEndpointConnectionsClient", "CreateOrUpdate", nil, "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client PrivateEndpointConnectionsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, accountName string, privateEndpointConnectionName string, parameters PrivateEndpointConnection) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "privateEndpointConnectionName": autorest.Encode("path", privateEndpointConnectionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + 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.DocumentDB/databaseAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateEndpointConnectionsClient) CreateOrUpdateSender(req *http.Request) (future PrivateEndpointConnectionsCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client PrivateEndpointConnectionsClient) CreateOrUpdateResponder(resp *http.Response) (result PrivateEndpointConnection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a private endpoint connection with a given name. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// privateEndpointConnectionName - the name of the private endpoint connection. +func (client PrivateEndpointConnectionsClient) Delete(ctx context.Context, resourceGroupName string, accountName string, privateEndpointConnectionName string) (result PrivateEndpointConnectionsDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.PrivateEndpointConnectionsClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, accountName, privateEndpointConnectionName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.PrivateEndpointConnectionsClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.PrivateEndpointConnectionsClient", "Delete", nil, "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client PrivateEndpointConnectionsClient) DeletePreparer(ctx context.Context, resourceGroupName string, accountName string, privateEndpointConnectionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "privateEndpointConnectionName": autorest.Encode("path", privateEndpointConnectionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateEndpointConnectionsClient) DeleteSender(req *http.Request) (future PrivateEndpointConnectionsDeleteFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client PrivateEndpointConnectionsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a private endpoint connection. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// privateEndpointConnectionName - the name of the private endpoint connection. +func (client PrivateEndpointConnectionsClient) Get(ctx context.Context, resourceGroupName string, accountName string, privateEndpointConnectionName string) (result PrivateEndpointConnection, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.PrivateEndpointConnectionsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, accountName, privateEndpointConnectionName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.PrivateEndpointConnectionsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.PrivateEndpointConnectionsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.PrivateEndpointConnectionsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client PrivateEndpointConnectionsClient) GetPreparer(ctx context.Context, resourceGroupName string, accountName string, privateEndpointConnectionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "privateEndpointConnectionName": autorest.Encode("path", privateEndpointConnectionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateEndpointConnectionsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client PrivateEndpointConnectionsClient) GetResponder(resp *http.Response) (result PrivateEndpointConnection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByDatabaseAccount list all private endpoint connections on a Cosmos DB account. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +func (client PrivateEndpointConnectionsClient) ListByDatabaseAccount(ctx context.Context, resourceGroupName string, accountName string) (result PrivateEndpointConnectionListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsClient.ListByDatabaseAccount") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.PrivateEndpointConnectionsClient", "ListByDatabaseAccount", err.Error()) + } + + req, err := client.ListByDatabaseAccountPreparer(ctx, resourceGroupName, accountName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.PrivateEndpointConnectionsClient", "ListByDatabaseAccount", nil, "Failure preparing request") + return + } + + resp, err := client.ListByDatabaseAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.PrivateEndpointConnectionsClient", "ListByDatabaseAccount", resp, "Failure sending request") + return + } + + result, err = client.ListByDatabaseAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.PrivateEndpointConnectionsClient", "ListByDatabaseAccount", resp, "Failure responding to request") + return + } + + return +} + +// ListByDatabaseAccountPreparer prepares the ListByDatabaseAccount request. +func (client PrivateEndpointConnectionsClient) ListByDatabaseAccountPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/privateEndpointConnections", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByDatabaseAccountSender sends the ListByDatabaseAccount request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateEndpointConnectionsClient) ListByDatabaseAccountSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByDatabaseAccountResponder handles the response to the ListByDatabaseAccount request. The method always +// closes the http.Response Body. +func (client PrivateEndpointConnectionsClient) ListByDatabaseAccountResponder(resp *http.Response) (result PrivateEndpointConnectionListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/cosmos-db/mgmt/2021-06-15/documentdb/privatelinkresources.go b/services/cosmos-db/mgmt/2021-06-15/documentdb/privatelinkresources.go new file mode 100644 index 000000000000..f36ed334dc3c --- /dev/null +++ b/services/cosmos-db/mgmt/2021-06-15/documentdb/privatelinkresources.go @@ -0,0 +1,213 @@ +package documentdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// PrivateLinkResourcesClient is the client for the PrivateLinkResources methods of the Documentdb service. +type PrivateLinkResourcesClient struct { + BaseClient +} + +// NewPrivateLinkResourcesClient creates an instance of the PrivateLinkResourcesClient client. +func NewPrivateLinkResourcesClient(subscriptionID string) PrivateLinkResourcesClient { + return NewPrivateLinkResourcesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewPrivateLinkResourcesClientWithBaseURI creates an instance of the PrivateLinkResourcesClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewPrivateLinkResourcesClientWithBaseURI(baseURI string, subscriptionID string) PrivateLinkResourcesClient { + return PrivateLinkResourcesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get gets the private link resources that need to be created for a Cosmos DB account. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// groupName - the name of the private link resource. +func (client PrivateLinkResourcesClient) Get(ctx context.Context, resourceGroupName string, accountName string, groupName string) (result PrivateLinkResource, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkResourcesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.PrivateLinkResourcesClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, accountName, groupName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.PrivateLinkResourcesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.PrivateLinkResourcesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.PrivateLinkResourcesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client PrivateLinkResourcesClient) GetPreparer(ctx context.Context, resourceGroupName string, accountName string, groupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "groupName": autorest.Encode("path", groupName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/privateLinkResources/{groupName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateLinkResourcesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client PrivateLinkResourcesClient) GetResponder(resp *http.Response) (result PrivateLinkResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByDatabaseAccount gets the private link resources that need to be created for a Cosmos DB account. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +func (client PrivateLinkResourcesClient) ListByDatabaseAccount(ctx context.Context, resourceGroupName string, accountName string) (result PrivateLinkResourceListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkResourcesClient.ListByDatabaseAccount") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.PrivateLinkResourcesClient", "ListByDatabaseAccount", err.Error()) + } + + req, err := client.ListByDatabaseAccountPreparer(ctx, resourceGroupName, accountName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.PrivateLinkResourcesClient", "ListByDatabaseAccount", nil, "Failure preparing request") + return + } + + resp, err := client.ListByDatabaseAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.PrivateLinkResourcesClient", "ListByDatabaseAccount", resp, "Failure sending request") + return + } + + result, err = client.ListByDatabaseAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.PrivateLinkResourcesClient", "ListByDatabaseAccount", resp, "Failure responding to request") + return + } + + return +} + +// ListByDatabaseAccountPreparer prepares the ListByDatabaseAccount request. +func (client PrivateLinkResourcesClient) ListByDatabaseAccountPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/privateLinkResources", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByDatabaseAccountSender sends the ListByDatabaseAccount request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateLinkResourcesClient) ListByDatabaseAccountSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByDatabaseAccountResponder handles the response to the ListByDatabaseAccount request. The method always +// closes the http.Response Body. +func (client PrivateLinkResourcesClient) ListByDatabaseAccountResponder(resp *http.Response) (result PrivateLinkResourceListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/cosmos-db/mgmt/2021-06-15/documentdb/restorabledatabaseaccounts.go b/services/cosmos-db/mgmt/2021-06-15/documentdb/restorabledatabaseaccounts.go new file mode 100644 index 000000000000..920f2602c10c --- /dev/null +++ b/services/cosmos-db/mgmt/2021-06-15/documentdb/restorabledatabaseaccounts.go @@ -0,0 +1,275 @@ +package documentdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// RestorableDatabaseAccountsClient is the client for the RestorableDatabaseAccounts methods of the Documentdb service. +type RestorableDatabaseAccountsClient struct { + BaseClient +} + +// NewRestorableDatabaseAccountsClient creates an instance of the RestorableDatabaseAccountsClient client. +func NewRestorableDatabaseAccountsClient(subscriptionID string) RestorableDatabaseAccountsClient { + return NewRestorableDatabaseAccountsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewRestorableDatabaseAccountsClientWithBaseURI creates an instance of the RestorableDatabaseAccountsClient client +// using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign +// clouds, Azure stack). +func NewRestorableDatabaseAccountsClientWithBaseURI(baseURI string, subscriptionID string) RestorableDatabaseAccountsClient { + return RestorableDatabaseAccountsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// GetByLocation retrieves the properties of an existing Azure Cosmos DB restorable database account. This call +// requires 'Microsoft.DocumentDB/locations/restorableDatabaseAccounts/read/*' permission. +// Parameters: +// location - cosmos DB region, with spaces between words and each word capitalized. +// instanceID - the instanceId GUID of a restorable database account. +func (client RestorableDatabaseAccountsClient) GetByLocation(ctx context.Context, location string, instanceID string) (result RestorableDatabaseAccountGetResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RestorableDatabaseAccountsClient.GetByLocation") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.RestorableDatabaseAccountsClient", "GetByLocation", err.Error()) + } + + req, err := client.GetByLocationPreparer(ctx, location, instanceID) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.RestorableDatabaseAccountsClient", "GetByLocation", nil, "Failure preparing request") + return + } + + resp, err := client.GetByLocationSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.RestorableDatabaseAccountsClient", "GetByLocation", resp, "Failure sending request") + return + } + + result, err = client.GetByLocationResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.RestorableDatabaseAccountsClient", "GetByLocation", resp, "Failure responding to request") + return + } + + return +} + +// GetByLocationPreparer prepares the GetByLocation request. +func (client RestorableDatabaseAccountsClient) GetByLocationPreparer(ctx context.Context, location string, instanceID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "instanceId": autorest.Encode("path", instanceID), + "location": autorest.Encode("path", location), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetByLocationSender sends the GetByLocation request. The method will close the +// http.Response Body if it receives an error. +func (client RestorableDatabaseAccountsClient) GetByLocationSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetByLocationResponder handles the response to the GetByLocation request. The method always +// closes the http.Response Body. +func (client RestorableDatabaseAccountsClient) GetByLocationResponder(resp *http.Response) (result RestorableDatabaseAccountGetResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List lists all the restorable Azure Cosmos DB database accounts available under the subscription. This call requires +// 'Microsoft.DocumentDB/locations/restorableDatabaseAccounts/read' permission. +func (client RestorableDatabaseAccountsClient) List(ctx context.Context) (result RestorableDatabaseAccountsListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RestorableDatabaseAccountsClient.List") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.RestorableDatabaseAccountsClient", "List", err.Error()) + } + + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.RestorableDatabaseAccountsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.RestorableDatabaseAccountsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.RestorableDatabaseAccountsClient", "List", resp, "Failure responding to request") + return + } + + return +} + +// ListPreparer prepares the List request. +func (client RestorableDatabaseAccountsClient) ListPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/restorableDatabaseAccounts", 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 RestorableDatabaseAccountsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client RestorableDatabaseAccountsClient) ListResponder(resp *http.Response) (result RestorableDatabaseAccountsListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByLocation lists all the restorable Azure Cosmos DB database accounts available under the subscription and in a +// region. This call requires 'Microsoft.DocumentDB/locations/restorableDatabaseAccounts/read' permission. +// Parameters: +// location - cosmos DB region, with spaces between words and each word capitalized. +func (client RestorableDatabaseAccountsClient) ListByLocation(ctx context.Context, location string) (result RestorableDatabaseAccountsListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RestorableDatabaseAccountsClient.ListByLocation") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.RestorableDatabaseAccountsClient", "ListByLocation", err.Error()) + } + + req, err := client.ListByLocationPreparer(ctx, location) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.RestorableDatabaseAccountsClient", "ListByLocation", nil, "Failure preparing request") + return + } + + resp, err := client.ListByLocationSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.RestorableDatabaseAccountsClient", "ListByLocation", resp, "Failure sending request") + return + } + + result, err = client.ListByLocationResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.RestorableDatabaseAccountsClient", "ListByLocation", resp, "Failure responding to request") + return + } + + return +} + +// ListByLocationPreparer prepares the ListByLocation request. +func (client RestorableDatabaseAccountsClient) ListByLocationPreparer(ctx context.Context, location string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "location": autorest.Encode("path", location), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts", 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 RestorableDatabaseAccountsClient) ListByLocationSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByLocationResponder handles the response to the ListByLocation request. The method always +// closes the http.Response Body. +func (client RestorableDatabaseAccountsClient) ListByLocationResponder(resp *http.Response) (result RestorableDatabaseAccountsListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/cosmos-db/mgmt/2021-06-15/documentdb/restorablemongodbcollections.go b/services/cosmos-db/mgmt/2021-06-15/documentdb/restorablemongodbcollections.go new file mode 100644 index 000000000000..0540aefab862 --- /dev/null +++ b/services/cosmos-db/mgmt/2021-06-15/documentdb/restorablemongodbcollections.go @@ -0,0 +1,122 @@ +package documentdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// RestorableMongodbCollectionsClient is the client for the RestorableMongodbCollections methods of the Documentdb +// service. +type RestorableMongodbCollectionsClient struct { + BaseClient +} + +// NewRestorableMongodbCollectionsClient creates an instance of the RestorableMongodbCollectionsClient client. +func NewRestorableMongodbCollectionsClient(subscriptionID string) RestorableMongodbCollectionsClient { + return NewRestorableMongodbCollectionsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewRestorableMongodbCollectionsClientWithBaseURI creates an instance of the RestorableMongodbCollectionsClient +// client using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI +// (sovereign clouds, Azure stack). +func NewRestorableMongodbCollectionsClientWithBaseURI(baseURI string, subscriptionID string) RestorableMongodbCollectionsClient { + return RestorableMongodbCollectionsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List show the event feed of all mutations done on all the Azure Cosmos DB MongoDB collections under a specific +// database. This helps in scenario where container was accidentally deleted. This API requires +// 'Microsoft.DocumentDB/locations/restorableDatabaseAccounts/.../read' permission +// Parameters: +// location - cosmos DB region, with spaces between words and each word capitalized. +// instanceID - the instanceId GUID of a restorable database account. +// restorableMongodbDatabaseRid - the resource ID of the MongoDB database. +func (client RestorableMongodbCollectionsClient) List(ctx context.Context, location string, instanceID string, restorableMongodbDatabaseRid string) (result RestorableMongodbCollectionsListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RestorableMongodbCollectionsClient.List") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.RestorableMongodbCollectionsClient", "List", err.Error()) + } + + req, err := client.ListPreparer(ctx, location, instanceID, restorableMongodbDatabaseRid) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.RestorableMongodbCollectionsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.RestorableMongodbCollectionsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.RestorableMongodbCollectionsClient", "List", resp, "Failure responding to request") + return + } + + return +} + +// ListPreparer prepares the List request. +func (client RestorableMongodbCollectionsClient) ListPreparer(ctx context.Context, location string, instanceID string, restorableMongodbDatabaseRid string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "instanceId": autorest.Encode("path", instanceID), + "location": autorest.Encode("path", location), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(restorableMongodbDatabaseRid) > 0 { + queryParameters["restorableMongodbDatabaseRid"] = autorest.Encode("query", restorableMongodbDatabaseRid) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}/restorableMongodbCollections", 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 RestorableMongodbCollectionsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client RestorableMongodbCollectionsClient) ListResponder(resp *http.Response) (result RestorableMongodbCollectionsListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/cosmos-db/mgmt/2021-06-15/documentdb/restorablemongodbdatabases.go b/services/cosmos-db/mgmt/2021-06-15/documentdb/restorablemongodbdatabases.go new file mode 100644 index 000000000000..dc1cae8c11fe --- /dev/null +++ b/services/cosmos-db/mgmt/2021-06-15/documentdb/restorablemongodbdatabases.go @@ -0,0 +1,117 @@ +package documentdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// RestorableMongodbDatabasesClient is the client for the RestorableMongodbDatabases methods of the Documentdb service. +type RestorableMongodbDatabasesClient struct { + BaseClient +} + +// NewRestorableMongodbDatabasesClient creates an instance of the RestorableMongodbDatabasesClient client. +func NewRestorableMongodbDatabasesClient(subscriptionID string) RestorableMongodbDatabasesClient { + return NewRestorableMongodbDatabasesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewRestorableMongodbDatabasesClientWithBaseURI creates an instance of the RestorableMongodbDatabasesClient client +// using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign +// clouds, Azure stack). +func NewRestorableMongodbDatabasesClientWithBaseURI(baseURI string, subscriptionID string) RestorableMongodbDatabasesClient { + return RestorableMongodbDatabasesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List show the event feed of all mutations done on all the Azure Cosmos DB MongoDB databases under the restorable +// account. This helps in scenario where database was accidentally deleted to get the deletion time. This API +// requires 'Microsoft.DocumentDB/locations/restorableDatabaseAccounts/.../read' permission +// Parameters: +// location - cosmos DB region, with spaces between words and each word capitalized. +// instanceID - the instanceId GUID of a restorable database account. +func (client RestorableMongodbDatabasesClient) List(ctx context.Context, location string, instanceID string) (result RestorableMongodbDatabasesListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RestorableMongodbDatabasesClient.List") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.RestorableMongodbDatabasesClient", "List", err.Error()) + } + + req, err := client.ListPreparer(ctx, location, instanceID) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.RestorableMongodbDatabasesClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.RestorableMongodbDatabasesClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.RestorableMongodbDatabasesClient", "List", resp, "Failure responding to request") + return + } + + return +} + +// ListPreparer prepares the List request. +func (client RestorableMongodbDatabasesClient) ListPreparer(ctx context.Context, location string, instanceID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "instanceId": autorest.Encode("path", instanceID), + "location": autorest.Encode("path", location), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}/restorableMongodbDatabases", 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 RestorableMongodbDatabasesClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client RestorableMongodbDatabasesClient) ListResponder(resp *http.Response) (result RestorableMongodbDatabasesListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/cosmos-db/mgmt/2021-06-15/documentdb/restorablemongodbresources.go b/services/cosmos-db/mgmt/2021-06-15/documentdb/restorablemongodbresources.go new file mode 100644 index 000000000000..8339ac05b6c6 --- /dev/null +++ b/services/cosmos-db/mgmt/2021-06-15/documentdb/restorablemongodbresources.go @@ -0,0 +1,125 @@ +package documentdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// RestorableMongodbResourcesClient is the client for the RestorableMongodbResources methods of the Documentdb service. +type RestorableMongodbResourcesClient struct { + BaseClient +} + +// NewRestorableMongodbResourcesClient creates an instance of the RestorableMongodbResourcesClient client. +func NewRestorableMongodbResourcesClient(subscriptionID string) RestorableMongodbResourcesClient { + return NewRestorableMongodbResourcesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewRestorableMongodbResourcesClientWithBaseURI creates an instance of the RestorableMongodbResourcesClient client +// using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign +// clouds, Azure stack). +func NewRestorableMongodbResourcesClientWithBaseURI(baseURI string, subscriptionID string) RestorableMongodbResourcesClient { + return RestorableMongodbResourcesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List return a list of database and collection combo that exist on the account at the given timestamp and location. +// This helps in scenarios to validate what resources exist at given timestamp and location. This API requires +// 'Microsoft.DocumentDB/locations/restorableDatabaseAccounts/.../read' permission. +// Parameters: +// location - cosmos DB region, with spaces between words and each word capitalized. +// instanceID - the instanceId GUID of a restorable database account. +// restoreLocation - the location where the restorable resources are located. +// restoreTimestampInUtc - the timestamp when the restorable resources existed. +func (client RestorableMongodbResourcesClient) List(ctx context.Context, location string, instanceID string, restoreLocation string, restoreTimestampInUtc string) (result RestorableMongodbResourcesListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RestorableMongodbResourcesClient.List") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.RestorableMongodbResourcesClient", "List", err.Error()) + } + + req, err := client.ListPreparer(ctx, location, instanceID, restoreLocation, restoreTimestampInUtc) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.RestorableMongodbResourcesClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.RestorableMongodbResourcesClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.RestorableMongodbResourcesClient", "List", resp, "Failure responding to request") + return + } + + return +} + +// ListPreparer prepares the List request. +func (client RestorableMongodbResourcesClient) ListPreparer(ctx context.Context, location string, instanceID string, restoreLocation string, restoreTimestampInUtc string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "instanceId": autorest.Encode("path", instanceID), + "location": autorest.Encode("path", location), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(restoreLocation) > 0 { + queryParameters["restoreLocation"] = autorest.Encode("query", restoreLocation) + } + if len(restoreTimestampInUtc) > 0 { + queryParameters["restoreTimestampInUtc"] = autorest.Encode("query", restoreTimestampInUtc) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}/restorableMongodbResources", 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 RestorableMongodbResourcesClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client RestorableMongodbResourcesClient) ListResponder(resp *http.Response) (result RestorableMongodbResourcesListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/cosmos-db/mgmt/2021-06-15/documentdb/restorablesqlcontainers.go b/services/cosmos-db/mgmt/2021-06-15/documentdb/restorablesqlcontainers.go new file mode 100644 index 000000000000..a59bdf97315c --- /dev/null +++ b/services/cosmos-db/mgmt/2021-06-15/documentdb/restorablesqlcontainers.go @@ -0,0 +1,129 @@ +package documentdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// RestorableSQLContainersClient is the client for the RestorableSQLContainers methods of the Documentdb service. +type RestorableSQLContainersClient struct { + BaseClient +} + +// NewRestorableSQLContainersClient creates an instance of the RestorableSQLContainersClient client. +func NewRestorableSQLContainersClient(subscriptionID string) RestorableSQLContainersClient { + return NewRestorableSQLContainersClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewRestorableSQLContainersClientWithBaseURI creates an instance of the RestorableSQLContainersClient client using a +// custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, +// Azure stack). +func NewRestorableSQLContainersClientWithBaseURI(baseURI string, subscriptionID string) RestorableSQLContainersClient { + return RestorableSQLContainersClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List show the event feed of all mutations done on all the Azure Cosmos DB SQL containers under a specific database. +// This helps in scenario where container was accidentally deleted. This API requires +// 'Microsoft.DocumentDB/locations/restorableDatabaseAccounts/.../read' permission +// Parameters: +// location - cosmos DB region, with spaces between words and each word capitalized. +// instanceID - the instanceId GUID of a restorable database account. +// restorableSQLDatabaseRid - the resource ID of the SQL database. +// startTime - the snapshot create timestamp after which snapshots need to be listed. +// endTime - the snapshot create timestamp before which snapshots need to be listed. +func (client RestorableSQLContainersClient) List(ctx context.Context, location string, instanceID string, restorableSQLDatabaseRid string, startTime string, endTime string) (result RestorableSQLContainersListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RestorableSQLContainersClient.List") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.RestorableSQLContainersClient", "List", err.Error()) + } + + req, err := client.ListPreparer(ctx, location, instanceID, restorableSQLDatabaseRid, startTime, endTime) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.RestorableSQLContainersClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.RestorableSQLContainersClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.RestorableSQLContainersClient", "List", resp, "Failure responding to request") + return + } + + return +} + +// ListPreparer prepares the List request. +func (client RestorableSQLContainersClient) ListPreparer(ctx context.Context, location string, instanceID string, restorableSQLDatabaseRid string, startTime string, endTime string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "instanceId": autorest.Encode("path", instanceID), + "location": autorest.Encode("path", location), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(restorableSQLDatabaseRid) > 0 { + queryParameters["restorableSqlDatabaseRid"] = autorest.Encode("query", restorableSQLDatabaseRid) + } + if len(startTime) > 0 { + queryParameters["startTime"] = autorest.Encode("query", startTime) + } + if len(endTime) > 0 { + queryParameters["endTime"] = autorest.Encode("query", endTime) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}/restorableSqlContainers", 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 RestorableSQLContainersClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client RestorableSQLContainersClient) ListResponder(resp *http.Response) (result RestorableSQLContainersListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/cosmos-db/mgmt/2021-06-15/documentdb/restorablesqldatabases.go b/services/cosmos-db/mgmt/2021-06-15/documentdb/restorablesqldatabases.go new file mode 100644 index 000000000000..af3edde9f6ed --- /dev/null +++ b/services/cosmos-db/mgmt/2021-06-15/documentdb/restorablesqldatabases.go @@ -0,0 +1,117 @@ +package documentdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// RestorableSQLDatabasesClient is the client for the RestorableSQLDatabases methods of the Documentdb service. +type RestorableSQLDatabasesClient struct { + BaseClient +} + +// NewRestorableSQLDatabasesClient creates an instance of the RestorableSQLDatabasesClient client. +func NewRestorableSQLDatabasesClient(subscriptionID string) RestorableSQLDatabasesClient { + return NewRestorableSQLDatabasesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewRestorableSQLDatabasesClientWithBaseURI creates an instance of the RestorableSQLDatabasesClient client using a +// custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, +// Azure stack). +func NewRestorableSQLDatabasesClientWithBaseURI(baseURI string, subscriptionID string) RestorableSQLDatabasesClient { + return RestorableSQLDatabasesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List show the event feed of all mutations done on all the Azure Cosmos DB SQL databases under the restorable +// account. This helps in scenario where database was accidentally deleted to get the deletion time. This API +// requires 'Microsoft.DocumentDB/locations/restorableDatabaseAccounts/.../read' permission +// Parameters: +// location - cosmos DB region, with spaces between words and each word capitalized. +// instanceID - the instanceId GUID of a restorable database account. +func (client RestorableSQLDatabasesClient) List(ctx context.Context, location string, instanceID string) (result RestorableSQLDatabasesListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RestorableSQLDatabasesClient.List") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.RestorableSQLDatabasesClient", "List", err.Error()) + } + + req, err := client.ListPreparer(ctx, location, instanceID) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.RestorableSQLDatabasesClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.RestorableSQLDatabasesClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.RestorableSQLDatabasesClient", "List", resp, "Failure responding to request") + return + } + + return +} + +// ListPreparer prepares the List request. +func (client RestorableSQLDatabasesClient) ListPreparer(ctx context.Context, location string, instanceID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "instanceId": autorest.Encode("path", instanceID), + "location": autorest.Encode("path", location), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}/restorableSqlDatabases", 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 RestorableSQLDatabasesClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client RestorableSQLDatabasesClient) ListResponder(resp *http.Response) (result RestorableSQLDatabasesListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/cosmos-db/mgmt/2021-06-15/documentdb/restorablesqlresources.go b/services/cosmos-db/mgmt/2021-06-15/documentdb/restorablesqlresources.go new file mode 100644 index 000000000000..268829d3f9bd --- /dev/null +++ b/services/cosmos-db/mgmt/2021-06-15/documentdb/restorablesqlresources.go @@ -0,0 +1,125 @@ +package documentdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// RestorableSQLResourcesClient is the client for the RestorableSQLResources methods of the Documentdb service. +type RestorableSQLResourcesClient struct { + BaseClient +} + +// NewRestorableSQLResourcesClient creates an instance of the RestorableSQLResourcesClient client. +func NewRestorableSQLResourcesClient(subscriptionID string) RestorableSQLResourcesClient { + return NewRestorableSQLResourcesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewRestorableSQLResourcesClientWithBaseURI creates an instance of the RestorableSQLResourcesClient client using a +// custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, +// Azure stack). +func NewRestorableSQLResourcesClientWithBaseURI(baseURI string, subscriptionID string) RestorableSQLResourcesClient { + return RestorableSQLResourcesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List return a list of database and container combo that exist on the account at the given timestamp and location. +// This helps in scenarios to validate what resources exist at given timestamp and location. This API requires +// 'Microsoft.DocumentDB/locations/restorableDatabaseAccounts/.../read' permission. +// Parameters: +// location - cosmos DB region, with spaces between words and each word capitalized. +// instanceID - the instanceId GUID of a restorable database account. +// restoreLocation - the location where the restorable resources are located. +// restoreTimestampInUtc - the timestamp when the restorable resources existed. +func (client RestorableSQLResourcesClient) List(ctx context.Context, location string, instanceID string, restoreLocation string, restoreTimestampInUtc string) (result RestorableSQLResourcesListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RestorableSQLResourcesClient.List") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.RestorableSQLResourcesClient", "List", err.Error()) + } + + req, err := client.ListPreparer(ctx, location, instanceID, restoreLocation, restoreTimestampInUtc) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.RestorableSQLResourcesClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.RestorableSQLResourcesClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.RestorableSQLResourcesClient", "List", resp, "Failure responding to request") + return + } + + return +} + +// ListPreparer prepares the List request. +func (client RestorableSQLResourcesClient) ListPreparer(ctx context.Context, location string, instanceID string, restoreLocation string, restoreTimestampInUtc string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "instanceId": autorest.Encode("path", instanceID), + "location": autorest.Encode("path", location), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(restoreLocation) > 0 { + queryParameters["restoreLocation"] = autorest.Encode("query", restoreLocation) + } + if len(restoreTimestampInUtc) > 0 { + queryParameters["restoreTimestampInUtc"] = autorest.Encode("query", restoreTimestampInUtc) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}/restorableSqlResources", 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 RestorableSQLResourcesClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client RestorableSQLResourcesClient) ListResponder(resp *http.Response) (result RestorableSQLResourcesListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/cosmos-db/mgmt/2021-06-15/documentdb/sqlresources.go b/services/cosmos-db/mgmt/2021-06-15/documentdb/sqlresources.go new file mode 100644 index 000000000000..1b2104035c94 --- /dev/null +++ b/services/cosmos-db/mgmt/2021-06-15/documentdb/sqlresources.go @@ -0,0 +1,3565 @@ +package documentdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// SQLResourcesClient is the client for the SQLResources methods of the Documentdb service. +type SQLResourcesClient struct { + BaseClient +} + +// NewSQLResourcesClient creates an instance of the SQLResourcesClient client. +func NewSQLResourcesClient(subscriptionID string) SQLResourcesClient { + return NewSQLResourcesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewSQLResourcesClientWithBaseURI creates an instance of the SQLResourcesClient client using a custom endpoint. Use +// this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewSQLResourcesClientWithBaseURI(baseURI string, subscriptionID string) SQLResourcesClient { + return SQLResourcesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateUpdateSQLContainer create or update an Azure Cosmos DB SQL container +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +// containerName - cosmos DB container name. +// createUpdateSQLContainerParameters - the parameters to provide for the current SQL container. +func (client SQLResourcesClient) CreateUpdateSQLContainer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string, createUpdateSQLContainerParameters SQLContainerCreateUpdateParameters) (result SQLResourcesCreateUpdateSQLContainerFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.CreateUpdateSQLContainer") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}, + {TargetValue: createUpdateSQLContainerParameters, + Constraints: []validation.Constraint{{Target: "createUpdateSQLContainerParameters.SQLContainerCreateUpdateProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "createUpdateSQLContainerParameters.SQLContainerCreateUpdateProperties.Resource", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "createUpdateSQLContainerParameters.SQLContainerCreateUpdateProperties.Resource.ID", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "createUpdateSQLContainerParameters.SQLContainerCreateUpdateProperties.Resource.PartitionKey", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "createUpdateSQLContainerParameters.SQLContainerCreateUpdateProperties.Resource.PartitionKey.Version", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "createUpdateSQLContainerParameters.SQLContainerCreateUpdateProperties.Resource.PartitionKey.Version", Name: validation.InclusiveMaximum, Rule: int64(2), Chain: nil}, + {Target: "createUpdateSQLContainerParameters.SQLContainerCreateUpdateProperties.Resource.PartitionKey.Version", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}, + }}, + }}, + }}, + }}}}}); err != nil { + return result, validation.NewError("documentdb.SQLResourcesClient", "CreateUpdateSQLContainer", err.Error()) + } + + req, err := client.CreateUpdateSQLContainerPreparer(ctx, resourceGroupName, accountName, databaseName, containerName, createUpdateSQLContainerParameters) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "CreateUpdateSQLContainer", nil, "Failure preparing request") + return + } + + result, err = client.CreateUpdateSQLContainerSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "CreateUpdateSQLContainer", nil, "Failure sending request") + return + } + + return +} + +// CreateUpdateSQLContainerPreparer prepares the CreateUpdateSQLContainer request. +func (client SQLResourcesClient) CreateUpdateSQLContainerPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string, createUpdateSQLContainerParameters SQLContainerCreateUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "containerName": autorest.Encode("path", containerName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + 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.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}", pathParameters), + autorest.WithJSON(createUpdateSQLContainerParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateUpdateSQLContainerSender sends the CreateUpdateSQLContainer request. The method will close the +// http.Response Body if it receives an error. +func (client SQLResourcesClient) CreateUpdateSQLContainerSender(req *http.Request) (future SQLResourcesCreateUpdateSQLContainerFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateUpdateSQLContainerResponder handles the response to the CreateUpdateSQLContainer request. The method always +// closes the http.Response Body. +func (client SQLResourcesClient) CreateUpdateSQLContainerResponder(resp *http.Response) (result SQLContainerGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// CreateUpdateSQLDatabase create or update an Azure Cosmos DB SQL database +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +// createUpdateSQLDatabaseParameters - the parameters to provide for the current SQL database. +func (client SQLResourcesClient) CreateUpdateSQLDatabase(ctx context.Context, resourceGroupName string, accountName string, databaseName string, createUpdateSQLDatabaseParameters SQLDatabaseCreateUpdateParameters) (result SQLResourcesCreateUpdateSQLDatabaseFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.CreateUpdateSQLDatabase") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}, + {TargetValue: createUpdateSQLDatabaseParameters, + Constraints: []validation.Constraint{{Target: "createUpdateSQLDatabaseParameters.SQLDatabaseCreateUpdateProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "createUpdateSQLDatabaseParameters.SQLDatabaseCreateUpdateProperties.Resource", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "createUpdateSQLDatabaseParameters.SQLDatabaseCreateUpdateProperties.Resource.ID", Name: validation.Null, Rule: true, Chain: nil}}}, + }}}}}); err != nil { + return result, validation.NewError("documentdb.SQLResourcesClient", "CreateUpdateSQLDatabase", err.Error()) + } + + req, err := client.CreateUpdateSQLDatabasePreparer(ctx, resourceGroupName, accountName, databaseName, createUpdateSQLDatabaseParameters) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "CreateUpdateSQLDatabase", nil, "Failure preparing request") + return + } + + result, err = client.CreateUpdateSQLDatabaseSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "CreateUpdateSQLDatabase", nil, "Failure sending request") + return + } + + return +} + +// CreateUpdateSQLDatabasePreparer prepares the CreateUpdateSQLDatabase request. +func (client SQLResourcesClient) CreateUpdateSQLDatabasePreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, createUpdateSQLDatabaseParameters SQLDatabaseCreateUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + 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.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}", pathParameters), + autorest.WithJSON(createUpdateSQLDatabaseParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateUpdateSQLDatabaseSender sends the CreateUpdateSQLDatabase request. The method will close the +// http.Response Body if it receives an error. +func (client SQLResourcesClient) CreateUpdateSQLDatabaseSender(req *http.Request) (future SQLResourcesCreateUpdateSQLDatabaseFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateUpdateSQLDatabaseResponder handles the response to the CreateUpdateSQLDatabase request. The method always +// closes the http.Response Body. +func (client SQLResourcesClient) CreateUpdateSQLDatabaseResponder(resp *http.Response) (result SQLDatabaseGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// CreateUpdateSQLRoleAssignment creates or updates an Azure Cosmos DB SQL Role Assignment. +// Parameters: +// roleAssignmentID - the GUID for the Role Assignment. +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// createUpdateSQLRoleAssignmentParameters - the properties required to create or update a Role Assignment. +func (client SQLResourcesClient) CreateUpdateSQLRoleAssignment(ctx context.Context, roleAssignmentID string, resourceGroupName string, accountName string, createUpdateSQLRoleAssignmentParameters SQLRoleAssignmentCreateUpdateParameters) (result SQLResourcesCreateUpdateSQLRoleAssignmentFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.CreateUpdateSQLRoleAssignment") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.SQLResourcesClient", "CreateUpdateSQLRoleAssignment", err.Error()) + } + + req, err := client.CreateUpdateSQLRoleAssignmentPreparer(ctx, roleAssignmentID, resourceGroupName, accountName, createUpdateSQLRoleAssignmentParameters) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "CreateUpdateSQLRoleAssignment", nil, "Failure preparing request") + return + } + + result, err = client.CreateUpdateSQLRoleAssignmentSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "CreateUpdateSQLRoleAssignment", nil, "Failure sending request") + return + } + + return +} + +// CreateUpdateSQLRoleAssignmentPreparer prepares the CreateUpdateSQLRoleAssignment request. +func (client SQLResourcesClient) CreateUpdateSQLRoleAssignmentPreparer(ctx context.Context, roleAssignmentID string, resourceGroupName string, accountName string, createUpdateSQLRoleAssignmentParameters SQLRoleAssignmentCreateUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "roleAssignmentId": autorest.Encode("path", roleAssignmentID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + 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.DocumentDB/databaseAccounts/{accountName}/sqlRoleAssignments/{roleAssignmentId}", pathParameters), + autorest.WithJSON(createUpdateSQLRoleAssignmentParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateUpdateSQLRoleAssignmentSender sends the CreateUpdateSQLRoleAssignment request. The method will close the +// http.Response Body if it receives an error. +func (client SQLResourcesClient) CreateUpdateSQLRoleAssignmentSender(req *http.Request) (future SQLResourcesCreateUpdateSQLRoleAssignmentFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateUpdateSQLRoleAssignmentResponder handles the response to the CreateUpdateSQLRoleAssignment request. The method always +// closes the http.Response Body. +func (client SQLResourcesClient) CreateUpdateSQLRoleAssignmentResponder(resp *http.Response) (result SQLRoleAssignmentGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// CreateUpdateSQLRoleDefinition creates or updates an Azure Cosmos DB SQL Role Definition. +// Parameters: +// roleDefinitionID - the GUID for the Role Definition. +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// createUpdateSQLRoleDefinitionParameters - the properties required to create or update a Role Definition. +func (client SQLResourcesClient) CreateUpdateSQLRoleDefinition(ctx context.Context, roleDefinitionID string, resourceGroupName string, accountName string, createUpdateSQLRoleDefinitionParameters SQLRoleDefinitionCreateUpdateParameters) (result SQLResourcesCreateUpdateSQLRoleDefinitionFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.CreateUpdateSQLRoleDefinition") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.SQLResourcesClient", "CreateUpdateSQLRoleDefinition", err.Error()) + } + + req, err := client.CreateUpdateSQLRoleDefinitionPreparer(ctx, roleDefinitionID, resourceGroupName, accountName, createUpdateSQLRoleDefinitionParameters) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "CreateUpdateSQLRoleDefinition", nil, "Failure preparing request") + return + } + + result, err = client.CreateUpdateSQLRoleDefinitionSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "CreateUpdateSQLRoleDefinition", nil, "Failure sending request") + return + } + + return +} + +// CreateUpdateSQLRoleDefinitionPreparer prepares the CreateUpdateSQLRoleDefinition request. +func (client SQLResourcesClient) CreateUpdateSQLRoleDefinitionPreparer(ctx context.Context, roleDefinitionID string, resourceGroupName string, accountName string, createUpdateSQLRoleDefinitionParameters SQLRoleDefinitionCreateUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "roleDefinitionId": autorest.Encode("path", roleDefinitionID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + 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.DocumentDB/databaseAccounts/{accountName}/sqlRoleDefinitions/{roleDefinitionId}", pathParameters), + autorest.WithJSON(createUpdateSQLRoleDefinitionParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateUpdateSQLRoleDefinitionSender sends the CreateUpdateSQLRoleDefinition request. The method will close the +// http.Response Body if it receives an error. +func (client SQLResourcesClient) CreateUpdateSQLRoleDefinitionSender(req *http.Request) (future SQLResourcesCreateUpdateSQLRoleDefinitionFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateUpdateSQLRoleDefinitionResponder handles the response to the CreateUpdateSQLRoleDefinition request. The method always +// closes the http.Response Body. +func (client SQLResourcesClient) CreateUpdateSQLRoleDefinitionResponder(resp *http.Response) (result SQLRoleDefinitionGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// CreateUpdateSQLStoredProcedure create or update an Azure Cosmos DB SQL storedProcedure +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +// containerName - cosmos DB container name. +// storedProcedureName - cosmos DB storedProcedure name. +// createUpdateSQLStoredProcedureParameters - the parameters to provide for the current SQL storedProcedure. +func (client SQLResourcesClient) CreateUpdateSQLStoredProcedure(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string, storedProcedureName string, createUpdateSQLStoredProcedureParameters SQLStoredProcedureCreateUpdateParameters) (result SQLResourcesCreateUpdateSQLStoredProcedureFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.CreateUpdateSQLStoredProcedure") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}, + {TargetValue: createUpdateSQLStoredProcedureParameters, + Constraints: []validation.Constraint{{Target: "createUpdateSQLStoredProcedureParameters.SQLStoredProcedureCreateUpdateProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "createUpdateSQLStoredProcedureParameters.SQLStoredProcedureCreateUpdateProperties.Resource", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "createUpdateSQLStoredProcedureParameters.SQLStoredProcedureCreateUpdateProperties.Resource.ID", Name: validation.Null, Rule: true, Chain: nil}}}, + }}}}}); err != nil { + return result, validation.NewError("documentdb.SQLResourcesClient", "CreateUpdateSQLStoredProcedure", err.Error()) + } + + req, err := client.CreateUpdateSQLStoredProcedurePreparer(ctx, resourceGroupName, accountName, databaseName, containerName, storedProcedureName, createUpdateSQLStoredProcedureParameters) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "CreateUpdateSQLStoredProcedure", nil, "Failure preparing request") + return + } + + result, err = client.CreateUpdateSQLStoredProcedureSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "CreateUpdateSQLStoredProcedure", nil, "Failure sending request") + return + } + + return +} + +// CreateUpdateSQLStoredProcedurePreparer prepares the CreateUpdateSQLStoredProcedure request. +func (client SQLResourcesClient) CreateUpdateSQLStoredProcedurePreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string, storedProcedureName string, createUpdateSQLStoredProcedureParameters SQLStoredProcedureCreateUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "containerName": autorest.Encode("path", containerName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "storedProcedureName": autorest.Encode("path", storedProcedureName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + 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.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/storedProcedures/{storedProcedureName}", pathParameters), + autorest.WithJSON(createUpdateSQLStoredProcedureParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateUpdateSQLStoredProcedureSender sends the CreateUpdateSQLStoredProcedure request. The method will close the +// http.Response Body if it receives an error. +func (client SQLResourcesClient) CreateUpdateSQLStoredProcedureSender(req *http.Request) (future SQLResourcesCreateUpdateSQLStoredProcedureFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateUpdateSQLStoredProcedureResponder handles the response to the CreateUpdateSQLStoredProcedure request. The method always +// closes the http.Response Body. +func (client SQLResourcesClient) CreateUpdateSQLStoredProcedureResponder(resp *http.Response) (result SQLStoredProcedureGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// CreateUpdateSQLTrigger create or update an Azure Cosmos DB SQL trigger +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +// containerName - cosmos DB container name. +// triggerName - cosmos DB trigger name. +// createUpdateSQLTriggerParameters - the parameters to provide for the current SQL trigger. +func (client SQLResourcesClient) CreateUpdateSQLTrigger(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string, triggerName string, createUpdateSQLTriggerParameters SQLTriggerCreateUpdateParameters) (result SQLResourcesCreateUpdateSQLTriggerFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.CreateUpdateSQLTrigger") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}, + {TargetValue: createUpdateSQLTriggerParameters, + Constraints: []validation.Constraint{{Target: "createUpdateSQLTriggerParameters.SQLTriggerCreateUpdateProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "createUpdateSQLTriggerParameters.SQLTriggerCreateUpdateProperties.Resource", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "createUpdateSQLTriggerParameters.SQLTriggerCreateUpdateProperties.Resource.ID", Name: validation.Null, Rule: true, Chain: nil}}}, + }}}}}); err != nil { + return result, validation.NewError("documentdb.SQLResourcesClient", "CreateUpdateSQLTrigger", err.Error()) + } + + req, err := client.CreateUpdateSQLTriggerPreparer(ctx, resourceGroupName, accountName, databaseName, containerName, triggerName, createUpdateSQLTriggerParameters) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "CreateUpdateSQLTrigger", nil, "Failure preparing request") + return + } + + result, err = client.CreateUpdateSQLTriggerSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "CreateUpdateSQLTrigger", nil, "Failure sending request") + return + } + + return +} + +// CreateUpdateSQLTriggerPreparer prepares the CreateUpdateSQLTrigger request. +func (client SQLResourcesClient) CreateUpdateSQLTriggerPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string, triggerName string, createUpdateSQLTriggerParameters SQLTriggerCreateUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "containerName": autorest.Encode("path", containerName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "triggerName": autorest.Encode("path", triggerName), + } + + const APIVersion = "2021-06-15" + 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.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/triggers/{triggerName}", pathParameters), + autorest.WithJSON(createUpdateSQLTriggerParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateUpdateSQLTriggerSender sends the CreateUpdateSQLTrigger request. The method will close the +// http.Response Body if it receives an error. +func (client SQLResourcesClient) CreateUpdateSQLTriggerSender(req *http.Request) (future SQLResourcesCreateUpdateSQLTriggerFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateUpdateSQLTriggerResponder handles the response to the CreateUpdateSQLTrigger request. The method always +// closes the http.Response Body. +func (client SQLResourcesClient) CreateUpdateSQLTriggerResponder(resp *http.Response) (result SQLTriggerGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// CreateUpdateSQLUserDefinedFunction create or update an Azure Cosmos DB SQL userDefinedFunction +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +// containerName - cosmos DB container name. +// userDefinedFunctionName - cosmos DB userDefinedFunction name. +// createUpdateSQLUserDefinedFunctionParameters - the parameters to provide for the current SQL +// userDefinedFunction. +func (client SQLResourcesClient) CreateUpdateSQLUserDefinedFunction(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string, userDefinedFunctionName string, createUpdateSQLUserDefinedFunctionParameters SQLUserDefinedFunctionCreateUpdateParameters) (result SQLResourcesCreateUpdateSQLUserDefinedFunctionFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.CreateUpdateSQLUserDefinedFunction") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}, + {TargetValue: createUpdateSQLUserDefinedFunctionParameters, + Constraints: []validation.Constraint{{Target: "createUpdateSQLUserDefinedFunctionParameters.SQLUserDefinedFunctionCreateUpdateProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "createUpdateSQLUserDefinedFunctionParameters.SQLUserDefinedFunctionCreateUpdateProperties.Resource", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "createUpdateSQLUserDefinedFunctionParameters.SQLUserDefinedFunctionCreateUpdateProperties.Resource.ID", Name: validation.Null, Rule: true, Chain: nil}}}, + }}}}}); err != nil { + return result, validation.NewError("documentdb.SQLResourcesClient", "CreateUpdateSQLUserDefinedFunction", err.Error()) + } + + req, err := client.CreateUpdateSQLUserDefinedFunctionPreparer(ctx, resourceGroupName, accountName, databaseName, containerName, userDefinedFunctionName, createUpdateSQLUserDefinedFunctionParameters) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "CreateUpdateSQLUserDefinedFunction", nil, "Failure preparing request") + return + } + + result, err = client.CreateUpdateSQLUserDefinedFunctionSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "CreateUpdateSQLUserDefinedFunction", nil, "Failure sending request") + return + } + + return +} + +// CreateUpdateSQLUserDefinedFunctionPreparer prepares the CreateUpdateSQLUserDefinedFunction request. +func (client SQLResourcesClient) CreateUpdateSQLUserDefinedFunctionPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string, userDefinedFunctionName string, createUpdateSQLUserDefinedFunctionParameters SQLUserDefinedFunctionCreateUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "containerName": autorest.Encode("path", containerName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "userDefinedFunctionName": autorest.Encode("path", userDefinedFunctionName), + } + + const APIVersion = "2021-06-15" + 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.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/userDefinedFunctions/{userDefinedFunctionName}", pathParameters), + autorest.WithJSON(createUpdateSQLUserDefinedFunctionParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateUpdateSQLUserDefinedFunctionSender sends the CreateUpdateSQLUserDefinedFunction request. The method will close the +// http.Response Body if it receives an error. +func (client SQLResourcesClient) CreateUpdateSQLUserDefinedFunctionSender(req *http.Request) (future SQLResourcesCreateUpdateSQLUserDefinedFunctionFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateUpdateSQLUserDefinedFunctionResponder handles the response to the CreateUpdateSQLUserDefinedFunction request. The method always +// closes the http.Response Body. +func (client SQLResourcesClient) CreateUpdateSQLUserDefinedFunctionResponder(resp *http.Response) (result SQLUserDefinedFunctionGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// DeleteSQLContainer deletes an existing Azure Cosmos DB SQL container. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +// containerName - cosmos DB container name. +func (client SQLResourcesClient) DeleteSQLContainer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string) (result SQLResourcesDeleteSQLContainerFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.DeleteSQLContainer") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.SQLResourcesClient", "DeleteSQLContainer", err.Error()) + } + + req, err := client.DeleteSQLContainerPreparer(ctx, resourceGroupName, accountName, databaseName, containerName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "DeleteSQLContainer", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSQLContainerSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "DeleteSQLContainer", nil, "Failure sending request") + return + } + + return +} + +// DeleteSQLContainerPreparer prepares the DeleteSQLContainer request. +func (client SQLResourcesClient) DeleteSQLContainerPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "containerName": autorest.Encode("path", containerName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSQLContainerSender sends the DeleteSQLContainer request. The method will close the +// http.Response Body if it receives an error. +func (client SQLResourcesClient) DeleteSQLContainerSender(req *http.Request) (future SQLResourcesDeleteSQLContainerFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteSQLContainerResponder handles the response to the DeleteSQLContainer request. The method always +// closes the http.Response Body. +func (client SQLResourcesClient) DeleteSQLContainerResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// DeleteSQLDatabase deletes an existing Azure Cosmos DB SQL database. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +func (client SQLResourcesClient) DeleteSQLDatabase(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result SQLResourcesDeleteSQLDatabaseFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.DeleteSQLDatabase") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.SQLResourcesClient", "DeleteSQLDatabase", err.Error()) + } + + req, err := client.DeleteSQLDatabasePreparer(ctx, resourceGroupName, accountName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "DeleteSQLDatabase", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSQLDatabaseSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "DeleteSQLDatabase", nil, "Failure sending request") + return + } + + return +} + +// DeleteSQLDatabasePreparer prepares the DeleteSQLDatabase request. +func (client SQLResourcesClient) DeleteSQLDatabasePreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSQLDatabaseSender sends the DeleteSQLDatabase request. The method will close the +// http.Response Body if it receives an error. +func (client SQLResourcesClient) DeleteSQLDatabaseSender(req *http.Request) (future SQLResourcesDeleteSQLDatabaseFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteSQLDatabaseResponder handles the response to the DeleteSQLDatabase request. The method always +// closes the http.Response Body. +func (client SQLResourcesClient) DeleteSQLDatabaseResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// DeleteSQLRoleAssignment deletes an existing Azure Cosmos DB SQL Role Assignment. +// Parameters: +// roleAssignmentID - the GUID for the Role Assignment. +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +func (client SQLResourcesClient) DeleteSQLRoleAssignment(ctx context.Context, roleAssignmentID string, resourceGroupName string, accountName string) (result SQLResourcesDeleteSQLRoleAssignmentFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.DeleteSQLRoleAssignment") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.SQLResourcesClient", "DeleteSQLRoleAssignment", err.Error()) + } + + req, err := client.DeleteSQLRoleAssignmentPreparer(ctx, roleAssignmentID, resourceGroupName, accountName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "DeleteSQLRoleAssignment", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSQLRoleAssignmentSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "DeleteSQLRoleAssignment", nil, "Failure sending request") + return + } + + return +} + +// DeleteSQLRoleAssignmentPreparer prepares the DeleteSQLRoleAssignment request. +func (client SQLResourcesClient) DeleteSQLRoleAssignmentPreparer(ctx context.Context, roleAssignmentID string, resourceGroupName string, accountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "roleAssignmentId": autorest.Encode("path", roleAssignmentID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlRoleAssignments/{roleAssignmentId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSQLRoleAssignmentSender sends the DeleteSQLRoleAssignment request. The method will close the +// http.Response Body if it receives an error. +func (client SQLResourcesClient) DeleteSQLRoleAssignmentSender(req *http.Request) (future SQLResourcesDeleteSQLRoleAssignmentFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteSQLRoleAssignmentResponder handles the response to the DeleteSQLRoleAssignment request. The method always +// closes the http.Response Body. +func (client SQLResourcesClient) DeleteSQLRoleAssignmentResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// DeleteSQLRoleDefinition deletes an existing Azure Cosmos DB SQL Role Definition. +// Parameters: +// roleDefinitionID - the GUID for the Role Definition. +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +func (client SQLResourcesClient) DeleteSQLRoleDefinition(ctx context.Context, roleDefinitionID string, resourceGroupName string, accountName string) (result SQLResourcesDeleteSQLRoleDefinitionFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.DeleteSQLRoleDefinition") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.SQLResourcesClient", "DeleteSQLRoleDefinition", err.Error()) + } + + req, err := client.DeleteSQLRoleDefinitionPreparer(ctx, roleDefinitionID, resourceGroupName, accountName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "DeleteSQLRoleDefinition", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSQLRoleDefinitionSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "DeleteSQLRoleDefinition", nil, "Failure sending request") + return + } + + return +} + +// DeleteSQLRoleDefinitionPreparer prepares the DeleteSQLRoleDefinition request. +func (client SQLResourcesClient) DeleteSQLRoleDefinitionPreparer(ctx context.Context, roleDefinitionID string, resourceGroupName string, accountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "roleDefinitionId": autorest.Encode("path", roleDefinitionID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlRoleDefinitions/{roleDefinitionId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSQLRoleDefinitionSender sends the DeleteSQLRoleDefinition request. The method will close the +// http.Response Body if it receives an error. +func (client SQLResourcesClient) DeleteSQLRoleDefinitionSender(req *http.Request) (future SQLResourcesDeleteSQLRoleDefinitionFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteSQLRoleDefinitionResponder handles the response to the DeleteSQLRoleDefinition request. The method always +// closes the http.Response Body. +func (client SQLResourcesClient) DeleteSQLRoleDefinitionResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// DeleteSQLStoredProcedure deletes an existing Azure Cosmos DB SQL storedProcedure. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +// containerName - cosmos DB container name. +// storedProcedureName - cosmos DB storedProcedure name. +func (client SQLResourcesClient) DeleteSQLStoredProcedure(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string, storedProcedureName string) (result SQLResourcesDeleteSQLStoredProcedureFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.DeleteSQLStoredProcedure") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.SQLResourcesClient", "DeleteSQLStoredProcedure", err.Error()) + } + + req, err := client.DeleteSQLStoredProcedurePreparer(ctx, resourceGroupName, accountName, databaseName, containerName, storedProcedureName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "DeleteSQLStoredProcedure", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSQLStoredProcedureSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "DeleteSQLStoredProcedure", nil, "Failure sending request") + return + } + + return +} + +// DeleteSQLStoredProcedurePreparer prepares the DeleteSQLStoredProcedure request. +func (client SQLResourcesClient) DeleteSQLStoredProcedurePreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string, storedProcedureName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "containerName": autorest.Encode("path", containerName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "storedProcedureName": autorest.Encode("path", storedProcedureName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/storedProcedures/{storedProcedureName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSQLStoredProcedureSender sends the DeleteSQLStoredProcedure request. The method will close the +// http.Response Body if it receives an error. +func (client SQLResourcesClient) DeleteSQLStoredProcedureSender(req *http.Request) (future SQLResourcesDeleteSQLStoredProcedureFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteSQLStoredProcedureResponder handles the response to the DeleteSQLStoredProcedure request. The method always +// closes the http.Response Body. +func (client SQLResourcesClient) DeleteSQLStoredProcedureResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// DeleteSQLTrigger deletes an existing Azure Cosmos DB SQL trigger. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +// containerName - cosmos DB container name. +// triggerName - cosmos DB trigger name. +func (client SQLResourcesClient) DeleteSQLTrigger(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string, triggerName string) (result SQLResourcesDeleteSQLTriggerFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.DeleteSQLTrigger") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.SQLResourcesClient", "DeleteSQLTrigger", err.Error()) + } + + req, err := client.DeleteSQLTriggerPreparer(ctx, resourceGroupName, accountName, databaseName, containerName, triggerName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "DeleteSQLTrigger", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSQLTriggerSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "DeleteSQLTrigger", nil, "Failure sending request") + return + } + + return +} + +// DeleteSQLTriggerPreparer prepares the DeleteSQLTrigger request. +func (client SQLResourcesClient) DeleteSQLTriggerPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string, triggerName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "containerName": autorest.Encode("path", containerName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "triggerName": autorest.Encode("path", triggerName), + } + + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/triggers/{triggerName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSQLTriggerSender sends the DeleteSQLTrigger request. The method will close the +// http.Response Body if it receives an error. +func (client SQLResourcesClient) DeleteSQLTriggerSender(req *http.Request) (future SQLResourcesDeleteSQLTriggerFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteSQLTriggerResponder handles the response to the DeleteSQLTrigger request. The method always +// closes the http.Response Body. +func (client SQLResourcesClient) DeleteSQLTriggerResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// DeleteSQLUserDefinedFunction deletes an existing Azure Cosmos DB SQL userDefinedFunction. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +// containerName - cosmos DB container name. +// userDefinedFunctionName - cosmos DB userDefinedFunction name. +func (client SQLResourcesClient) DeleteSQLUserDefinedFunction(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string, userDefinedFunctionName string) (result SQLResourcesDeleteSQLUserDefinedFunctionFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.DeleteSQLUserDefinedFunction") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.SQLResourcesClient", "DeleteSQLUserDefinedFunction", err.Error()) + } + + req, err := client.DeleteSQLUserDefinedFunctionPreparer(ctx, resourceGroupName, accountName, databaseName, containerName, userDefinedFunctionName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "DeleteSQLUserDefinedFunction", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSQLUserDefinedFunctionSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "DeleteSQLUserDefinedFunction", nil, "Failure sending request") + return + } + + return +} + +// DeleteSQLUserDefinedFunctionPreparer prepares the DeleteSQLUserDefinedFunction request. +func (client SQLResourcesClient) DeleteSQLUserDefinedFunctionPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string, userDefinedFunctionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "containerName": autorest.Encode("path", containerName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "userDefinedFunctionName": autorest.Encode("path", userDefinedFunctionName), + } + + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/userDefinedFunctions/{userDefinedFunctionName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSQLUserDefinedFunctionSender sends the DeleteSQLUserDefinedFunction request. The method will close the +// http.Response Body if it receives an error. +func (client SQLResourcesClient) DeleteSQLUserDefinedFunctionSender(req *http.Request) (future SQLResourcesDeleteSQLUserDefinedFunctionFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteSQLUserDefinedFunctionResponder handles the response to the DeleteSQLUserDefinedFunction request. The method always +// closes the http.Response Body. +func (client SQLResourcesClient) DeleteSQLUserDefinedFunctionResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// GetSQLContainer gets the SQL container under an existing Azure Cosmos DB database account. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +// containerName - cosmos DB container name. +func (client SQLResourcesClient) GetSQLContainer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string) (result SQLContainerGetResults, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.GetSQLContainer") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.SQLResourcesClient", "GetSQLContainer", err.Error()) + } + + req, err := client.GetSQLContainerPreparer(ctx, resourceGroupName, accountName, databaseName, containerName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "GetSQLContainer", nil, "Failure preparing request") + return + } + + resp, err := client.GetSQLContainerSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "GetSQLContainer", resp, "Failure sending request") + return + } + + result, err = client.GetSQLContainerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "GetSQLContainer", resp, "Failure responding to request") + return + } + + return +} + +// GetSQLContainerPreparer prepares the GetSQLContainer request. +func (client SQLResourcesClient) GetSQLContainerPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "containerName": autorest.Encode("path", containerName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSQLContainerSender sends the GetSQLContainer request. The method will close the +// http.Response Body if it receives an error. +func (client SQLResourcesClient) GetSQLContainerSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetSQLContainerResponder handles the response to the GetSQLContainer request. The method always +// closes the http.Response Body. +func (client SQLResourcesClient) GetSQLContainerResponder(resp *http.Response) (result SQLContainerGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetSQLContainerThroughput gets the RUs per second of the SQL container under an existing Azure Cosmos DB database +// account. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +// containerName - cosmos DB container name. +func (client SQLResourcesClient) GetSQLContainerThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string) (result ThroughputSettingsGetResults, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.GetSQLContainerThroughput") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.SQLResourcesClient", "GetSQLContainerThroughput", err.Error()) + } + + req, err := client.GetSQLContainerThroughputPreparer(ctx, resourceGroupName, accountName, databaseName, containerName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "GetSQLContainerThroughput", nil, "Failure preparing request") + return + } + + resp, err := client.GetSQLContainerThroughputSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "GetSQLContainerThroughput", resp, "Failure sending request") + return + } + + result, err = client.GetSQLContainerThroughputResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "GetSQLContainerThroughput", resp, "Failure responding to request") + return + } + + return +} + +// GetSQLContainerThroughputPreparer prepares the GetSQLContainerThroughput request. +func (client SQLResourcesClient) GetSQLContainerThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "containerName": autorest.Encode("path", containerName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/throughputSettings/default", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSQLContainerThroughputSender sends the GetSQLContainerThroughput request. The method will close the +// http.Response Body if it receives an error. +func (client SQLResourcesClient) GetSQLContainerThroughputSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetSQLContainerThroughputResponder handles the response to the GetSQLContainerThroughput request. The method always +// closes the http.Response Body. +func (client SQLResourcesClient) GetSQLContainerThroughputResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetSQLDatabase gets the SQL database under an existing Azure Cosmos DB database account with the provided name. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +func (client SQLResourcesClient) GetSQLDatabase(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result SQLDatabaseGetResults, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.GetSQLDatabase") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.SQLResourcesClient", "GetSQLDatabase", err.Error()) + } + + req, err := client.GetSQLDatabasePreparer(ctx, resourceGroupName, accountName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "GetSQLDatabase", nil, "Failure preparing request") + return + } + + resp, err := client.GetSQLDatabaseSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "GetSQLDatabase", resp, "Failure sending request") + return + } + + result, err = client.GetSQLDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "GetSQLDatabase", resp, "Failure responding to request") + return + } + + return +} + +// GetSQLDatabasePreparer prepares the GetSQLDatabase request. +func (client SQLResourcesClient) GetSQLDatabasePreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSQLDatabaseSender sends the GetSQLDatabase request. The method will close the +// http.Response Body if it receives an error. +func (client SQLResourcesClient) GetSQLDatabaseSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetSQLDatabaseResponder handles the response to the GetSQLDatabase request. The method always +// closes the http.Response Body. +func (client SQLResourcesClient) GetSQLDatabaseResponder(resp *http.Response) (result SQLDatabaseGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetSQLDatabaseThroughput gets the RUs per second of the SQL database under an existing Azure Cosmos DB database +// account with the provided name. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +func (client SQLResourcesClient) GetSQLDatabaseThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result ThroughputSettingsGetResults, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.GetSQLDatabaseThroughput") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.SQLResourcesClient", "GetSQLDatabaseThroughput", err.Error()) + } + + req, err := client.GetSQLDatabaseThroughputPreparer(ctx, resourceGroupName, accountName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "GetSQLDatabaseThroughput", nil, "Failure preparing request") + return + } + + resp, err := client.GetSQLDatabaseThroughputSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "GetSQLDatabaseThroughput", resp, "Failure sending request") + return + } + + result, err = client.GetSQLDatabaseThroughputResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "GetSQLDatabaseThroughput", resp, "Failure responding to request") + return + } + + return +} + +// GetSQLDatabaseThroughputPreparer prepares the GetSQLDatabaseThroughput request. +func (client SQLResourcesClient) GetSQLDatabaseThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/throughputSettings/default", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSQLDatabaseThroughputSender sends the GetSQLDatabaseThroughput request. The method will close the +// http.Response Body if it receives an error. +func (client SQLResourcesClient) GetSQLDatabaseThroughputSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetSQLDatabaseThroughputResponder handles the response to the GetSQLDatabaseThroughput request. The method always +// closes the http.Response Body. +func (client SQLResourcesClient) GetSQLDatabaseThroughputResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetSQLRoleAssignment retrieves the properties of an existing Azure Cosmos DB SQL Role Assignment with the given Id. +// Parameters: +// roleAssignmentID - the GUID for the Role Assignment. +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +func (client SQLResourcesClient) GetSQLRoleAssignment(ctx context.Context, roleAssignmentID string, resourceGroupName string, accountName string) (result SQLRoleAssignmentGetResults, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.GetSQLRoleAssignment") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.SQLResourcesClient", "GetSQLRoleAssignment", err.Error()) + } + + req, err := client.GetSQLRoleAssignmentPreparer(ctx, roleAssignmentID, resourceGroupName, accountName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "GetSQLRoleAssignment", nil, "Failure preparing request") + return + } + + resp, err := client.GetSQLRoleAssignmentSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "GetSQLRoleAssignment", resp, "Failure sending request") + return + } + + result, err = client.GetSQLRoleAssignmentResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "GetSQLRoleAssignment", resp, "Failure responding to request") + return + } + + return +} + +// GetSQLRoleAssignmentPreparer prepares the GetSQLRoleAssignment request. +func (client SQLResourcesClient) GetSQLRoleAssignmentPreparer(ctx context.Context, roleAssignmentID string, resourceGroupName string, accountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "roleAssignmentId": autorest.Encode("path", roleAssignmentID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlRoleAssignments/{roleAssignmentId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSQLRoleAssignmentSender sends the GetSQLRoleAssignment request. The method will close the +// http.Response Body if it receives an error. +func (client SQLResourcesClient) GetSQLRoleAssignmentSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetSQLRoleAssignmentResponder handles the response to the GetSQLRoleAssignment request. The method always +// closes the http.Response Body. +func (client SQLResourcesClient) GetSQLRoleAssignmentResponder(resp *http.Response) (result SQLRoleAssignmentGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetSQLRoleDefinition retrieves the properties of an existing Azure Cosmos DB SQL Role Definition with the given Id. +// Parameters: +// roleDefinitionID - the GUID for the Role Definition. +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +func (client SQLResourcesClient) GetSQLRoleDefinition(ctx context.Context, roleDefinitionID string, resourceGroupName string, accountName string) (result SQLRoleDefinitionGetResults, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.GetSQLRoleDefinition") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.SQLResourcesClient", "GetSQLRoleDefinition", err.Error()) + } + + req, err := client.GetSQLRoleDefinitionPreparer(ctx, roleDefinitionID, resourceGroupName, accountName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "GetSQLRoleDefinition", nil, "Failure preparing request") + return + } + + resp, err := client.GetSQLRoleDefinitionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "GetSQLRoleDefinition", resp, "Failure sending request") + return + } + + result, err = client.GetSQLRoleDefinitionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "GetSQLRoleDefinition", resp, "Failure responding to request") + return + } + + return +} + +// GetSQLRoleDefinitionPreparer prepares the GetSQLRoleDefinition request. +func (client SQLResourcesClient) GetSQLRoleDefinitionPreparer(ctx context.Context, roleDefinitionID string, resourceGroupName string, accountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "roleDefinitionId": autorest.Encode("path", roleDefinitionID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlRoleDefinitions/{roleDefinitionId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSQLRoleDefinitionSender sends the GetSQLRoleDefinition request. The method will close the +// http.Response Body if it receives an error. +func (client SQLResourcesClient) GetSQLRoleDefinitionSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetSQLRoleDefinitionResponder handles the response to the GetSQLRoleDefinition request. The method always +// closes the http.Response Body. +func (client SQLResourcesClient) GetSQLRoleDefinitionResponder(resp *http.Response) (result SQLRoleDefinitionGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetSQLStoredProcedure gets the SQL storedProcedure under an existing Azure Cosmos DB database account. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +// containerName - cosmos DB container name. +// storedProcedureName - cosmos DB storedProcedure name. +func (client SQLResourcesClient) GetSQLStoredProcedure(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string, storedProcedureName string) (result SQLStoredProcedureGetResults, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.GetSQLStoredProcedure") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.SQLResourcesClient", "GetSQLStoredProcedure", err.Error()) + } + + req, err := client.GetSQLStoredProcedurePreparer(ctx, resourceGroupName, accountName, databaseName, containerName, storedProcedureName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "GetSQLStoredProcedure", nil, "Failure preparing request") + return + } + + resp, err := client.GetSQLStoredProcedureSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "GetSQLStoredProcedure", resp, "Failure sending request") + return + } + + result, err = client.GetSQLStoredProcedureResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "GetSQLStoredProcedure", resp, "Failure responding to request") + return + } + + return +} + +// GetSQLStoredProcedurePreparer prepares the GetSQLStoredProcedure request. +func (client SQLResourcesClient) GetSQLStoredProcedurePreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string, storedProcedureName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "containerName": autorest.Encode("path", containerName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "storedProcedureName": autorest.Encode("path", storedProcedureName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/storedProcedures/{storedProcedureName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSQLStoredProcedureSender sends the GetSQLStoredProcedure request. The method will close the +// http.Response Body if it receives an error. +func (client SQLResourcesClient) GetSQLStoredProcedureSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetSQLStoredProcedureResponder handles the response to the GetSQLStoredProcedure request. The method always +// closes the http.Response Body. +func (client SQLResourcesClient) GetSQLStoredProcedureResponder(resp *http.Response) (result SQLStoredProcedureGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetSQLTrigger gets the SQL trigger under an existing Azure Cosmos DB database account. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +// containerName - cosmos DB container name. +// triggerName - cosmos DB trigger name. +func (client SQLResourcesClient) GetSQLTrigger(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string, triggerName string) (result SQLTriggerGetResults, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.GetSQLTrigger") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.SQLResourcesClient", "GetSQLTrigger", err.Error()) + } + + req, err := client.GetSQLTriggerPreparer(ctx, resourceGroupName, accountName, databaseName, containerName, triggerName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "GetSQLTrigger", nil, "Failure preparing request") + return + } + + resp, err := client.GetSQLTriggerSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "GetSQLTrigger", resp, "Failure sending request") + return + } + + result, err = client.GetSQLTriggerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "GetSQLTrigger", resp, "Failure responding to request") + return + } + + return +} + +// GetSQLTriggerPreparer prepares the GetSQLTrigger request. +func (client SQLResourcesClient) GetSQLTriggerPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string, triggerName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "containerName": autorest.Encode("path", containerName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "triggerName": autorest.Encode("path", triggerName), + } + + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/triggers/{triggerName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSQLTriggerSender sends the GetSQLTrigger request. The method will close the +// http.Response Body if it receives an error. +func (client SQLResourcesClient) GetSQLTriggerSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetSQLTriggerResponder handles the response to the GetSQLTrigger request. The method always +// closes the http.Response Body. +func (client SQLResourcesClient) GetSQLTriggerResponder(resp *http.Response) (result SQLTriggerGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetSQLUserDefinedFunction gets the SQL userDefinedFunction under an existing Azure Cosmos DB database account. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +// containerName - cosmos DB container name. +// userDefinedFunctionName - cosmos DB userDefinedFunction name. +func (client SQLResourcesClient) GetSQLUserDefinedFunction(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string, userDefinedFunctionName string) (result SQLUserDefinedFunctionGetResults, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.GetSQLUserDefinedFunction") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.SQLResourcesClient", "GetSQLUserDefinedFunction", err.Error()) + } + + req, err := client.GetSQLUserDefinedFunctionPreparer(ctx, resourceGroupName, accountName, databaseName, containerName, userDefinedFunctionName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "GetSQLUserDefinedFunction", nil, "Failure preparing request") + return + } + + resp, err := client.GetSQLUserDefinedFunctionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "GetSQLUserDefinedFunction", resp, "Failure sending request") + return + } + + result, err = client.GetSQLUserDefinedFunctionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "GetSQLUserDefinedFunction", resp, "Failure responding to request") + return + } + + return +} + +// GetSQLUserDefinedFunctionPreparer prepares the GetSQLUserDefinedFunction request. +func (client SQLResourcesClient) GetSQLUserDefinedFunctionPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string, userDefinedFunctionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "containerName": autorest.Encode("path", containerName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "userDefinedFunctionName": autorest.Encode("path", userDefinedFunctionName), + } + + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/userDefinedFunctions/{userDefinedFunctionName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSQLUserDefinedFunctionSender sends the GetSQLUserDefinedFunction request. The method will close the +// http.Response Body if it receives an error. +func (client SQLResourcesClient) GetSQLUserDefinedFunctionSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetSQLUserDefinedFunctionResponder handles the response to the GetSQLUserDefinedFunction request. The method always +// closes the http.Response Body. +func (client SQLResourcesClient) GetSQLUserDefinedFunctionResponder(resp *http.Response) (result SQLUserDefinedFunctionGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListSQLContainers lists the SQL container under an existing Azure Cosmos DB database account. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +func (client SQLResourcesClient) ListSQLContainers(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result SQLContainerListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.ListSQLContainers") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.SQLResourcesClient", "ListSQLContainers", err.Error()) + } + + req, err := client.ListSQLContainersPreparer(ctx, resourceGroupName, accountName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "ListSQLContainers", nil, "Failure preparing request") + return + } + + resp, err := client.ListSQLContainersSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "ListSQLContainers", resp, "Failure sending request") + return + } + + result, err = client.ListSQLContainersResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "ListSQLContainers", resp, "Failure responding to request") + return + } + + return +} + +// ListSQLContainersPreparer prepares the ListSQLContainers request. +func (client SQLResourcesClient) ListSQLContainersPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSQLContainersSender sends the ListSQLContainers request. The method will close the +// http.Response Body if it receives an error. +func (client SQLResourcesClient) ListSQLContainersSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListSQLContainersResponder handles the response to the ListSQLContainers request. The method always +// closes the http.Response Body. +func (client SQLResourcesClient) ListSQLContainersResponder(resp *http.Response) (result SQLContainerListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListSQLDatabases lists the SQL databases under an existing Azure Cosmos DB database account. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +func (client SQLResourcesClient) ListSQLDatabases(ctx context.Context, resourceGroupName string, accountName string) (result SQLDatabaseListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.ListSQLDatabases") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.SQLResourcesClient", "ListSQLDatabases", err.Error()) + } + + req, err := client.ListSQLDatabasesPreparer(ctx, resourceGroupName, accountName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "ListSQLDatabases", nil, "Failure preparing request") + return + } + + resp, err := client.ListSQLDatabasesSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "ListSQLDatabases", resp, "Failure sending request") + return + } + + result, err = client.ListSQLDatabasesResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "ListSQLDatabases", resp, "Failure responding to request") + return + } + + return +} + +// ListSQLDatabasesPreparer prepares the ListSQLDatabases request. +func (client SQLResourcesClient) ListSQLDatabasesPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSQLDatabasesSender sends the ListSQLDatabases request. The method will close the +// http.Response Body if it receives an error. +func (client SQLResourcesClient) ListSQLDatabasesSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListSQLDatabasesResponder handles the response to the ListSQLDatabases request. The method always +// closes the http.Response Body. +func (client SQLResourcesClient) ListSQLDatabasesResponder(resp *http.Response) (result SQLDatabaseListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListSQLRoleAssignments retrieves the list of all Azure Cosmos DB SQL Role Assignments. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +func (client SQLResourcesClient) ListSQLRoleAssignments(ctx context.Context, resourceGroupName string, accountName string) (result SQLRoleAssignmentListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.ListSQLRoleAssignments") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.SQLResourcesClient", "ListSQLRoleAssignments", err.Error()) + } + + req, err := client.ListSQLRoleAssignmentsPreparer(ctx, resourceGroupName, accountName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "ListSQLRoleAssignments", nil, "Failure preparing request") + return + } + + resp, err := client.ListSQLRoleAssignmentsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "ListSQLRoleAssignments", resp, "Failure sending request") + return + } + + result, err = client.ListSQLRoleAssignmentsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "ListSQLRoleAssignments", resp, "Failure responding to request") + return + } + + return +} + +// ListSQLRoleAssignmentsPreparer prepares the ListSQLRoleAssignments request. +func (client SQLResourcesClient) ListSQLRoleAssignmentsPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlRoleAssignments", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSQLRoleAssignmentsSender sends the ListSQLRoleAssignments request. The method will close the +// http.Response Body if it receives an error. +func (client SQLResourcesClient) ListSQLRoleAssignmentsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListSQLRoleAssignmentsResponder handles the response to the ListSQLRoleAssignments request. The method always +// closes the http.Response Body. +func (client SQLResourcesClient) ListSQLRoleAssignmentsResponder(resp *http.Response) (result SQLRoleAssignmentListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListSQLRoleDefinitions retrieves the list of all Azure Cosmos DB SQL Role Definitions. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +func (client SQLResourcesClient) ListSQLRoleDefinitions(ctx context.Context, resourceGroupName string, accountName string) (result SQLRoleDefinitionListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.ListSQLRoleDefinitions") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.SQLResourcesClient", "ListSQLRoleDefinitions", err.Error()) + } + + req, err := client.ListSQLRoleDefinitionsPreparer(ctx, resourceGroupName, accountName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "ListSQLRoleDefinitions", nil, "Failure preparing request") + return + } + + resp, err := client.ListSQLRoleDefinitionsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "ListSQLRoleDefinitions", resp, "Failure sending request") + return + } + + result, err = client.ListSQLRoleDefinitionsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "ListSQLRoleDefinitions", resp, "Failure responding to request") + return + } + + return +} + +// ListSQLRoleDefinitionsPreparer prepares the ListSQLRoleDefinitions request. +func (client SQLResourcesClient) ListSQLRoleDefinitionsPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlRoleDefinitions", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSQLRoleDefinitionsSender sends the ListSQLRoleDefinitions request. The method will close the +// http.Response Body if it receives an error. +func (client SQLResourcesClient) ListSQLRoleDefinitionsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListSQLRoleDefinitionsResponder handles the response to the ListSQLRoleDefinitions request. The method always +// closes the http.Response Body. +func (client SQLResourcesClient) ListSQLRoleDefinitionsResponder(resp *http.Response) (result SQLRoleDefinitionListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListSQLStoredProcedures lists the SQL storedProcedure under an existing Azure Cosmos DB database account. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +// containerName - cosmos DB container name. +func (client SQLResourcesClient) ListSQLStoredProcedures(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string) (result SQLStoredProcedureListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.ListSQLStoredProcedures") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.SQLResourcesClient", "ListSQLStoredProcedures", err.Error()) + } + + req, err := client.ListSQLStoredProceduresPreparer(ctx, resourceGroupName, accountName, databaseName, containerName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "ListSQLStoredProcedures", nil, "Failure preparing request") + return + } + + resp, err := client.ListSQLStoredProceduresSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "ListSQLStoredProcedures", resp, "Failure sending request") + return + } + + result, err = client.ListSQLStoredProceduresResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "ListSQLStoredProcedures", resp, "Failure responding to request") + return + } + + return +} + +// ListSQLStoredProceduresPreparer prepares the ListSQLStoredProcedures request. +func (client SQLResourcesClient) ListSQLStoredProceduresPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "containerName": autorest.Encode("path", containerName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/storedProcedures", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSQLStoredProceduresSender sends the ListSQLStoredProcedures request. The method will close the +// http.Response Body if it receives an error. +func (client SQLResourcesClient) ListSQLStoredProceduresSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListSQLStoredProceduresResponder handles the response to the ListSQLStoredProcedures request. The method always +// closes the http.Response Body. +func (client SQLResourcesClient) ListSQLStoredProceduresResponder(resp *http.Response) (result SQLStoredProcedureListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListSQLTriggers lists the SQL trigger under an existing Azure Cosmos DB database account. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +// containerName - cosmos DB container name. +func (client SQLResourcesClient) ListSQLTriggers(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string) (result SQLTriggerListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.ListSQLTriggers") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.SQLResourcesClient", "ListSQLTriggers", err.Error()) + } + + req, err := client.ListSQLTriggersPreparer(ctx, resourceGroupName, accountName, databaseName, containerName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "ListSQLTriggers", nil, "Failure preparing request") + return + } + + resp, err := client.ListSQLTriggersSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "ListSQLTriggers", resp, "Failure sending request") + return + } + + result, err = client.ListSQLTriggersResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "ListSQLTriggers", resp, "Failure responding to request") + return + } + + return +} + +// ListSQLTriggersPreparer prepares the ListSQLTriggers request. +func (client SQLResourcesClient) ListSQLTriggersPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "containerName": autorest.Encode("path", containerName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/triggers", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSQLTriggersSender sends the ListSQLTriggers request. The method will close the +// http.Response Body if it receives an error. +func (client SQLResourcesClient) ListSQLTriggersSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListSQLTriggersResponder handles the response to the ListSQLTriggers request. The method always +// closes the http.Response Body. +func (client SQLResourcesClient) ListSQLTriggersResponder(resp *http.Response) (result SQLTriggerListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListSQLUserDefinedFunctions lists the SQL userDefinedFunction under an existing Azure Cosmos DB database account. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +// containerName - cosmos DB container name. +func (client SQLResourcesClient) ListSQLUserDefinedFunctions(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string) (result SQLUserDefinedFunctionListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.ListSQLUserDefinedFunctions") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.SQLResourcesClient", "ListSQLUserDefinedFunctions", err.Error()) + } + + req, err := client.ListSQLUserDefinedFunctionsPreparer(ctx, resourceGroupName, accountName, databaseName, containerName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "ListSQLUserDefinedFunctions", nil, "Failure preparing request") + return + } + + resp, err := client.ListSQLUserDefinedFunctionsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "ListSQLUserDefinedFunctions", resp, "Failure sending request") + return + } + + result, err = client.ListSQLUserDefinedFunctionsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "ListSQLUserDefinedFunctions", resp, "Failure responding to request") + return + } + + return +} + +// ListSQLUserDefinedFunctionsPreparer prepares the ListSQLUserDefinedFunctions request. +func (client SQLResourcesClient) ListSQLUserDefinedFunctionsPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "containerName": autorest.Encode("path", containerName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/userDefinedFunctions", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSQLUserDefinedFunctionsSender sends the ListSQLUserDefinedFunctions request. The method will close the +// http.Response Body if it receives an error. +func (client SQLResourcesClient) ListSQLUserDefinedFunctionsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListSQLUserDefinedFunctionsResponder handles the response to the ListSQLUserDefinedFunctions request. The method always +// closes the http.Response Body. +func (client SQLResourcesClient) ListSQLUserDefinedFunctionsResponder(resp *http.Response) (result SQLUserDefinedFunctionListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// MigrateSQLContainerToAutoscale migrate an Azure Cosmos DB SQL container from manual throughput to autoscale +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +// containerName - cosmos DB container name. +func (client SQLResourcesClient) MigrateSQLContainerToAutoscale(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string) (result SQLResourcesMigrateSQLContainerToAutoscaleFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.MigrateSQLContainerToAutoscale") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.SQLResourcesClient", "MigrateSQLContainerToAutoscale", err.Error()) + } + + req, err := client.MigrateSQLContainerToAutoscalePreparer(ctx, resourceGroupName, accountName, databaseName, containerName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "MigrateSQLContainerToAutoscale", nil, "Failure preparing request") + return + } + + result, err = client.MigrateSQLContainerToAutoscaleSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "MigrateSQLContainerToAutoscale", nil, "Failure sending request") + return + } + + return +} + +// MigrateSQLContainerToAutoscalePreparer prepares the MigrateSQLContainerToAutoscale request. +func (client SQLResourcesClient) MigrateSQLContainerToAutoscalePreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "containerName": autorest.Encode("path", containerName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/throughputSettings/default/migrateToAutoscale", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// MigrateSQLContainerToAutoscaleSender sends the MigrateSQLContainerToAutoscale request. The method will close the +// http.Response Body if it receives an error. +func (client SQLResourcesClient) MigrateSQLContainerToAutoscaleSender(req *http.Request) (future SQLResourcesMigrateSQLContainerToAutoscaleFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// MigrateSQLContainerToAutoscaleResponder handles the response to the MigrateSQLContainerToAutoscale request. The method always +// closes the http.Response Body. +func (client SQLResourcesClient) MigrateSQLContainerToAutoscaleResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// MigrateSQLContainerToManualThroughput migrate an Azure Cosmos DB SQL container from autoscale to manual throughput +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +// containerName - cosmos DB container name. +func (client SQLResourcesClient) MigrateSQLContainerToManualThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string) (result SQLResourcesMigrateSQLContainerToManualThroughputFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.MigrateSQLContainerToManualThroughput") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.SQLResourcesClient", "MigrateSQLContainerToManualThroughput", err.Error()) + } + + req, err := client.MigrateSQLContainerToManualThroughputPreparer(ctx, resourceGroupName, accountName, databaseName, containerName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "MigrateSQLContainerToManualThroughput", nil, "Failure preparing request") + return + } + + result, err = client.MigrateSQLContainerToManualThroughputSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "MigrateSQLContainerToManualThroughput", nil, "Failure sending request") + return + } + + return +} + +// MigrateSQLContainerToManualThroughputPreparer prepares the MigrateSQLContainerToManualThroughput request. +func (client SQLResourcesClient) MigrateSQLContainerToManualThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "containerName": autorest.Encode("path", containerName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/throughputSettings/default/migrateToManualThroughput", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// MigrateSQLContainerToManualThroughputSender sends the MigrateSQLContainerToManualThroughput request. The method will close the +// http.Response Body if it receives an error. +func (client SQLResourcesClient) MigrateSQLContainerToManualThroughputSender(req *http.Request) (future SQLResourcesMigrateSQLContainerToManualThroughputFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// MigrateSQLContainerToManualThroughputResponder handles the response to the MigrateSQLContainerToManualThroughput request. The method always +// closes the http.Response Body. +func (client SQLResourcesClient) MigrateSQLContainerToManualThroughputResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// MigrateSQLDatabaseToAutoscale migrate an Azure Cosmos DB SQL database from manual throughput to autoscale +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +func (client SQLResourcesClient) MigrateSQLDatabaseToAutoscale(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result SQLResourcesMigrateSQLDatabaseToAutoscaleFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.MigrateSQLDatabaseToAutoscale") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.SQLResourcesClient", "MigrateSQLDatabaseToAutoscale", err.Error()) + } + + req, err := client.MigrateSQLDatabaseToAutoscalePreparer(ctx, resourceGroupName, accountName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "MigrateSQLDatabaseToAutoscale", nil, "Failure preparing request") + return + } + + result, err = client.MigrateSQLDatabaseToAutoscaleSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "MigrateSQLDatabaseToAutoscale", nil, "Failure sending request") + return + } + + return +} + +// MigrateSQLDatabaseToAutoscalePreparer prepares the MigrateSQLDatabaseToAutoscale request. +func (client SQLResourcesClient) MigrateSQLDatabaseToAutoscalePreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/throughputSettings/default/migrateToAutoscale", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// MigrateSQLDatabaseToAutoscaleSender sends the MigrateSQLDatabaseToAutoscale request. The method will close the +// http.Response Body if it receives an error. +func (client SQLResourcesClient) MigrateSQLDatabaseToAutoscaleSender(req *http.Request) (future SQLResourcesMigrateSQLDatabaseToAutoscaleFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// MigrateSQLDatabaseToAutoscaleResponder handles the response to the MigrateSQLDatabaseToAutoscale request. The method always +// closes the http.Response Body. +func (client SQLResourcesClient) MigrateSQLDatabaseToAutoscaleResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// MigrateSQLDatabaseToManualThroughput migrate an Azure Cosmos DB SQL database from autoscale to manual throughput +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +func (client SQLResourcesClient) MigrateSQLDatabaseToManualThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result SQLResourcesMigrateSQLDatabaseToManualThroughputFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.MigrateSQLDatabaseToManualThroughput") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.SQLResourcesClient", "MigrateSQLDatabaseToManualThroughput", err.Error()) + } + + req, err := client.MigrateSQLDatabaseToManualThroughputPreparer(ctx, resourceGroupName, accountName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "MigrateSQLDatabaseToManualThroughput", nil, "Failure preparing request") + return + } + + result, err = client.MigrateSQLDatabaseToManualThroughputSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "MigrateSQLDatabaseToManualThroughput", nil, "Failure sending request") + return + } + + return +} + +// MigrateSQLDatabaseToManualThroughputPreparer prepares the MigrateSQLDatabaseToManualThroughput request. +func (client SQLResourcesClient) MigrateSQLDatabaseToManualThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/throughputSettings/default/migrateToManualThroughput", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// MigrateSQLDatabaseToManualThroughputSender sends the MigrateSQLDatabaseToManualThroughput request. The method will close the +// http.Response Body if it receives an error. +func (client SQLResourcesClient) MigrateSQLDatabaseToManualThroughputSender(req *http.Request) (future SQLResourcesMigrateSQLDatabaseToManualThroughputFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// MigrateSQLDatabaseToManualThroughputResponder handles the response to the MigrateSQLDatabaseToManualThroughput request. The method always +// closes the http.Response Body. +func (client SQLResourcesClient) MigrateSQLDatabaseToManualThroughputResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// RetrieveContinuousBackupInformation retrieves continuous backup information for a container resource. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +// containerName - cosmos DB container name. +// location - the name of the continuous backup restore location. +func (client SQLResourcesClient) RetrieveContinuousBackupInformation(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string, location ContinuousBackupRestoreLocation) (result SQLResourcesRetrieveContinuousBackupInformationFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.RetrieveContinuousBackupInformation") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.SQLResourcesClient", "RetrieveContinuousBackupInformation", err.Error()) + } + + req, err := client.RetrieveContinuousBackupInformationPreparer(ctx, resourceGroupName, accountName, databaseName, containerName, location) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "RetrieveContinuousBackupInformation", nil, "Failure preparing request") + return + } + + result, err = client.RetrieveContinuousBackupInformationSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "RetrieveContinuousBackupInformation", nil, "Failure sending request") + return + } + + return +} + +// RetrieveContinuousBackupInformationPreparer prepares the RetrieveContinuousBackupInformation request. +func (client SQLResourcesClient) RetrieveContinuousBackupInformationPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string, location ContinuousBackupRestoreLocation) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "containerName": autorest.Encode("path", containerName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + 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.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/retrieveContinuousBackupInformation", pathParameters), + autorest.WithJSON(location), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// RetrieveContinuousBackupInformationSender sends the RetrieveContinuousBackupInformation request. The method will close the +// http.Response Body if it receives an error. +func (client SQLResourcesClient) RetrieveContinuousBackupInformationSender(req *http.Request) (future SQLResourcesRetrieveContinuousBackupInformationFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// RetrieveContinuousBackupInformationResponder handles the response to the RetrieveContinuousBackupInformation request. The method always +// closes the http.Response Body. +func (client SQLResourcesClient) RetrieveContinuousBackupInformationResponder(resp *http.Response) (result BackupInformation, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// UpdateSQLContainerThroughput update RUs per second of an Azure Cosmos DB SQL container +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +// containerName - cosmos DB container name. +// updateThroughputParameters - the parameters to provide for the RUs per second of the current SQL container. +func (client SQLResourcesClient) UpdateSQLContainerThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string, updateThroughputParameters ThroughputSettingsUpdateParameters) (result SQLResourcesUpdateSQLContainerThroughputFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.UpdateSQLContainerThroughput") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}, + {TargetValue: updateThroughputParameters, + Constraints: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties.Resource", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties.Resource.AutoscaleSettings", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties.Resource.AutoscaleSettings.MaxThroughput", Name: validation.Null, Rule: true, Chain: nil}}}, + }}, + }}}}}); err != nil { + return result, validation.NewError("documentdb.SQLResourcesClient", "UpdateSQLContainerThroughput", err.Error()) + } + + req, err := client.UpdateSQLContainerThroughputPreparer(ctx, resourceGroupName, accountName, databaseName, containerName, updateThroughputParameters) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "UpdateSQLContainerThroughput", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSQLContainerThroughputSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "UpdateSQLContainerThroughput", nil, "Failure sending request") + return + } + + return +} + +// UpdateSQLContainerThroughputPreparer prepares the UpdateSQLContainerThroughput request. +func (client SQLResourcesClient) UpdateSQLContainerThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string, updateThroughputParameters ThroughputSettingsUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "containerName": autorest.Encode("path", containerName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + 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.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/throughputSettings/default", pathParameters), + autorest.WithJSON(updateThroughputParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSQLContainerThroughputSender sends the UpdateSQLContainerThroughput request. The method will close the +// http.Response Body if it receives an error. +func (client SQLResourcesClient) UpdateSQLContainerThroughputSender(req *http.Request) (future SQLResourcesUpdateSQLContainerThroughputFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// UpdateSQLContainerThroughputResponder handles the response to the UpdateSQLContainerThroughput request. The method always +// closes the http.Response Body. +func (client SQLResourcesClient) UpdateSQLContainerThroughputResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// UpdateSQLDatabaseThroughput update RUs per second of an Azure Cosmos DB SQL database +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// databaseName - cosmos DB database name. +// updateThroughputParameters - the parameters to provide for the RUs per second of the current SQL database. +func (client SQLResourcesClient) UpdateSQLDatabaseThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string, updateThroughputParameters ThroughputSettingsUpdateParameters) (result SQLResourcesUpdateSQLDatabaseThroughputFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.UpdateSQLDatabaseThroughput") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}, + {TargetValue: updateThroughputParameters, + Constraints: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties.Resource", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties.Resource.AutoscaleSettings", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties.Resource.AutoscaleSettings.MaxThroughput", Name: validation.Null, Rule: true, Chain: nil}}}, + }}, + }}}}}); err != nil { + return result, validation.NewError("documentdb.SQLResourcesClient", "UpdateSQLDatabaseThroughput", err.Error()) + } + + req, err := client.UpdateSQLDatabaseThroughputPreparer(ctx, resourceGroupName, accountName, databaseName, updateThroughputParameters) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "UpdateSQLDatabaseThroughput", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSQLDatabaseThroughputSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "UpdateSQLDatabaseThroughput", nil, "Failure sending request") + return + } + + return +} + +// UpdateSQLDatabaseThroughputPreparer prepares the UpdateSQLDatabaseThroughput request. +func (client SQLResourcesClient) UpdateSQLDatabaseThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, updateThroughputParameters ThroughputSettingsUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + 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.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/throughputSettings/default", pathParameters), + autorest.WithJSON(updateThroughputParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSQLDatabaseThroughputSender sends the UpdateSQLDatabaseThroughput request. The method will close the +// http.Response Body if it receives an error. +func (client SQLResourcesClient) UpdateSQLDatabaseThroughputSender(req *http.Request) (future SQLResourcesUpdateSQLDatabaseThroughputFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// UpdateSQLDatabaseThroughputResponder handles the response to the UpdateSQLDatabaseThroughput request. The method always +// closes the http.Response Body. +func (client SQLResourcesClient) UpdateSQLDatabaseThroughputResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/cosmos-db/mgmt/2021-06-15/documentdb/tableresources.go b/services/cosmos-db/mgmt/2021-06-15/documentdb/tableresources.go new file mode 100644 index 000000000000..2127bb491281 --- /dev/null +++ b/services/cosmos-db/mgmt/2021-06-15/documentdb/tableresources.go @@ -0,0 +1,786 @@ +package documentdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// TableResourcesClient is the client for the TableResources methods of the Documentdb service. +type TableResourcesClient struct { + BaseClient +} + +// NewTableResourcesClient creates an instance of the TableResourcesClient client. +func NewTableResourcesClient(subscriptionID string) TableResourcesClient { + return NewTableResourcesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewTableResourcesClientWithBaseURI creates an instance of the TableResourcesClient client using a custom endpoint. +// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewTableResourcesClientWithBaseURI(baseURI string, subscriptionID string) TableResourcesClient { + return TableResourcesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateUpdateTable create or update an Azure Cosmos DB Table +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// tableName - cosmos DB table name. +// createUpdateTableParameters - the parameters to provide for the current Table. +func (client TableResourcesClient) CreateUpdateTable(ctx context.Context, resourceGroupName string, accountName string, tableName string, createUpdateTableParameters TableCreateUpdateParameters) (result TableResourcesCreateUpdateTableFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TableResourcesClient.CreateUpdateTable") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}, + {TargetValue: createUpdateTableParameters, + Constraints: []validation.Constraint{{Target: "createUpdateTableParameters.TableCreateUpdateProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "createUpdateTableParameters.TableCreateUpdateProperties.Resource", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "createUpdateTableParameters.TableCreateUpdateProperties.Resource.ID", Name: validation.Null, Rule: true, Chain: nil}}}, + }}}}}); err != nil { + return result, validation.NewError("documentdb.TableResourcesClient", "CreateUpdateTable", err.Error()) + } + + req, err := client.CreateUpdateTablePreparer(ctx, resourceGroupName, accountName, tableName, createUpdateTableParameters) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.TableResourcesClient", "CreateUpdateTable", nil, "Failure preparing request") + return + } + + result, err = client.CreateUpdateTableSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.TableResourcesClient", "CreateUpdateTable", nil, "Failure sending request") + return + } + + return +} + +// CreateUpdateTablePreparer prepares the CreateUpdateTable request. +func (client TableResourcesClient) CreateUpdateTablePreparer(ctx context.Context, resourceGroupName string, accountName string, tableName string, createUpdateTableParameters TableCreateUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "tableName": autorest.Encode("path", tableName), + } + + const APIVersion = "2021-06-15" + 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.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}", pathParameters), + autorest.WithJSON(createUpdateTableParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateUpdateTableSender sends the CreateUpdateTable request. The method will close the +// http.Response Body if it receives an error. +func (client TableResourcesClient) CreateUpdateTableSender(req *http.Request) (future TableResourcesCreateUpdateTableFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateUpdateTableResponder handles the response to the CreateUpdateTable request. The method always +// closes the http.Response Body. +func (client TableResourcesClient) CreateUpdateTableResponder(resp *http.Response) (result TableGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// DeleteTable deletes an existing Azure Cosmos DB Table. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// tableName - cosmos DB table name. +func (client TableResourcesClient) DeleteTable(ctx context.Context, resourceGroupName string, accountName string, tableName string) (result TableResourcesDeleteTableFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TableResourcesClient.DeleteTable") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.TableResourcesClient", "DeleteTable", err.Error()) + } + + req, err := client.DeleteTablePreparer(ctx, resourceGroupName, accountName, tableName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.TableResourcesClient", "DeleteTable", nil, "Failure preparing request") + return + } + + result, err = client.DeleteTableSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.TableResourcesClient", "DeleteTable", nil, "Failure sending request") + return + } + + return +} + +// DeleteTablePreparer prepares the DeleteTable request. +func (client TableResourcesClient) DeleteTablePreparer(ctx context.Context, resourceGroupName string, accountName string, tableName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "tableName": autorest.Encode("path", tableName), + } + + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteTableSender sends the DeleteTable request. The method will close the +// http.Response Body if it receives an error. +func (client TableResourcesClient) DeleteTableSender(req *http.Request) (future TableResourcesDeleteTableFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteTableResponder handles the response to the DeleteTable request. The method always +// closes the http.Response Body. +func (client TableResourcesClient) DeleteTableResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// GetTable gets the Tables under an existing Azure Cosmos DB database account with the provided name. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// tableName - cosmos DB table name. +func (client TableResourcesClient) GetTable(ctx context.Context, resourceGroupName string, accountName string, tableName string) (result TableGetResults, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TableResourcesClient.GetTable") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.TableResourcesClient", "GetTable", err.Error()) + } + + req, err := client.GetTablePreparer(ctx, resourceGroupName, accountName, tableName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.TableResourcesClient", "GetTable", nil, "Failure preparing request") + return + } + + resp, err := client.GetTableSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.TableResourcesClient", "GetTable", resp, "Failure sending request") + return + } + + result, err = client.GetTableResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.TableResourcesClient", "GetTable", resp, "Failure responding to request") + return + } + + return +} + +// GetTablePreparer prepares the GetTable request. +func (client TableResourcesClient) GetTablePreparer(ctx context.Context, resourceGroupName string, accountName string, tableName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "tableName": autorest.Encode("path", tableName), + } + + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetTableSender sends the GetTable request. The method will close the +// http.Response Body if it receives an error. +func (client TableResourcesClient) GetTableSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetTableResponder handles the response to the GetTable request. The method always +// closes the http.Response Body. +func (client TableResourcesClient) GetTableResponder(resp *http.Response) (result TableGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetTableThroughput gets the RUs per second of the Table under an existing Azure Cosmos DB database account with the +// provided name. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// tableName - cosmos DB table name. +func (client TableResourcesClient) GetTableThroughput(ctx context.Context, resourceGroupName string, accountName string, tableName string) (result ThroughputSettingsGetResults, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TableResourcesClient.GetTableThroughput") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.TableResourcesClient", "GetTableThroughput", err.Error()) + } + + req, err := client.GetTableThroughputPreparer(ctx, resourceGroupName, accountName, tableName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.TableResourcesClient", "GetTableThroughput", nil, "Failure preparing request") + return + } + + resp, err := client.GetTableThroughputSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.TableResourcesClient", "GetTableThroughput", resp, "Failure sending request") + return + } + + result, err = client.GetTableThroughputResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.TableResourcesClient", "GetTableThroughput", resp, "Failure responding to request") + return + } + + return +} + +// GetTableThroughputPreparer prepares the GetTableThroughput request. +func (client TableResourcesClient) GetTableThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, tableName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "tableName": autorest.Encode("path", tableName), + } + + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}/throughputSettings/default", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetTableThroughputSender sends the GetTableThroughput request. The method will close the +// http.Response Body if it receives an error. +func (client TableResourcesClient) GetTableThroughputSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetTableThroughputResponder handles the response to the GetTableThroughput request. The method always +// closes the http.Response Body. +func (client TableResourcesClient) GetTableThroughputResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListTables lists the Tables under an existing Azure Cosmos DB database account. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +func (client TableResourcesClient) ListTables(ctx context.Context, resourceGroupName string, accountName string) (result TableListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TableResourcesClient.ListTables") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.TableResourcesClient", "ListTables", err.Error()) + } + + req, err := client.ListTablesPreparer(ctx, resourceGroupName, accountName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.TableResourcesClient", "ListTables", nil, "Failure preparing request") + return + } + + resp, err := client.ListTablesSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "documentdb.TableResourcesClient", "ListTables", resp, "Failure sending request") + return + } + + result, err = client.ListTablesResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.TableResourcesClient", "ListTables", resp, "Failure responding to request") + return + } + + return +} + +// ListTablesPreparer prepares the ListTables request. +func (client TableResourcesClient) ListTablesPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListTablesSender sends the ListTables request. The method will close the +// http.Response Body if it receives an error. +func (client TableResourcesClient) ListTablesSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListTablesResponder handles the response to the ListTables request. The method always +// closes the http.Response Body. +func (client TableResourcesClient) ListTablesResponder(resp *http.Response) (result TableListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// MigrateTableToAutoscale migrate an Azure Cosmos DB Table from manual throughput to autoscale +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// tableName - cosmos DB table name. +func (client TableResourcesClient) MigrateTableToAutoscale(ctx context.Context, resourceGroupName string, accountName string, tableName string) (result TableResourcesMigrateTableToAutoscaleFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TableResourcesClient.MigrateTableToAutoscale") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.TableResourcesClient", "MigrateTableToAutoscale", err.Error()) + } + + req, err := client.MigrateTableToAutoscalePreparer(ctx, resourceGroupName, accountName, tableName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.TableResourcesClient", "MigrateTableToAutoscale", nil, "Failure preparing request") + return + } + + result, err = client.MigrateTableToAutoscaleSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.TableResourcesClient", "MigrateTableToAutoscale", nil, "Failure sending request") + return + } + + return +} + +// MigrateTableToAutoscalePreparer prepares the MigrateTableToAutoscale request. +func (client TableResourcesClient) MigrateTableToAutoscalePreparer(ctx context.Context, resourceGroupName string, accountName string, tableName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "tableName": autorest.Encode("path", tableName), + } + + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}/throughputSettings/default/migrateToAutoscale", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// MigrateTableToAutoscaleSender sends the MigrateTableToAutoscale request. The method will close the +// http.Response Body if it receives an error. +func (client TableResourcesClient) MigrateTableToAutoscaleSender(req *http.Request) (future TableResourcesMigrateTableToAutoscaleFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// MigrateTableToAutoscaleResponder handles the response to the MigrateTableToAutoscale request. The method always +// closes the http.Response Body. +func (client TableResourcesClient) MigrateTableToAutoscaleResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// MigrateTableToManualThroughput migrate an Azure Cosmos DB Table from autoscale to manual throughput +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// tableName - cosmos DB table name. +func (client TableResourcesClient) MigrateTableToManualThroughput(ctx context.Context, resourceGroupName string, accountName string, tableName string) (result TableResourcesMigrateTableToManualThroughputFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TableResourcesClient.MigrateTableToManualThroughput") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { + return result, validation.NewError("documentdb.TableResourcesClient", "MigrateTableToManualThroughput", err.Error()) + } + + req, err := client.MigrateTableToManualThroughputPreparer(ctx, resourceGroupName, accountName, tableName) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.TableResourcesClient", "MigrateTableToManualThroughput", nil, "Failure preparing request") + return + } + + result, err = client.MigrateTableToManualThroughputSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.TableResourcesClient", "MigrateTableToManualThroughput", nil, "Failure sending request") + return + } + + return +} + +// MigrateTableToManualThroughputPreparer prepares the MigrateTableToManualThroughput request. +func (client TableResourcesClient) MigrateTableToManualThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, tableName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "tableName": autorest.Encode("path", tableName), + } + + const APIVersion = "2021-06-15" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}/throughputSettings/default/migrateToManualThroughput", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// MigrateTableToManualThroughputSender sends the MigrateTableToManualThroughput request. The method will close the +// http.Response Body if it receives an error. +func (client TableResourcesClient) MigrateTableToManualThroughputSender(req *http.Request) (future TableResourcesMigrateTableToManualThroughputFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// MigrateTableToManualThroughputResponder handles the response to the MigrateTableToManualThroughput request. The method always +// closes the http.Response Body. +func (client TableResourcesClient) MigrateTableToManualThroughputResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// UpdateTableThroughput update RUs per second of an Azure Cosmos DB Table +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// accountName - cosmos DB database account name. +// tableName - cosmos DB table name. +// updateThroughputParameters - the parameters to provide for the RUs per second of the current Table. +func (client TableResourcesClient) UpdateTableThroughput(ctx context.Context, resourceGroupName string, accountName string, tableName string, updateThroughputParameters ThroughputSettingsUpdateParameters) (result TableResourcesUpdateTableThroughputFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TableResourcesClient.UpdateTableThroughput") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: accountName, + Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, + {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}, + {TargetValue: updateThroughputParameters, + Constraints: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties.Resource", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties.Resource.AutoscaleSettings", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties.Resource.AutoscaleSettings.MaxThroughput", Name: validation.Null, Rule: true, Chain: nil}}}, + }}, + }}}}}); err != nil { + return result, validation.NewError("documentdb.TableResourcesClient", "UpdateTableThroughput", err.Error()) + } + + req, err := client.UpdateTableThroughputPreparer(ctx, resourceGroupName, accountName, tableName, updateThroughputParameters) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.TableResourcesClient", "UpdateTableThroughput", nil, "Failure preparing request") + return + } + + result, err = client.UpdateTableThroughputSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "documentdb.TableResourcesClient", "UpdateTableThroughput", nil, "Failure sending request") + return + } + + return +} + +// UpdateTableThroughputPreparer prepares the UpdateTableThroughput request. +func (client TableResourcesClient) UpdateTableThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, tableName string, updateThroughputParameters ThroughputSettingsUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "tableName": autorest.Encode("path", tableName), + } + + const APIVersion = "2021-06-15" + 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.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}/throughputSettings/default", pathParameters), + autorest.WithJSON(updateThroughputParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateTableThroughputSender sends the UpdateTableThroughput request. The method will close the +// http.Response Body if it receives an error. +func (client TableResourcesClient) UpdateTableThroughputSender(req *http.Request) (future TableResourcesUpdateTableThroughputFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// UpdateTableThroughputResponder handles the response to the UpdateTableThroughput request. The method always +// closes the http.Response Body. +func (client TableResourcesClient) UpdateTableThroughputResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/cosmos-db/mgmt/2021-06-15/documentdb/version.go b/services/cosmos-db/mgmt/2021-06-15/documentdb/version.go new file mode 100644 index 000000000000..766bc1f245e4 --- /dev/null +++ b/services/cosmos-db/mgmt/2021-06-15/documentdb/version.go @@ -0,0 +1,19 @@ +package documentdb + +import "github.com/Azure/azure-sdk-for-go/version" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// UserAgent returns the UserAgent string to use when sending http.Requests. +func UserAgent() string { + return "Azure-SDK-For-Go/" + Version() + " documentdb/2021-06-15" +} + +// Version returns the semantic version (see http://semver.org) of the client. +func Version() string { + return version.Number +} diff --git a/services/postgresql/mgmt/2021-06-01/postgresqlflexibleservers/CHANGELOG.md b/services/postgresql/mgmt/2021-06-01/postgresqlflexibleservers/CHANGELOG.md new file mode 100644 index 000000000000..52911e4cc5e4 --- /dev/null +++ b/services/postgresql/mgmt/2021-06-01/postgresqlflexibleservers/CHANGELOG.md @@ -0,0 +1,2 @@ +# Change History + diff --git a/services/postgresql/mgmt/2021-06-01/postgresqlflexibleservers/_meta.json b/services/postgresql/mgmt/2021-06-01/postgresqlflexibleservers/_meta.json new file mode 100644 index 000000000000..64b0ebcc1a17 --- /dev/null +++ b/services/postgresql/mgmt/2021-06-01/postgresqlflexibleservers/_meta.json @@ -0,0 +1,11 @@ +{ + "commit": "8dff86df71bee429af84ea4713288ef3cdd1db2f", + "readme": "/_/azure-rest-api-specs/specification/postgresql/resource-manager/readme.md", + "tag": "package-flexibleserver-2021-06", + "use": "@microsoft.azure/autorest.go@2.1.183", + "repository_url": "https://github.com/Azure/azure-rest-api-specs.git", + "autorest_command": "autorest --use=@microsoft.azure/autorest.go@2.1.183 --tag=package-flexibleserver-2021-06 --go-sdk-folder=/_/azure-sdk-for-go --go --verbose --use-onever --version=V2 --go.license-header=MICROSOFT_MIT_NO_VERSION --enum-prefix /_/azure-rest-api-specs/specification/postgresql/resource-manager/readme.md", + "additional_properties": { + "additional_options": "--go --verbose --use-onever --version=V2 --go.license-header=MICROSOFT_MIT_NO_VERSION --enum-prefix" + } +} \ No newline at end of file diff --git a/services/postgresql/mgmt/2021-06-01/postgresqlflexibleservers/checknameavailability.go b/services/postgresql/mgmt/2021-06-01/postgresqlflexibleservers/checknameavailability.go new file mode 100644 index 000000000000..f8187aaf040e --- /dev/null +++ b/services/postgresql/mgmt/2021-06-01/postgresqlflexibleservers/checknameavailability.go @@ -0,0 +1,118 @@ +package postgresqlflexibleservers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// CheckNameAvailabilityClient is the the Microsoft Azure management API provides create, read, update, and delete +// functionality for Azure PostgreSQL resources including servers, databases, firewall rules, VNET rules, security +// alert policies, log files and configurations with new business model. +type CheckNameAvailabilityClient struct { + BaseClient +} + +// NewCheckNameAvailabilityClient creates an instance of the CheckNameAvailabilityClient client. +func NewCheckNameAvailabilityClient(subscriptionID string) CheckNameAvailabilityClient { + return NewCheckNameAvailabilityClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewCheckNameAvailabilityClientWithBaseURI creates an instance of the CheckNameAvailabilityClient client using a +// custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, +// Azure stack). +func NewCheckNameAvailabilityClientWithBaseURI(baseURI string, subscriptionID string) CheckNameAvailabilityClient { + return CheckNameAvailabilityClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Execute check the availability of name for resource +// Parameters: +// nameAvailabilityRequest - the required parameters for checking if resource name is available. +func (client CheckNameAvailabilityClient) Execute(ctx context.Context, nameAvailabilityRequest NameAvailabilityRequest) (result NameAvailability, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CheckNameAvailabilityClient.Execute") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: nameAvailabilityRequest, + Constraints: []validation.Constraint{{Target: "nameAvailabilityRequest.Name", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewError("postgresqlflexibleservers.CheckNameAvailabilityClient", "Execute", err.Error()) + } + + req, err := client.ExecutePreparer(ctx, nameAvailabilityRequest) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.CheckNameAvailabilityClient", "Execute", nil, "Failure preparing request") + return + } + + resp, err := client.ExecuteSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.CheckNameAvailabilityClient", "Execute", resp, "Failure sending request") + return + } + + result, err = client.ExecuteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.CheckNameAvailabilityClient", "Execute", resp, "Failure responding to request") + return + } + + return +} + +// ExecutePreparer prepares the Execute request. +func (client CheckNameAvailabilityClient) ExecutePreparer(ctx context.Context, nameAvailabilityRequest NameAvailabilityRequest) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-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.DBForPostgreSql/checkNameAvailability", pathParameters), + autorest.WithJSON(nameAvailabilityRequest), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ExecuteSender sends the Execute request. The method will close the +// http.Response Body if it receives an error. +func (client CheckNameAvailabilityClient) ExecuteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ExecuteResponder handles the response to the Execute request. The method always +// closes the http.Response Body. +func (client CheckNameAvailabilityClient) ExecuteResponder(resp *http.Response) (result NameAvailability, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/postgresql/mgmt/2021-06-01/postgresqlflexibleservers/client.go b/services/postgresql/mgmt/2021-06-01/postgresqlflexibleservers/client.go new file mode 100644 index 000000000000..a3b40a7fc77a --- /dev/null +++ b/services/postgresql/mgmt/2021-06-01/postgresqlflexibleservers/client.go @@ -0,0 +1,43 @@ +// Package postgresqlflexibleservers implements the Azure ARM Postgresqlflexibleservers service API version 2021-06-01. +// +// The Microsoft Azure management API provides create, read, update, and delete functionality for Azure PostgreSQL +// resources including servers, databases, firewall rules, VNET rules, security alert policies, log files and +// configurations with new business model. +package postgresqlflexibleservers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" +) + +const ( + // DefaultBaseURI is the default URI used for the service Postgresqlflexibleservers + DefaultBaseURI = "https://management.azure.com" +) + +// BaseClient is the base client for Postgresqlflexibleservers. +type BaseClient struct { + autorest.Client + BaseURI string + SubscriptionID string +} + +// New creates an instance of the BaseClient client. +func New(subscriptionID string) BaseClient { + return NewWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewWithBaseURI creates an instance of the BaseClient client using a custom endpoint. Use this when interacting with +// an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { + return BaseClient{ + Client: autorest.NewClientWithUserAgent(UserAgent()), + BaseURI: baseURI, + SubscriptionID: subscriptionID, + } +} diff --git a/services/postgresql/mgmt/2021-06-01/postgresqlflexibleservers/configurations.go b/services/postgresql/mgmt/2021-06-01/postgresqlflexibleservers/configurations.go new file mode 100644 index 000000000000..5b2fa4b70660 --- /dev/null +++ b/services/postgresql/mgmt/2021-06-01/postgresqlflexibleservers/configurations.go @@ -0,0 +1,434 @@ +package postgresqlflexibleservers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ConfigurationsClient is the the Microsoft Azure management API provides create, read, update, and delete +// functionality for Azure PostgreSQL resources including servers, databases, firewall rules, VNET rules, security +// alert policies, log files and configurations with new business model. +type ConfigurationsClient struct { + BaseClient +} + +// NewConfigurationsClient creates an instance of the ConfigurationsClient client. +func NewConfigurationsClient(subscriptionID string) ConfigurationsClient { + return NewConfigurationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewConfigurationsClientWithBaseURI creates an instance of the ConfigurationsClient client using a custom endpoint. +// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewConfigurationsClientWithBaseURI(baseURI string, subscriptionID string) ConfigurationsClient { + return ConfigurationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get gets information about a configuration of server. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// serverName - the name of the server. +// configurationName - the name of the server configuration. +func (client ConfigurationsClient) Get(ctx context.Context, resourceGroupName string, serverName string, configurationName string) (result Configuration, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConfigurationsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("postgresqlflexibleservers.ConfigurationsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, configurationName) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ConfigurationsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ConfigurationsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ConfigurationsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ConfigurationsClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, configurationName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "configurationName": autorest.Encode("path", configurationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-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.DBForPostgreSql/flexibleServers/{serverName}/configurations/{configurationName}", 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 ConfigurationsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ConfigurationsClient) GetResponder(resp *http.Response) (result Configuration, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer list all the configurations in a given server. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// serverName - the name of the server. +func (client ConfigurationsClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result ConfigurationListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConfigurationsClient.ListByServer") + defer func() { + sc := -1 + if result.clr.Response.Response != nil { + sc = result.clr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("postgresqlflexibleservers.ConfigurationsClient", "ListByServer", err.Error()) + } + + result.fn = client.listByServerNextResults + req, err := client.ListByServerPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ConfigurationsClient", "ListByServer", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServerSender(req) + if err != nil { + result.clr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ConfigurationsClient", "ListByServer", resp, "Failure sending request") + return + } + + result.clr, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ConfigurationsClient", "ListByServer", resp, "Failure responding to request") + return + } + if result.clr.hasNextLink() && result.clr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServerPreparer prepares the ListByServer request. +func (client ConfigurationsClient) ListByServerPreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-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.DBForPostgreSql/flexibleServers/{serverName}/configurations", 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 ConfigurationsClient) ListByServerSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client ConfigurationsClient) ListByServerResponder(resp *http.Response) (result ConfigurationListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByServerNextResults retrieves the next set of results, if any. +func (client ConfigurationsClient) listByServerNextResults(ctx context.Context, lastResults ConfigurationListResult) (result ConfigurationListResult, err error) { + req, err := lastResults.configurationListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "postgresqlflexibleservers.ConfigurationsClient", "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, "postgresqlflexibleservers.ConfigurationsClient", "listByServerNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ConfigurationsClient", "listByServerNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServerComplete enumerates all values, automatically crossing page boundaries as required. +func (client ConfigurationsClient) ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result ConfigurationListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConfigurationsClient.ListByServer") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByServer(ctx, resourceGroupName, serverName) + return +} + +// Put updates a configuration of a server. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// serverName - the name of the server. +// configurationName - the name of the server configuration. +// parameters - the required parameters for updating a server configuration. +func (client ConfigurationsClient) Put(ctx context.Context, resourceGroupName string, serverName string, configurationName string, parameters Configuration) (result ConfigurationsPutFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConfigurationsClient.Put") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("postgresqlflexibleservers.ConfigurationsClient", "Put", err.Error()) + } + + req, err := client.PutPreparer(ctx, resourceGroupName, serverName, configurationName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ConfigurationsClient", "Put", nil, "Failure preparing request") + return + } + + result, err = client.PutSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ConfigurationsClient", "Put", nil, "Failure sending request") + return + } + + return +} + +// PutPreparer prepares the Put request. +func (client ConfigurationsClient) PutPreparer(ctx context.Context, resourceGroupName string, serverName string, configurationName string, parameters Configuration) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "configurationName": autorest.Encode("path", configurationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + parameters.SystemData = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/flexibleServers/{serverName}/configurations/{configurationName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// PutSender sends the Put request. The method will close the +// http.Response Body if it receives an error. +func (client ConfigurationsClient) PutSender(req *http.Request) (future ConfigurationsPutFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// PutResponder handles the response to the Put request. The method always +// closes the http.Response Body. +func (client ConfigurationsClient) PutResponder(resp *http.Response) (result Configuration, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Update updates a configuration of a server. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// serverName - the name of the server. +// configurationName - the name of the server configuration. +// parameters - the required parameters for updating a server configuration. +func (client ConfigurationsClient) Update(ctx context.Context, resourceGroupName string, serverName string, configurationName string, parameters Configuration) (result ConfigurationsUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConfigurationsClient.Update") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("postgresqlflexibleservers.ConfigurationsClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, serverName, configurationName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ConfigurationsClient", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ConfigurationsClient", "Update", nil, "Failure sending request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client ConfigurationsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, configurationName string, parameters Configuration) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "configurationName": autorest.Encode("path", configurationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + parameters.SystemData = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/flexibleServers/{serverName}/configurations/{configurationName}", 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 ConfigurationsClient) UpdateSender(req *http.Request) (future ConfigurationsUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client ConfigurationsClient) UpdateResponder(resp *http.Response) (result Configuration, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/postgresql/mgmt/2021-06-01/postgresqlflexibleservers/databases.go b/services/postgresql/mgmt/2021-06-01/postgresqlflexibleservers/databases.go new file mode 100644 index 000000000000..6e9a51c8dc71 --- /dev/null +++ b/services/postgresql/mgmt/2021-06-01/postgresqlflexibleservers/databases.go @@ -0,0 +1,429 @@ +package postgresqlflexibleservers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// DatabasesClient is the the Microsoft Azure management API provides create, read, update, and delete functionality +// for Azure PostgreSQL resources including servers, databases, firewall rules, VNET rules, security alert policies, +// log files and configurations with new business model. +type DatabasesClient struct { + BaseClient +} + +// NewDatabasesClient creates an instance of the DatabasesClient client. +func NewDatabasesClient(subscriptionID string) DatabasesClient { + return NewDatabasesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewDatabasesClientWithBaseURI creates an instance of the DatabasesClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewDatabasesClientWithBaseURI(baseURI string, subscriptionID string) DatabasesClient { + return DatabasesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Create creates a new database or updates an existing database. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// serverName - the name of the server. +// databaseName - the name of the database. +// parameters - the required parameters for creating or updating a database. +func (client DatabasesClient) Create(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters Database) (result DatabasesCreateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabasesClient.Create") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("postgresqlflexibleservers.DatabasesClient", "Create", err.Error()) + } + + req, err := client.CreatePreparer(ctx, resourceGroupName, serverName, databaseName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.DatabasesClient", "Create", nil, "Failure preparing request") + return + } + + result, err = client.CreateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.DatabasesClient", "Create", nil, "Failure sending request") + return + } + + return +} + +// CreatePreparer prepares the Create request. +func (client DatabasesClient) CreatePreparer(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 = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + parameters.SystemData = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/flexibleServers/{serverName}/databases/{databaseName}", 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 DatabasesClient) CreateSender(req *http.Request) (future DatabasesCreateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client DatabasesClient) CreateResponder(resp *http.Response) (result Database, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a database. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// serverName - the name of the server. +// databaseName - the name of the database. +func (client DatabasesClient) Delete(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result DatabasesDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabasesClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("postgresqlflexibleservers.DatabasesClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.DatabasesClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.DatabasesClient", "Delete", nil, "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 = "2021-06-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.DBForPostgreSql/flexibleServers/{serverName}/databases/{databaseName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client DatabasesClient) DeleteSender(req *http.Request) (future DatabasesDeleteFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client DatabasesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets information about a database. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// serverName - the name of the server. +// databaseName - the name of the database. +func (client DatabasesClient) Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result Database, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabasesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("postgresqlflexibleservers.DatabasesClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.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, "postgresqlflexibleservers.DatabasesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.DatabasesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client DatabasesClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-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.DBForPostgreSql/flexibleServers/{serverName}/databases/{databaseName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client DatabasesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client DatabasesClient) GetResponder(resp *http.Response) (result Database, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer list all the databases in a given server. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// serverName - the name of the server. +func (client DatabasesClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result DatabaseListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabasesClient.ListByServer") + defer func() { + sc := -1 + if result.dlr.Response.Response != nil { + sc = result.dlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("postgresqlflexibleservers.DatabasesClient", "ListByServer", err.Error()) + } + + result.fn = client.listByServerNextResults + req, err := client.ListByServerPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.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, "postgresqlflexibleservers.DatabasesClient", "ListByServer", resp, "Failure sending request") + return + } + + result.dlr, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.DatabasesClient", "ListByServer", resp, "Failure responding to request") + return + } + if result.dlr.hasNextLink() && result.dlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServerPreparer prepares the ListByServer request. +func (client DatabasesClient) ListByServerPreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-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.DBForPostgreSql/flexibleServers/{serverName}/databases", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByServerSender sends the ListByServer request. The method will close the +// http.Response Body if it receives an error. +func (client DatabasesClient) ListByServerSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client DatabasesClient) ListByServerResponder(resp *http.Response) (result DatabaseListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByServerNextResults retrieves the next set of results, if any. +func (client DatabasesClient) listByServerNextResults(ctx context.Context, lastResults DatabaseListResult) (result DatabaseListResult, err error) { + req, err := lastResults.databaseListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "postgresqlflexibleservers.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, "postgresqlflexibleservers.DatabasesClient", "listByServerNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.DatabasesClient", "listByServerNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServerComplete enumerates all values, automatically crossing page boundaries as required. +func (client DatabasesClient) ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result DatabaseListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabasesClient.ListByServer") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByServer(ctx, resourceGroupName, serverName) + return +} diff --git a/services/postgresql/mgmt/2021-06-01/postgresqlflexibleservers/enums.go b/services/postgresql/mgmt/2021-06-01/postgresqlflexibleservers/enums.go new file mode 100644 index 000000000000..9941d56ca3c7 --- /dev/null +++ b/services/postgresql/mgmt/2021-06-01/postgresqlflexibleservers/enums.go @@ -0,0 +1,236 @@ +package postgresqlflexibleservers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// ConfigurationDataType enumerates the values for configuration data type. +type ConfigurationDataType string + +const ( + // ConfigurationDataTypeBoolean ... + ConfigurationDataTypeBoolean ConfigurationDataType = "Boolean" + // ConfigurationDataTypeEnumeration ... + ConfigurationDataTypeEnumeration ConfigurationDataType = "Enumeration" + // ConfigurationDataTypeInteger ... + ConfigurationDataTypeInteger ConfigurationDataType = "Integer" + // ConfigurationDataTypeNumeric ... + ConfigurationDataTypeNumeric ConfigurationDataType = "Numeric" +) + +// PossibleConfigurationDataTypeValues returns an array of possible values for the ConfigurationDataType const type. +func PossibleConfigurationDataTypeValues() []ConfigurationDataType { + return []ConfigurationDataType{ConfigurationDataTypeBoolean, ConfigurationDataTypeEnumeration, ConfigurationDataTypeInteger, ConfigurationDataTypeNumeric} +} + +// CreatedByType enumerates the values for created by type. +type CreatedByType string + +const ( + // CreatedByTypeApplication ... + CreatedByTypeApplication CreatedByType = "Application" + // CreatedByTypeKey ... + CreatedByTypeKey CreatedByType = "Key" + // CreatedByTypeManagedIdentity ... + CreatedByTypeManagedIdentity CreatedByType = "ManagedIdentity" + // CreatedByTypeUser ... + CreatedByTypeUser CreatedByType = "User" +) + +// PossibleCreatedByTypeValues returns an array of possible values for the CreatedByType const type. +func PossibleCreatedByTypeValues() []CreatedByType { + return []CreatedByType{CreatedByTypeApplication, CreatedByTypeKey, CreatedByTypeManagedIdentity, CreatedByTypeUser} +} + +// CreateMode enumerates the values for create mode. +type CreateMode string + +const ( + // CreateModeCreate ... + CreateModeCreate CreateMode = "Create" + // CreateModeDefault ... + CreateModeDefault CreateMode = "Default" + // CreateModePointInTimeRestore ... + CreateModePointInTimeRestore CreateMode = "PointInTimeRestore" + // CreateModeUpdate ... + CreateModeUpdate CreateMode = "Update" +) + +// PossibleCreateModeValues returns an array of possible values for the CreateMode const type. +func PossibleCreateModeValues() []CreateMode { + return []CreateMode{CreateModeCreate, CreateModeDefault, CreateModePointInTimeRestore, CreateModeUpdate} +} + +// CreateModeForUpdate enumerates the values for create mode for update. +type CreateModeForUpdate string + +const ( + // CreateModeForUpdateDefault ... + CreateModeForUpdateDefault CreateModeForUpdate = "Default" + // CreateModeForUpdateUpdate ... + CreateModeForUpdateUpdate CreateModeForUpdate = "Update" +) + +// PossibleCreateModeForUpdateValues returns an array of possible values for the CreateModeForUpdate const type. +func PossibleCreateModeForUpdateValues() []CreateModeForUpdate { + return []CreateModeForUpdate{CreateModeForUpdateDefault, CreateModeForUpdateUpdate} +} + +// GeoRedundantBackupEnum enumerates the values for geo redundant backup enum. +type GeoRedundantBackupEnum string + +const ( + // GeoRedundantBackupEnumDisabled ... + GeoRedundantBackupEnumDisabled GeoRedundantBackupEnum = "Disabled" + // GeoRedundantBackupEnumEnabled ... + GeoRedundantBackupEnumEnabled GeoRedundantBackupEnum = "Enabled" +) + +// PossibleGeoRedundantBackupEnumValues returns an array of possible values for the GeoRedundantBackupEnum const type. +func PossibleGeoRedundantBackupEnumValues() []GeoRedundantBackupEnum { + return []GeoRedundantBackupEnum{GeoRedundantBackupEnumDisabled, GeoRedundantBackupEnumEnabled} +} + +// HighAvailabilityMode enumerates the values for high availability mode. +type HighAvailabilityMode string + +const ( + // HighAvailabilityModeDisabled ... + HighAvailabilityModeDisabled HighAvailabilityMode = "Disabled" + // HighAvailabilityModeZoneRedundant ... + HighAvailabilityModeZoneRedundant HighAvailabilityMode = "ZoneRedundant" +) + +// PossibleHighAvailabilityModeValues returns an array of possible values for the HighAvailabilityMode const type. +func PossibleHighAvailabilityModeValues() []HighAvailabilityMode { + return []HighAvailabilityMode{HighAvailabilityModeDisabled, HighAvailabilityModeZoneRedundant} +} + +// OperationOrigin enumerates the values for operation origin. +type OperationOrigin string + +const ( + // OperationOriginNotSpecified ... + OperationOriginNotSpecified OperationOrigin = "NotSpecified" + // 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{OperationOriginNotSpecified, OperationOriginSystem, OperationOriginUser} +} + +// ResourceIdentityType enumerates the values for resource identity type. +type ResourceIdentityType string + +const ( + // ResourceIdentityTypeSystemAssigned ... + ResourceIdentityTypeSystemAssigned ResourceIdentityType = "SystemAssigned" +) + +// PossibleResourceIdentityTypeValues returns an array of possible values for the ResourceIdentityType const type. +func PossibleResourceIdentityTypeValues() []ResourceIdentityType { + return []ResourceIdentityType{ResourceIdentityTypeSystemAssigned} +} + +// ServerHAState enumerates the values for server ha state. +type ServerHAState string + +const ( + // ServerHAStateCreatingStandby ... + ServerHAStateCreatingStandby ServerHAState = "CreatingStandby" + // ServerHAStateFailingOver ... + ServerHAStateFailingOver ServerHAState = "FailingOver" + // ServerHAStateHealthy ... + ServerHAStateHealthy ServerHAState = "Healthy" + // ServerHAStateNotEnabled ... + ServerHAStateNotEnabled ServerHAState = "NotEnabled" + // ServerHAStateRemovingStandby ... + ServerHAStateRemovingStandby ServerHAState = "RemovingStandby" + // ServerHAStateReplicatingData ... + ServerHAStateReplicatingData ServerHAState = "ReplicatingData" +) + +// PossibleServerHAStateValues returns an array of possible values for the ServerHAState const type. +func PossibleServerHAStateValues() []ServerHAState { + return []ServerHAState{ServerHAStateCreatingStandby, ServerHAStateFailingOver, ServerHAStateHealthy, ServerHAStateNotEnabled, ServerHAStateRemovingStandby, ServerHAStateReplicatingData} +} + +// ServerPublicNetworkAccessState enumerates the values for server public network access state. +type ServerPublicNetworkAccessState string + +const ( + // ServerPublicNetworkAccessStateDisabled ... + ServerPublicNetworkAccessStateDisabled ServerPublicNetworkAccessState = "Disabled" + // ServerPublicNetworkAccessStateEnabled ... + ServerPublicNetworkAccessStateEnabled ServerPublicNetworkAccessState = "Enabled" +) + +// PossibleServerPublicNetworkAccessStateValues returns an array of possible values for the ServerPublicNetworkAccessState const type. +func PossibleServerPublicNetworkAccessStateValues() []ServerPublicNetworkAccessState { + return []ServerPublicNetworkAccessState{ServerPublicNetworkAccessStateDisabled, ServerPublicNetworkAccessStateEnabled} +} + +// ServerState enumerates the values for server state. +type ServerState string + +const ( + // ServerStateDisabled ... + ServerStateDisabled ServerState = "Disabled" + // ServerStateDropping ... + ServerStateDropping ServerState = "Dropping" + // ServerStateReady ... + ServerStateReady ServerState = "Ready" + // ServerStateStarting ... + ServerStateStarting ServerState = "Starting" + // ServerStateStopped ... + ServerStateStopped ServerState = "Stopped" + // ServerStateStopping ... + ServerStateStopping ServerState = "Stopping" + // ServerStateUpdating ... + ServerStateUpdating ServerState = "Updating" +) + +// PossibleServerStateValues returns an array of possible values for the ServerState const type. +func PossibleServerStateValues() []ServerState { + return []ServerState{ServerStateDisabled, ServerStateDropping, ServerStateReady, ServerStateStarting, ServerStateStopped, ServerStateStopping, ServerStateUpdating} +} + +// ServerVersion enumerates the values for server version. +type ServerVersion string + +const ( + // ServerVersionOneOne ... + ServerVersionOneOne ServerVersion = "11" + // ServerVersionOneThree ... + ServerVersionOneThree ServerVersion = "13" + // ServerVersionOneTwo ... + ServerVersionOneTwo ServerVersion = "12" +) + +// PossibleServerVersionValues returns an array of possible values for the ServerVersion const type. +func PossibleServerVersionValues() []ServerVersion { + return []ServerVersion{ServerVersionOneOne, ServerVersionOneThree, ServerVersionOneTwo} +} + +// SkuTier enumerates the values for sku tier. +type SkuTier string + +const ( + // SkuTierBurstable ... + SkuTierBurstable SkuTier = "Burstable" + // SkuTierGeneralPurpose ... + SkuTierGeneralPurpose SkuTier = "GeneralPurpose" + // SkuTierMemoryOptimized ... + SkuTierMemoryOptimized SkuTier = "MemoryOptimized" +) + +// PossibleSkuTierValues returns an array of possible values for the SkuTier const type. +func PossibleSkuTierValues() []SkuTier { + return []SkuTier{SkuTierBurstable, SkuTierGeneralPurpose, SkuTierMemoryOptimized} +} diff --git a/services/postgresql/mgmt/2021-06-01/postgresqlflexibleservers/firewallrules.go b/services/postgresql/mgmt/2021-06-01/postgresqlflexibleservers/firewallrules.go new file mode 100644 index 000000000000..0e631a40aa53 --- /dev/null +++ b/services/postgresql/mgmt/2021-06-01/postgresqlflexibleservers/firewallrules.go @@ -0,0 +1,436 @@ +package postgresqlflexibleservers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// FirewallRulesClient is the the Microsoft Azure management API provides create, read, update, and delete +// functionality for Azure PostgreSQL resources including servers, databases, firewall rules, VNET rules, security +// alert policies, log files and configurations with new business model. +type FirewallRulesClient struct { + BaseClient +} + +// NewFirewallRulesClient creates an instance of the FirewallRulesClient client. +func NewFirewallRulesClient(subscriptionID string) FirewallRulesClient { + return NewFirewallRulesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewFirewallRulesClientWithBaseURI creates an instance of the FirewallRulesClient client using a custom endpoint. +// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewFirewallRulesClientWithBaseURI(baseURI string, subscriptionID string) FirewallRulesClient { + return FirewallRulesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates a new firewall rule or updates an existing firewall rule. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// serverName - the name of the server. +// firewallRuleName - the name of the server firewall rule. +// parameters - the required parameters for creating or updating a firewall rule. +func (client FirewallRulesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, firewallRuleName string, parameters FirewallRule) (result FirewallRulesCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/FirewallRulesClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.FirewallRuleProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.FirewallRuleProperties.StartIPAddress", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.FirewallRuleProperties.StartIPAddress", Name: validation.Pattern, Rule: `^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$`, Chain: nil}}}, + {Target: "parameters.FirewallRuleProperties.EndIPAddress", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.FirewallRuleProperties.EndIPAddress", Name: validation.Pattern, Rule: `^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$`, Chain: nil}}}, + }}}}}); err != nil { + return result, validation.NewError("postgresqlflexibleservers.FirewallRulesClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, firewallRuleName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.FirewallRulesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.FirewallRulesClient", "CreateOrUpdate", nil, "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client FirewallRulesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, firewallRuleName string, parameters FirewallRule) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "firewallRuleName": autorest.Encode("path", firewallRuleName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + parameters.SystemData = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/flexibleServers/{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) (future FirewallRulesCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client FirewallRulesClient) CreateOrUpdateResponder(resp *http.Response) (result FirewallRule, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a PostgreSQL server firewall rule. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// serverName - the name of the server. +// firewallRuleName - the name of the server firewall rule. +func (client FirewallRulesClient) Delete(ctx context.Context, resourceGroupName string, serverName string, firewallRuleName string) (result FirewallRulesDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/FirewallRulesClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("postgresqlflexibleservers.FirewallRulesClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, serverName, firewallRuleName) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.FirewallRulesClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.FirewallRulesClient", "Delete", nil, "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client FirewallRulesClient) DeletePreparer(ctx context.Context, resourceGroupName string, serverName string, firewallRuleName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "firewallRuleName": autorest.Encode("path", firewallRuleName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-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.DBForPostgreSql/flexibleServers/{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) (future FirewallRulesDeleteFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client FirewallRulesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get list all the firewall rules in a given server. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// serverName - the name of the server. +// firewallRuleName - the name of the server firewall rule. +func (client FirewallRulesClient) Get(ctx context.Context, resourceGroupName string, serverName string, firewallRuleName string) (result FirewallRule, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/FirewallRulesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("postgresqlflexibleservers.FirewallRulesClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, firewallRuleName) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.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, "postgresqlflexibleservers.FirewallRulesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.FirewallRulesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client FirewallRulesClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, firewallRuleName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "firewallRuleName": autorest.Encode("path", firewallRuleName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-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.DBForPostgreSql/flexibleServers/{serverName}/firewallRules/{firewallRuleName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client FirewallRulesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client FirewallRulesClient) GetResponder(resp *http.Response) (result FirewallRule, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer list all the firewall rules in a given PostgreSQL server. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// serverName - the name of the server. +func (client FirewallRulesClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result FirewallRuleListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/FirewallRulesClient.ListByServer") + defer func() { + sc := -1 + if result.frlr.Response.Response != nil { + sc = result.frlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("postgresqlflexibleservers.FirewallRulesClient", "ListByServer", err.Error()) + } + + result.fn = client.listByServerNextResults + req, err := client.ListByServerPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.FirewallRulesClient", "ListByServer", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServerSender(req) + if err != nil { + result.frlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.FirewallRulesClient", "ListByServer", resp, "Failure sending request") + return + } + + result.frlr, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.FirewallRulesClient", "ListByServer", resp, "Failure responding to request") + return + } + if result.frlr.hasNextLink() && result.frlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServerPreparer prepares the ListByServer request. +func (client FirewallRulesClient) ListByServerPreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-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.DBForPostgreSql/flexibleServers/{serverName}/firewallRules", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByServerSender sends the ListByServer request. The method will close the +// http.Response Body if it receives an error. +func (client FirewallRulesClient) ListByServerSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client FirewallRulesClient) ListByServerResponder(resp *http.Response) (result FirewallRuleListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByServerNextResults retrieves the next set of results, if any. +func (client FirewallRulesClient) listByServerNextResults(ctx context.Context, lastResults FirewallRuleListResult) (result FirewallRuleListResult, err error) { + req, err := lastResults.firewallRuleListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "postgresqlflexibleservers.FirewallRulesClient", "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, "postgresqlflexibleservers.FirewallRulesClient", "listByServerNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.FirewallRulesClient", "listByServerNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServerComplete enumerates all values, automatically crossing page boundaries as required. +func (client FirewallRulesClient) ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result FirewallRuleListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/FirewallRulesClient.ListByServer") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByServer(ctx, resourceGroupName, serverName) + return +} diff --git a/services/postgresql/mgmt/2021-06-01/postgresqlflexibleservers/getprivatednszonesuffix.go b/services/postgresql/mgmt/2021-06-01/postgresqlflexibleservers/getprivatednszonesuffix.go new file mode 100644 index 000000000000..0c0fe2ef390c --- /dev/null +++ b/services/postgresql/mgmt/2021-06-01/postgresqlflexibleservers/getprivatednszonesuffix.go @@ -0,0 +1,101 @@ +package postgresqlflexibleservers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// GetPrivateDNSZoneSuffixClient is the the Microsoft Azure management API provides create, read, update, and delete +// functionality for Azure PostgreSQL resources including servers, databases, firewall rules, VNET rules, security +// alert policies, log files and configurations with new business model. +type GetPrivateDNSZoneSuffixClient struct { + BaseClient +} + +// NewGetPrivateDNSZoneSuffixClient creates an instance of the GetPrivateDNSZoneSuffixClient client. +func NewGetPrivateDNSZoneSuffixClient(subscriptionID string) GetPrivateDNSZoneSuffixClient { + return NewGetPrivateDNSZoneSuffixClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewGetPrivateDNSZoneSuffixClientWithBaseURI creates an instance of the GetPrivateDNSZoneSuffixClient client using a +// custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, +// Azure stack). +func NewGetPrivateDNSZoneSuffixClientWithBaseURI(baseURI string, subscriptionID string) GetPrivateDNSZoneSuffixClient { + return GetPrivateDNSZoneSuffixClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Execute get private DNS zone suffix in the cloud +func (client GetPrivateDNSZoneSuffixClient) Execute(ctx context.Context) (result String, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GetPrivateDNSZoneSuffixClient.Execute") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ExecutePreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.GetPrivateDNSZoneSuffixClient", "Execute", nil, "Failure preparing request") + return + } + + resp, err := client.ExecuteSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.GetPrivateDNSZoneSuffixClient", "Execute", resp, "Failure sending request") + return + } + + result, err = client.ExecuteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.GetPrivateDNSZoneSuffixClient", "Execute", resp, "Failure responding to request") + return + } + + return +} + +// ExecutePreparer prepares the Execute request. +func (client GetPrivateDNSZoneSuffixClient) ExecutePreparer(ctx context.Context) (*http.Request, error) { + const APIVersion = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.DBForPostgreSql/getPrivateDnsZoneSuffix"), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ExecuteSender sends the Execute request. The method will close the +// http.Response Body if it receives an error. +func (client GetPrivateDNSZoneSuffixClient) ExecuteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ExecuteResponder handles the response to the Execute request. The method always +// closes the http.Response Body. +func (client GetPrivateDNSZoneSuffixClient) ExecuteResponder(resp *http.Response) (result String, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Value), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/postgresql/mgmt/2021-06-01/postgresqlflexibleservers/locationbasedcapabilities.go b/services/postgresql/mgmt/2021-06-01/postgresqlflexibleservers/locationbasedcapabilities.go new file mode 100644 index 000000000000..65d7191dcb73 --- /dev/null +++ b/services/postgresql/mgmt/2021-06-01/postgresqlflexibleservers/locationbasedcapabilities.go @@ -0,0 +1,157 @@ +package postgresqlflexibleservers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// LocationBasedCapabilitiesClient is the the Microsoft Azure management API provides create, read, update, and delete +// functionality for Azure PostgreSQL resources including servers, databases, firewall rules, VNET rules, security +// alert policies, log files and configurations with new business model. +type LocationBasedCapabilitiesClient struct { + BaseClient +} + +// NewLocationBasedCapabilitiesClient creates an instance of the LocationBasedCapabilitiesClient client. +func NewLocationBasedCapabilitiesClient(subscriptionID string) LocationBasedCapabilitiesClient { + return NewLocationBasedCapabilitiesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewLocationBasedCapabilitiesClientWithBaseURI creates an instance of the LocationBasedCapabilitiesClient client +// using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign +// clouds, Azure stack). +func NewLocationBasedCapabilitiesClientWithBaseURI(baseURI string, subscriptionID string) LocationBasedCapabilitiesClient { + return LocationBasedCapabilitiesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Execute get capabilities at specified location in a given subscription. +// Parameters: +// locationName - the name of the location. +func (client LocationBasedCapabilitiesClient) Execute(ctx context.Context, locationName string) (result CapabilitiesListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LocationBasedCapabilitiesClient.Execute") + defer func() { + sc := -1 + if result.clr.Response.Response != nil { + sc = result.clr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("postgresqlflexibleservers.LocationBasedCapabilitiesClient", "Execute", err.Error()) + } + + result.fn = client.executeNextResults + req, err := client.ExecutePreparer(ctx, locationName) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.LocationBasedCapabilitiesClient", "Execute", nil, "Failure preparing request") + return + } + + resp, err := client.ExecuteSender(req) + if err != nil { + result.clr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.LocationBasedCapabilitiesClient", "Execute", resp, "Failure sending request") + return + } + + result.clr, err = client.ExecuteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.LocationBasedCapabilitiesClient", "Execute", resp, "Failure responding to request") + return + } + if result.clr.hasNextLink() && result.clr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ExecutePreparer prepares the Execute request. +func (client LocationBasedCapabilitiesClient) ExecutePreparer(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 = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.DBForPostgreSql/locations/{locationName}/capabilities", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ExecuteSender sends the Execute request. The method will close the +// http.Response Body if it receives an error. +func (client LocationBasedCapabilitiesClient) ExecuteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ExecuteResponder handles the response to the Execute request. The method always +// closes the http.Response Body. +func (client LocationBasedCapabilitiesClient) ExecuteResponder(resp *http.Response) (result CapabilitiesListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// executeNextResults retrieves the next set of results, if any. +func (client LocationBasedCapabilitiesClient) executeNextResults(ctx context.Context, lastResults CapabilitiesListResult) (result CapabilitiesListResult, err error) { + req, err := lastResults.capabilitiesListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "postgresqlflexibleservers.LocationBasedCapabilitiesClient", "executeNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ExecuteSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "postgresqlflexibleservers.LocationBasedCapabilitiesClient", "executeNextResults", resp, "Failure sending next results request") + } + result, err = client.ExecuteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.LocationBasedCapabilitiesClient", "executeNextResults", resp, "Failure responding to next results request") + } + return +} + +// ExecuteComplete enumerates all values, automatically crossing page boundaries as required. +func (client LocationBasedCapabilitiesClient) ExecuteComplete(ctx context.Context, locationName string) (result CapabilitiesListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LocationBasedCapabilitiesClient.Execute") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.Execute(ctx, locationName) + return +} diff --git a/services/postgresql/mgmt/2021-06-01/postgresqlflexibleservers/models.go b/services/postgresql/mgmt/2021-06-01/postgresqlflexibleservers/models.go new file mode 100644 index 000000000000..e3ae89b26bbb --- /dev/null +++ b/services/postgresql/mgmt/2021-06-01/postgresqlflexibleservers/models.go @@ -0,0 +1,2533 @@ +package postgresqlflexibleservers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "encoding/json" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/date" + "github.com/Azure/go-autorest/autorest/to" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// The package's fully qualified name. +const fqdn = "github.com/Azure/azure-sdk-for-go/services/postgresql/mgmt/2021-06-01/postgresqlflexibleservers" + +// AzureEntityResource the resource model definition for an Azure Resource Manager resource with an etag. +type AzureEntityResource struct { + // Etag - READ-ONLY; Resource Etag. + Etag *string `json:"etag,omitempty"` + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for AzureEntityResource. +func (aer AzureEntityResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// Backup backup properties of a server +type Backup struct { + // BackupRetentionDays - Backup retention days for the server. + BackupRetentionDays *int32 `json:"backupRetentionDays,omitempty"` + // GeoRedundantBackup - A value indicating whether Geo-Redundant backup is enabled on the server. Possible values include: 'GeoRedundantBackupEnumEnabled', 'GeoRedundantBackupEnumDisabled' + GeoRedundantBackup GeoRedundantBackupEnum `json:"geoRedundantBackup,omitempty"` + // EarliestRestoreDate - READ-ONLY; The earliest restore point time (ISO8601 format) for server. + EarliestRestoreDate *date.Time `json:"earliestRestoreDate,omitempty"` +} + +// MarshalJSON is the custom marshaler for Backup. +func (b Backup) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if b.BackupRetentionDays != nil { + objectMap["backupRetentionDays"] = b.BackupRetentionDays + } + if b.GeoRedundantBackup != "" { + objectMap["geoRedundantBackup"] = b.GeoRedundantBackup + } + return json.Marshal(objectMap) +} + +// CapabilitiesListResult location capability +type CapabilitiesListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; A list of supported capabilities. + Value *[]CapabilityProperties `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for CapabilitiesListResult. +func (clr CapabilitiesListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// CapabilitiesListResultIterator provides access to a complete listing of CapabilityProperties values. +type CapabilitiesListResultIterator struct { + i int + page CapabilitiesListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *CapabilitiesListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CapabilitiesListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *CapabilitiesListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter CapabilitiesListResultIterator) 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 CapabilitiesListResultIterator) Response() CapabilitiesListResult { + 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 CapabilitiesListResultIterator) Value() CapabilityProperties { + if !iter.page.NotDone() { + return CapabilityProperties{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the CapabilitiesListResultIterator type. +func NewCapabilitiesListResultIterator(page CapabilitiesListResultPage) CapabilitiesListResultIterator { + return CapabilitiesListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (clr CapabilitiesListResult) IsEmpty() bool { + return clr.Value == nil || len(*clr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (clr CapabilitiesListResult) hasNextLink() bool { + return clr.NextLink != nil && len(*clr.NextLink) != 0 +} + +// capabilitiesListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (clr CapabilitiesListResult) capabilitiesListResultPreparer(ctx context.Context) (*http.Request, error) { + if !clr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(clr.NextLink))) +} + +// CapabilitiesListResultPage contains a page of CapabilityProperties values. +type CapabilitiesListResultPage struct { + fn func(context.Context, CapabilitiesListResult) (CapabilitiesListResult, error) + clr CapabilitiesListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *CapabilitiesListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CapabilitiesListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.clr) + if err != nil { + return err + } + page.clr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *CapabilitiesListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page CapabilitiesListResultPage) NotDone() bool { + return !page.clr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page CapabilitiesListResultPage) Response() CapabilitiesListResult { + return page.clr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page CapabilitiesListResultPage) Values() []CapabilityProperties { + if page.clr.IsEmpty() { + return nil + } + return *page.clr.Value +} + +// Creates a new instance of the CapabilitiesListResultPage type. +func NewCapabilitiesListResultPage(cur CapabilitiesListResult, getNextPage func(context.Context, CapabilitiesListResult) (CapabilitiesListResult, error)) CapabilitiesListResultPage { + return CapabilitiesListResultPage{ + fn: getNextPage, + clr: cur, + } +} + +// CapabilityProperties location capabilities. +type CapabilityProperties struct { + // Zone - READ-ONLY; zone name + Zone *string `json:"zone,omitempty"` + // GeoBackupSupported - READ-ONLY; A value indicating whether a new server in this region can have geo-backups to paired region. + GeoBackupSupported *bool `json:"geoBackupSupported,omitempty"` + // ZoneRedundantHaSupported - READ-ONLY; A value indicating whether a new server in this region can support multi zone HA. + ZoneRedundantHaSupported *bool `json:"zoneRedundantHaSupported,omitempty"` + // ZoneRedundantHaAndGeoBackupSupported - READ-ONLY; A value indicating whether a new server in this region can have geo-backups to paired region. + ZoneRedundantHaAndGeoBackupSupported *bool `json:"zoneRedundantHaAndGeoBackupSupported,omitempty"` + // SupportedFlexibleServerEditions - READ-ONLY + SupportedFlexibleServerEditions *[]FlexibleServerEditionCapability `json:"supportedFlexibleServerEditions,omitempty"` + // SupportedHyperscaleNodeEditions - READ-ONLY + SupportedHyperscaleNodeEditions *[]HyperscaleNodeEditionCapability `json:"supportedHyperscaleNodeEditions,omitempty"` + // Status - READ-ONLY; The status + Status *string `json:"status,omitempty"` +} + +// MarshalJSON is the custom marshaler for CapabilityProperties. +func (cp CapabilityProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// CloudError an error response from the Batch service. +type CloudError struct { + Error *ErrorResponse `json:"error,omitempty"` +} + +// Configuration represents a Configuration. +type Configuration struct { + autorest.Response `json:"-"` + // ConfigurationProperties - The properties of a configuration. + *ConfigurationProperties `json:"properties,omitempty"` + // SystemData - READ-ONLY; The system metadata relating to this resource. + SystemData *SystemData `json:"systemData,omitempty"` + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Configuration. +func (c Configuration) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if c.ConfigurationProperties != nil { + objectMap["properties"] = c.ConfigurationProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Configuration struct. +func (c *Configuration) UnmarshalJSON(body []byte) error { + 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 configurationProperties ConfigurationProperties + err = json.Unmarshal(*v, &configurationProperties) + if err != nil { + return err + } + c.ConfigurationProperties = &configurationProperties + } + case "systemData": + if v != nil { + var systemData SystemData + err = json.Unmarshal(*v, &systemData) + if err != nil { + return err + } + c.SystemData = &systemData + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + c.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + c.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + c.Type = &typeVar + } + } + } + + return nil +} + +// ConfigurationListResult a list of server configurations. +type ConfigurationListResult struct { + autorest.Response `json:"-"` + // Value - The list of server configurations. + Value *[]Configuration `json:"value,omitempty"` + // NextLink - The link used to get the next page of operations. + NextLink *string `json:"nextLink,omitempty"` +} + +// ConfigurationListResultIterator provides access to a complete listing of Configuration values. +type ConfigurationListResultIterator struct { + i int + page ConfigurationListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *ConfigurationListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConfigurationListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ConfigurationListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ConfigurationListResultIterator) 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 ConfigurationListResultIterator) Response() ConfigurationListResult { + 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 ConfigurationListResultIterator) Value() Configuration { + if !iter.page.NotDone() { + return Configuration{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ConfigurationListResultIterator type. +func NewConfigurationListResultIterator(page ConfigurationListResultPage) ConfigurationListResultIterator { + return ConfigurationListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (clr ConfigurationListResult) IsEmpty() bool { + return clr.Value == nil || len(*clr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (clr ConfigurationListResult) hasNextLink() bool { + return clr.NextLink != nil && len(*clr.NextLink) != 0 +} + +// configurationListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (clr ConfigurationListResult) configurationListResultPreparer(ctx context.Context) (*http.Request, error) { + if !clr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(clr.NextLink))) +} + +// ConfigurationListResultPage contains a page of Configuration values. +type ConfigurationListResultPage struct { + fn func(context.Context, ConfigurationListResult) (ConfigurationListResult, error) + clr ConfigurationListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *ConfigurationListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConfigurationListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.clr) + if err != nil { + return err + } + page.clr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *ConfigurationListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ConfigurationListResultPage) NotDone() bool { + return !page.clr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ConfigurationListResultPage) Response() ConfigurationListResult { + return page.clr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ConfigurationListResultPage) Values() []Configuration { + if page.clr.IsEmpty() { + return nil + } + return *page.clr.Value +} + +// Creates a new instance of the ConfigurationListResultPage type. +func NewConfigurationListResultPage(cur ConfigurationListResult, getNextPage func(context.Context, ConfigurationListResult) (ConfigurationListResult, error)) ConfigurationListResultPage { + return ConfigurationListResultPage{ + fn: getNextPage, + clr: cur, + } +} + +// ConfigurationProperties the properties of a configuration. +type ConfigurationProperties struct { + // Value - Value of the configuration. + Value *string `json:"value,omitempty"` + // Description - READ-ONLY; Description of the configuration. + Description *string `json:"description,omitempty"` + // DefaultValue - READ-ONLY; Default value of the configuration. + DefaultValue *string `json:"defaultValue,omitempty"` + // DataType - READ-ONLY; Data type of the configuration. Possible values include: 'ConfigurationDataTypeBoolean', 'ConfigurationDataTypeNumeric', 'ConfigurationDataTypeInteger', 'ConfigurationDataTypeEnumeration' + DataType ConfigurationDataType `json:"dataType,omitempty"` + // AllowedValues - READ-ONLY; Allowed values of the configuration. + AllowedValues *string `json:"allowedValues,omitempty"` + // Source - Source of the configuration. + Source *string `json:"source,omitempty"` +} + +// MarshalJSON is the custom marshaler for ConfigurationProperties. +func (cp ConfigurationProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if cp.Value != nil { + objectMap["value"] = cp.Value + } + if cp.Source != nil { + objectMap["source"] = cp.Source + } + return json.Marshal(objectMap) +} + +// ConfigurationsPutFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ConfigurationsPutFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ConfigurationsClient) (Configuration, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ConfigurationsPutFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ConfigurationsPutFuture.Result. +func (future *ConfigurationsPutFuture) result(client ConfigurationsClient) (c Configuration, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ConfigurationsPutFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + c.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("postgresqlflexibleservers.ConfigurationsPutFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if c.Response.Response, err = future.GetResult(sender); err == nil && c.Response.Response.StatusCode != http.StatusNoContent { + c, err = client.PutResponder(c.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ConfigurationsPutFuture", "Result", c.Response.Response, "Failure responding to request") + } + } + return +} + +// ConfigurationsUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ConfigurationsUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ConfigurationsClient) (Configuration, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ConfigurationsUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ConfigurationsUpdateFuture.Result. +func (future *ConfigurationsUpdateFuture) result(client ConfigurationsClient) (c Configuration, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ConfigurationsUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + c.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("postgresqlflexibleservers.ConfigurationsUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if c.Response.Response, err = future.GetResult(sender); err == nil && c.Response.Response.StatusCode != http.StatusNoContent { + c, err = client.UpdateResponder(c.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ConfigurationsUpdateFuture", "Result", c.Response.Response, "Failure responding to request") + } + } + return +} + +// Database represents a Database. +type Database struct { + autorest.Response `json:"-"` + // DatabaseProperties - The properties of a database. + *DatabaseProperties `json:"properties,omitempty"` + // SystemData - READ-ONLY; The system metadata relating to this resource. + SystemData *SystemData `json:"systemData,omitempty"` + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Database. +func (d Database) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if d.DatabaseProperties != nil { + objectMap["properties"] = d.DatabaseProperties + } + 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 "properties": + if v != nil { + var databaseProperties DatabaseProperties + err = json.Unmarshal(*v, &databaseProperties) + if err != nil { + return err + } + d.DatabaseProperties = &databaseProperties + } + case "systemData": + if v != nil { + var systemData SystemData + err = json.Unmarshal(*v, &systemData) + if err != nil { + return err + } + d.SystemData = &systemData + } + 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 - The list of databases housed in a server + Value *[]Database `json:"value,omitempty"` + // NextLink - The link used to get the next page of databases. + NextLink *string `json:"nextLink,omitempty"` +} + +// DatabaseListResultIterator provides access to a complete listing of Database values. +type DatabaseListResultIterator struct { + i int + page DatabaseListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *DatabaseListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *DatabaseListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter DatabaseListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter DatabaseListResultIterator) Response() DatabaseListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter DatabaseListResultIterator) Value() Database { + if !iter.page.NotDone() { + return Database{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the DatabaseListResultIterator type. +func NewDatabaseListResultIterator(page DatabaseListResultPage) DatabaseListResultIterator { + return DatabaseListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (dlr DatabaseListResult) IsEmpty() bool { + return dlr.Value == nil || len(*dlr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (dlr DatabaseListResult) hasNextLink() bool { + return dlr.NextLink != nil && len(*dlr.NextLink) != 0 +} + +// databaseListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (dlr DatabaseListResult) databaseListResultPreparer(ctx context.Context) (*http.Request, error) { + if !dlr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(dlr.NextLink))) +} + +// DatabaseListResultPage contains a page of Database values. +type DatabaseListResultPage struct { + fn func(context.Context, DatabaseListResult) (DatabaseListResult, error) + dlr DatabaseListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *DatabaseListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.dlr) + if err != nil { + return err + } + page.dlr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *DatabaseListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page DatabaseListResultPage) NotDone() bool { + return !page.dlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page DatabaseListResultPage) Response() DatabaseListResult { + return page.dlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page DatabaseListResultPage) Values() []Database { + if page.dlr.IsEmpty() { + return nil + } + return *page.dlr.Value +} + +// Creates a new instance of the DatabaseListResultPage type. +func NewDatabaseListResultPage(cur DatabaseListResult, getNextPage func(context.Context, DatabaseListResult) (DatabaseListResult, error)) DatabaseListResultPage { + return DatabaseListResultPage{ + fn: getNextPage, + dlr: cur, + } +} + +// DatabaseProperties the properties of a database. +type DatabaseProperties struct { + // Charset - The charset of the database. + Charset *string `json:"charset,omitempty"` + // Collation - The collation of the database. + Collation *string `json:"collation,omitempty"` +} + +// DatabasesCreateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type DatabasesCreateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(DatabasesClient) (Database, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *DatabasesCreateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for DatabasesCreateFuture.Result. +func (future *DatabasesCreateFuture) result(client DatabasesClient) (d Database, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.DatabasesCreateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + d.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("postgresqlflexibleservers.DatabasesCreateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if d.Response.Response, err = future.GetResult(sender); err == nil && d.Response.Response.StatusCode != http.StatusNoContent { + d, err = client.CreateResponder(d.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.DatabasesCreateFuture", "Result", d.Response.Response, "Failure responding to request") + } + } + return +} + +// DatabasesDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type DatabasesDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(DatabasesClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *DatabasesDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for DatabasesDeleteFuture.Result. +func (future *DatabasesDeleteFuture) result(client DatabasesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.DatabasesDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("postgresqlflexibleservers.DatabasesDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// DelegatedSubnetUsage delegated subnet usage data. +type DelegatedSubnetUsage struct { + // SubnetName - READ-ONLY; name of the subnet + SubnetName *string `json:"subnetName,omitempty"` + // Usage - READ-ONLY; Number of used delegated subnets + Usage *int64 `json:"usage,omitempty"` +} + +// MarshalJSON is the custom marshaler for DelegatedSubnetUsage. +func (dsu DelegatedSubnetUsage) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ErrorAdditionalInfo the resource management error additional info. +type ErrorAdditionalInfo struct { + // Type - READ-ONLY; The additional info type. + Type *string `json:"type,omitempty"` + // Info - READ-ONLY; The additional info. + Info interface{} `json:"info,omitempty"` +} + +// MarshalJSON is the custom marshaler for ErrorAdditionalInfo. +func (eai ErrorAdditionalInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ErrorResponse common error response for all Azure Resource Manager APIs to return error details for +// failed operations. (This also follows the OData error response format.) +type ErrorResponse struct { + // Code - READ-ONLY; The error code. + Code *string `json:"code,omitempty"` + // Message - READ-ONLY; The error message. + Message *string `json:"message,omitempty"` + // Target - READ-ONLY; The error target. + Target *string `json:"target,omitempty"` + // Details - READ-ONLY; The error details. + Details *[]ErrorResponse `json:"details,omitempty"` + // AdditionalInfo - READ-ONLY; The error additional info. + AdditionalInfo *[]ErrorAdditionalInfo `json:"additionalInfo,omitempty"` +} + +// MarshalJSON is the custom marshaler for ErrorResponse. +func (er ErrorResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// FirewallRule represents a server firewall rule. +type FirewallRule struct { + autorest.Response `json:"-"` + // FirewallRuleProperties - The properties of a firewall rule. + *FirewallRuleProperties `json:"properties,omitempty"` + // SystemData - READ-ONLY; The system metadata relating to this resource. + SystemData *SystemData `json:"systemData,omitempty"` + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for FirewallRule. +func (fr FirewallRule) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if fr.FirewallRuleProperties != nil { + objectMap["properties"] = fr.FirewallRuleProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for FirewallRule struct. +func (fr *FirewallRule) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var firewallRuleProperties FirewallRuleProperties + err = json.Unmarshal(*v, &firewallRuleProperties) + if err != nil { + return err + } + fr.FirewallRuleProperties = &firewallRuleProperties + } + case "systemData": + if v != nil { + var systemData SystemData + err = json.Unmarshal(*v, &systemData) + if err != nil { + return err + } + fr.SystemData = &systemData + } + 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 a list of firewall rules. +type FirewallRuleListResult struct { + autorest.Response `json:"-"` + // Value - The list of firewall rules in a server. + Value *[]FirewallRule `json:"value,omitempty"` + // NextLink - The link used to get the next page of operations. + NextLink *string `json:"nextLink,omitempty"` +} + +// FirewallRuleListResultIterator provides access to a complete listing of FirewallRule values. +type FirewallRuleListResultIterator struct { + i int + page FirewallRuleListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *FirewallRuleListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/FirewallRuleListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *FirewallRuleListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter FirewallRuleListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter FirewallRuleListResultIterator) Response() FirewallRuleListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter FirewallRuleListResultIterator) Value() FirewallRule { + if !iter.page.NotDone() { + return FirewallRule{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the FirewallRuleListResultIterator type. +func NewFirewallRuleListResultIterator(page FirewallRuleListResultPage) FirewallRuleListResultIterator { + return FirewallRuleListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (frlr FirewallRuleListResult) IsEmpty() bool { + return frlr.Value == nil || len(*frlr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (frlr FirewallRuleListResult) hasNextLink() bool { + return frlr.NextLink != nil && len(*frlr.NextLink) != 0 +} + +// firewallRuleListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (frlr FirewallRuleListResult) firewallRuleListResultPreparer(ctx context.Context) (*http.Request, error) { + if !frlr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(frlr.NextLink))) +} + +// FirewallRuleListResultPage contains a page of FirewallRule values. +type FirewallRuleListResultPage struct { + fn func(context.Context, FirewallRuleListResult) (FirewallRuleListResult, error) + frlr FirewallRuleListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *FirewallRuleListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/FirewallRuleListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.frlr) + if err != nil { + return err + } + page.frlr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *FirewallRuleListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page FirewallRuleListResultPage) NotDone() bool { + return !page.frlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page FirewallRuleListResultPage) Response() FirewallRuleListResult { + return page.frlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page FirewallRuleListResultPage) Values() []FirewallRule { + if page.frlr.IsEmpty() { + return nil + } + return *page.frlr.Value +} + +// Creates a new instance of the FirewallRuleListResultPage type. +func NewFirewallRuleListResultPage(cur FirewallRuleListResult, getNextPage func(context.Context, FirewallRuleListResult) (FirewallRuleListResult, error)) FirewallRuleListResultPage { + return FirewallRuleListResultPage{ + fn: getNextPage, + frlr: cur, + } +} + +// FirewallRuleProperties the properties of a server firewall rule. +type FirewallRuleProperties struct { + // StartIPAddress - The start IP address of the server firewall rule. Must be IPv4 format. + StartIPAddress *string `json:"startIpAddress,omitempty"` + // EndIPAddress - The end IP address of the server firewall rule. Must be IPv4 format. + EndIPAddress *string `json:"endIpAddress,omitempty"` +} + +// FirewallRulesCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type FirewallRulesCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(FirewallRulesClient) (FirewallRule, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *FirewallRulesCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for FirewallRulesCreateOrUpdateFuture.Result. +func (future *FirewallRulesCreateOrUpdateFuture) result(client FirewallRulesClient) (fr FirewallRule, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.FirewallRulesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + fr.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("postgresqlflexibleservers.FirewallRulesCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if fr.Response.Response, err = future.GetResult(sender); err == nil && fr.Response.Response.StatusCode != http.StatusNoContent { + fr, err = client.CreateOrUpdateResponder(fr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.FirewallRulesCreateOrUpdateFuture", "Result", fr.Response.Response, "Failure responding to request") + } + } + return +} + +// FirewallRulesDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type FirewallRulesDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(FirewallRulesClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *FirewallRulesDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for FirewallRulesDeleteFuture.Result. +func (future *FirewallRulesDeleteFuture) result(client FirewallRulesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.FirewallRulesDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("postgresqlflexibleservers.FirewallRulesDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// FlexibleServerEditionCapability flexible server edition capabilities. +type FlexibleServerEditionCapability struct { + // Name - READ-ONLY; Server edition name + Name *string `json:"name,omitempty"` + // SupportedStorageEditions - READ-ONLY; The list of editions supported by this server edition. + SupportedStorageEditions *[]StorageEditionCapability `json:"supportedStorageEditions,omitempty"` + // SupportedServerVersions - READ-ONLY; The list of server versions supported by this server edition. + SupportedServerVersions *[]ServerVersionCapability `json:"supportedServerVersions,omitempty"` + // Status - READ-ONLY; The status + Status *string `json:"status,omitempty"` +} + +// MarshalJSON is the custom marshaler for FlexibleServerEditionCapability. +func (fsec FlexibleServerEditionCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// HighAvailability high availability properties of a server +type HighAvailability struct { + // Mode - The HA mode for the server. Possible values include: 'HighAvailabilityModeDisabled', 'HighAvailabilityModeZoneRedundant' + Mode HighAvailabilityMode `json:"mode,omitempty"` + // State - READ-ONLY; A state of a HA server that is visible to user. Possible values include: 'ServerHAStateNotEnabled', 'ServerHAStateCreatingStandby', 'ServerHAStateReplicatingData', 'ServerHAStateFailingOver', 'ServerHAStateHealthy', 'ServerHAStateRemovingStandby' + State ServerHAState `json:"state,omitempty"` + // StandbyAvailabilityZone - availability zone information of the standby. + StandbyAvailabilityZone *string `json:"standbyAvailabilityZone,omitempty"` +} + +// MarshalJSON is the custom marshaler for HighAvailability. +func (ha HighAvailability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ha.Mode != "" { + objectMap["mode"] = ha.Mode + } + if ha.StandbyAvailabilityZone != nil { + objectMap["standbyAvailabilityZone"] = ha.StandbyAvailabilityZone + } + return json.Marshal(objectMap) +} + +// HyperscaleNodeEditionCapability hyperscale node edition capabilities. +type HyperscaleNodeEditionCapability struct { + // Name - READ-ONLY; Server edition name + Name *string `json:"name,omitempty"` + // SupportedStorageEditions - READ-ONLY; The list of editions supported by this server edition. + SupportedStorageEditions *[]StorageEditionCapability `json:"supportedStorageEditions,omitempty"` + // SupportedServerVersions - READ-ONLY; The list of server versions supported by this server edition. + SupportedServerVersions *[]ServerVersionCapability `json:"supportedServerVersions,omitempty"` + // SupportedNodeTypes - READ-ONLY; The list of Node Types supported by this server edition. + SupportedNodeTypes *[]NodeTypeCapability `json:"supportedNodeTypes,omitempty"` + // Status - READ-ONLY; The status + Status *string `json:"status,omitempty"` +} + +// MarshalJSON is the custom marshaler for HyperscaleNodeEditionCapability. +func (hnec HyperscaleNodeEditionCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// Identity identity for the resource. +type Identity struct { + // PrincipalID - READ-ONLY; The principal ID of resource identity. + PrincipalID *string `json:"principalId,omitempty"` + // TenantID - READ-ONLY; The tenant ID of resource. + TenantID *string `json:"tenantId,omitempty"` + // Type - The identity type. Possible values include: 'ResourceIdentityTypeSystemAssigned' + Type ResourceIdentityType `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Identity. +func (i Identity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if i.Type != "" { + objectMap["type"] = i.Type + } + return json.Marshal(objectMap) +} + +// MaintenanceWindow maintenance window properties of a server. +type MaintenanceWindow struct { + // CustomWindow - indicates whether custom window is enabled or disabled + CustomWindow *string `json:"customWindow,omitempty"` + // StartHour - start hour for maintenance window + StartHour *int32 `json:"startHour,omitempty"` + // StartMinute - start minute for maintenance window + StartMinute *int32 `json:"startMinute,omitempty"` + // DayOfWeek - day of week for maintenance window + DayOfWeek *int32 `json:"dayOfWeek,omitempty"` +} + +// NameAvailability represents a resource name availability. +type NameAvailability struct { + autorest.Response `json:"-"` + // Message - Error Message. + Message *string `json:"message,omitempty"` + // NameAvailable - Indicates whether the resource name is available. + NameAvailable *bool `json:"nameAvailable,omitempty"` + // Name - name of the PostgreSQL server. + Name *string `json:"name,omitempty"` + // Type - type of the server + Type *string `json:"type,omitempty"` +} + +// NameAvailabilityRequest request from client to check resource name availability. +type NameAvailabilityRequest struct { + // Name - Resource name to verify. + Name *string `json:"name,omitempty"` + // Type - Resource type used for verification. + Type *string `json:"type,omitempty"` +} + +// Network network properties of a server +type Network struct { + // PublicNetworkAccess - READ-ONLY; public network access is enabled or not. Possible values include: 'ServerPublicNetworkAccessStateEnabled', 'ServerPublicNetworkAccessStateDisabled' + PublicNetworkAccess ServerPublicNetworkAccessState `json:"publicNetworkAccess,omitempty"` + // DelegatedSubnetResourceID - delegated subnet arm resource id. + DelegatedSubnetResourceID *string `json:"delegatedSubnetResourceId,omitempty"` + // PrivateDNSZoneArmResourceID - private dns zone arm resource id. + PrivateDNSZoneArmResourceID *string `json:"privateDnsZoneArmResourceId,omitempty"` +} + +// MarshalJSON is the custom marshaler for Network. +func (n Network) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if n.DelegatedSubnetResourceID != nil { + objectMap["delegatedSubnetResourceId"] = n.DelegatedSubnetResourceID + } + if n.PrivateDNSZoneArmResourceID != nil { + objectMap["privateDnsZoneArmResourceId"] = n.PrivateDNSZoneArmResourceID + } + return json.Marshal(objectMap) +} + +// NodeTypeCapability node type capability +type NodeTypeCapability struct { + // Name - READ-ONLY; note type name + Name *string `json:"name,omitempty"` + // NodeType - READ-ONLY; note type + NodeType *string `json:"nodeType,omitempty"` + // Status - READ-ONLY; The status + Status *string `json:"status,omitempty"` +} + +// MarshalJSON is the custom marshaler for NodeTypeCapability. +func (ntc NodeTypeCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// Operation REST API operation definition. +type Operation struct { + // Name - READ-ONLY; The name of the operation being performed on this particular object. + Name *string `json:"name,omitempty"` + // Display - READ-ONLY; The localized display information for this particular operation or action. + Display *OperationDisplay `json:"display,omitempty"` + // IsDataAction - Indicates whether the operation is a data action + IsDataAction *bool `json:"isDataAction,omitempty"` + // Origin - READ-ONLY; The intended executor of the operation. Possible values include: 'OperationOriginNotSpecified', 'OperationOriginUser', 'OperationOriginSystem' + Origin OperationOrigin `json:"origin,omitempty"` + // Properties - READ-ONLY; Additional descriptions for the operation. + Properties map[string]interface{} `json:"properties"` +} + +// MarshalJSON is the custom marshaler for Operation. +func (o Operation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if o.IsDataAction != nil { + objectMap["isDataAction"] = o.IsDataAction + } + return json.Marshal(objectMap) +} + +// OperationDisplay display metadata associated with the operation. +type OperationDisplay struct { + // Provider - READ-ONLY; Operation resource provider name. + Provider *string `json:"provider,omitempty"` + // Resource - READ-ONLY; Resource on which the operation is performed. + Resource *string `json:"resource,omitempty"` + // Operation - READ-ONLY; Localized friendly name for the operation. + Operation *string `json:"operation,omitempty"` + // Description - READ-ONLY; Operation description. + Description *string `json:"description,omitempty"` +} + +// MarshalJSON is the custom marshaler for OperationDisplay. +func (od OperationDisplay) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// OperationListResult a list of resource provider operations. +type OperationListResult struct { + autorest.Response `json:"-"` + // Value - Collection of available operation details + Value *[]Operation `json:"value,omitempty"` + // NextLink - URL client should use to fetch the next page (per server side paging). + // It's null for now, added for future use. + NextLink *string `json:"nextLink,omitempty"` +} + +// Plan plan for the resource. +type Plan struct { + // Name - A user defined name of the 3rd Party Artifact that is being procured. + Name *string `json:"name,omitempty"` + // Publisher - The publisher of the 3rd Party Artifact that is being bought. E.g. NewRelic + Publisher *string `json:"publisher,omitempty"` + // Product - The 3rd Party artifact that is being procured. E.g. NewRelic. Product maps to the OfferID specified for the artifact at the time of Data Market onboarding. + Product *string `json:"product,omitempty"` + // PromotionCode - A publisher provided promotion code as provisioned in Data Market for the said product/artifact. + PromotionCode *string `json:"promotionCode,omitempty"` + // Version - The version of the desired product/artifact. + Version *string `json:"version,omitempty"` +} + +// ProxyResource the resource model definition for a Azure Resource Manager proxy resource. It will not +// have tags and a location +type ProxyResource struct { + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ProxyResource. +func (pr ProxyResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// Resource common fields that are returned in the response for all Azure Resource Manager resources +type Resource struct { + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Resource. +func (r Resource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ResourceModelWithAllowedPropertySet the resource model definition containing the full set of allowed +// properties for a resource. Except properties bag, there cannot be a top level property outside of this +// set. +type ResourceModelWithAllowedPropertySet struct { + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty"` + // Location - The geo-location where the resource lives + Location *string `json:"location,omitempty"` + // ManagedBy - The fully qualified resource ID of the resource that manages this resource. Indicates if this resource is managed by another Azure resource. If this is present, complete mode deployment will not delete the resource if it is removed from the template since it is managed by another resource. + ManagedBy *string `json:"managedBy,omitempty"` + // Kind - Metadata used by portal/tooling/etc to render different UX experiences for resources of the same type; e.g. ApiApps are a kind of Microsoft.Web/sites type. If supported, the resource provider must validate and persist this value. + Kind *string `json:"kind,omitempty"` + // Etag - READ-ONLY; The etag field is *not* required. If it is provided in the response body, it must also be provided as a header per the normal etag convention. Entity tags are used for comparing two or more entities from the same requested resource. HTTP/1.1 uses entity tags in the etag (section 14.19), If-Match (section 14.24), If-None-Match (section 14.26), and If-Range (section 14.27) header fields. + Etag *string `json:"etag,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + Identity *ResourceModelWithAllowedPropertySetIdentity `json:"identity,omitempty"` + Sku *ResourceModelWithAllowedPropertySetSku `json:"sku,omitempty"` + Plan *ResourceModelWithAllowedPropertySetPlan `json:"plan,omitempty"` +} + +// MarshalJSON is the custom marshaler for ResourceModelWithAllowedPropertySet. +func (rmwaps ResourceModelWithAllowedPropertySet) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rmwaps.Location != nil { + objectMap["location"] = rmwaps.Location + } + if rmwaps.ManagedBy != nil { + objectMap["managedBy"] = rmwaps.ManagedBy + } + if rmwaps.Kind != nil { + objectMap["kind"] = rmwaps.Kind + } + if rmwaps.Tags != nil { + objectMap["tags"] = rmwaps.Tags + } + if rmwaps.Identity != nil { + objectMap["identity"] = rmwaps.Identity + } + if rmwaps.Sku != nil { + objectMap["sku"] = rmwaps.Sku + } + if rmwaps.Plan != nil { + objectMap["plan"] = rmwaps.Plan + } + return json.Marshal(objectMap) +} + +// ResourceModelWithAllowedPropertySetIdentity ... +type ResourceModelWithAllowedPropertySetIdentity struct { + // PrincipalID - READ-ONLY; The principal ID of resource identity. + PrincipalID *string `json:"principalId,omitempty"` + // TenantID - READ-ONLY; The tenant ID of resource. + TenantID *string `json:"tenantId,omitempty"` + // Type - The identity type. Possible values include: 'ResourceIdentityTypeSystemAssigned' + Type ResourceIdentityType `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ResourceModelWithAllowedPropertySetIdentity. +func (rmwaps ResourceModelWithAllowedPropertySetIdentity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rmwaps.Type != "" { + objectMap["type"] = rmwaps.Type + } + return json.Marshal(objectMap) +} + +// ResourceModelWithAllowedPropertySetPlan ... +type ResourceModelWithAllowedPropertySetPlan struct { + // Name - A user defined name of the 3rd Party Artifact that is being procured. + Name *string `json:"name,omitempty"` + // Publisher - The publisher of the 3rd Party Artifact that is being bought. E.g. NewRelic + Publisher *string `json:"publisher,omitempty"` + // Product - The 3rd Party artifact that is being procured. E.g. NewRelic. Product maps to the OfferID specified for the artifact at the time of Data Market onboarding. + Product *string `json:"product,omitempty"` + // PromotionCode - A publisher provided promotion code as provisioned in Data Market for the said product/artifact. + PromotionCode *string `json:"promotionCode,omitempty"` + // Version - The version of the desired product/artifact. + Version *string `json:"version,omitempty"` +} + +// ResourceModelWithAllowedPropertySetSku ... +type ResourceModelWithAllowedPropertySetSku struct { + // Name - The name of the sku, typically, tier + family + cores, e.g. Standard_D4s_v3. + Name *string `json:"name,omitempty"` + // Tier - The tier of the particular SKU, e.g. Burstable. Possible values include: 'SkuTierBurstable', 'SkuTierGeneralPurpose', 'SkuTierMemoryOptimized' + Tier SkuTier `json:"tier,omitempty"` +} + +// RestartParameter represents server restart parameters. +type RestartParameter struct { + // RestartWithFailover - Indicates whether to restart the server with failover. + RestartWithFailover *bool `json:"restartWithFailover,omitempty"` + // FailoverMode - Failover mode. + FailoverMode *string `json:"failoverMode,omitempty"` +} + +// Server represents a server. +type Server struct { + autorest.Response `json:"-"` + // Identity - The Azure Active Directory identity of the server. + Identity *Identity `json:"identity,omitempty"` + // Sku - The SKU (pricing tier) of the server. + Sku *Sku `json:"sku,omitempty"` + // ServerProperties - Properties of the server. + *ServerProperties `json:"properties,omitempty"` + // SystemData - READ-ONLY; The system metadata relating to this resource. + SystemData *SystemData `json:"systemData,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // Location - The geo-location where the resource lives + Location *string `json:"location,omitempty"` + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + 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.Sku != nil { + objectMap["sku"] = s.Sku + } + if s.ServerProperties != nil { + objectMap["properties"] = s.ServerProperties + } + if s.Tags != nil { + objectMap["tags"] = s.Tags + } + if s.Location != nil { + objectMap["location"] = s.Location + } + 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 Identity + err = json.Unmarshal(*v, &identity) + if err != nil { + return err + } + s.Identity = &identity + } + case "sku": + if v != nil { + var sku Sku + err = json.Unmarshal(*v, &sku) + if err != nil { + return err + } + s.Sku = &sku + } + case "properties": + if v != nil { + var serverProperties ServerProperties + err = json.Unmarshal(*v, &serverProperties) + if err != nil { + return err + } + s.ServerProperties = &serverProperties + } + case "systemData": + if v != nil { + var systemData SystemData + err = json.Unmarshal(*v, &systemData) + if err != nil { + return err + } + s.SystemData = &systemData + } + 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 +} + +// ServerForUpdate represents a server to be updated. +type ServerForUpdate struct { + // Location - The location the resource resides in. + Location *string `json:"location,omitempty"` + // Sku - The SKU (pricing tier) of the server. + Sku *Sku `json:"sku,omitempty"` + // ServerPropertiesForUpdate - Properties of the server. + *ServerPropertiesForUpdate `json:"properties,omitempty"` + // Tags - Application-specific metadata in the form of key-value pairs. + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for ServerForUpdate. +func (sfu ServerForUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sfu.Location != nil { + objectMap["location"] = sfu.Location + } + if sfu.Sku != nil { + objectMap["sku"] = sfu.Sku + } + if sfu.ServerPropertiesForUpdate != nil { + objectMap["properties"] = sfu.ServerPropertiesForUpdate + } + if sfu.Tags != nil { + objectMap["tags"] = sfu.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ServerForUpdate struct. +func (sfu *ServerForUpdate) UnmarshalJSON(body []byte) error { + 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 + } + sfu.Location = &location + } + case "sku": + if v != nil { + var sku Sku + err = json.Unmarshal(*v, &sku) + if err != nil { + return err + } + sfu.Sku = &sku + } + case "properties": + if v != nil { + var serverPropertiesForUpdate ServerPropertiesForUpdate + err = json.Unmarshal(*v, &serverPropertiesForUpdate) + if err != nil { + return err + } + sfu.ServerPropertiesForUpdate = &serverPropertiesForUpdate + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + sfu.Tags = tags + } + } + } + + return nil +} + +// ServerListResult a list of servers. +type ServerListResult struct { + autorest.Response `json:"-"` + // Value - The list of flexible servers + Value *[]Server `json:"value,omitempty"` + // NextLink - The link used to get the next page of operations. + NextLink *string `json:"nextLink,omitempty"` +} + +// ServerListResultIterator provides access to a complete listing of Server values. +type ServerListResultIterator struct { + i int + page ServerListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *ServerListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ServerListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ServerListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter ServerListResultIterator) Response() ServerListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter ServerListResultIterator) Value() Server { + if !iter.page.NotDone() { + return Server{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ServerListResultIterator type. +func NewServerListResultIterator(page ServerListResultPage) ServerListResultIterator { + return ServerListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (slr ServerListResult) IsEmpty() bool { + return slr.Value == nil || len(*slr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (slr ServerListResult) hasNextLink() bool { + return slr.NextLink != nil && len(*slr.NextLink) != 0 +} + +// serverListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (slr ServerListResult) serverListResultPreparer(ctx context.Context) (*http.Request, error) { + if !slr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(slr.NextLink))) +} + +// ServerListResultPage contains a page of Server values. +type ServerListResultPage struct { + fn func(context.Context, ServerListResult) (ServerListResult, error) + slr ServerListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *ServerListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.slr) + if err != nil { + return err + } + page.slr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *ServerListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ServerListResultPage) NotDone() bool { + return !page.slr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ServerListResultPage) Response() ServerListResult { + return page.slr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ServerListResultPage) Values() []Server { + if page.slr.IsEmpty() { + return nil + } + return *page.slr.Value +} + +// Creates a new instance of the ServerListResultPage type. +func NewServerListResultPage(cur ServerListResult, getNextPage func(context.Context, ServerListResult) (ServerListResult, error)) ServerListResultPage { + return ServerListResultPage{ + fn: getNextPage, + slr: cur, + } +} + +// ServerProperties the properties of a server. +type ServerProperties struct { + // AdministratorLogin - The administrator's login name of a server. Can only be specified when the server is being created (and is required for creation). + AdministratorLogin *string `json:"administratorLogin,omitempty"` + // AdministratorLoginPassword - The administrator login password (required for server creation). + AdministratorLoginPassword *string `json:"administratorLoginPassword,omitempty"` + // Version - PostgreSQL Server version. Possible values include: 'ServerVersionOneThree', 'ServerVersionOneTwo', 'ServerVersionOneOne' + Version ServerVersion `json:"version,omitempty"` + // MinorVersion - READ-ONLY; The minor version of the server. + MinorVersion *string `json:"minorVersion,omitempty"` + // State - READ-ONLY; A state of a server that is visible to user. Possible values include: 'ServerStateReady', 'ServerStateDropping', 'ServerStateDisabled', 'ServerStateStarting', 'ServerStateStopping', 'ServerStateStopped', 'ServerStateUpdating' + State ServerState `json:"state,omitempty"` + // FullyQualifiedDomainName - READ-ONLY; The fully qualified domain name of a server. + FullyQualifiedDomainName *string `json:"fullyQualifiedDomainName,omitempty"` + // Storage - Storage properties of a server. + Storage *Storage `json:"storage,omitempty"` + // Backup - Backup properties of a server. + Backup *Backup `json:"backup,omitempty"` + // Network - Network properties of a server. + Network *Network `json:"network,omitempty"` + // HighAvailability - High availability properties of a server. + HighAvailability *HighAvailability `json:"highAvailability,omitempty"` + // MaintenanceWindow - Maintenance window properties of a server. + MaintenanceWindow *MaintenanceWindow `json:"maintenanceWindow,omitempty"` + // SourceServerResourceID - The source server resource ID to restore from. It's required when 'createMode' is 'PointInTimeRestore'. + SourceServerResourceID *string `json:"sourceServerResourceId,omitempty"` + // PointInTimeUTC - Restore point creation time (ISO8601 format), specifying the time to restore from. It's required when 'createMode' is 'PointInTimeRestore'. + PointInTimeUTC *date.Time `json:"pointInTimeUTC,omitempty"` + // AvailabilityZone - availability zone information of the server. + AvailabilityZone *string `json:"availabilityZone,omitempty"` + // CreateMode - The mode to create a new PostgreSQL server. Possible values include: 'CreateModeDefault', 'CreateModeCreate', 'CreateModeUpdate', 'CreateModePointInTimeRestore' + CreateMode CreateMode `json:"createMode,omitempty"` + // Tags - Application-specific metadata in the form of key-value pairs. + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for ServerProperties. +func (sp ServerProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sp.AdministratorLogin != nil { + objectMap["administratorLogin"] = sp.AdministratorLogin + } + if sp.AdministratorLoginPassword != nil { + objectMap["administratorLoginPassword"] = sp.AdministratorLoginPassword + } + if sp.Version != "" { + objectMap["version"] = sp.Version + } + if sp.Storage != nil { + objectMap["storage"] = sp.Storage + } + if sp.Backup != nil { + objectMap["backup"] = sp.Backup + } + if sp.Network != nil { + objectMap["network"] = sp.Network + } + if sp.HighAvailability != nil { + objectMap["highAvailability"] = sp.HighAvailability + } + if sp.MaintenanceWindow != nil { + objectMap["maintenanceWindow"] = sp.MaintenanceWindow + } + if sp.SourceServerResourceID != nil { + objectMap["sourceServerResourceId"] = sp.SourceServerResourceID + } + if sp.PointInTimeUTC != nil { + objectMap["pointInTimeUTC"] = sp.PointInTimeUTC + } + if sp.AvailabilityZone != nil { + objectMap["availabilityZone"] = sp.AvailabilityZone + } + if sp.CreateMode != "" { + objectMap["createMode"] = sp.CreateMode + } + if sp.Tags != nil { + objectMap["tags"] = sp.Tags + } + return json.Marshal(objectMap) +} + +// ServerPropertiesForUpdate ... +type ServerPropertiesForUpdate struct { + // AdministratorLoginPassword - The password of the administrator login. + AdministratorLoginPassword *string `json:"administratorLoginPassword,omitempty"` + // Storage - Storage properties of a server. + Storage *Storage `json:"storage,omitempty"` + // Backup - Backup properties of a server. + Backup *Backup `json:"backup,omitempty"` + // HighAvailability - High availability properties of a server. + HighAvailability *HighAvailability `json:"highAvailability,omitempty"` + // MaintenanceWindow - Maintenance window properties of a server. + MaintenanceWindow *MaintenanceWindow `json:"maintenanceWindow,omitempty"` + // CreateMode - The mode to update a new PostgreSQL server. Possible values include: 'CreateModeForUpdateDefault', 'CreateModeForUpdateUpdate' + CreateMode CreateModeForUpdate `json:"createMode,omitempty"` +} + +// ServersCreateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ServersCreateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ServersClient) (Server, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ServersCreateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ServersCreateFuture.Result. +func (future *ServersCreateFuture) result(client ServersClient) (s Server, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ServersCreateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + s.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("postgresqlflexibleservers.ServersCreateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if s.Response.Response, err = future.GetResult(sender); err == nil && s.Response.Response.StatusCode != http.StatusNoContent { + s, err = client.CreateResponder(s.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ServersCreateFuture", "Result", s.Response.Response, "Failure responding to request") + } + } + return +} + +// ServersDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ServersDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ServersClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ServersDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ServersDeleteFuture.Result. +func (future *ServersDeleteFuture) result(client ServersClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ServersDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("postgresqlflexibleservers.ServersDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// ServersRestartFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ServersRestartFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ServersClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ServersRestartFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ServersRestartFuture.Result. +func (future *ServersRestartFuture) result(client ServersClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ServersRestartFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("postgresqlflexibleservers.ServersRestartFuture") + return + } + ar.Response = future.Response() + return +} + +// ServersStartFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type ServersStartFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ServersClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ServersStartFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ServersStartFuture.Result. +func (future *ServersStartFuture) result(client ServersClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ServersStartFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("postgresqlflexibleservers.ServersStartFuture") + return + } + ar.Response = future.Response() + return +} + +// ServersStopFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type ServersStopFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ServersClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ServersStopFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ServersStopFuture.Result. +func (future *ServersStopFuture) result(client ServersClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ServersStopFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("postgresqlflexibleservers.ServersStopFuture") + return + } + ar.Response = future.Response() + return +} + +// ServersUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ServersUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ServersClient) (Server, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ServersUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ServersUpdateFuture.Result. +func (future *ServersUpdateFuture) result(client ServersClient) (s Server, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ServersUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + s.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("postgresqlflexibleservers.ServersUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if s.Response.Response, err = future.GetResult(sender); err == nil && s.Response.Response.StatusCode != http.StatusNoContent { + s, err = client.UpdateResponder(s.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ServersUpdateFuture", "Result", s.Response.Response, "Failure responding to request") + } + } + return +} + +// ServerVersionCapability server version capabilities. +type ServerVersionCapability struct { + // Name - READ-ONLY; server version + Name *string `json:"name,omitempty"` + // SupportedVcores - READ-ONLY + SupportedVcores *[]VcoreCapability `json:"supportedVcores,omitempty"` + // Status - READ-ONLY; The status + Status *string `json:"status,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServerVersionCapability. +func (svc ServerVersionCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// Sku sku information related properties of a server. +type Sku struct { + // Name - The name of the sku, typically, tier + family + cores, e.g. Standard_D4s_v3. + Name *string `json:"name,omitempty"` + // Tier - The tier of the particular SKU, e.g. Burstable. Possible values include: 'SkuTierBurstable', 'SkuTierGeneralPurpose', 'SkuTierMemoryOptimized' + Tier SkuTier `json:"tier,omitempty"` +} + +// Storage storage properties of a server +type Storage struct { + // StorageSizeGB - Max storage allowed for a server. + StorageSizeGB *int32 `json:"storageSizeGB,omitempty"` +} + +// StorageEditionCapability storage edition capability +type StorageEditionCapability struct { + // Name - READ-ONLY; storage edition name + Name *string `json:"name,omitempty"` + // SupportedStorageMB - READ-ONLY + SupportedStorageMB *[]StorageMBCapability `json:"supportedStorageMB,omitempty"` + // Status - READ-ONLY; The status + Status *string `json:"status,omitempty"` +} + +// MarshalJSON is the custom marshaler for StorageEditionCapability. +func (sec StorageEditionCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// StorageMBCapability storage size in MB capability +type StorageMBCapability struct { + // Name - READ-ONLY; storage MB name + Name *string `json:"name,omitempty"` + // SupportedIops - READ-ONLY; supported IOPS + SupportedIops *int64 `json:"supportedIops,omitempty"` + // StorageSizeMB - READ-ONLY; storage size in MB + StorageSizeMB *int64 `json:"storageSizeMB,omitempty"` + // Status - READ-ONLY; The status + Status *string `json:"status,omitempty"` +} + +// MarshalJSON is the custom marshaler for StorageMBCapability. +func (smc StorageMBCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// String ... +type String struct { + autorest.Response `json:"-"` + Value *string `json:"value,omitempty"` +} + +// SystemData metadata pertaining to creation and last modification of the resource. +type SystemData struct { + // CreatedBy - The identity that created the resource. + CreatedBy *string `json:"createdBy,omitempty"` + // CreatedByType - The type of identity that created the resource. Possible values include: 'CreatedByTypeUser', 'CreatedByTypeApplication', 'CreatedByTypeManagedIdentity', 'CreatedByTypeKey' + CreatedByType CreatedByType `json:"createdByType,omitempty"` + // CreatedAt - The timestamp of resource creation (UTC). + CreatedAt *date.Time `json:"createdAt,omitempty"` + // LastModifiedBy - The identity that last modified the resource. + LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + // LastModifiedByType - The type of identity that last modified the resource. Possible values include: 'CreatedByTypeUser', 'CreatedByTypeApplication', 'CreatedByTypeManagedIdentity', 'CreatedByTypeKey' + LastModifiedByType CreatedByType `json:"lastModifiedByType,omitempty"` + // LastModifiedAt - The timestamp of resource last modification (UTC) + LastModifiedAt *date.Time `json:"lastModifiedAt,omitempty"` +} + +// TrackedResource the resource model definition for an Azure Resource Manager tracked top level resource +// which has 'tags' and a 'location' +type TrackedResource struct { + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // Location - The geo-location where the resource lives + Location *string `json:"location,omitempty"` + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + 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 + } + return json.Marshal(objectMap) +} + +// VcoreCapability vcores capability +type VcoreCapability struct { + // Name - READ-ONLY; vCore name + Name *string `json:"name,omitempty"` + // VCores - READ-ONLY; supported vCores + VCores *int64 `json:"vCores,omitempty"` + // SupportedIops - READ-ONLY; supported IOPS + SupportedIops *int64 `json:"supportedIops,omitempty"` + // SupportedMemoryPerVcoreMB - READ-ONLY; supported memory per vCore in MB + SupportedMemoryPerVcoreMB *int64 `json:"supportedMemoryPerVcoreMB,omitempty"` + // Status - READ-ONLY; The status + Status *string `json:"status,omitempty"` +} + +// MarshalJSON is the custom marshaler for VcoreCapability. +func (vc VcoreCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// VirtualNetworkSubnetUsageParameter virtual network subnet usage parameter +type VirtualNetworkSubnetUsageParameter struct { + // VirtualNetworkArmResourceID - Virtual network resource id. + VirtualNetworkArmResourceID *string `json:"virtualNetworkArmResourceId,omitempty"` +} + +// VirtualNetworkSubnetUsageResult virtual network subnet usage data. +type VirtualNetworkSubnetUsageResult struct { + autorest.Response `json:"-"` + // DelegatedSubnetsUsage - READ-ONLY + DelegatedSubnetsUsage *[]DelegatedSubnetUsage `json:"delegatedSubnetsUsage,omitempty"` +} + +// MarshalJSON is the custom marshaler for VirtualNetworkSubnetUsageResult. +func (vnsur VirtualNetworkSubnetUsageResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} diff --git a/services/postgresql/mgmt/2021-06-01/postgresqlflexibleservers/operations.go b/services/postgresql/mgmt/2021-06-01/postgresqlflexibleservers/operations.go new file mode 100644 index 000000000000..93008c1c249c --- /dev/null +++ b/services/postgresql/mgmt/2021-06-01/postgresqlflexibleservers/operations.go @@ -0,0 +1,100 @@ +package postgresqlflexibleservers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// OperationsClient is the the Microsoft Azure management API provides create, read, update, and delete functionality +// for Azure PostgreSQL resources including servers, databases, firewall rules, VNET rules, security alert policies, +// log files and configurations with new business model. +type OperationsClient struct { + BaseClient +} + +// NewOperationsClient creates an instance of the OperationsClient client. +func NewOperationsClient(subscriptionID string) OperationsClient { + return NewOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewOperationsClientWithBaseURI creates an instance of the OperationsClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient { + return OperationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List lists all of the available REST API operations. +func (client OperationsClient) List(ctx context.Context) (result OperationListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.OperationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.OperationsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.OperationsClient", "List", resp, "Failure responding to request") + return + } + + return +} + +// ListPreparer prepares the List request. +func (client OperationsClient) ListPreparer(ctx context.Context) (*http.Request, error) { + const APIVersion = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.DBForPostgreSql/operations"), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client OperationsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client OperationsClient) ListResponder(resp *http.Response) (result OperationListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/postgresql/mgmt/2021-06-01/postgresqlflexibleservers/postgresqlflexibleserversapi/interfaces.go b/services/postgresql/mgmt/2021-06-01/postgresqlflexibleservers/postgresqlflexibleserversapi/interfaces.go new file mode 100644 index 000000000000..90724e170676 --- /dev/null +++ b/services/postgresql/mgmt/2021-06-01/postgresqlflexibleservers/postgresqlflexibleserversapi/interfaces.go @@ -0,0 +1,98 @@ +package postgresqlflexibleserversapi + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/services/postgresql/mgmt/2021-06-01/postgresqlflexibleservers" +) + +// ServersClientAPI contains the set of methods on the ServersClient type. +type ServersClientAPI interface { + Create(ctx context.Context, resourceGroupName string, serverName string, parameters postgresqlflexibleservers.Server) (result postgresqlflexibleservers.ServersCreateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, serverName string) (result postgresqlflexibleservers.ServersDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, serverName string) (result postgresqlflexibleservers.Server, err error) + List(ctx context.Context) (result postgresqlflexibleservers.ServerListResultPage, err error) + ListComplete(ctx context.Context) (result postgresqlflexibleservers.ServerListResultIterator, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string) (result postgresqlflexibleservers.ServerListResultPage, err error) + ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result postgresqlflexibleservers.ServerListResultIterator, err error) + Restart(ctx context.Context, resourceGroupName string, serverName string, parameters *postgresqlflexibleservers.RestartParameter) (result postgresqlflexibleservers.ServersRestartFuture, err error) + Start(ctx context.Context, resourceGroupName string, serverName string) (result postgresqlflexibleservers.ServersStartFuture, err error) + Stop(ctx context.Context, resourceGroupName string, serverName string) (result postgresqlflexibleservers.ServersStopFuture, err error) + Update(ctx context.Context, resourceGroupName string, serverName string, parameters postgresqlflexibleservers.ServerForUpdate) (result postgresqlflexibleservers.ServersUpdateFuture, err error) +} + +var _ ServersClientAPI = (*postgresqlflexibleservers.ServersClient)(nil) + +// FirewallRulesClientAPI contains the set of methods on the FirewallRulesClient type. +type FirewallRulesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, firewallRuleName string, parameters postgresqlflexibleservers.FirewallRule) (result postgresqlflexibleservers.FirewallRulesCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, serverName string, firewallRuleName string) (result postgresqlflexibleservers.FirewallRulesDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, firewallRuleName string) (result postgresqlflexibleservers.FirewallRule, err error) + ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result postgresqlflexibleservers.FirewallRuleListResultPage, err error) + ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result postgresqlflexibleservers.FirewallRuleListResultIterator, err error) +} + +var _ FirewallRulesClientAPI = (*postgresqlflexibleservers.FirewallRulesClient)(nil) + +// ConfigurationsClientAPI contains the set of methods on the ConfigurationsClient type. +type ConfigurationsClientAPI interface { + Get(ctx context.Context, resourceGroupName string, serverName string, configurationName string) (result postgresqlflexibleservers.Configuration, err error) + ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result postgresqlflexibleservers.ConfigurationListResultPage, err error) + ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result postgresqlflexibleservers.ConfigurationListResultIterator, err error) + Put(ctx context.Context, resourceGroupName string, serverName string, configurationName string, parameters postgresqlflexibleservers.Configuration) (result postgresqlflexibleservers.ConfigurationsPutFuture, err error) + Update(ctx context.Context, resourceGroupName string, serverName string, configurationName string, parameters postgresqlflexibleservers.Configuration) (result postgresqlflexibleservers.ConfigurationsUpdateFuture, err error) +} + +var _ ConfigurationsClientAPI = (*postgresqlflexibleservers.ConfigurationsClient)(nil) + +// CheckNameAvailabilityClientAPI contains the set of methods on the CheckNameAvailabilityClient type. +type CheckNameAvailabilityClientAPI interface { + Execute(ctx context.Context, nameAvailabilityRequest postgresqlflexibleservers.NameAvailabilityRequest) (result postgresqlflexibleservers.NameAvailability, err error) +} + +var _ CheckNameAvailabilityClientAPI = (*postgresqlflexibleservers.CheckNameAvailabilityClient)(nil) + +// LocationBasedCapabilitiesClientAPI contains the set of methods on the LocationBasedCapabilitiesClient type. +type LocationBasedCapabilitiesClientAPI interface { + Execute(ctx context.Context, locationName string) (result postgresqlflexibleservers.CapabilitiesListResultPage, err error) + ExecuteComplete(ctx context.Context, locationName string) (result postgresqlflexibleservers.CapabilitiesListResultIterator, err error) +} + +var _ LocationBasedCapabilitiesClientAPI = (*postgresqlflexibleservers.LocationBasedCapabilitiesClient)(nil) + +// VirtualNetworkSubnetUsageClientAPI contains the set of methods on the VirtualNetworkSubnetUsageClient type. +type VirtualNetworkSubnetUsageClientAPI interface { + Execute(ctx context.Context, locationName string, parameters postgresqlflexibleservers.VirtualNetworkSubnetUsageParameter) (result postgresqlflexibleservers.VirtualNetworkSubnetUsageResult, err error) +} + +var _ VirtualNetworkSubnetUsageClientAPI = (*postgresqlflexibleservers.VirtualNetworkSubnetUsageClient)(nil) + +// OperationsClientAPI contains the set of methods on the OperationsClient type. +type OperationsClientAPI interface { + List(ctx context.Context) (result postgresqlflexibleservers.OperationListResult, err error) +} + +var _ OperationsClientAPI = (*postgresqlflexibleservers.OperationsClient)(nil) + +// DatabasesClientAPI contains the set of methods on the DatabasesClient type. +type DatabasesClientAPI interface { + Create(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters postgresqlflexibleservers.Database) (result postgresqlflexibleservers.DatabasesCreateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result postgresqlflexibleservers.DatabasesDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result postgresqlflexibleservers.Database, err error) + ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result postgresqlflexibleservers.DatabaseListResultPage, err error) + ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result postgresqlflexibleservers.DatabaseListResultIterator, err error) +} + +var _ DatabasesClientAPI = (*postgresqlflexibleservers.DatabasesClient)(nil) + +// GetPrivateDNSZoneSuffixClientAPI contains the set of methods on the GetPrivateDNSZoneSuffixClient type. +type GetPrivateDNSZoneSuffixClientAPI interface { + Execute(ctx context.Context) (result postgresqlflexibleservers.String, err error) +} + +var _ GetPrivateDNSZoneSuffixClientAPI = (*postgresqlflexibleservers.GetPrivateDNSZoneSuffixClient)(nil) diff --git a/services/postgresql/mgmt/2021-06-01/postgresqlflexibleservers/servers.go b/services/postgresql/mgmt/2021-06-01/postgresqlflexibleservers/servers.go new file mode 100644 index 000000000000..090e59b2e3ac --- /dev/null +++ b/services/postgresql/mgmt/2021-06-01/postgresqlflexibleservers/servers.go @@ -0,0 +1,898 @@ +package postgresqlflexibleservers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ServersClient is the the Microsoft Azure management API provides create, read, update, and delete functionality for +// Azure PostgreSQL resources including servers, databases, firewall rules, VNET rules, security alert policies, log +// files and configurations with new business model. +type ServersClient struct { + BaseClient +} + +// NewServersClient creates an instance of the ServersClient client. +func NewServersClient(subscriptionID string) ServersClient { + return NewServersClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewServersClientWithBaseURI creates an instance of the ServersClient client using a custom endpoint. Use this when +// interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewServersClientWithBaseURI(baseURI string, subscriptionID string) ServersClient { + return ServersClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Create creates a new server. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// serverName - the name of the server. +// parameters - the required parameters for creating or updating a server. +func (client ServersClient) Create(ctx context.Context, resourceGroupName string, serverName string, parameters Server) (result ServersCreateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServersClient.Create") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {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("postgresqlflexibleservers.ServersClient", "Create", err.Error()) + } + + req, err := client.CreatePreparer(ctx, resourceGroupName, serverName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ServersClient", "Create", nil, "Failure preparing request") + return + } + + result, err = client.CreateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ServersClient", "Create", nil, "Failure sending request") + return + } + + return +} + +// CreatePreparer prepares the Create request. +func (client ServersClient) CreatePreparer(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 = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + parameters.SystemData = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/flexibleServers/{serverName}", 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 ServersClient) CreateSender(req *http.Request) (future ServersCreateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client ServersClient) CreateResponder(resp *http.Response) (result Server, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a server. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// serverName - the name of the server. +func (client ServersClient) Delete(ctx context.Context, resourceGroupName string, serverName string) (result ServersDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServersClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("postgresqlflexibleservers.ServersClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ServersClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ServersClient", "Delete", nil, "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 = "2021-06-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.DBForPostgreSql/flexibleServers/{serverName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client ServersClient) DeleteSender(req *http.Request) (future ServersDeleteFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ServersClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets information about a server. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// serverName - the name of the server. +func (client ServersClient) Get(ctx context.Context, resourceGroupName string, serverName string) (result Server, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServersClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("postgresqlflexibleservers.ServersClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.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, "postgresqlflexibleservers.ServersClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ServersClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ServersClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-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.DBForPostgreSql/flexibleServers/{serverName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ServersClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ServersClient) GetResponder(resp *http.Response) (result Server, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List list all the servers in a given subscription. +func (client ServersClient) List(ctx context.Context) (result ServerListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServersClient.List") + defer func() { + sc := -1 + if result.slr.Response.Response != nil { + sc = result.slr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("postgresqlflexibleservers.ServersClient", "List", err.Error()) + } + + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.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, "postgresqlflexibleservers.ServersClient", "List", resp, "Failure sending request") + return + } + + result.slr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ServersClient", "List", resp, "Failure responding to request") + return + } + if result.slr.hasNextLink() && result.slr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client ServersClient) ListPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.DBForPostgreSql/flexibleServers", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client ServersClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client ServersClient) ListResponder(resp *http.Response) (result ServerListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client ServersClient) listNextResults(ctx context.Context, lastResults ServerListResult) (result ServerListResult, err error) { + req, err := lastResults.serverListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "postgresqlflexibleservers.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, "postgresqlflexibleservers.ServersClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ServersClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client ServersClient) ListComplete(ctx context.Context) (result ServerListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServersClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx) + return +} + +// ListByResourceGroup list all the servers in a given resource group. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +func (client ServersClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result ServerListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServersClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.slr.Response.Response != nil { + sc = result.slr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("postgresqlflexibleservers.ServersClient", "ListByResourceGroup", err.Error()) + } + + result.fn = client.listByResourceGroupNextResults + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.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, "postgresqlflexibleservers.ServersClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result.slr, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ServersClient", "ListByResourceGroup", resp, "Failure responding to request") + return + } + if result.slr.hasNextLink() && result.slr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client ServersClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-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.DBForPostgreSql/flexibleServers", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client ServersClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client ServersClient) ListByResourceGroupResponder(resp *http.Response) (result ServerListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByResourceGroupNextResults retrieves the next set of results, if any. +func (client ServersClient) listByResourceGroupNextResults(ctx context.Context, lastResults ServerListResult) (result ServerListResult, err error) { + req, err := lastResults.serverListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "postgresqlflexibleservers.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, "postgresqlflexibleservers.ServersClient", "listByResourceGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ServersClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. +func (client ServersClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result ServerListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServersClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByResourceGroup(ctx, resourceGroupName) + return +} + +// Restart restarts a server. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// serverName - the name of the server. +// parameters - the parameters for restarting a server. +func (client ServersClient) Restart(ctx context.Context, resourceGroupName string, serverName string, parameters *RestartParameter) (result ServersRestartFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServersClient.Restart") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("postgresqlflexibleservers.ServersClient", "Restart", err.Error()) + } + + req, err := client.RestartPreparer(ctx, resourceGroupName, serverName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ServersClient", "Restart", nil, "Failure preparing request") + return + } + + result, err = client.RestartSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ServersClient", "Restart", nil, "Failure sending request") + return + } + + return +} + +// RestartPreparer prepares the Restart request. +func (client ServersClient) RestartPreparer(ctx context.Context, resourceGroupName string, serverName string, parameters *RestartParameter) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-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.DBForPostgreSql/flexibleServers/{serverName}/restart", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if parameters != nil { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithJSON(parameters)) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// RestartSender sends the Restart request. The method will close the +// http.Response Body if it receives an error. +func (client ServersClient) RestartSender(req *http.Request) (future ServersRestartFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// RestartResponder handles the response to the Restart request. The method always +// closes the http.Response Body. +func (client ServersClient) RestartResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + +// Start starts a server. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// serverName - the name of the server. +func (client ServersClient) Start(ctx context.Context, resourceGroupName string, serverName string) (result ServersStartFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServersClient.Start") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("postgresqlflexibleservers.ServersClient", "Start", err.Error()) + } + + req, err := client.StartPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ServersClient", "Start", nil, "Failure preparing request") + return + } + + result, err = client.StartSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ServersClient", "Start", nil, "Failure sending request") + return + } + + return +} + +// StartPreparer prepares the Start request. +func (client ServersClient) StartPreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-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.DBForPostgreSql/flexibleServers/{serverName}/start", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// StartSender sends the Start request. The method will close the +// http.Response Body if it receives an error. +func (client ServersClient) StartSender(req *http.Request) (future ServersStartFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// StartResponder handles the response to the Start request. The method always +// closes the http.Response Body. +func (client ServersClient) StartResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + +// Stop stops a server. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// serverName - the name of the server. +func (client ServersClient) Stop(ctx context.Context, resourceGroupName string, serverName string) (result ServersStopFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServersClient.Stop") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("postgresqlflexibleservers.ServersClient", "Stop", err.Error()) + } + + req, err := client.StopPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ServersClient", "Stop", nil, "Failure preparing request") + return + } + + result, err = client.StopSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ServersClient", "Stop", nil, "Failure sending request") + return + } + + return +} + +// StopPreparer prepares the Stop request. +func (client ServersClient) StopPreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-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.DBForPostgreSql/flexibleServers/{serverName}/stop", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// StopSender sends the Stop request. The method will close the +// http.Response Body if it receives an error. +func (client ServersClient) StopSender(req *http.Request) (future ServersStopFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// StopResponder handles the response to the Stop request. The method always +// closes the http.Response Body. +func (client ServersClient) StopResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + +// Update updates an existing server. The request body can contain one to many of the properties present in the normal +// server definition. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// serverName - the name of the server. +// parameters - the required parameters for updating a server. +func (client ServersClient) Update(ctx context.Context, resourceGroupName string, serverName string, parameters ServerForUpdate) (result ServersUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServersClient.Update") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("postgresqlflexibleservers.ServersClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, serverName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ServersClient", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.ServersClient", "Update", nil, "Failure sending request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client ServersClient) UpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, parameters ServerForUpdate) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-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.DBForPostgreSql/flexibleServers/{serverName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client ServersClient) UpdateSender(req *http.Request) (future ServersUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client ServersClient) UpdateResponder(resp *http.Response) (result Server, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/postgresql/mgmt/2021-06-01/postgresqlflexibleservers/version.go b/services/postgresql/mgmt/2021-06-01/postgresqlflexibleservers/version.go new file mode 100644 index 000000000000..e13132f4b75a --- /dev/null +++ b/services/postgresql/mgmt/2021-06-01/postgresqlflexibleservers/version.go @@ -0,0 +1,19 @@ +package postgresqlflexibleservers + +import "github.com/Azure/azure-sdk-for-go/version" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// UserAgent returns the UserAgent string to use when sending http.Requests. +func UserAgent() string { + return "Azure-SDK-For-Go/" + Version() + " postgresqlflexibleservers/2021-06-01" +} + +// Version returns the semantic version (see http://semver.org) of the client. +func Version() string { + return version.Number +} diff --git a/services/postgresql/mgmt/2021-06-01/postgresqlflexibleservers/virtualnetworksubnetusage.go b/services/postgresql/mgmt/2021-06-01/postgresqlflexibleservers/virtualnetworksubnetusage.go new file mode 100644 index 000000000000..729356b5cf89 --- /dev/null +++ b/services/postgresql/mgmt/2021-06-01/postgresqlflexibleservers/virtualnetworksubnetusage.go @@ -0,0 +1,118 @@ +package postgresqlflexibleservers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// VirtualNetworkSubnetUsageClient is the the Microsoft Azure management API provides create, read, update, and delete +// functionality for Azure PostgreSQL resources including servers, databases, firewall rules, VNET rules, security +// alert policies, log files and configurations with new business model. +type VirtualNetworkSubnetUsageClient struct { + BaseClient +} + +// NewVirtualNetworkSubnetUsageClient creates an instance of the VirtualNetworkSubnetUsageClient client. +func NewVirtualNetworkSubnetUsageClient(subscriptionID string) VirtualNetworkSubnetUsageClient { + return NewVirtualNetworkSubnetUsageClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewVirtualNetworkSubnetUsageClientWithBaseURI creates an instance of the VirtualNetworkSubnetUsageClient client +// using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign +// clouds, Azure stack). +func NewVirtualNetworkSubnetUsageClientWithBaseURI(baseURI string, subscriptionID string) VirtualNetworkSubnetUsageClient { + return VirtualNetworkSubnetUsageClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Execute get virtual network subnet usage for a given vNet resource id. +// Parameters: +// locationName - the name of the location. +// parameters - the required parameters for creating or updating a server. +func (client VirtualNetworkSubnetUsageClient) Execute(ctx context.Context, locationName string, parameters VirtualNetworkSubnetUsageParameter) (result VirtualNetworkSubnetUsageResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/VirtualNetworkSubnetUsageClient.Execute") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("postgresqlflexibleservers.VirtualNetworkSubnetUsageClient", "Execute", err.Error()) + } + + req, err := client.ExecutePreparer(ctx, locationName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.VirtualNetworkSubnetUsageClient", "Execute", nil, "Failure preparing request") + return + } + + resp, err := client.ExecuteSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.VirtualNetworkSubnetUsageClient", "Execute", resp, "Failure sending request") + return + } + + result, err = client.ExecuteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.VirtualNetworkSubnetUsageClient", "Execute", resp, "Failure responding to request") + return + } + + return +} + +// ExecutePreparer prepares the Execute request. +func (client VirtualNetworkSubnetUsageClient) ExecutePreparer(ctx context.Context, locationName string, parameters VirtualNetworkSubnetUsageParameter) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "locationName": autorest.Encode("path", locationName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-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.DBForPostgreSql/locations/{locationName}/checkVirtualNetworkSubnetUsage", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ExecuteSender sends the Execute request. The method will close the +// http.Response Body if it receives an error. +func (client VirtualNetworkSubnetUsageClient) ExecuteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ExecuteResponder handles the response to the Execute request. The method always +// closes the http.Response Body. +func (client VirtualNetworkSubnetUsageClient) ExecuteResponder(resp *http.Response) (result VirtualNetworkSubnetUsageResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/azurestackhci/mgmt/2021-01-01-preview/azurestackhci/CHANGELOG.md b/services/preview/azurestackhci/mgmt/2021-01-01-preview/azurestackhci/CHANGELOG.md new file mode 100644 index 000000000000..52911e4cc5e4 --- /dev/null +++ b/services/preview/azurestackhci/mgmt/2021-01-01-preview/azurestackhci/CHANGELOG.md @@ -0,0 +1,2 @@ +# Change History + diff --git a/services/preview/azurestackhci/mgmt/2021-01-01-preview/azurestackhci/_meta.json b/services/preview/azurestackhci/mgmt/2021-01-01-preview/azurestackhci/_meta.json new file mode 100644 index 000000000000..8263a6e28303 --- /dev/null +++ b/services/preview/azurestackhci/mgmt/2021-01-01-preview/azurestackhci/_meta.json @@ -0,0 +1,11 @@ +{ + "commit": "8dff86df71bee429af84ea4713288ef3cdd1db2f", + "readme": "/_/azure-rest-api-specs/specification/azurestackhci/resource-manager/readme.md", + "tag": "package-preview-2021-01", + "use": "@microsoft.azure/autorest.go@2.1.183", + "repository_url": "https://github.com/Azure/azure-rest-api-specs.git", + "autorest_command": "autorest --use=@microsoft.azure/autorest.go@2.1.183 --tag=package-preview-2021-01 --go-sdk-folder=/_/azure-sdk-for-go --go --verbose --use-onever --version=V2 --go.license-header=MICROSOFT_MIT_NO_VERSION --enum-prefix /_/azure-rest-api-specs/specification/azurestackhci/resource-manager/readme.md", + "additional_properties": { + "additional_options": "--go --verbose --use-onever --version=V2 --go.license-header=MICROSOFT_MIT_NO_VERSION --enum-prefix" + } +} \ No newline at end of file diff --git a/services/preview/azurestackhci/mgmt/2021-01-01-preview/azurestackhci/arcsettings.go b/services/preview/azurestackhci/mgmt/2021-01-01-preview/azurestackhci/arcsettings.go new file mode 100644 index 000000000000..ee1ae14c7dbf --- /dev/null +++ b/services/preview/azurestackhci/mgmt/2021-01-01-preview/azurestackhci/arcsettings.go @@ -0,0 +1,425 @@ +package azurestackhci + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ArcSettingsClient is the azure Stack HCI management service +type ArcSettingsClient struct { + BaseClient +} + +// NewArcSettingsClient creates an instance of the ArcSettingsClient client. +func NewArcSettingsClient(subscriptionID string) ArcSettingsClient { + return NewArcSettingsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewArcSettingsClientWithBaseURI creates an instance of the ArcSettingsClient client using a custom endpoint. Use +// this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewArcSettingsClientWithBaseURI(baseURI string, subscriptionID string) ArcSettingsClient { + return ArcSettingsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Create create ArcSetting for HCI cluster. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// clusterName - the name of the cluster. +// arcSettingName - the name of the proxy resource holding details of HCI ArcSetting information. +// arcSetting - parameters supplied to the Create ArcSetting resource for this HCI cluster. +func (client ArcSettingsClient) Create(ctx context.Context, resourceGroupName string, clusterName string, arcSettingName string, arcSetting ArcSetting) (result ArcSetting, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ArcSettingsClient.Create") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("azurestackhci.ArcSettingsClient", "Create", err.Error()) + } + + req, err := client.CreatePreparer(ctx, resourceGroupName, clusterName, arcSettingName, arcSetting) + if err != nil { + err = autorest.NewErrorWithError(err, "azurestackhci.ArcSettingsClient", "Create", nil, "Failure preparing request") + return + } + + resp, err := client.CreateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "azurestackhci.ArcSettingsClient", "Create", resp, "Failure sending request") + return + } + + result, err = client.CreateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "azurestackhci.ArcSettingsClient", "Create", resp, "Failure responding to request") + return + } + + return +} + +// CreatePreparer prepares the Create request. +func (client ArcSettingsClient) CreatePreparer(ctx context.Context, resourceGroupName string, clusterName string, arcSettingName string, arcSetting ArcSetting) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "arcSettingName": autorest.Encode("path", arcSettingName), + "clusterName": autorest.Encode("path", clusterName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + arcSetting.SystemData = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/arcSettings/{arcSettingName}", pathParameters), + autorest.WithJSON(arcSetting), + 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 ArcSettingsClient) CreateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client ArcSettingsClient) CreateResponder(resp *http.Response) (result ArcSetting, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete ArcSetting resource details of HCI Cluster. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// clusterName - the name of the cluster. +// arcSettingName - the name of the proxy resource holding details of HCI ArcSetting information. +func (client ArcSettingsClient) Delete(ctx context.Context, resourceGroupName string, clusterName string, arcSettingName string) (result ArcSettingsDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ArcSettingsClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("azurestackhci.ArcSettingsClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, clusterName, arcSettingName) + if err != nil { + err = autorest.NewErrorWithError(err, "azurestackhci.ArcSettingsClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "azurestackhci.ArcSettingsClient", "Delete", nil, "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ArcSettingsClient) DeletePreparer(ctx context.Context, resourceGroupName string, clusterName string, arcSettingName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "arcSettingName": autorest.Encode("path", arcSettingName), + "clusterName": autorest.Encode("path", clusterName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-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.AzureStackHCI/clusters/{clusterName}/arcSettings/{arcSettingName}", 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 ArcSettingsClient) DeleteSender(req *http.Request) (future ArcSettingsDeleteFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ArcSettingsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get get ArcSetting resource details of HCI Cluster. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// clusterName - the name of the cluster. +// arcSettingName - the name of the proxy resource holding details of HCI ArcSetting information. +func (client ArcSettingsClient) Get(ctx context.Context, resourceGroupName string, clusterName string, arcSettingName string) (result ArcSetting, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ArcSettingsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("azurestackhci.ArcSettingsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, clusterName, arcSettingName) + if err != nil { + err = autorest.NewErrorWithError(err, "azurestackhci.ArcSettingsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "azurestackhci.ArcSettingsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "azurestackhci.ArcSettingsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ArcSettingsClient) GetPreparer(ctx context.Context, resourceGroupName string, clusterName string, arcSettingName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "arcSettingName": autorest.Encode("path", arcSettingName), + "clusterName": autorest.Encode("path", clusterName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/arcSettings/{arcSettingName}", 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 ArcSettingsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ArcSettingsClient) GetResponder(resp *http.Response) (result ArcSetting, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByCluster get ArcSetting resources of HCI Cluster. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// clusterName - the name of the cluster. +func (client ArcSettingsClient) ListByCluster(ctx context.Context, resourceGroupName string, clusterName string) (result ArcSettingListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ArcSettingsClient.ListByCluster") + defer func() { + sc := -1 + if result.asl.Response.Response != nil { + sc = result.asl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("azurestackhci.ArcSettingsClient", "ListByCluster", err.Error()) + } + + result.fn = client.listByClusterNextResults + req, err := client.ListByClusterPreparer(ctx, resourceGroupName, clusterName) + if err != nil { + err = autorest.NewErrorWithError(err, "azurestackhci.ArcSettingsClient", "ListByCluster", nil, "Failure preparing request") + return + } + + resp, err := client.ListByClusterSender(req) + if err != nil { + result.asl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "azurestackhci.ArcSettingsClient", "ListByCluster", resp, "Failure sending request") + return + } + + result.asl, err = client.ListByClusterResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "azurestackhci.ArcSettingsClient", "ListByCluster", resp, "Failure responding to request") + return + } + if result.asl.hasNextLink() && result.asl.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByClusterPreparer prepares the ListByCluster request. +func (client ArcSettingsClient) ListByClusterPreparer(ctx context.Context, resourceGroupName string, clusterName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "clusterName": autorest.Encode("path", clusterName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/arcSettings", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByClusterSender sends the ListByCluster request. The method will close the +// http.Response Body if it receives an error. +func (client ArcSettingsClient) ListByClusterSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByClusterResponder handles the response to the ListByCluster request. The method always +// closes the http.Response Body. +func (client ArcSettingsClient) ListByClusterResponder(resp *http.Response) (result ArcSettingList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByClusterNextResults retrieves the next set of results, if any. +func (client ArcSettingsClient) listByClusterNextResults(ctx context.Context, lastResults ArcSettingList) (result ArcSettingList, err error) { + req, err := lastResults.arcSettingListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "azurestackhci.ArcSettingsClient", "listByClusterNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByClusterSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "azurestackhci.ArcSettingsClient", "listByClusterNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByClusterResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "azurestackhci.ArcSettingsClient", "listByClusterNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByClusterComplete enumerates all values, automatically crossing page boundaries as required. +func (client ArcSettingsClient) ListByClusterComplete(ctx context.Context, resourceGroupName string, clusterName string) (result ArcSettingListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ArcSettingsClient.ListByCluster") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByCluster(ctx, resourceGroupName, clusterName) + return +} diff --git a/services/preview/azurestackhci/mgmt/2021-01-01-preview/azurestackhci/azurestackhciapi/interfaces.go b/services/preview/azurestackhci/mgmt/2021-01-01-preview/azurestackhci/azurestackhciapi/interfaces.go new file mode 100644 index 000000000000..bcd93cbb6839 --- /dev/null +++ b/services/preview/azurestackhci/mgmt/2021-01-01-preview/azurestackhci/azurestackhciapi/interfaces.go @@ -0,0 +1,57 @@ +package azurestackhciapi + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/services/preview/azurestackhci/mgmt/2021-01-01-preview/azurestackhci" + "github.com/Azure/go-autorest/autorest" +) + +// ArcSettingsClientAPI contains the set of methods on the ArcSettingsClient type. +type ArcSettingsClientAPI interface { + Create(ctx context.Context, resourceGroupName string, clusterName string, arcSettingName string, arcSetting azurestackhci.ArcSetting) (result azurestackhci.ArcSetting, err error) + Delete(ctx context.Context, resourceGroupName string, clusterName string, arcSettingName string) (result azurestackhci.ArcSettingsDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, clusterName string, arcSettingName string) (result azurestackhci.ArcSetting, err error) + ListByCluster(ctx context.Context, resourceGroupName string, clusterName string) (result azurestackhci.ArcSettingListPage, err error) + ListByClusterComplete(ctx context.Context, resourceGroupName string, clusterName string) (result azurestackhci.ArcSettingListIterator, err error) +} + +var _ ArcSettingsClientAPI = (*azurestackhci.ArcSettingsClient)(nil) + +// ClustersClientAPI contains the set of methods on the ClustersClient type. +type ClustersClientAPI interface { + Create(ctx context.Context, resourceGroupName string, clusterName string, cluster azurestackhci.Cluster) (result azurestackhci.Cluster, err error) + Delete(ctx context.Context, resourceGroupName string, clusterName string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, clusterName string) (result azurestackhci.Cluster, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string) (result azurestackhci.ClusterListPage, err error) + ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result azurestackhci.ClusterListIterator, err error) + ListBySubscription(ctx context.Context) (result azurestackhci.ClusterListPage, err error) + ListBySubscriptionComplete(ctx context.Context) (result azurestackhci.ClusterListIterator, err error) + Update(ctx context.Context, resourceGroupName string, clusterName string, cluster azurestackhci.ClusterPatch) (result azurestackhci.Cluster, err error) +} + +var _ ClustersClientAPI = (*azurestackhci.ClustersClient)(nil) + +// ExtensionsClientAPI contains the set of methods on the ExtensionsClient type. +type ExtensionsClientAPI interface { + Create(ctx context.Context, resourceGroupName string, clusterName string, arcSettingName string, extensionName string, extension azurestackhci.Extension) (result azurestackhci.ExtensionsCreateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, clusterName string, arcSettingName string, extensionName string) (result azurestackhci.ExtensionsDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, clusterName string, arcSettingName string, extensionName string) (result azurestackhci.Extension, err error) + ListByArcSetting(ctx context.Context, resourceGroupName string, clusterName string, arcSettingName string) (result azurestackhci.ExtensionListPage, err error) + ListByArcSettingComplete(ctx context.Context, resourceGroupName string, clusterName string, arcSettingName string) (result azurestackhci.ExtensionListIterator, err error) + Update(ctx context.Context, resourceGroupName string, clusterName string, arcSettingName string, extensionName string, extension azurestackhci.Extension) (result azurestackhci.ExtensionsUpdateFuture, err error) +} + +var _ ExtensionsClientAPI = (*azurestackhci.ExtensionsClient)(nil) + +// OperationsClientAPI contains the set of methods on the OperationsClient type. +type OperationsClientAPI interface { + List(ctx context.Context) (result azurestackhci.OperationListResult, err error) +} + +var _ OperationsClientAPI = (*azurestackhci.OperationsClient)(nil) diff --git a/services/preview/azurestackhci/mgmt/2021-01-01-preview/azurestackhci/client.go b/services/preview/azurestackhci/mgmt/2021-01-01-preview/azurestackhci/client.go new file mode 100644 index 000000000000..50b1665e8a18 --- /dev/null +++ b/services/preview/azurestackhci/mgmt/2021-01-01-preview/azurestackhci/client.go @@ -0,0 +1,41 @@ +// Package azurestackhci implements the Azure ARM Azurestackhci service API version 2021-01-01-preview. +// +// Azure Stack HCI management service +package azurestackhci + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" +) + +const ( + // DefaultBaseURI is the default URI used for the service Azurestackhci + DefaultBaseURI = "https://management.azure.com" +) + +// BaseClient is the base client for Azurestackhci. +type BaseClient struct { + autorest.Client + BaseURI string + SubscriptionID string +} + +// New creates an instance of the BaseClient client. +func New(subscriptionID string) BaseClient { + return NewWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewWithBaseURI creates an instance of the BaseClient client using a custom endpoint. Use this when interacting with +// an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { + return BaseClient{ + Client: autorest.NewClientWithUserAgent(UserAgent()), + BaseURI: baseURI, + SubscriptionID: subscriptionID, + } +} diff --git a/services/preview/azurestackhci/mgmt/2021-01-01-preview/azurestackhci/clusters.go b/services/preview/azurestackhci/mgmt/2021-01-01-preview/azurestackhci/clusters.go new file mode 100644 index 000000000000..8876c45a47ca --- /dev/null +++ b/services/preview/azurestackhci/mgmt/2021-01-01-preview/azurestackhci/clusters.go @@ -0,0 +1,627 @@ +package azurestackhci + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ClustersClient is the azure Stack HCI management service +type ClustersClient struct { + BaseClient +} + +// NewClustersClient creates an instance of the ClustersClient client. +func NewClustersClient(subscriptionID string) ClustersClient { + return NewClustersClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewClustersClientWithBaseURI creates an instance of the ClustersClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewClustersClientWithBaseURI(baseURI string, subscriptionID string) ClustersClient { + return ClustersClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Create create an HCI cluster. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// clusterName - the name of the cluster. +// cluster - details of the HCI cluster. +func (client ClustersClient) Create(ctx context.Context, resourceGroupName string, clusterName string, cluster Cluster) (result Cluster, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ClustersClient.Create") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: cluster, + Constraints: []validation.Constraint{{Target: "cluster.ClusterProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "cluster.ClusterProperties.AadClientID", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "cluster.ClusterProperties.AadTenantID", Name: validation.Null, Rule: true, Chain: nil}, + }}}}}); err != nil { + return result, validation.NewError("azurestackhci.ClustersClient", "Create", err.Error()) + } + + req, err := client.CreatePreparer(ctx, resourceGroupName, clusterName, cluster) + if err != nil { + err = autorest.NewErrorWithError(err, "azurestackhci.ClustersClient", "Create", nil, "Failure preparing request") + return + } + + resp, err := client.CreateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "azurestackhci.ClustersClient", "Create", resp, "Failure sending request") + return + } + + result, err = client.CreateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "azurestackhci.ClustersClient", "Create", resp, "Failure responding to request") + return + } + + return +} + +// CreatePreparer prepares the Create request. +func (client ClustersClient) CreatePreparer(ctx context.Context, resourceGroupName string, clusterName string, cluster Cluster) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "clusterName": autorest.Encode("path", clusterName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + cluster.SystemData = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}", pathParameters), + autorest.WithJSON(cluster), + 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 ClustersClient) CreateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client ClustersClient) CreateResponder(resp *http.Response) (result Cluster, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete an HCI cluster. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// clusterName - the name of the cluster. +func (client ClustersClient) Delete(ctx context.Context, resourceGroupName string, clusterName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ClustersClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("azurestackhci.ClustersClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, clusterName) + if err != nil { + err = autorest.NewErrorWithError(err, "azurestackhci.ClustersClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "azurestackhci.ClustersClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "azurestackhci.ClustersClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ClustersClient) DeletePreparer(ctx context.Context, resourceGroupName string, clusterName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "clusterName": autorest.Encode("path", clusterName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-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.AzureStackHCI/clusters/{clusterName}", 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 ClustersClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ClustersClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get get HCI cluster. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// clusterName - the name of the cluster. +func (client ClustersClient) Get(ctx context.Context, resourceGroupName string, clusterName string) (result Cluster, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ClustersClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("azurestackhci.ClustersClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, clusterName) + if err != nil { + err = autorest.NewErrorWithError(err, "azurestackhci.ClustersClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "azurestackhci.ClustersClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "azurestackhci.ClustersClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ClustersClient) GetPreparer(ctx context.Context, resourceGroupName string, clusterName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "clusterName": autorest.Encode("path", clusterName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}", 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 ClustersClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ClustersClient) GetResponder(resp *http.Response) (result Cluster, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByResourceGroup list all HCI clusters in a resource group. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +func (client ClustersClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result ClusterListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ClustersClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.cl.Response.Response != nil { + sc = result.cl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("azurestackhci.ClustersClient", "ListByResourceGroup", err.Error()) + } + + result.fn = client.listByResourceGroupNextResults + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "azurestackhci.ClustersClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.cl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "azurestackhci.ClustersClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result.cl, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "azurestackhci.ClustersClient", "ListByResourceGroup", resp, "Failure responding to request") + return + } + if result.cl.hasNextLink() && result.cl.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client ClustersClient) 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 = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters", 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 ClustersClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client ClustersClient) ListByResourceGroupResponder(resp *http.Response) (result ClusterList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByResourceGroupNextResults retrieves the next set of results, if any. +func (client ClustersClient) listByResourceGroupNextResults(ctx context.Context, lastResults ClusterList) (result ClusterList, err error) { + req, err := lastResults.clusterListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "azurestackhci.ClustersClient", "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, "azurestackhci.ClustersClient", "listByResourceGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "azurestackhci.ClustersClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. +func (client ClustersClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result ClusterListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ClustersClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByResourceGroup(ctx, resourceGroupName) + return +} + +// ListBySubscription list all HCI clusters in a subscription. +func (client ClustersClient) ListBySubscription(ctx context.Context) (result ClusterListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ClustersClient.ListBySubscription") + defer func() { + sc := -1 + if result.cl.Response.Response != nil { + sc = result.cl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("azurestackhci.ClustersClient", "ListBySubscription", err.Error()) + } + + result.fn = client.listBySubscriptionNextResults + req, err := client.ListBySubscriptionPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "azurestackhci.ClustersClient", "ListBySubscription", nil, "Failure preparing request") + return + } + + resp, err := client.ListBySubscriptionSender(req) + if err != nil { + result.cl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "azurestackhci.ClustersClient", "ListBySubscription", resp, "Failure sending request") + return + } + + result.cl, err = client.ListBySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "azurestackhci.ClustersClient", "ListBySubscription", resp, "Failure responding to request") + return + } + if result.cl.hasNextLink() && result.cl.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListBySubscriptionPreparer prepares the ListBySubscription request. +func (client ClustersClient) ListBySubscriptionPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.AzureStackHCI/clusters", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListBySubscriptionSender sends the ListBySubscription request. The method will close the +// http.Response Body if it receives an error. +func (client ClustersClient) ListBySubscriptionSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListBySubscriptionResponder handles the response to the ListBySubscription request. The method always +// closes the http.Response Body. +func (client ClustersClient) ListBySubscriptionResponder(resp *http.Response) (result ClusterList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listBySubscriptionNextResults retrieves the next set of results, if any. +func (client ClustersClient) listBySubscriptionNextResults(ctx context.Context, lastResults ClusterList) (result ClusterList, err error) { + req, err := lastResults.clusterListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "azurestackhci.ClustersClient", "listBySubscriptionNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListBySubscriptionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "azurestackhci.ClustersClient", "listBySubscriptionNextResults", resp, "Failure sending next results request") + } + result, err = client.ListBySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "azurestackhci.ClustersClient", "listBySubscriptionNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListBySubscriptionComplete enumerates all values, automatically crossing page boundaries as required. +func (client ClustersClient) ListBySubscriptionComplete(ctx context.Context) (result ClusterListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ClustersClient.ListBySubscription") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListBySubscription(ctx) + return +} + +// Update update an HCI cluster. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// clusterName - the name of the cluster. +// cluster - details of the HCI cluster. +func (client ClustersClient) Update(ctx context.Context, resourceGroupName string, clusterName string, cluster ClusterPatch) (result Cluster, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ClustersClient.Update") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("azurestackhci.ClustersClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, clusterName, cluster) + if err != nil { + err = autorest.NewErrorWithError(err, "azurestackhci.ClustersClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "azurestackhci.ClustersClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "azurestackhci.ClustersClient", "Update", resp, "Failure responding to request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client ClustersClient) UpdatePreparer(ctx context.Context, resourceGroupName string, clusterName string, cluster ClusterPatch) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "clusterName": autorest.Encode("path", clusterName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-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.AzureStackHCI/clusters/{clusterName}", pathParameters), + autorest.WithJSON(cluster), + 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 ClustersClient) UpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client ClustersClient) UpdateResponder(resp *http.Response) (result Cluster, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/azurestackhci/mgmt/2021-01-01-preview/azurestackhci/enums.go b/services/preview/azurestackhci/mgmt/2021-01-01-preview/azurestackhci/enums.go new file mode 100644 index 000000000000..0f2e62c894cc --- /dev/null +++ b/services/preview/azurestackhci/mgmt/2021-01-01-preview/azurestackhci/enums.go @@ -0,0 +1,250 @@ +package azurestackhci + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// ActionType enumerates the values for action type. +type ActionType string + +const ( + // ActionTypeInternal ... + ActionTypeInternal ActionType = "Internal" +) + +// PossibleActionTypeValues returns an array of possible values for the ActionType const type. +func PossibleActionTypeValues() []ActionType { + return []ActionType{ActionTypeInternal} +} + +// ArcSettingAggregateState enumerates the values for arc setting aggregate state. +type ArcSettingAggregateState string + +const ( + // ArcSettingAggregateStateCanceled ... + ArcSettingAggregateStateCanceled ArcSettingAggregateState = "Canceled" + // ArcSettingAggregateStateConnected ... + ArcSettingAggregateStateConnected ArcSettingAggregateState = "Connected" + // ArcSettingAggregateStateCreating ... + ArcSettingAggregateStateCreating ArcSettingAggregateState = "Creating" + // ArcSettingAggregateStateDeleted ... + ArcSettingAggregateStateDeleted ArcSettingAggregateState = "Deleted" + // ArcSettingAggregateStateDeleting ... + ArcSettingAggregateStateDeleting ArcSettingAggregateState = "Deleting" + // ArcSettingAggregateStateDisconnected ... + ArcSettingAggregateStateDisconnected ArcSettingAggregateState = "Disconnected" + // ArcSettingAggregateStateError ... + ArcSettingAggregateStateError ArcSettingAggregateState = "Error" + // ArcSettingAggregateStateFailed ... + ArcSettingAggregateStateFailed ArcSettingAggregateState = "Failed" + // ArcSettingAggregateStateInProgress ... + ArcSettingAggregateStateInProgress ArcSettingAggregateState = "InProgress" + // ArcSettingAggregateStateMoving ... + ArcSettingAggregateStateMoving ArcSettingAggregateState = "Moving" + // ArcSettingAggregateStateNotSpecified ... + ArcSettingAggregateStateNotSpecified ArcSettingAggregateState = "NotSpecified" + // ArcSettingAggregateStatePartiallyConnected ... + ArcSettingAggregateStatePartiallyConnected ArcSettingAggregateState = "PartiallyConnected" + // ArcSettingAggregateStatePartiallySucceeded ... + ArcSettingAggregateStatePartiallySucceeded ArcSettingAggregateState = "PartiallySucceeded" + // ArcSettingAggregateStateSucceeded ... + ArcSettingAggregateStateSucceeded ArcSettingAggregateState = "Succeeded" + // ArcSettingAggregateStateUpdating ... + ArcSettingAggregateStateUpdating ArcSettingAggregateState = "Updating" +) + +// PossibleArcSettingAggregateStateValues returns an array of possible values for the ArcSettingAggregateState const type. +func PossibleArcSettingAggregateStateValues() []ArcSettingAggregateState { + return []ArcSettingAggregateState{ArcSettingAggregateStateCanceled, ArcSettingAggregateStateConnected, ArcSettingAggregateStateCreating, ArcSettingAggregateStateDeleted, ArcSettingAggregateStateDeleting, ArcSettingAggregateStateDisconnected, ArcSettingAggregateStateError, ArcSettingAggregateStateFailed, ArcSettingAggregateStateInProgress, ArcSettingAggregateStateMoving, ArcSettingAggregateStateNotSpecified, ArcSettingAggregateStatePartiallyConnected, ArcSettingAggregateStatePartiallySucceeded, ArcSettingAggregateStateSucceeded, ArcSettingAggregateStateUpdating} +} + +// CreatedByType enumerates the values for created by type. +type CreatedByType string + +const ( + // CreatedByTypeApplication ... + CreatedByTypeApplication CreatedByType = "Application" + // CreatedByTypeKey ... + CreatedByTypeKey CreatedByType = "Key" + // CreatedByTypeManagedIdentity ... + CreatedByTypeManagedIdentity CreatedByType = "ManagedIdentity" + // CreatedByTypeUser ... + CreatedByTypeUser CreatedByType = "User" +) + +// PossibleCreatedByTypeValues returns an array of possible values for the CreatedByType const type. +func PossibleCreatedByTypeValues() []CreatedByType { + return []CreatedByType{CreatedByTypeApplication, CreatedByTypeKey, CreatedByTypeManagedIdentity, CreatedByTypeUser} +} + +// ExtensionAggregateState enumerates the values for extension aggregate state. +type ExtensionAggregateState string + +const ( + // ExtensionAggregateStateCanceled ... + ExtensionAggregateStateCanceled ExtensionAggregateState = "Canceled" + // ExtensionAggregateStateConnected ... + ExtensionAggregateStateConnected ExtensionAggregateState = "Connected" + // ExtensionAggregateStateCreating ... + ExtensionAggregateStateCreating ExtensionAggregateState = "Creating" + // ExtensionAggregateStateDeleted ... + ExtensionAggregateStateDeleted ExtensionAggregateState = "Deleted" + // ExtensionAggregateStateDeleting ... + ExtensionAggregateStateDeleting ExtensionAggregateState = "Deleting" + // ExtensionAggregateStateDisconnected ... + ExtensionAggregateStateDisconnected ExtensionAggregateState = "Disconnected" + // ExtensionAggregateStateError ... + ExtensionAggregateStateError ExtensionAggregateState = "Error" + // ExtensionAggregateStateFailed ... + ExtensionAggregateStateFailed ExtensionAggregateState = "Failed" + // ExtensionAggregateStateInProgress ... + ExtensionAggregateStateInProgress ExtensionAggregateState = "InProgress" + // ExtensionAggregateStateMoving ... + ExtensionAggregateStateMoving ExtensionAggregateState = "Moving" + // ExtensionAggregateStateNotSpecified ... + ExtensionAggregateStateNotSpecified ExtensionAggregateState = "NotSpecified" + // ExtensionAggregateStatePartiallyConnected ... + ExtensionAggregateStatePartiallyConnected ExtensionAggregateState = "PartiallyConnected" + // ExtensionAggregateStatePartiallySucceeded ... + ExtensionAggregateStatePartiallySucceeded ExtensionAggregateState = "PartiallySucceeded" + // ExtensionAggregateStateSucceeded ... + ExtensionAggregateStateSucceeded ExtensionAggregateState = "Succeeded" + // ExtensionAggregateStateUpdating ... + ExtensionAggregateStateUpdating ExtensionAggregateState = "Updating" +) + +// PossibleExtensionAggregateStateValues returns an array of possible values for the ExtensionAggregateState const type. +func PossibleExtensionAggregateStateValues() []ExtensionAggregateState { + return []ExtensionAggregateState{ExtensionAggregateStateCanceled, ExtensionAggregateStateConnected, ExtensionAggregateStateCreating, ExtensionAggregateStateDeleted, ExtensionAggregateStateDeleting, ExtensionAggregateStateDisconnected, ExtensionAggregateStateError, ExtensionAggregateStateFailed, ExtensionAggregateStateInProgress, ExtensionAggregateStateMoving, ExtensionAggregateStateNotSpecified, ExtensionAggregateStatePartiallyConnected, ExtensionAggregateStatePartiallySucceeded, ExtensionAggregateStateSucceeded, ExtensionAggregateStateUpdating} +} + +// NodeArcState enumerates the values for node arc state. +type NodeArcState string + +const ( + // NodeArcStateCanceled ... + NodeArcStateCanceled NodeArcState = "Canceled" + // NodeArcStateConnected ... + NodeArcStateConnected NodeArcState = "Connected" + // NodeArcStateCreating ... + NodeArcStateCreating NodeArcState = "Creating" + // NodeArcStateDeleted ... + NodeArcStateDeleted NodeArcState = "Deleted" + // NodeArcStateDeleting ... + NodeArcStateDeleting NodeArcState = "Deleting" + // NodeArcStateDisconnected ... + NodeArcStateDisconnected NodeArcState = "Disconnected" + // NodeArcStateError ... + NodeArcStateError NodeArcState = "Error" + // NodeArcStateFailed ... + NodeArcStateFailed NodeArcState = "Failed" + // NodeArcStateMoving ... + NodeArcStateMoving NodeArcState = "Moving" + // NodeArcStateNotSpecified ... + NodeArcStateNotSpecified NodeArcState = "NotSpecified" + // NodeArcStateSucceeded ... + NodeArcStateSucceeded NodeArcState = "Succeeded" + // NodeArcStateUpdating ... + NodeArcStateUpdating NodeArcState = "Updating" +) + +// PossibleNodeArcStateValues returns an array of possible values for the NodeArcState const type. +func PossibleNodeArcStateValues() []NodeArcState { + return []NodeArcState{NodeArcStateCanceled, NodeArcStateConnected, NodeArcStateCreating, NodeArcStateDeleted, NodeArcStateDeleting, NodeArcStateDisconnected, NodeArcStateError, NodeArcStateFailed, NodeArcStateMoving, NodeArcStateNotSpecified, NodeArcStateSucceeded, NodeArcStateUpdating} +} + +// NodeExtensionState enumerates the values for node extension state. +type NodeExtensionState string + +const ( + // NodeExtensionStateCanceled ... + NodeExtensionStateCanceled NodeExtensionState = "Canceled" + // NodeExtensionStateConnected ... + NodeExtensionStateConnected NodeExtensionState = "Connected" + // NodeExtensionStateCreating ... + NodeExtensionStateCreating NodeExtensionState = "Creating" + // NodeExtensionStateDeleted ... + NodeExtensionStateDeleted NodeExtensionState = "Deleted" + // NodeExtensionStateDeleting ... + NodeExtensionStateDeleting NodeExtensionState = "Deleting" + // NodeExtensionStateDisconnected ... + NodeExtensionStateDisconnected NodeExtensionState = "Disconnected" + // NodeExtensionStateError ... + NodeExtensionStateError NodeExtensionState = "Error" + // NodeExtensionStateFailed ... + NodeExtensionStateFailed NodeExtensionState = "Failed" + // NodeExtensionStateMoving ... + NodeExtensionStateMoving NodeExtensionState = "Moving" + // NodeExtensionStateNotSpecified ... + NodeExtensionStateNotSpecified NodeExtensionState = "NotSpecified" + // NodeExtensionStateSucceeded ... + NodeExtensionStateSucceeded NodeExtensionState = "Succeeded" + // NodeExtensionStateUpdating ... + NodeExtensionStateUpdating NodeExtensionState = "Updating" +) + +// PossibleNodeExtensionStateValues returns an array of possible values for the NodeExtensionState const type. +func PossibleNodeExtensionStateValues() []NodeExtensionState { + return []NodeExtensionState{NodeExtensionStateCanceled, NodeExtensionStateConnected, NodeExtensionStateCreating, NodeExtensionStateDeleted, NodeExtensionStateDeleting, NodeExtensionStateDisconnected, NodeExtensionStateError, NodeExtensionStateFailed, NodeExtensionStateMoving, NodeExtensionStateNotSpecified, NodeExtensionStateSucceeded, NodeExtensionStateUpdating} +} + +// Origin enumerates the values for origin. +type Origin string + +const ( + // OriginSystem ... + OriginSystem Origin = "system" + // OriginUser ... + OriginUser Origin = "user" + // OriginUsersystem ... + OriginUsersystem Origin = "user,system" +) + +// PossibleOriginValues returns an array of possible values for the Origin const type. +func PossibleOriginValues() []Origin { + return []Origin{OriginSystem, OriginUser, OriginUsersystem} +} + +// ProvisioningState enumerates the values for provisioning state. +type ProvisioningState string + +const ( + // ProvisioningStateAccepted ... + ProvisioningStateAccepted ProvisioningState = "Accepted" + // ProvisioningStateCanceled ... + ProvisioningStateCanceled ProvisioningState = "Canceled" + // ProvisioningStateFailed ... + ProvisioningStateFailed ProvisioningState = "Failed" + // ProvisioningStateProvisioning ... + ProvisioningStateProvisioning ProvisioningState = "Provisioning" + // ProvisioningStateSucceeded ... + ProvisioningStateSucceeded ProvisioningState = "Succeeded" +) + +// PossibleProvisioningStateValues returns an array of possible values for the ProvisioningState const type. +func PossibleProvisioningStateValues() []ProvisioningState { + return []ProvisioningState{ProvisioningStateAccepted, ProvisioningStateCanceled, ProvisioningStateFailed, ProvisioningStateProvisioning, ProvisioningStateSucceeded} +} + +// Status enumerates the values for status. +type Status string + +const ( + // StatusConnectedRecently ... + StatusConnectedRecently Status = "ConnectedRecently" + // StatusDisconnected ... + StatusDisconnected Status = "Disconnected" + // StatusError ... + StatusError Status = "Error" + // StatusNotConnectedRecently ... + StatusNotConnectedRecently Status = "NotConnectedRecently" + // StatusNotYetRegistered ... + StatusNotYetRegistered Status = "NotYetRegistered" +) + +// PossibleStatusValues returns an array of possible values for the Status const type. +func PossibleStatusValues() []Status { + return []Status{StatusConnectedRecently, StatusDisconnected, StatusError, StatusNotConnectedRecently, StatusNotYetRegistered} +} diff --git a/services/preview/azurestackhci/mgmt/2021-01-01-preview/azurestackhci/extensions.go b/services/preview/azurestackhci/mgmt/2021-01-01-preview/azurestackhci/extensions.go new file mode 100644 index 000000000000..d41e2ff8ebb9 --- /dev/null +++ b/services/preview/azurestackhci/mgmt/2021-01-01-preview/azurestackhci/extensions.go @@ -0,0 +1,530 @@ +package azurestackhci + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ExtensionsClient is the azure Stack HCI management service +type ExtensionsClient struct { + BaseClient +} + +// NewExtensionsClient creates an instance of the ExtensionsClient client. +func NewExtensionsClient(subscriptionID string) ExtensionsClient { + return NewExtensionsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewExtensionsClientWithBaseURI creates an instance of the ExtensionsClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewExtensionsClientWithBaseURI(baseURI string, subscriptionID string) ExtensionsClient { + return ExtensionsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Create create Extension for HCI cluster. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// clusterName - the name of the cluster. +// arcSettingName - the name of the proxy resource holding details of HCI ArcSetting information. +// extensionName - the name of the machine extension. +// extension - details of the Machine Extension to be created. +func (client ExtensionsClient) Create(ctx context.Context, resourceGroupName string, clusterName string, arcSettingName string, extensionName string, extension Extension) (result ExtensionsCreateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ExtensionsClient.Create") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("azurestackhci.ExtensionsClient", "Create", err.Error()) + } + + req, err := client.CreatePreparer(ctx, resourceGroupName, clusterName, arcSettingName, extensionName, extension) + if err != nil { + err = autorest.NewErrorWithError(err, "azurestackhci.ExtensionsClient", "Create", nil, "Failure preparing request") + return + } + + result, err = client.CreateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "azurestackhci.ExtensionsClient", "Create", nil, "Failure sending request") + return + } + + return +} + +// CreatePreparer prepares the Create request. +func (client ExtensionsClient) CreatePreparer(ctx context.Context, resourceGroupName string, clusterName string, arcSettingName string, extensionName string, extension Extension) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "arcSettingName": autorest.Encode("path", arcSettingName), + "clusterName": autorest.Encode("path", clusterName), + "extensionName": autorest.Encode("path", extensionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + extension.SystemData = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/arcSettings/{arcSettingName}/extensions/{extensionName}", pathParameters), + autorest.WithJSON(extension), + 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 ExtensionsClient) CreateSender(req *http.Request) (future ExtensionsCreateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client ExtensionsClient) CreateResponder(resp *http.Response) (result Extension, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete particular Arc Extension of HCI Cluster. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// clusterName - the name of the cluster. +// arcSettingName - the name of the proxy resource holding details of HCI ArcSetting information. +// extensionName - the name of the machine extension. +func (client ExtensionsClient) Delete(ctx context.Context, resourceGroupName string, clusterName string, arcSettingName string, extensionName string) (result ExtensionsDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ExtensionsClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("azurestackhci.ExtensionsClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, clusterName, arcSettingName, extensionName) + if err != nil { + err = autorest.NewErrorWithError(err, "azurestackhci.ExtensionsClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "azurestackhci.ExtensionsClient", "Delete", nil, "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ExtensionsClient) DeletePreparer(ctx context.Context, resourceGroupName string, clusterName string, arcSettingName string, extensionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "arcSettingName": autorest.Encode("path", arcSettingName), + "clusterName": autorest.Encode("path", clusterName), + "extensionName": autorest.Encode("path", extensionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-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.AzureStackHCI/clusters/{clusterName}/arcSettings/{arcSettingName}/extensions/{extensionName}", 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 ExtensionsClient) DeleteSender(req *http.Request) (future ExtensionsDeleteFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ExtensionsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get get particular Arc Extension of HCI Cluster. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// clusterName - the name of the cluster. +// arcSettingName - the name of the proxy resource holding details of HCI ArcSetting information. +// extensionName - the name of the machine extension. +func (client ExtensionsClient) Get(ctx context.Context, resourceGroupName string, clusterName string, arcSettingName string, extensionName string) (result Extension, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ExtensionsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("azurestackhci.ExtensionsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, clusterName, arcSettingName, extensionName) + if err != nil { + err = autorest.NewErrorWithError(err, "azurestackhci.ExtensionsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "azurestackhci.ExtensionsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "azurestackhci.ExtensionsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ExtensionsClient) GetPreparer(ctx context.Context, resourceGroupName string, clusterName string, arcSettingName string, extensionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "arcSettingName": autorest.Encode("path", arcSettingName), + "clusterName": autorest.Encode("path", clusterName), + "extensionName": autorest.Encode("path", extensionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/arcSettings/{arcSettingName}/extensions/{extensionName}", 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 ExtensionsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ExtensionsClient) GetResponder(resp *http.Response) (result Extension, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByArcSetting list all Extensions under ArcSetting resource. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// clusterName - the name of the cluster. +// arcSettingName - the name of the proxy resource holding details of HCI ArcSetting information. +func (client ExtensionsClient) ListByArcSetting(ctx context.Context, resourceGroupName string, clusterName string, arcSettingName string) (result ExtensionListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ExtensionsClient.ListByArcSetting") + defer func() { + sc := -1 + if result.el.Response.Response != nil { + sc = result.el.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("azurestackhci.ExtensionsClient", "ListByArcSetting", err.Error()) + } + + result.fn = client.listByArcSettingNextResults + req, err := client.ListByArcSettingPreparer(ctx, resourceGroupName, clusterName, arcSettingName) + if err != nil { + err = autorest.NewErrorWithError(err, "azurestackhci.ExtensionsClient", "ListByArcSetting", nil, "Failure preparing request") + return + } + + resp, err := client.ListByArcSettingSender(req) + if err != nil { + result.el.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "azurestackhci.ExtensionsClient", "ListByArcSetting", resp, "Failure sending request") + return + } + + result.el, err = client.ListByArcSettingResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "azurestackhci.ExtensionsClient", "ListByArcSetting", resp, "Failure responding to request") + return + } + if result.el.hasNextLink() && result.el.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByArcSettingPreparer prepares the ListByArcSetting request. +func (client ExtensionsClient) ListByArcSettingPreparer(ctx context.Context, resourceGroupName string, clusterName string, arcSettingName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "arcSettingName": autorest.Encode("path", arcSettingName), + "clusterName": autorest.Encode("path", clusterName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/arcSettings/{arcSettingName}/extensions", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByArcSettingSender sends the ListByArcSetting request. The method will close the +// http.Response Body if it receives an error. +func (client ExtensionsClient) ListByArcSettingSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByArcSettingResponder handles the response to the ListByArcSetting request. The method always +// closes the http.Response Body. +func (client ExtensionsClient) ListByArcSettingResponder(resp *http.Response) (result ExtensionList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByArcSettingNextResults retrieves the next set of results, if any. +func (client ExtensionsClient) listByArcSettingNextResults(ctx context.Context, lastResults ExtensionList) (result ExtensionList, err error) { + req, err := lastResults.extensionListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "azurestackhci.ExtensionsClient", "listByArcSettingNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByArcSettingSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "azurestackhci.ExtensionsClient", "listByArcSettingNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByArcSettingResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "azurestackhci.ExtensionsClient", "listByArcSettingNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByArcSettingComplete enumerates all values, automatically crossing page boundaries as required. +func (client ExtensionsClient) ListByArcSettingComplete(ctx context.Context, resourceGroupName string, clusterName string, arcSettingName string) (result ExtensionListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ExtensionsClient.ListByArcSetting") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByArcSetting(ctx, resourceGroupName, clusterName, arcSettingName) + return +} + +// Update update Extension for HCI cluster. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// clusterName - the name of the cluster. +// arcSettingName - the name of the proxy resource holding details of HCI ArcSetting information. +// extensionName - the name of the machine extension. +// extension - details of the Machine Extension to be created. +func (client ExtensionsClient) Update(ctx context.Context, resourceGroupName string, clusterName string, arcSettingName string, extensionName string, extension Extension) (result ExtensionsUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ExtensionsClient.Update") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("azurestackhci.ExtensionsClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, clusterName, arcSettingName, extensionName, extension) + if err != nil { + err = autorest.NewErrorWithError(err, "azurestackhci.ExtensionsClient", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "azurestackhci.ExtensionsClient", "Update", nil, "Failure sending request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client ExtensionsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, clusterName string, arcSettingName string, extensionName string, extension Extension) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "arcSettingName": autorest.Encode("path", arcSettingName), + "clusterName": autorest.Encode("path", clusterName), + "extensionName": autorest.Encode("path", extensionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + extension.SystemData = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/arcSettings/{arcSettingName}/extensions/{extensionName}", pathParameters), + autorest.WithJSON(extension), + 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 ExtensionsClient) UpdateSender(req *http.Request) (future ExtensionsUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client ExtensionsClient) UpdateResponder(resp *http.Response) (result Extension, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/azurestackhci/mgmt/2021-01-01-preview/azurestackhci/models.go b/services/preview/azurestackhci/mgmt/2021-01-01-preview/azurestackhci/models.go new file mode 100644 index 000000000000..86f5ba7f88a3 --- /dev/null +++ b/services/preview/azurestackhci/mgmt/2021-01-01-preview/azurestackhci/models.go @@ -0,0 +1,1442 @@ +package azurestackhci + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "encoding/json" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/date" + "github.com/Azure/go-autorest/autorest/to" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// The package's fully qualified name. +const fqdn = "github.com/Azure/azure-sdk-for-go/services/preview/azurestackhci/mgmt/2021-01-01-preview/azurestackhci" + +// ArcSetting arcSetting details. +type ArcSetting struct { + autorest.Response `json:"-"` + // SystemData - READ-ONLY; System data of ArcSetting resource + *SystemData `json:"systemData,omitempty"` + // ArcSettingProperties - ArcSetting properties. + *ArcSettingProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ArcSetting. +func (as ArcSetting) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if as.ArcSettingProperties != nil { + objectMap["properties"] = as.ArcSettingProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ArcSetting struct. +func (as *ArcSetting) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "systemData": + if v != nil { + var systemData SystemData + err = json.Unmarshal(*v, &systemData) + if err != nil { + return err + } + as.SystemData = &systemData + } + case "properties": + if v != nil { + var arcSettingProperties ArcSettingProperties + err = json.Unmarshal(*v, &arcSettingProperties) + if err != nil { + return err + } + as.ArcSettingProperties = &arcSettingProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + as.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + as.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + as.Type = &typeVar + } + } + } + + return nil +} + +// ArcSettingList list of ArcSetting proxy resources for the HCI cluster. +type ArcSettingList struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; List of ArcSetting proxy resources. + Value *[]ArcSetting `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to the next set of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for ArcSettingList. +func (asl ArcSettingList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ArcSettingListIterator provides access to a complete listing of ArcSetting values. +type ArcSettingListIterator struct { + i int + page ArcSettingListPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *ArcSettingListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ArcSettingListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ArcSettingListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ArcSettingListIterator) 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 ArcSettingListIterator) Response() ArcSettingList { + 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 ArcSettingListIterator) Value() ArcSetting { + if !iter.page.NotDone() { + return ArcSetting{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ArcSettingListIterator type. +func NewArcSettingListIterator(page ArcSettingListPage) ArcSettingListIterator { + return ArcSettingListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (asl ArcSettingList) IsEmpty() bool { + return asl.Value == nil || len(*asl.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (asl ArcSettingList) hasNextLink() bool { + return asl.NextLink != nil && len(*asl.NextLink) != 0 +} + +// arcSettingListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (asl ArcSettingList) arcSettingListPreparer(ctx context.Context) (*http.Request, error) { + if !asl.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(asl.NextLink))) +} + +// ArcSettingListPage contains a page of ArcSetting values. +type ArcSettingListPage struct { + fn func(context.Context, ArcSettingList) (ArcSettingList, error) + asl ArcSettingList +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *ArcSettingListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ArcSettingListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.asl) + if err != nil { + return err + } + page.asl = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *ArcSettingListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ArcSettingListPage) NotDone() bool { + return !page.asl.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ArcSettingListPage) Response() ArcSettingList { + return page.asl +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ArcSettingListPage) Values() []ArcSetting { + if page.asl.IsEmpty() { + return nil + } + return *page.asl.Value +} + +// Creates a new instance of the ArcSettingListPage type. +func NewArcSettingListPage(cur ArcSettingList, getNextPage func(context.Context, ArcSettingList) (ArcSettingList, error)) ArcSettingListPage { + return ArcSettingListPage{ + fn: getNextPage, + asl: cur, + } +} + +// ArcSettingProperties arcSetting properties. +type ArcSettingProperties struct { + // ProvisioningState - READ-ONLY; Provisioning state of the ArcSetting proxy resource. Possible values include: 'ProvisioningStateSucceeded', 'ProvisioningStateFailed', 'ProvisioningStateCanceled', 'ProvisioningStateAccepted', 'ProvisioningStateProvisioning' + ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` + // ArcInstanceResourceGroup - READ-ONLY; The resource group that hosts the Arc agents, ie. Hybrid Compute Machine resources. + ArcInstanceResourceGroup *string `json:"arcInstanceResourceGroup,omitempty"` + // AggregateState - READ-ONLY; Aggregate state of Arc agent across the nodes in this HCI cluster. Possible values include: 'ArcSettingAggregateStateNotSpecified', 'ArcSettingAggregateStateError', 'ArcSettingAggregateStateSucceeded', 'ArcSettingAggregateStateCanceled', 'ArcSettingAggregateStateFailed', 'ArcSettingAggregateStateConnected', 'ArcSettingAggregateStateDisconnected', 'ArcSettingAggregateStateDeleted', 'ArcSettingAggregateStateCreating', 'ArcSettingAggregateStateUpdating', 'ArcSettingAggregateStateDeleting', 'ArcSettingAggregateStateMoving', 'ArcSettingAggregateStatePartiallySucceeded', 'ArcSettingAggregateStatePartiallyConnected', 'ArcSettingAggregateStateInProgress' + AggregateState ArcSettingAggregateState `json:"aggregateState,omitempty"` + // PerNodeDetails - READ-ONLY; State of Arc agent in each of the nodes. + PerNodeDetails *[]PerNodeState `json:"perNodeDetails,omitempty"` +} + +// MarshalJSON is the custom marshaler for ArcSettingProperties. +func (asp ArcSettingProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ArcSettingsDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ArcSettingsDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ArcSettingsClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ArcSettingsDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ArcSettingsDeleteFuture.Result. +func (future *ArcSettingsDeleteFuture) result(client ArcSettingsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "azurestackhci.ArcSettingsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("azurestackhci.ArcSettingsDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// AzureEntityResource the resource model definition for an Azure Resource Manager resource with an etag. +type AzureEntityResource struct { + // Etag - READ-ONLY; Resource Etag. + Etag *string `json:"etag,omitempty"` + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for AzureEntityResource. +func (aer AzureEntityResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// Cluster cluster details. +type Cluster struct { + autorest.Response `json:"-"` + // SystemData - READ-ONLY; System data of Cluster resource + *SystemData `json:"systemData,omitempty"` + // ClusterProperties - Cluster properties. + *ClusterProperties `json:"properties,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // Location - The geo-location where the resource lives + Location *string `json:"location,omitempty"` + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Cluster. +func (c Cluster) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if c.ClusterProperties != nil { + objectMap["properties"] = c.ClusterProperties + } + if c.Tags != nil { + objectMap["tags"] = c.Tags + } + if c.Location != nil { + objectMap["location"] = c.Location + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Cluster struct. +func (c *Cluster) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "systemData": + if v != nil { + var systemData SystemData + err = json.Unmarshal(*v, &systemData) + if err != nil { + return err + } + c.SystemData = &systemData + } + case "properties": + if v != nil { + var clusterProperties ClusterProperties + err = json.Unmarshal(*v, &clusterProperties) + if err != nil { + return err + } + c.ClusterProperties = &clusterProperties + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + c.Tags = tags + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + c.Location = &location + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + c.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + c.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + c.Type = &typeVar + } + } + } + + return nil +} + +// ClusterList list of clusters. +type ClusterList struct { + autorest.Response `json:"-"` + // Value - List of clusters. + Value *[]Cluster `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to the next set of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for ClusterList. +func (cl ClusterList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if cl.Value != nil { + objectMap["value"] = cl.Value + } + return json.Marshal(objectMap) +} + +// ClusterListIterator provides access to a complete listing of Cluster values. +type ClusterListIterator struct { + i int + page ClusterListPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *ClusterListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ClusterListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ClusterListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ClusterListIterator) 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 ClusterListIterator) Response() ClusterList { + 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 ClusterListIterator) Value() Cluster { + if !iter.page.NotDone() { + return Cluster{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ClusterListIterator type. +func NewClusterListIterator(page ClusterListPage) ClusterListIterator { + return ClusterListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (cl ClusterList) IsEmpty() bool { + return cl.Value == nil || len(*cl.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (cl ClusterList) hasNextLink() bool { + return cl.NextLink != nil && len(*cl.NextLink) != 0 +} + +// clusterListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (cl ClusterList) clusterListPreparer(ctx context.Context) (*http.Request, error) { + if !cl.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(cl.NextLink))) +} + +// ClusterListPage contains a page of Cluster values. +type ClusterListPage struct { + fn func(context.Context, ClusterList) (ClusterList, error) + cl ClusterList +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *ClusterListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ClusterListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.cl) + if err != nil { + return err + } + page.cl = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *ClusterListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ClusterListPage) NotDone() bool { + return !page.cl.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ClusterListPage) Response() ClusterList { + return page.cl +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ClusterListPage) Values() []Cluster { + if page.cl.IsEmpty() { + return nil + } + return *page.cl.Value +} + +// Creates a new instance of the ClusterListPage type. +func NewClusterListPage(cur ClusterList, getNextPage func(context.Context, ClusterList) (ClusterList, error)) ClusterListPage { + return ClusterListPage{ + fn: getNextPage, + cl: cur, + } +} + +// ClusterNode cluster node details. +type ClusterNode struct { + // Name - READ-ONLY; Name of the cluster node. + Name *string `json:"name,omitempty"` + // ID - READ-ONLY; Id of the node in the cluster. + ID *float64 `json:"id,omitempty"` + // Manufacturer - READ-ONLY; Manufacturer of the cluster node hardware. + Manufacturer *string `json:"manufacturer,omitempty"` + // Model - READ-ONLY; Model name of the cluster node hardware. + Model *string `json:"model,omitempty"` + // OsName - READ-ONLY; Operating system running on the cluster node. + OsName *string `json:"osName,omitempty"` + // OsVersion - READ-ONLY; Version of the operating system running on the cluster node. + OsVersion *string `json:"osVersion,omitempty"` + // SerialNumber - READ-ONLY; Immutable id of the cluster node. + SerialNumber *string `json:"serialNumber,omitempty"` + // CoreCount - READ-ONLY; Number of physical cores on the cluster node. + CoreCount *float64 `json:"coreCount,omitempty"` + // MemoryInGiB - READ-ONLY; Total available memory on the cluster node (in GiB). + MemoryInGiB *float64 `json:"memoryInGiB,omitempty"` +} + +// MarshalJSON is the custom marshaler for ClusterNode. +func (cn ClusterNode) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ClusterPatch cluster details to update. +type ClusterPatch struct { + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // ClusterPatchProperties - Cluster properties. + *ClusterPatchProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for ClusterPatch. +func (cp ClusterPatch) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if cp.Tags != nil { + objectMap["tags"] = cp.Tags + } + if cp.ClusterPatchProperties != nil { + objectMap["properties"] = cp.ClusterPatchProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ClusterPatch struct. +func (cp *ClusterPatch) UnmarshalJSON(body []byte) error { + 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 + } + cp.Tags = tags + } + case "properties": + if v != nil { + var clusterPatchProperties ClusterPatchProperties + err = json.Unmarshal(*v, &clusterPatchProperties) + if err != nil { + return err + } + cp.ClusterPatchProperties = &clusterPatchProperties + } + } + } + + return nil +} + +// ClusterPatchProperties cluster properties. +type ClusterPatchProperties struct { + // CloudManagementEndpoint - Endpoint configured for management from the Azure portal + CloudManagementEndpoint *string `json:"cloudManagementEndpoint,omitempty"` +} + +// ClusterProperties cluster properties. +type ClusterProperties struct { + // ProvisioningState - READ-ONLY; Provisioning state. Possible values include: 'ProvisioningStateSucceeded', 'ProvisioningStateFailed', 'ProvisioningStateCanceled', 'ProvisioningStateAccepted', 'ProvisioningStateProvisioning' + ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` + // Status - READ-ONLY; Status of the cluster agent. Possible values include: 'StatusNotYetRegistered', 'StatusConnectedRecently', 'StatusNotConnectedRecently', 'StatusDisconnected', 'StatusError' + Status Status `json:"status,omitempty"` + // CloudID - READ-ONLY; Unique, immutable resource id. + CloudID *string `json:"cloudId,omitempty"` + // CloudManagementEndpoint - Endpoint configured for management from the Azure portal + CloudManagementEndpoint *string `json:"cloudManagementEndpoint,omitempty"` + // AadClientID - App id of cluster AAD identity. + AadClientID *string `json:"aadClientId,omitempty"` + // AadTenantID - Tenant id of cluster AAD identity. + AadTenantID *string `json:"aadTenantId,omitempty"` + // ReportedProperties - READ-ONLY; Properties reported by cluster agent. + ReportedProperties *ClusterReportedProperties `json:"reportedProperties,omitempty"` + // TrialDaysRemaining - READ-ONLY; Number of days remaining in the trial period. + TrialDaysRemaining *float64 `json:"trialDaysRemaining,omitempty"` + // BillingModel - READ-ONLY; Type of billing applied to the resource. + BillingModel *string `json:"billingModel,omitempty"` + // RegistrationTimestamp - READ-ONLY; First cluster sync timestamp. + RegistrationTimestamp *date.Time `json:"registrationTimestamp,omitempty"` + // LastSyncTimestamp - READ-ONLY; Most recent cluster sync timestamp. + LastSyncTimestamp *date.Time `json:"lastSyncTimestamp,omitempty"` + // LastBillingTimestamp - READ-ONLY; Most recent billing meter timestamp. + LastBillingTimestamp *date.Time `json:"lastBillingTimestamp,omitempty"` +} + +// MarshalJSON is the custom marshaler for ClusterProperties. +func (cp ClusterProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if cp.CloudManagementEndpoint != nil { + objectMap["cloudManagementEndpoint"] = cp.CloudManagementEndpoint + } + if cp.AadClientID != nil { + objectMap["aadClientId"] = cp.AadClientID + } + if cp.AadTenantID != nil { + objectMap["aadTenantId"] = cp.AadTenantID + } + return json.Marshal(objectMap) +} + +// ClusterReportedProperties properties reported by cluster agent. +type ClusterReportedProperties struct { + // ClusterName - READ-ONLY; Name of the on-prem cluster connected to this resource. + ClusterName *string `json:"clusterName,omitempty"` + // ClusterID - READ-ONLY; Unique id generated by the on-prem cluster. + ClusterID *string `json:"clusterId,omitempty"` + // ClusterVersion - READ-ONLY; Version of the cluster software. + ClusterVersion *string `json:"clusterVersion,omitempty"` + // Nodes - READ-ONLY; List of nodes reported by the cluster. + Nodes *[]ClusterNode `json:"nodes,omitempty"` + // LastUpdated - READ-ONLY; Last time the cluster reported the data. + LastUpdated *date.Time `json:"lastUpdated,omitempty"` +} + +// MarshalJSON is the custom marshaler for ClusterReportedProperties. +func (crp ClusterReportedProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ErrorAdditionalInfo the resource management error additional info. +type ErrorAdditionalInfo struct { + // Type - READ-ONLY; The additional info type. + Type *string `json:"type,omitempty"` + // Info - READ-ONLY; The additional info. + Info interface{} `json:"info,omitempty"` +} + +// MarshalJSON is the custom marshaler for ErrorAdditionalInfo. +func (eai ErrorAdditionalInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ErrorDetail the error detail. +type ErrorDetail struct { + // Code - READ-ONLY; The error code. + Code *string `json:"code,omitempty"` + // Message - READ-ONLY; The error message. + Message *string `json:"message,omitempty"` + // Target - READ-ONLY; The error target. + Target *string `json:"target,omitempty"` + // Details - READ-ONLY; The error details. + Details *[]ErrorDetail `json:"details,omitempty"` + // AdditionalInfo - READ-ONLY; The error additional info. + AdditionalInfo *[]ErrorAdditionalInfo `json:"additionalInfo,omitempty"` +} + +// MarshalJSON is the custom marshaler for ErrorDetail. +func (ed ErrorDetail) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ErrorResponse common error response for all Azure Resource Manager APIs to return error details for +// failed operations. (This also follows the OData error response format.). +type ErrorResponse struct { + // Error - The error object. + Error *ErrorDetail `json:"error,omitempty"` +} + +// Extension details of a particular extension in HCI Cluster. +type Extension struct { + autorest.Response `json:"-"` + // SystemData - READ-ONLY; System data of Extension resource. + *SystemData `json:"systemData,omitempty"` + // ExtensionProperties - Describes Machine Extension Properties. + *ExtensionProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Extension. +func (e Extension) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if e.ExtensionProperties != nil { + objectMap["properties"] = e.ExtensionProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Extension struct. +func (e *Extension) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "systemData": + if v != nil { + var systemData SystemData + err = json.Unmarshal(*v, &systemData) + if err != nil { + return err + } + e.SystemData = &systemData + } + case "properties": + if v != nil { + var extensionProperties ExtensionProperties + err = json.Unmarshal(*v, &extensionProperties) + if err != nil { + return err + } + e.ExtensionProperties = &extensionProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + e.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + e.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + e.Type = &typeVar + } + } + } + + return nil +} + +// ExtensionList list of Extensions in HCI cluster. +type ExtensionList struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; List of Extensions in HCI cluster. + Value *[]Extension `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to the next set of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for ExtensionList. +func (el ExtensionList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ExtensionListIterator provides access to a complete listing of Extension values. +type ExtensionListIterator struct { + i int + page ExtensionListPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *ExtensionListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ExtensionListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ExtensionListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ExtensionListIterator) 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 ExtensionListIterator) Response() ExtensionList { + 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 ExtensionListIterator) Value() Extension { + if !iter.page.NotDone() { + return Extension{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ExtensionListIterator type. +func NewExtensionListIterator(page ExtensionListPage) ExtensionListIterator { + return ExtensionListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (el ExtensionList) IsEmpty() bool { + return el.Value == nil || len(*el.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (el ExtensionList) hasNextLink() bool { + return el.NextLink != nil && len(*el.NextLink) != 0 +} + +// extensionListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (el ExtensionList) extensionListPreparer(ctx context.Context) (*http.Request, error) { + if !el.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(el.NextLink))) +} + +// ExtensionListPage contains a page of Extension values. +type ExtensionListPage struct { + fn func(context.Context, ExtensionList) (ExtensionList, error) + el ExtensionList +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *ExtensionListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ExtensionListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.el) + if err != nil { + return err + } + page.el = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *ExtensionListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ExtensionListPage) NotDone() bool { + return !page.el.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ExtensionListPage) Response() ExtensionList { + return page.el +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ExtensionListPage) Values() []Extension { + if page.el.IsEmpty() { + return nil + } + return *page.el.Value +} + +// Creates a new instance of the ExtensionListPage type. +func NewExtensionListPage(cur ExtensionList, getNextPage func(context.Context, ExtensionList) (ExtensionList, error)) ExtensionListPage { + return ExtensionListPage{ + fn: getNextPage, + el: cur, + } +} + +// ExtensionParameters describes the properties of a Machine Extension. This object mirrors the definition +// in HybridCompute. +type ExtensionParameters struct { + // ForceUpdateTag - How the extension handler should be forced to update even if the extension configuration has not changed. + ForceUpdateTag *string `json:"forceUpdateTag,omitempty"` + // Publisher - The name of the extension handler publisher. + Publisher *string `json:"publisher,omitempty"` + // Type - Specifies the type of the extension; an example is "CustomScriptExtension". + Type *string `json:"type,omitempty"` + // TypeHandlerVersion - Specifies the version of the script handler. + TypeHandlerVersion *string `json:"typeHandlerVersion,omitempty"` + // AutoUpgradeMinorVersion - Indicates whether the extension should use a newer minor version if one is available at deployment time. Once deployed, however, the extension will not upgrade minor versions unless redeployed, even with this property set to true. + AutoUpgradeMinorVersion *bool `json:"autoUpgradeMinorVersion,omitempty"` + // Settings - Json formatted public settings for the extension. + Settings interface{} `json:"settings,omitempty"` + // ProtectedSettings - Protected settings (may contain secrets). + ProtectedSettings interface{} `json:"protectedSettings,omitempty"` +} + +// ExtensionProperties status of Arc Extension for a particular node in HCI Cluster. +type ExtensionProperties struct { + // ProvisioningState - READ-ONLY; Provisioning state of the Extension proxy resource. Possible values include: 'ProvisioningStateSucceeded', 'ProvisioningStateFailed', 'ProvisioningStateCanceled', 'ProvisioningStateAccepted', 'ProvisioningStateProvisioning' + ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` + // ExtensionParameters - Parameters specific to this extension type. + *ExtensionParameters `json:"extensionParameters,omitempty"` + // AggregateState - READ-ONLY; Aggregate state of Arc Extensions across the nodes in this HCI cluster. Possible values include: 'ExtensionAggregateStateNotSpecified', 'ExtensionAggregateStateError', 'ExtensionAggregateStateSucceeded', 'ExtensionAggregateStateCanceled', 'ExtensionAggregateStateFailed', 'ExtensionAggregateStateConnected', 'ExtensionAggregateStateDisconnected', 'ExtensionAggregateStateDeleted', 'ExtensionAggregateStateCreating', 'ExtensionAggregateStateUpdating', 'ExtensionAggregateStateDeleting', 'ExtensionAggregateStateMoving', 'ExtensionAggregateStatePartiallySucceeded', 'ExtensionAggregateStatePartiallyConnected', 'ExtensionAggregateStateInProgress' + AggregateState ExtensionAggregateState `json:"aggregateState,omitempty"` + // PerNodeExtensionDetails - READ-ONLY; State of Arc Extension in each of the nodes. + PerNodeExtensionDetails *[]PerNodeExtensionState `json:"perNodeExtensionDetails,omitempty"` +} + +// MarshalJSON is the custom marshaler for ExtensionProperties. +func (ep ExtensionProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ep.ExtensionParameters != nil { + objectMap["extensionParameters"] = ep.ExtensionParameters + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ExtensionProperties struct. +func (ep *ExtensionProperties) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "provisioningState": + if v != nil { + var provisioningState ProvisioningState + err = json.Unmarshal(*v, &provisioningState) + if err != nil { + return err + } + ep.ProvisioningState = provisioningState + } + case "extensionParameters": + if v != nil { + var extensionParameters ExtensionParameters + err = json.Unmarshal(*v, &extensionParameters) + if err != nil { + return err + } + ep.ExtensionParameters = &extensionParameters + } + case "aggregateState": + if v != nil { + var aggregateState ExtensionAggregateState + err = json.Unmarshal(*v, &aggregateState) + if err != nil { + return err + } + ep.AggregateState = aggregateState + } + case "perNodeExtensionDetails": + if v != nil { + var perNodeExtensionDetails []PerNodeExtensionState + err = json.Unmarshal(*v, &perNodeExtensionDetails) + if err != nil { + return err + } + ep.PerNodeExtensionDetails = &perNodeExtensionDetails + } + } + } + + return nil +} + +// ExtensionsCreateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ExtensionsCreateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ExtensionsClient) (Extension, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ExtensionsCreateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ExtensionsCreateFuture.Result. +func (future *ExtensionsCreateFuture) result(client ExtensionsClient) (e Extension, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "azurestackhci.ExtensionsCreateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + e.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("azurestackhci.ExtensionsCreateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if e.Response.Response, err = future.GetResult(sender); err == nil && e.Response.Response.StatusCode != http.StatusNoContent { + e, err = client.CreateResponder(e.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "azurestackhci.ExtensionsCreateFuture", "Result", e.Response.Response, "Failure responding to request") + } + } + return +} + +// ExtensionsDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ExtensionsDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ExtensionsClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ExtensionsDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ExtensionsDeleteFuture.Result. +func (future *ExtensionsDeleteFuture) result(client ExtensionsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "azurestackhci.ExtensionsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("azurestackhci.ExtensionsDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// ExtensionsUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ExtensionsUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ExtensionsClient) (Extension, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ExtensionsUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ExtensionsUpdateFuture.Result. +func (future *ExtensionsUpdateFuture) result(client ExtensionsClient) (e Extension, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "azurestackhci.ExtensionsUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + e.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("azurestackhci.ExtensionsUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if e.Response.Response, err = future.GetResult(sender); err == nil && e.Response.Response.StatusCode != http.StatusNoContent { + e, err = client.UpdateResponder(e.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "azurestackhci.ExtensionsUpdateFuture", "Result", e.Response.Response, "Failure responding to request") + } + } + return +} + +// Operation details of a REST API operation, returned from the Resource Provider Operations API +type Operation struct { + // Name - READ-ONLY; The name of the operation, as per Resource-Based Access Control (RBAC). Examples: "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action" + Name *string `json:"name,omitempty"` + // IsDataAction - READ-ONLY; Whether the operation applies to data-plane. This is "true" for data-plane operations and "false" for ARM/control-plane operations. + IsDataAction *bool `json:"isDataAction,omitempty"` + // Display - Localized display information for this particular operation. + Display *OperationDisplay `json:"display,omitempty"` + // Origin - READ-ONLY; The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default value is "user,system". Possible values include: 'OriginUser', 'OriginSystem', 'OriginUsersystem' + Origin Origin `json:"origin,omitempty"` + // ActionType - READ-ONLY; Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. Possible values include: 'ActionTypeInternal' + ActionType ActionType `json:"actionType,omitempty"` +} + +// MarshalJSON is the custom marshaler for Operation. +func (o Operation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if o.Display != nil { + objectMap["display"] = o.Display + } + return json.Marshal(objectMap) +} + +// OperationDisplay localized display information for this particular operation. +type OperationDisplay struct { + // Provider - READ-ONLY; The localized friendly form of the resource provider name, e.g. "Microsoft Monitoring Insights" or "Microsoft Compute". + Provider *string `json:"provider,omitempty"` + // Resource - READ-ONLY; The localized friendly name of the resource type related to this operation. E.g. "Virtual Machines" or "Job Schedule Collections". + Resource *string `json:"resource,omitempty"` + // Operation - READ-ONLY; The concise, localized friendly name for the operation; suitable for dropdowns. E.g. "Create or Update Virtual Machine", "Restart Virtual Machine". + Operation *string `json:"operation,omitempty"` + // Description - READ-ONLY; The short, localized friendly description of the operation; suitable for tool tips and detailed views. + Description *string `json:"description,omitempty"` +} + +// MarshalJSON is the custom marshaler for OperationDisplay. +func (o OperationDisplay) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// OperationListResult a list of REST API operations supported by an Azure Resource Provider. It contains +// an URL link to get the next set of results. +type OperationListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; List of operations supported by the resource provider + Value *[]Operation `json:"value,omitempty"` + // NextLink - READ-ONLY; URL to get the next set of operation list results (if there are any). + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for OperationListResult. +func (olr OperationListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// PerNodeExtensionState status of Arc Extension for a particular node in HCI Cluster. +type PerNodeExtensionState struct { + // Name - READ-ONLY; Name of the node in HCI Cluster. + Name *string `json:"name,omitempty"` + // Extension - READ-ONLY; Fully qualified resource ID for the particular Arc Extension on this node. + Extension *string `json:"extension,omitempty"` + // State - READ-ONLY; State of Arc Extension in this node. Possible values include: 'NodeExtensionStateNotSpecified', 'NodeExtensionStateError', 'NodeExtensionStateSucceeded', 'NodeExtensionStateCanceled', 'NodeExtensionStateFailed', 'NodeExtensionStateConnected', 'NodeExtensionStateDisconnected', 'NodeExtensionStateDeleted', 'NodeExtensionStateCreating', 'NodeExtensionStateUpdating', 'NodeExtensionStateDeleting', 'NodeExtensionStateMoving' + State NodeExtensionState `json:"state,omitempty"` +} + +// MarshalJSON is the custom marshaler for PerNodeExtensionState. +func (pnes PerNodeExtensionState) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// PerNodeState status of Arc agent for a particular node in HCI Cluster. +type PerNodeState struct { + // Name - READ-ONLY; Name of the Node in HCI Cluster + Name *string `json:"name,omitempty"` + // ArcInstance - READ-ONLY; Fully qualified resource ID for the Arc agent of this node. + ArcInstance *string `json:"arcInstance,omitempty"` + // State - READ-ONLY; State of Arc agent in this node. Possible values include: 'NodeArcStateNotSpecified', 'NodeArcStateError', 'NodeArcStateSucceeded', 'NodeArcStateCanceled', 'NodeArcStateFailed', 'NodeArcStateConnected', 'NodeArcStateDisconnected', 'NodeArcStateDeleted', 'NodeArcStateCreating', 'NodeArcStateUpdating', 'NodeArcStateDeleting', 'NodeArcStateMoving' + State NodeArcState `json:"state,omitempty"` +} + +// MarshalJSON is the custom marshaler for PerNodeState. +func (pns PerNodeState) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ProxyResource the resource model definition for a Azure Resource Manager proxy resource. It will not +// have tags and a location +type ProxyResource struct { + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ProxyResource. +func (pr ProxyResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// Resource common fields that are returned in the response for all Azure Resource Manager resources +type Resource struct { + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Resource. +func (r Resource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// SystemData metadata pertaining to creation and last modification of the resource. +type SystemData struct { + // CreatedBy - The identity that created the resource. + CreatedBy *string `json:"createdBy,omitempty"` + // CreatedByType - The type of identity that created the resource. Possible values include: 'CreatedByTypeUser', 'CreatedByTypeApplication', 'CreatedByTypeManagedIdentity', 'CreatedByTypeKey' + CreatedByType CreatedByType `json:"createdByType,omitempty"` + // CreatedAt - The timestamp of resource creation (UTC). + CreatedAt *date.Time `json:"createdAt,omitempty"` + // LastModifiedBy - The identity that last modified the resource. + LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + // LastModifiedByType - The type of identity that last modified the resource. Possible values include: 'CreatedByTypeUser', 'CreatedByTypeApplication', 'CreatedByTypeManagedIdentity', 'CreatedByTypeKey' + LastModifiedByType CreatedByType `json:"lastModifiedByType,omitempty"` + // LastModifiedAt - The timestamp of resource last modification (UTC) + LastModifiedAt *date.Time `json:"lastModifiedAt,omitempty"` +} + +// TrackedResource the resource model definition for an Azure Resource Manager tracked top level resource +// which has 'tags' and a 'location' +type TrackedResource struct { + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // Location - The geo-location where the resource lives + Location *string `json:"location,omitempty"` + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + 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 + } + return json.Marshal(objectMap) +} diff --git a/services/preview/azurestackhci/mgmt/2021-01-01-preview/azurestackhci/operations.go b/services/preview/azurestackhci/mgmt/2021-01-01-preview/azurestackhci/operations.go new file mode 100644 index 000000000000..a6c3184d3485 --- /dev/null +++ b/services/preview/azurestackhci/mgmt/2021-01-01-preview/azurestackhci/operations.go @@ -0,0 +1,98 @@ +package azurestackhci + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// OperationsClient is the azure Stack HCI management service +type OperationsClient struct { + BaseClient +} + +// NewOperationsClient creates an instance of the OperationsClient client. +func NewOperationsClient(subscriptionID string) OperationsClient { + return NewOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewOperationsClientWithBaseURI creates an instance of the OperationsClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient { + return OperationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List list all available Microsoft.AzureStackHCI provider operations +func (client OperationsClient) List(ctx context.Context) (result OperationListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "azurestackhci.OperationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "azurestackhci.OperationsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "azurestackhci.OperationsClient", "List", resp, "Failure responding to request") + return + } + + return +} + +// ListPreparer prepares the List request. +func (client OperationsClient) ListPreparer(ctx context.Context) (*http.Request, error) { + const APIVersion = "2021-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.AzureStackHCI/operations"), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client OperationsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client OperationsClient) ListResponder(resp *http.Response) (result OperationListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/azurestackhci/mgmt/2021-01-01-preview/azurestackhci/version.go b/services/preview/azurestackhci/mgmt/2021-01-01-preview/azurestackhci/version.go new file mode 100644 index 000000000000..8a4d66fa8d22 --- /dev/null +++ b/services/preview/azurestackhci/mgmt/2021-01-01-preview/azurestackhci/version.go @@ -0,0 +1,19 @@ +package azurestackhci + +import "github.com/Azure/azure-sdk-for-go/version" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// UserAgent returns the UserAgent string to use when sending http.Requests. +func UserAgent() string { + return "Azure-SDK-For-Go/" + Version() + " azurestackhci/2021-01-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/hybridkubernetes/mgmt/2021-04-01-preview/hybridkubernetes/CHANGELOG.md b/services/preview/hybridkubernetes/mgmt/2021-04-01-preview/hybridkubernetes/CHANGELOG.md new file mode 100644 index 000000000000..52911e4cc5e4 --- /dev/null +++ b/services/preview/hybridkubernetes/mgmt/2021-04-01-preview/hybridkubernetes/CHANGELOG.md @@ -0,0 +1,2 @@ +# Change History + diff --git a/services/preview/hybridkubernetes/mgmt/2021-04-01-preview/hybridkubernetes/_meta.json b/services/preview/hybridkubernetes/mgmt/2021-04-01-preview/hybridkubernetes/_meta.json new file mode 100644 index 000000000000..cd599d691173 --- /dev/null +++ b/services/preview/hybridkubernetes/mgmt/2021-04-01-preview/hybridkubernetes/_meta.json @@ -0,0 +1,11 @@ +{ + "commit": "8dff86df71bee429af84ea4713288ef3cdd1db2f", + "readme": "/_/azure-rest-api-specs/specification/hybridkubernetes/resource-manager/readme.md", + "tag": "package-2021-04-01-preview", + "use": "@microsoft.azure/autorest.go@2.1.183", + "repository_url": "https://github.com/Azure/azure-rest-api-specs.git", + "autorest_command": "autorest --use=@microsoft.azure/autorest.go@2.1.183 --tag=package-2021-04-01-preview --go-sdk-folder=/_/azure-sdk-for-go --go --verbose --use-onever --version=V2 --go.license-header=MICROSOFT_MIT_NO_VERSION --enum-prefix /_/azure-rest-api-specs/specification/hybridkubernetes/resource-manager/readme.md", + "additional_properties": { + "additional_options": "--go --verbose --use-onever --version=V2 --go.license-header=MICROSOFT_MIT_NO_VERSION --enum-prefix" + } +} \ No newline at end of file diff --git a/services/preview/hybridkubernetes/mgmt/2021-04-01-preview/hybridkubernetes/client.go b/services/preview/hybridkubernetes/mgmt/2021-04-01-preview/hybridkubernetes/client.go new file mode 100644 index 000000000000..2c3bf3e9ac89 --- /dev/null +++ b/services/preview/hybridkubernetes/mgmt/2021-04-01-preview/hybridkubernetes/client.go @@ -0,0 +1,41 @@ +// Package hybridkubernetes implements the Azure ARM Hybridkubernetes service API version 2021-04-01-preview. +// +// Azure Connected Cluster Resource Provider API for adopting any Kubernetes Cluster +package hybridkubernetes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" +) + +const ( + // DefaultBaseURI is the default URI used for the service Hybridkubernetes + DefaultBaseURI = "https://management.azure.com" +) + +// BaseClient is the base client for Hybridkubernetes. +type BaseClient struct { + autorest.Client + BaseURI string + SubscriptionID string +} + +// New creates an instance of the BaseClient client. +func New(subscriptionID string) BaseClient { + return NewWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewWithBaseURI creates an instance of the BaseClient client using a custom endpoint. Use this when interacting with +// an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { + return BaseClient{ + Client: autorest.NewClientWithUserAgent(UserAgent()), + BaseURI: baseURI, + SubscriptionID: subscriptionID, + } +} diff --git a/services/preview/hybridkubernetes/mgmt/2021-04-01-preview/hybridkubernetes/connectedcluster.go b/services/preview/hybridkubernetes/mgmt/2021-04-01-preview/hybridkubernetes/connectedcluster.go new file mode 100644 index 000000000000..f1adc9a15c34 --- /dev/null +++ b/services/preview/hybridkubernetes/mgmt/2021-04-01-preview/hybridkubernetes/connectedcluster.go @@ -0,0 +1,725 @@ +package hybridkubernetes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ConnectedClusterClient is the azure Connected Cluster Resource Provider API for adopting any Kubernetes Cluster +type ConnectedClusterClient struct { + BaseClient +} + +// NewConnectedClusterClient creates an instance of the ConnectedClusterClient client. +func NewConnectedClusterClient(subscriptionID string) ConnectedClusterClient { + return NewConnectedClusterClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewConnectedClusterClientWithBaseURI creates an instance of the ConnectedClusterClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewConnectedClusterClientWithBaseURI(baseURI string, subscriptionID string) ConnectedClusterClient { + return ConnectedClusterClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Create API to register a new Kubernetes cluster and create a tracked resource in Azure Resource Manager (ARM). +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// clusterName - the name of the Kubernetes cluster on which get is called. +// connectedCluster - parameters supplied to Create a Connected Cluster. +func (client ConnectedClusterClient) Create(ctx context.Context, resourceGroupName string, clusterName string, connectedCluster ConnectedCluster) (result ConnectedClusterCreateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConnectedClusterClient.Create") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: connectedCluster, + Constraints: []validation.Constraint{{Target: "connectedCluster.Identity", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "connectedCluster.ConnectedClusterProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "connectedCluster.ConnectedClusterProperties.AgentPublicKeyCertificate", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("hybridkubernetes.ConnectedClusterClient", "Create", err.Error()) + } + + req, err := client.CreatePreparer(ctx, resourceGroupName, clusterName, connectedCluster) + if err != nil { + err = autorest.NewErrorWithError(err, "hybridkubernetes.ConnectedClusterClient", "Create", nil, "Failure preparing request") + return + } + + result, err = client.CreateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "hybridkubernetes.ConnectedClusterClient", "Create", nil, "Failure sending request") + return + } + + return +} + +// CreatePreparer prepares the Create request. +func (client ConnectedClusterClient) CreatePreparer(ctx context.Context, resourceGroupName string, clusterName string, connectedCluster ConnectedCluster) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "clusterName": autorest.Encode("path", clusterName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-04-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + connectedCluster.SystemData = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Kubernetes/connectedClusters/{clusterName}", pathParameters), + autorest.WithJSON(connectedCluster), + 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 ConnectedClusterClient) CreateSender(req *http.Request) (future ConnectedClusterCreateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client ConnectedClusterClient) CreateResponder(resp *http.Response) (result ConnectedCluster, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete a connected cluster, removing the tracked resource in Azure Resource Manager (ARM). +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// clusterName - the name of the Kubernetes cluster on which get is called. +func (client ConnectedClusterClient) Delete(ctx context.Context, resourceGroupName string, clusterName string) (result ConnectedClusterDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConnectedClusterClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("hybridkubernetes.ConnectedClusterClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, clusterName) + if err != nil { + err = autorest.NewErrorWithError(err, "hybridkubernetes.ConnectedClusterClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "hybridkubernetes.ConnectedClusterClient", "Delete", nil, "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ConnectedClusterClient) DeletePreparer(ctx context.Context, resourceGroupName string, clusterName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "clusterName": autorest.Encode("path", clusterName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-04-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.Kubernetes/connectedClusters/{clusterName}", 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 ConnectedClusterClient) DeleteSender(req *http.Request) (future ConnectedClusterDeleteFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ConnectedClusterClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get returns the properties of the specified connected cluster, including name, identity, properties, and additional +// cluster details. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// clusterName - the name of the Kubernetes cluster on which get is called. +func (client ConnectedClusterClient) Get(ctx context.Context, resourceGroupName string, clusterName string) (result ConnectedCluster, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConnectedClusterClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("hybridkubernetes.ConnectedClusterClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, clusterName) + if err != nil { + err = autorest.NewErrorWithError(err, "hybridkubernetes.ConnectedClusterClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "hybridkubernetes.ConnectedClusterClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "hybridkubernetes.ConnectedClusterClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ConnectedClusterClient) GetPreparer(ctx context.Context, resourceGroupName string, clusterName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "clusterName": autorest.Encode("path", clusterName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-04-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Kubernetes/connectedClusters/{clusterName}", 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 ConnectedClusterClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ConnectedClusterClient) GetResponder(resp *http.Response) (result ConnectedCluster, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByResourceGroup API to enumerate registered connected K8s clusters under a Resource Group +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +func (client ConnectedClusterClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result ConnectedClusterListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConnectedClusterClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.ccl.Response.Response != nil { + sc = result.ccl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("hybridkubernetes.ConnectedClusterClient", "ListByResourceGroup", err.Error()) + } + + result.fn = client.listByResourceGroupNextResults + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "hybridkubernetes.ConnectedClusterClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.ccl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "hybridkubernetes.ConnectedClusterClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result.ccl, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "hybridkubernetes.ConnectedClusterClient", "ListByResourceGroup", resp, "Failure responding to request") + return + } + if result.ccl.hasNextLink() && result.ccl.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client ConnectedClusterClient) 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 = "2021-04-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Kubernetes/connectedClusters", 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 ConnectedClusterClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client ConnectedClusterClient) ListByResourceGroupResponder(resp *http.Response) (result ConnectedClusterList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByResourceGroupNextResults retrieves the next set of results, if any. +func (client ConnectedClusterClient) listByResourceGroupNextResults(ctx context.Context, lastResults ConnectedClusterList) (result ConnectedClusterList, err error) { + req, err := lastResults.connectedClusterListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "hybridkubernetes.ConnectedClusterClient", "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, "hybridkubernetes.ConnectedClusterClient", "listByResourceGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "hybridkubernetes.ConnectedClusterClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. +func (client ConnectedClusterClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result ConnectedClusterListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConnectedClusterClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByResourceGroup(ctx, resourceGroupName) + return +} + +// ListBySubscription API to enumerate registered connected K8s clusters under a Subscription +func (client ConnectedClusterClient) ListBySubscription(ctx context.Context) (result ConnectedClusterListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConnectedClusterClient.ListBySubscription") + defer func() { + sc := -1 + if result.ccl.Response.Response != nil { + sc = result.ccl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("hybridkubernetes.ConnectedClusterClient", "ListBySubscription", err.Error()) + } + + result.fn = client.listBySubscriptionNextResults + req, err := client.ListBySubscriptionPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "hybridkubernetes.ConnectedClusterClient", "ListBySubscription", nil, "Failure preparing request") + return + } + + resp, err := client.ListBySubscriptionSender(req) + if err != nil { + result.ccl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "hybridkubernetes.ConnectedClusterClient", "ListBySubscription", resp, "Failure sending request") + return + } + + result.ccl, err = client.ListBySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "hybridkubernetes.ConnectedClusterClient", "ListBySubscription", resp, "Failure responding to request") + return + } + if result.ccl.hasNextLink() && result.ccl.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListBySubscriptionPreparer prepares the ListBySubscription request. +func (client ConnectedClusterClient) ListBySubscriptionPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-04-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Kubernetes/connectedClusters", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListBySubscriptionSender sends the ListBySubscription request. The method will close the +// http.Response Body if it receives an error. +func (client ConnectedClusterClient) ListBySubscriptionSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListBySubscriptionResponder handles the response to the ListBySubscription request. The method always +// closes the http.Response Body. +func (client ConnectedClusterClient) ListBySubscriptionResponder(resp *http.Response) (result ConnectedClusterList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listBySubscriptionNextResults retrieves the next set of results, if any. +func (client ConnectedClusterClient) listBySubscriptionNextResults(ctx context.Context, lastResults ConnectedClusterList) (result ConnectedClusterList, err error) { + req, err := lastResults.connectedClusterListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "hybridkubernetes.ConnectedClusterClient", "listBySubscriptionNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListBySubscriptionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "hybridkubernetes.ConnectedClusterClient", "listBySubscriptionNextResults", resp, "Failure sending next results request") + } + result, err = client.ListBySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "hybridkubernetes.ConnectedClusterClient", "listBySubscriptionNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListBySubscriptionComplete enumerates all values, automatically crossing page boundaries as required. +func (client ConnectedClusterClient) ListBySubscriptionComplete(ctx context.Context) (result ConnectedClusterListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConnectedClusterClient.ListBySubscription") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListBySubscription(ctx) + return +} + +// ListClusterUserCredentials gets cluster user credentials of the connected cluster with a specified resource group +// and name. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// clusterName - the name of the Kubernetes cluster on which get is called. +// properties - listClusterUserCredentials properties +func (client ConnectedClusterClient) ListClusterUserCredentials(ctx context.Context, resourceGroupName string, clusterName string, properties ListClusterUserCredentialsProperties) (result CredentialResults, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConnectedClusterClient.ListClusterUserCredentials") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: properties, + Constraints: []validation.Constraint{{Target: "properties.ClientProxy", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewError("hybridkubernetes.ConnectedClusterClient", "ListClusterUserCredentials", err.Error()) + } + + req, err := client.ListClusterUserCredentialsPreparer(ctx, resourceGroupName, clusterName, properties) + if err != nil { + err = autorest.NewErrorWithError(err, "hybridkubernetes.ConnectedClusterClient", "ListClusterUserCredentials", nil, "Failure preparing request") + return + } + + resp, err := client.ListClusterUserCredentialsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "hybridkubernetes.ConnectedClusterClient", "ListClusterUserCredentials", resp, "Failure sending request") + return + } + + result, err = client.ListClusterUserCredentialsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "hybridkubernetes.ConnectedClusterClient", "ListClusterUserCredentials", resp, "Failure responding to request") + return + } + + return +} + +// ListClusterUserCredentialsPreparer prepares the ListClusterUserCredentials request. +func (client ConnectedClusterClient) ListClusterUserCredentialsPreparer(ctx context.Context, resourceGroupName string, clusterName string, properties ListClusterUserCredentialsProperties) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "clusterName": autorest.Encode("path", clusterName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-04-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.Kubernetes/connectedClusters/{clusterName}/listClusterUserCredentials", pathParameters), + autorest.WithJSON(properties), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListClusterUserCredentialsSender sends the ListClusterUserCredentials request. The method will close the +// http.Response Body if it receives an error. +func (client ConnectedClusterClient) ListClusterUserCredentialsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListClusterUserCredentialsResponder handles the response to the ListClusterUserCredentials request. The method always +// closes the http.Response Body. +func (client ConnectedClusterClient) ListClusterUserCredentialsResponder(resp *http.Response) (result CredentialResults, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Update API to update certain properties of the connected cluster resource +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// clusterName - the name of the Kubernetes cluster on which get is called. +// connectedClusterPatch - parameters supplied to update Connected Cluster. +func (client ConnectedClusterClient) Update(ctx context.Context, resourceGroupName string, clusterName string, connectedClusterPatch ConnectedClusterPatch) (result ConnectedClusterUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConnectedClusterClient.Update") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("hybridkubernetes.ConnectedClusterClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, clusterName, connectedClusterPatch) + if err != nil { + err = autorest.NewErrorWithError(err, "hybridkubernetes.ConnectedClusterClient", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "hybridkubernetes.ConnectedClusterClient", "Update", nil, "Failure sending request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client ConnectedClusterClient) UpdatePreparer(ctx context.Context, resourceGroupName string, clusterName string, connectedClusterPatch ConnectedClusterPatch) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "clusterName": autorest.Encode("path", clusterName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-04-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.Kubernetes/connectedClusters/{clusterName}", pathParameters), + autorest.WithJSON(connectedClusterPatch), + 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 ConnectedClusterClient) UpdateSender(req *http.Request) (future ConnectedClusterUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client ConnectedClusterClient) UpdateResponder(resp *http.Response) (result ConnectedCluster, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/hybridkubernetes/mgmt/2021-04-01-preview/hybridkubernetes/enums.go b/services/preview/hybridkubernetes/mgmt/2021-04-01-preview/hybridkubernetes/enums.go new file mode 100644 index 000000000000..648b0106c71e --- /dev/null +++ b/services/preview/hybridkubernetes/mgmt/2021-04-01-preview/hybridkubernetes/enums.go @@ -0,0 +1,134 @@ +package hybridkubernetes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// AuthenticationMethod enumerates the values for authentication method. +type AuthenticationMethod string + +const ( + // AuthenticationMethodAAD ... + AuthenticationMethodAAD AuthenticationMethod = "AAD" + // AuthenticationMethodToken ... + AuthenticationMethodToken AuthenticationMethod = "Token" +) + +// PossibleAuthenticationMethodValues returns an array of possible values for the AuthenticationMethod const type. +func PossibleAuthenticationMethodValues() []AuthenticationMethod { + return []AuthenticationMethod{AuthenticationMethodAAD, AuthenticationMethodToken} +} + +// ConnectivityStatus enumerates the values for connectivity status. +type ConnectivityStatus string + +const ( + // ConnectivityStatusConnected ... + ConnectivityStatusConnected ConnectivityStatus = "Connected" + // ConnectivityStatusConnecting ... + ConnectivityStatusConnecting ConnectivityStatus = "Connecting" + // ConnectivityStatusExpired ... + ConnectivityStatusExpired ConnectivityStatus = "Expired" + // ConnectivityStatusOffline ... + ConnectivityStatusOffline ConnectivityStatus = "Offline" +) + +// PossibleConnectivityStatusValues returns an array of possible values for the ConnectivityStatus const type. +func PossibleConnectivityStatusValues() []ConnectivityStatus { + return []ConnectivityStatus{ConnectivityStatusConnected, ConnectivityStatusConnecting, ConnectivityStatusExpired, ConnectivityStatusOffline} +} + +// CreatedByType enumerates the values for created by type. +type CreatedByType string + +const ( + // CreatedByTypeApplication ... + CreatedByTypeApplication CreatedByType = "Application" + // CreatedByTypeKey ... + CreatedByTypeKey CreatedByType = "Key" + // CreatedByTypeManagedIdentity ... + CreatedByTypeManagedIdentity CreatedByType = "ManagedIdentity" + // CreatedByTypeUser ... + CreatedByTypeUser CreatedByType = "User" +) + +// PossibleCreatedByTypeValues returns an array of possible values for the CreatedByType const type. +func PossibleCreatedByTypeValues() []CreatedByType { + return []CreatedByType{CreatedByTypeApplication, CreatedByTypeKey, CreatedByTypeManagedIdentity, CreatedByTypeUser} +} + +// LastModifiedByType enumerates the values for last modified by type. +type LastModifiedByType string + +const ( + // LastModifiedByTypeApplication ... + LastModifiedByTypeApplication LastModifiedByType = "Application" + // LastModifiedByTypeKey ... + LastModifiedByTypeKey LastModifiedByType = "Key" + // LastModifiedByTypeManagedIdentity ... + LastModifiedByTypeManagedIdentity LastModifiedByType = "ManagedIdentity" + // LastModifiedByTypeUser ... + LastModifiedByTypeUser LastModifiedByType = "User" +) + +// PossibleLastModifiedByTypeValues returns an array of possible values for the LastModifiedByType const type. +func PossibleLastModifiedByTypeValues() []LastModifiedByType { + return []LastModifiedByType{LastModifiedByTypeApplication, LastModifiedByTypeKey, LastModifiedByTypeManagedIdentity, LastModifiedByTypeUser} +} + +// PrivateLinkState enumerates the values for private link state. +type PrivateLinkState string + +const ( + // PrivateLinkStateDisabled ... + PrivateLinkStateDisabled PrivateLinkState = "Disabled" + // PrivateLinkStateEnabled ... + PrivateLinkStateEnabled PrivateLinkState = "Enabled" +) + +// PossiblePrivateLinkStateValues returns an array of possible values for the PrivateLinkState const type. +func PossiblePrivateLinkStateValues() []PrivateLinkState { + return []PrivateLinkState{PrivateLinkStateDisabled, PrivateLinkStateEnabled} +} + +// ProvisioningState enumerates the values for provisioning state. +type ProvisioningState string + +const ( + // ProvisioningStateAccepted ... + ProvisioningStateAccepted ProvisioningState = "Accepted" + // ProvisioningStateCanceled ... + ProvisioningStateCanceled ProvisioningState = "Canceled" + // ProvisioningStateDeleting ... + ProvisioningStateDeleting ProvisioningState = "Deleting" + // ProvisioningStateFailed ... + ProvisioningStateFailed ProvisioningState = "Failed" + // ProvisioningStateProvisioning ... + ProvisioningStateProvisioning ProvisioningState = "Provisioning" + // ProvisioningStateSucceeded ... + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + // ProvisioningStateUpdating ... + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +// PossibleProvisioningStateValues returns an array of possible values for the ProvisioningState const type. +func PossibleProvisioningStateValues() []ProvisioningState { + return []ProvisioningState{ProvisioningStateAccepted, ProvisioningStateCanceled, ProvisioningStateDeleting, ProvisioningStateFailed, ProvisioningStateProvisioning, ProvisioningStateSucceeded, ProvisioningStateUpdating} +} + +// ResourceIdentityType enumerates the values for resource identity type. +type ResourceIdentityType string + +const ( + // ResourceIdentityTypeNone ... + ResourceIdentityTypeNone ResourceIdentityType = "None" + // ResourceIdentityTypeSystemAssigned ... + ResourceIdentityTypeSystemAssigned ResourceIdentityType = "SystemAssigned" +) + +// PossibleResourceIdentityTypeValues returns an array of possible values for the ResourceIdentityType const type. +func PossibleResourceIdentityTypeValues() []ResourceIdentityType { + return []ResourceIdentityType{ResourceIdentityTypeNone, ResourceIdentityTypeSystemAssigned} +} diff --git a/services/preview/hybridkubernetes/mgmt/2021-04-01-preview/hybridkubernetes/hybridkubernetesapi/interfaces.go b/services/preview/hybridkubernetes/mgmt/2021-04-01-preview/hybridkubernetes/hybridkubernetesapi/interfaces.go new file mode 100644 index 000000000000..33fab8e8ae9b --- /dev/null +++ b/services/preview/hybridkubernetes/mgmt/2021-04-01-preview/hybridkubernetes/hybridkubernetesapi/interfaces.go @@ -0,0 +1,35 @@ +package hybridkubernetesapi + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/services/preview/hybridkubernetes/mgmt/2021-04-01-preview/hybridkubernetes" +) + +// ConnectedClusterClientAPI contains the set of methods on the ConnectedClusterClient type. +type ConnectedClusterClientAPI interface { + Create(ctx context.Context, resourceGroupName string, clusterName string, connectedCluster hybridkubernetes.ConnectedCluster) (result hybridkubernetes.ConnectedClusterCreateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, clusterName string) (result hybridkubernetes.ConnectedClusterDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, clusterName string) (result hybridkubernetes.ConnectedCluster, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string) (result hybridkubernetes.ConnectedClusterListPage, err error) + ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result hybridkubernetes.ConnectedClusterListIterator, err error) + ListBySubscription(ctx context.Context) (result hybridkubernetes.ConnectedClusterListPage, err error) + ListBySubscriptionComplete(ctx context.Context) (result hybridkubernetes.ConnectedClusterListIterator, err error) + ListClusterUserCredentials(ctx context.Context, resourceGroupName string, clusterName string, properties hybridkubernetes.ListClusterUserCredentialsProperties) (result hybridkubernetes.CredentialResults, err error) + Update(ctx context.Context, resourceGroupName string, clusterName string, connectedClusterPatch hybridkubernetes.ConnectedClusterPatch) (result hybridkubernetes.ConnectedClusterUpdateFuture, err error) +} + +var _ ConnectedClusterClientAPI = (*hybridkubernetes.ConnectedClusterClient)(nil) + +// OperationsClientAPI contains the set of methods on the OperationsClient type. +type OperationsClientAPI interface { + Get(ctx context.Context) (result hybridkubernetes.OperationListPage, err error) + GetComplete(ctx context.Context) (result hybridkubernetes.OperationListIterator, err error) +} + +var _ OperationsClientAPI = (*hybridkubernetes.OperationsClient)(nil) diff --git a/services/preview/hybridkubernetes/mgmt/2021-04-01-preview/hybridkubernetes/models.go b/services/preview/hybridkubernetes/mgmt/2021-04-01-preview/hybridkubernetes/models.go new file mode 100644 index 000000000000..3453a215b847 --- /dev/null +++ b/services/preview/hybridkubernetes/mgmt/2021-04-01-preview/hybridkubernetes/models.go @@ -0,0 +1,949 @@ +package hybridkubernetes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "encoding/json" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/date" + "github.com/Azure/go-autorest/autorest/to" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// The package's fully qualified name. +const fqdn = "github.com/Azure/azure-sdk-for-go/services/preview/hybridkubernetes/mgmt/2021-04-01-preview/hybridkubernetes" + +// AzureEntityResource the resource model definition for an Azure Resource Manager resource with an etag. +type AzureEntityResource struct { + // Etag - READ-ONLY; Resource Etag. + Etag *string `json:"etag,omitempty"` + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for AzureEntityResource. +func (aer AzureEntityResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ConnectedCluster represents a connected cluster. +type ConnectedCluster struct { + autorest.Response `json:"-"` + // Identity - The identity of the connected cluster. + Identity *ConnectedClusterIdentity `json:"identity,omitempty"` + // ConnectedClusterProperties - Describes the connected cluster resource properties. + *ConnectedClusterProperties `json:"properties,omitempty"` + // SystemData - READ-ONLY; Metadata pertaining to creation and last modification of the resource + SystemData *SystemData `json:"systemData,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // Location - The geo-location where the resource lives + Location *string `json:"location,omitempty"` + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ConnectedCluster. +func (cc ConnectedCluster) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if cc.Identity != nil { + objectMap["identity"] = cc.Identity + } + if cc.ConnectedClusterProperties != nil { + objectMap["properties"] = cc.ConnectedClusterProperties + } + if cc.Tags != nil { + objectMap["tags"] = cc.Tags + } + if cc.Location != nil { + objectMap["location"] = cc.Location + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ConnectedCluster struct. +func (cc *ConnectedCluster) UnmarshalJSON(body []byte) error { + 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 ConnectedClusterIdentity + err = json.Unmarshal(*v, &identity) + if err != nil { + return err + } + cc.Identity = &identity + } + case "properties": + if v != nil { + var connectedClusterProperties ConnectedClusterProperties + err = json.Unmarshal(*v, &connectedClusterProperties) + if err != nil { + return err + } + cc.ConnectedClusterProperties = &connectedClusterProperties + } + case "systemData": + if v != nil { + var systemData SystemData + err = json.Unmarshal(*v, &systemData) + if err != nil { + return err + } + cc.SystemData = &systemData + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + cc.Tags = tags + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + cc.Location = &location + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + cc.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + cc.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + cc.Type = &typeVar + } + } + } + + return nil +} + +// ConnectedClusterCreateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ConnectedClusterCreateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ConnectedClusterClient) (ConnectedCluster, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ConnectedClusterCreateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ConnectedClusterCreateFuture.Result. +func (future *ConnectedClusterCreateFuture) result(client ConnectedClusterClient) (cc ConnectedCluster, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "hybridkubernetes.ConnectedClusterCreateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + cc.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("hybridkubernetes.ConnectedClusterCreateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if cc.Response.Response, err = future.GetResult(sender); err == nil && cc.Response.Response.StatusCode != http.StatusNoContent { + cc, err = client.CreateResponder(cc.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "hybridkubernetes.ConnectedClusterCreateFuture", "Result", cc.Response.Response, "Failure responding to request") + } + } + return +} + +// ConnectedClusterDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ConnectedClusterDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ConnectedClusterClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ConnectedClusterDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ConnectedClusterDeleteFuture.Result. +func (future *ConnectedClusterDeleteFuture) result(client ConnectedClusterClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "hybridkubernetes.ConnectedClusterDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("hybridkubernetes.ConnectedClusterDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// ConnectedClusterIdentity identity for the connected cluster. +type ConnectedClusterIdentity struct { + // PrincipalID - READ-ONLY; The principal id of connected cluster identity. This property will only be provided for a system assigned identity. + PrincipalID *string `json:"principalId,omitempty"` + // TenantID - READ-ONLY; The tenant id associated with the connected cluster. This property will only be provided for a system assigned identity. + TenantID *string `json:"tenantId,omitempty"` + // Type - The type of identity used for the connected cluster. The type 'SystemAssigned, includes a system created identity. The type 'None' means no identity is assigned to the connected cluster. Possible values include: 'ResourceIdentityTypeNone', 'ResourceIdentityTypeSystemAssigned' + Type ResourceIdentityType `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ConnectedClusterIdentity. +func (cci ConnectedClusterIdentity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if cci.Type != "" { + objectMap["type"] = cci.Type + } + return json.Marshal(objectMap) +} + +// ConnectedClusterList the paginated list of connected Clusters +type ConnectedClusterList struct { + autorest.Response `json:"-"` + // Value - The list of connected clusters + Value *[]ConnectedCluster `json:"value,omitempty"` + // NextLink - The link to fetch the next page of connected cluster + NextLink *string `json:"nextLink,omitempty"` +} + +// ConnectedClusterListIterator provides access to a complete listing of ConnectedCluster values. +type ConnectedClusterListIterator struct { + i int + page ConnectedClusterListPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *ConnectedClusterListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConnectedClusterListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ConnectedClusterListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ConnectedClusterListIterator) 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 ConnectedClusterListIterator) Response() ConnectedClusterList { + 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 ConnectedClusterListIterator) Value() ConnectedCluster { + if !iter.page.NotDone() { + return ConnectedCluster{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ConnectedClusterListIterator type. +func NewConnectedClusterListIterator(page ConnectedClusterListPage) ConnectedClusterListIterator { + return ConnectedClusterListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (ccl ConnectedClusterList) IsEmpty() bool { + return ccl.Value == nil || len(*ccl.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (ccl ConnectedClusterList) hasNextLink() bool { + return ccl.NextLink != nil && len(*ccl.NextLink) != 0 +} + +// connectedClusterListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (ccl ConnectedClusterList) connectedClusterListPreparer(ctx context.Context) (*http.Request, error) { + if !ccl.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(ccl.NextLink))) +} + +// ConnectedClusterListPage contains a page of ConnectedCluster values. +type ConnectedClusterListPage struct { + fn func(context.Context, ConnectedClusterList) (ConnectedClusterList, error) + ccl ConnectedClusterList +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *ConnectedClusterListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConnectedClusterListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.ccl) + if err != nil { + return err + } + page.ccl = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *ConnectedClusterListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ConnectedClusterListPage) NotDone() bool { + return !page.ccl.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ConnectedClusterListPage) Response() ConnectedClusterList { + return page.ccl +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ConnectedClusterListPage) Values() []ConnectedCluster { + if page.ccl.IsEmpty() { + return nil + } + return *page.ccl.Value +} + +// Creates a new instance of the ConnectedClusterListPage type. +func NewConnectedClusterListPage(cur ConnectedClusterList, getNextPage func(context.Context, ConnectedClusterList) (ConnectedClusterList, error)) ConnectedClusterListPage { + return ConnectedClusterListPage{ + fn: getNextPage, + ccl: cur, + } +} + +// ConnectedClusterPatch object containing updates for patch operations. +type ConnectedClusterPatch struct { + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // ConnectedClusterPatchProperties - Describes the connected cluster resource properties that can be updated during PATCH operation. + *ConnectedClusterPatchProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for ConnectedClusterPatch. +func (ccp ConnectedClusterPatch) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ccp.Tags != nil { + objectMap["tags"] = ccp.Tags + } + if ccp.ConnectedClusterPatchProperties != nil { + objectMap["properties"] = ccp.ConnectedClusterPatchProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ConnectedClusterPatch struct. +func (ccp *ConnectedClusterPatch) UnmarshalJSON(body []byte) error { + 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 + } + ccp.Tags = tags + } + case "properties": + if v != nil { + var connectedClusterPatchProperties ConnectedClusterPatchProperties + err = json.Unmarshal(*v, &connectedClusterPatchProperties) + if err != nil { + return err + } + ccp.ConnectedClusterPatchProperties = &connectedClusterPatchProperties + } + } + } + + return nil +} + +// ConnectedClusterPatchProperties properties which can be patched on the connected cluster resource. +type ConnectedClusterPatchProperties struct { + // PrivateLinkState - Property which describes the state of private link on a connected cluster resource. Possible values include: 'PrivateLinkStateEnabled', 'PrivateLinkStateDisabled' + PrivateLinkState PrivateLinkState `json:"privateLinkState,omitempty"` + // PrivateLinkScopeResourceID - The resource id of the private link scope this connected cluster is assigned to, if any. + PrivateLinkScopeResourceID *string `json:"privateLinkScopeResourceId,omitempty"` +} + +// ConnectedClusterProperties properties of the connected cluster. +type ConnectedClusterProperties struct { + // AgentPublicKeyCertificate - Base64 encoded public certificate used by the agent to do the initial handshake to the backend services in Azure. + AgentPublicKeyCertificate *string `json:"agentPublicKeyCertificate,omitempty"` + // KubernetesVersion - READ-ONLY; The Kubernetes version of the connected cluster resource + KubernetesVersion *string `json:"kubernetesVersion,omitempty"` + // TotalNodeCount - READ-ONLY; Number of nodes present in the connected cluster resource + TotalNodeCount *int32 `json:"totalNodeCount,omitempty"` + // TotalCoreCount - READ-ONLY; Number of CPU cores present in the connected cluster resource + TotalCoreCount *int32 `json:"totalCoreCount,omitempty"` + // AgentVersion - READ-ONLY; Version of the agent running on the connected cluster resource + AgentVersion *string `json:"agentVersion,omitempty"` + // ProvisioningState - Provisioning state of the connected cluster resource. Possible values include: 'ProvisioningStateSucceeded', 'ProvisioningStateFailed', 'ProvisioningStateCanceled', 'ProvisioningStateProvisioning', 'ProvisioningStateUpdating', 'ProvisioningStateDeleting', 'ProvisioningStateAccepted' + ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` + // Distribution - The Kubernetes distribution running on this connected cluster. + Distribution *string `json:"distribution,omitempty"` + // Infrastructure - The infrastructure on which the Kubernetes cluster represented by this connected cluster is running on. + Infrastructure *string `json:"infrastructure,omitempty"` + // Offering - READ-ONLY; Connected cluster offering + Offering *string `json:"offering,omitempty"` + // ManagedIdentityCertificateExpirationTime - READ-ONLY; Expiration time of the managed identity certificate + ManagedIdentityCertificateExpirationTime *date.Time `json:"managedIdentityCertificateExpirationTime,omitempty"` + // LastConnectivityTime - READ-ONLY; Time representing the last instance when heart beat was received from the cluster + LastConnectivityTime *date.Time `json:"lastConnectivityTime,omitempty"` + // ConnectivityStatus - READ-ONLY; Represents the connectivity status of the connected cluster. Possible values include: 'ConnectivityStatusConnecting', 'ConnectivityStatusConnected', 'ConnectivityStatusOffline', 'ConnectivityStatusExpired' + ConnectivityStatus ConnectivityStatus `json:"connectivityStatus,omitempty"` + // PrivateLinkState - Property which describes the state of private link on a connected cluster resource. Possible values include: 'PrivateLinkStateEnabled', 'PrivateLinkStateDisabled' + PrivateLinkState PrivateLinkState `json:"privateLinkState,omitempty"` + // PrivateLinkScopeResourceID - The resource id of the private link scope this connected cluster is assigned to, if any. + PrivateLinkScopeResourceID *string `json:"privateLinkScopeResourceId,omitempty"` +} + +// MarshalJSON is the custom marshaler for ConnectedClusterProperties. +func (ccp ConnectedClusterProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ccp.AgentPublicKeyCertificate != nil { + objectMap["agentPublicKeyCertificate"] = ccp.AgentPublicKeyCertificate + } + if ccp.ProvisioningState != "" { + objectMap["provisioningState"] = ccp.ProvisioningState + } + if ccp.Distribution != nil { + objectMap["distribution"] = ccp.Distribution + } + if ccp.Infrastructure != nil { + objectMap["infrastructure"] = ccp.Infrastructure + } + if ccp.PrivateLinkState != "" { + objectMap["privateLinkState"] = ccp.PrivateLinkState + } + if ccp.PrivateLinkScopeResourceID != nil { + objectMap["privateLinkScopeResourceId"] = ccp.PrivateLinkScopeResourceID + } + return json.Marshal(objectMap) +} + +// ConnectedClusterUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ConnectedClusterUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ConnectedClusterClient) (ConnectedCluster, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ConnectedClusterUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ConnectedClusterUpdateFuture.Result. +func (future *ConnectedClusterUpdateFuture) result(client ConnectedClusterClient) (cc ConnectedCluster, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "hybridkubernetes.ConnectedClusterUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + cc.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("hybridkubernetes.ConnectedClusterUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if cc.Response.Response, err = future.GetResult(sender); err == nil && cc.Response.Response.StatusCode != http.StatusNoContent { + cc, err = client.UpdateResponder(cc.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "hybridkubernetes.ConnectedClusterUpdateFuture", "Result", cc.Response.Response, "Failure responding to request") + } + } + return +} + +// CredentialResult the credential result response. +type CredentialResult struct { + // Name - READ-ONLY; The name of the credential. + Name *string `json:"name,omitempty"` + // Value - READ-ONLY; Base64-encoded Kubernetes configuration file. + Value *[]byte `json:"value,omitempty"` +} + +// MarshalJSON is the custom marshaler for CredentialResult. +func (cr CredentialResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// CredentialResults the list of credential result response. +type CredentialResults struct { + autorest.Response `json:"-"` + // HybridConnectionConfig - READ-ONLY; Contains the REP (rendezvous endpoint) and “Sender” access token. + HybridConnectionConfig *HybridConnectionConfig `json:"hybridConnectionConfig,omitempty"` + // Kubeconfigs - READ-ONLY; Base64-encoded Kubernetes configuration file. + Kubeconfigs *[]CredentialResult `json:"kubeconfigs,omitempty"` +} + +// MarshalJSON is the custom marshaler for CredentialResults. +func (cr CredentialResults) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ErrorAdditionalInfo the resource management error additional info. +type ErrorAdditionalInfo struct { + // Type - READ-ONLY; The additional info type. + Type *string `json:"type,omitempty"` + // Info - READ-ONLY; The additional info. + Info interface{} `json:"info,omitempty"` +} + +// MarshalJSON is the custom marshaler for ErrorAdditionalInfo. +func (eai ErrorAdditionalInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ErrorDetail the error detail. +type ErrorDetail struct { + // Code - READ-ONLY; The error code. + Code *string `json:"code,omitempty"` + // Message - READ-ONLY; The error message. + Message *string `json:"message,omitempty"` + // Target - READ-ONLY; The error target. + Target *string `json:"target,omitempty"` + // Details - READ-ONLY; The error details. + Details *[]ErrorDetail `json:"details,omitempty"` + // AdditionalInfo - READ-ONLY; The error additional info. + AdditionalInfo *[]ErrorAdditionalInfo `json:"additionalInfo,omitempty"` +} + +// MarshalJSON is the custom marshaler for ErrorDetail. +func (ed ErrorDetail) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ErrorResponse common error response for all Azure Resource Manager APIs to return error details for +// failed operations. (This also follows the OData error response format.). +type ErrorResponse struct { + // Error - The error object. + Error *ErrorDetail `json:"error,omitempty"` +} + +// HybridConnectionConfig contains the REP (rendezvous endpoint) and “Sender” access token. +type HybridConnectionConfig struct { + // ExpirationTime - READ-ONLY; Timestamp when this token will be expired. + ExpirationTime *int64 `json:"expirationTime,omitempty"` + // HybridConnectionName - READ-ONLY; Name of the connection + HybridConnectionName *string `json:"hybridConnectionName,omitempty"` + // Relay - READ-ONLY; Name of the relay. + Relay *string `json:"relay,omitempty"` + // Token - READ-ONLY; Sender access token + Token *string `json:"token,omitempty"` +} + +// MarshalJSON is the custom marshaler for HybridConnectionConfig. +func (hcc HybridConnectionConfig) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ListClusterUserCredentialsProperties ... +type ListClusterUserCredentialsProperties struct { + // AuthenticationMethod - The mode of client authentication. Possible values include: 'AuthenticationMethodToken', 'AuthenticationMethodAAD' + AuthenticationMethod AuthenticationMethod `json:"authenticationMethod,omitempty"` + // ClientProxy - Boolean value to indicate whether the request is for client side proxy or not + ClientProxy *bool `json:"clientProxy,omitempty"` +} + +// Operation the Connected cluster API operation +type Operation struct { + // Name - READ-ONLY; Operation name: {Microsoft.Kubernetes}/{resource}/{operation} + Name *string `json:"name,omitempty"` + // Display - READ-ONLY; The object that represents the operation. + Display *OperationDisplay `json:"display,omitempty"` +} + +// MarshalJSON is the custom marshaler for Operation. +func (o Operation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// OperationDisplay the object that represents the operation. +type OperationDisplay struct { + // Provider - Service provider: Microsoft.connectedClusters + Provider *string `json:"provider,omitempty"` + // Resource - Connected Cluster Resource on which the operation is performed + Resource *string `json:"resource,omitempty"` + // Operation - Operation type: Read, write, delete, etc. + Operation *string `json:"operation,omitempty"` + // Description - Description of the operation. + Description *string `json:"description,omitempty"` +} + +// OperationList the paginated list of connected cluster API operations. +type OperationList struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; The list of connected cluster API operations. + Value *[]Operation `json:"value,omitempty"` + // NextLink - The link to fetch the next page of connected cluster API operations. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for OperationList. +func (ol OperationList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ol.NextLink != nil { + objectMap["nextLink"] = ol.NextLink + } + return json.Marshal(objectMap) +} + +// OperationListIterator provides access to a complete listing of Operation values. +type OperationListIterator struct { + i int + page OperationListPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *OperationListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *OperationListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter OperationListIterator) 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 OperationListIterator) Response() OperationList { + 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 OperationListIterator) Value() Operation { + if !iter.page.NotDone() { + return Operation{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the OperationListIterator type. +func NewOperationListIterator(page OperationListPage) OperationListIterator { + return OperationListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (ol OperationList) IsEmpty() bool { + return ol.Value == nil || len(*ol.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (ol OperationList) hasNextLink() bool { + return ol.NextLink != nil && len(*ol.NextLink) != 0 +} + +// operationListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (ol OperationList) operationListPreparer(ctx context.Context) (*http.Request, error) { + if !ol.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(ol.NextLink))) +} + +// OperationListPage contains a page of Operation values. +type OperationListPage struct { + fn func(context.Context, OperationList) (OperationList, error) + ol OperationList +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *OperationListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.ol) + if err != nil { + return err + } + page.ol = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *OperationListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page OperationListPage) NotDone() bool { + return !page.ol.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page OperationListPage) Response() OperationList { + return page.ol +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page OperationListPage) Values() []Operation { + if page.ol.IsEmpty() { + return nil + } + return *page.ol.Value +} + +// Creates a new instance of the OperationListPage type. +func NewOperationListPage(cur OperationList, getNextPage func(context.Context, OperationList) (OperationList, error)) OperationListPage { + return OperationListPage{ + fn: getNextPage, + ol: cur, + } +} + +// ProxyResource the resource model definition for a Azure Resource Manager proxy resource. It will not +// have tags and a location +type ProxyResource struct { + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ProxyResource. +func (pr ProxyResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// Resource common fields that are returned in the response for all Azure Resource Manager resources +type Resource struct { + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Resource. +func (r Resource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// SystemData metadata pertaining to creation and last modification of the resource. +type SystemData struct { + // CreatedBy - The identity that created the resource. + CreatedBy *string `json:"createdBy,omitempty"` + // CreatedByType - The type of identity that created the resource. Possible values include: 'CreatedByTypeUser', 'CreatedByTypeApplication', 'CreatedByTypeManagedIdentity', 'CreatedByTypeKey' + CreatedByType CreatedByType `json:"createdByType,omitempty"` + // CreatedAt - The timestamp of resource creation (UTC). + CreatedAt *date.Time `json:"createdAt,omitempty"` + // LastModifiedBy - The identity that last modified the resource. + LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + // LastModifiedByType - The type of identity that last modified the resource. Possible values include: 'LastModifiedByTypeUser', 'LastModifiedByTypeApplication', 'LastModifiedByTypeManagedIdentity', 'LastModifiedByTypeKey' + LastModifiedByType LastModifiedByType `json:"lastModifiedByType,omitempty"` + // LastModifiedAt - The timestamp of resource modification (UTC). + LastModifiedAt *date.Time `json:"lastModifiedAt,omitempty"` +} + +// TrackedResource the resource model definition for an Azure Resource Manager tracked top level resource +// which has 'tags' and a 'location' +type TrackedResource struct { + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // Location - The geo-location where the resource lives + Location *string `json:"location,omitempty"` + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + 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 + } + return json.Marshal(objectMap) +} diff --git a/services/preview/hybridkubernetes/mgmt/2021-04-01-preview/hybridkubernetes/operations.go b/services/preview/hybridkubernetes/mgmt/2021-04-01-preview/hybridkubernetes/operations.go new file mode 100644 index 000000000000..2e6014560746 --- /dev/null +++ b/services/preview/hybridkubernetes/mgmt/2021-04-01-preview/hybridkubernetes/operations.go @@ -0,0 +1,140 @@ +package hybridkubernetes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// OperationsClient is the azure Connected Cluster Resource Provider API for adopting any Kubernetes Cluster +type OperationsClient struct { + BaseClient +} + +// NewOperationsClient creates an instance of the OperationsClient client. +func NewOperationsClient(subscriptionID string) OperationsClient { + return NewOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewOperationsClientWithBaseURI creates an instance of the OperationsClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient { + return OperationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get lists all of the available API operations for Connected Cluster resource. +func (client OperationsClient) Get(ctx context.Context) (result OperationListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.Get") + defer func() { + sc := -1 + if result.ol.Response.Response != nil { + sc = result.ol.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.getNextResults + req, err := client.GetPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "hybridkubernetes.OperationsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.ol.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "hybridkubernetes.OperationsClient", "Get", resp, "Failure sending request") + return + } + + result.ol, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "hybridkubernetes.OperationsClient", "Get", resp, "Failure responding to request") + return + } + if result.ol.hasNextLink() && result.ol.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client OperationsClient) GetPreparer(ctx context.Context) (*http.Request, error) { + const APIVersion = "2021-04-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.Kubernetes/operations"), + 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 OperationsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client OperationsClient) GetResponder(resp *http.Response) (result OperationList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// getNextResults retrieves the next set of results, if any. +func (client OperationsClient) getNextResults(ctx context.Context, lastResults OperationList) (result OperationList, err error) { + req, err := lastResults.operationListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "hybridkubernetes.OperationsClient", "getNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "hybridkubernetes.OperationsClient", "getNextResults", resp, "Failure sending next results request") + } + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "hybridkubernetes.OperationsClient", "getNextResults", resp, "Failure responding to next results request") + } + return +} + +// GetComplete enumerates all values, automatically crossing page boundaries as required. +func (client OperationsClient) GetComplete(ctx context.Context) (result OperationListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.Get") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.Get(ctx) + return +} diff --git a/services/preview/hybridkubernetes/mgmt/2021-04-01-preview/hybridkubernetes/version.go b/services/preview/hybridkubernetes/mgmt/2021-04-01-preview/hybridkubernetes/version.go new file mode 100644 index 000000000000..65e237569113 --- /dev/null +++ b/services/preview/hybridkubernetes/mgmt/2021-04-01-preview/hybridkubernetes/version.go @@ -0,0 +1,19 @@ +package hybridkubernetes + +import "github.com/Azure/azure-sdk-for-go/version" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// UserAgent returns the UserAgent string to use when sending http.Requests. +func UserAgent() string { + return "Azure-SDK-For-Go/" + Version() + " hybridkubernetes/2021-04-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/monitor/mgmt/2021-04-01-preview/insights/CHANGELOG.md b/services/preview/monitor/mgmt/2021-04-01-preview/insights/CHANGELOG.md new file mode 100644 index 000000000000..52911e4cc5e4 --- /dev/null +++ b/services/preview/monitor/mgmt/2021-04-01-preview/insights/CHANGELOG.md @@ -0,0 +1,2 @@ +# Change History + diff --git a/services/preview/monitor/mgmt/2021-04-01-preview/insights/_meta.json b/services/preview/monitor/mgmt/2021-04-01-preview/insights/_meta.json new file mode 100644 index 000000000000..bc07ab723a34 --- /dev/null +++ b/services/preview/monitor/mgmt/2021-04-01-preview/insights/_meta.json @@ -0,0 +1,11 @@ +{ + "commit": "8dff86df71bee429af84ea4713288ef3cdd1db2f", + "readme": "/_/azure-rest-api-specs/specification/monitor/resource-manager/readme.md", + "tag": "package-2021-04", + "use": "@microsoft.azure/autorest.go@2.1.183", + "repository_url": "https://github.com/Azure/azure-rest-api-specs.git", + "autorest_command": "autorest --use=@microsoft.azure/autorest.go@2.1.183 --tag=package-2021-04 --go-sdk-folder=/_/azure-sdk-for-go --go --verbose --use-onever --version=V2 --go.license-header=MICROSOFT_MIT_NO_VERSION --enum-prefix /_/azure-rest-api-specs/specification/monitor/resource-manager/readme.md", + "additional_properties": { + "additional_options": "--go --verbose --use-onever --version=V2 --go.license-header=MICROSOFT_MIT_NO_VERSION --enum-prefix" + } +} \ No newline at end of file diff --git a/services/preview/monitor/mgmt/2021-04-01-preview/insights/actiongroups.go b/services/preview/monitor/mgmt/2021-04-01-preview/insights/actiongroups.go new file mode 100644 index 000000000000..ce2e6509e2da --- /dev/null +++ b/services/preview/monitor/mgmt/2021-04-01-preview/insights/actiongroups.go @@ -0,0 +1,633 @@ +package insights + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ActionGroupsClient is the monitor Management Client +type ActionGroupsClient struct { + BaseClient +} + +// NewActionGroupsClient creates an instance of the ActionGroupsClient client. +func NewActionGroupsClient(subscriptionID string) ActionGroupsClient { + return NewActionGroupsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewActionGroupsClientWithBaseURI creates an instance of the ActionGroupsClient client using a custom endpoint. Use +// this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewActionGroupsClientWithBaseURI(baseURI string, subscriptionID string) ActionGroupsClient { + return ActionGroupsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate create a new action group or update an existing one. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// actionGroupName - the name of the action group. +// actionGroup - the action group to create or use for the update. +func (client ActionGroupsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, actionGroupName string, actionGroup ActionGroupResource) (result ActionGroupResource, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ActionGroupsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: actionGroup, + Constraints: []validation.Constraint{{Target: "actionGroup.ActionGroup", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "actionGroup.ActionGroup.GroupShortName", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "actionGroup.ActionGroup.GroupShortName", Name: validation.MaxLength, Rule: 12, Chain: nil}}}, + {Target: "actionGroup.ActionGroup.Enabled", Name: validation.Null, Rule: true, Chain: nil}, + }}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.ActionGroupsClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, actionGroupName, actionGroup) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ActionGroupsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, actionGroupName string, actionGroup ActionGroupResource) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "actionGroupName": autorest.Encode("path", actionGroupName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-06-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.insights/actionGroups/{actionGroupName}", pathParameters), + autorest.WithJSON(actionGroup), + 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 ActionGroupsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ActionGroupsClient) CreateOrUpdateResponder(resp *http.Response) (result ActionGroupResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete an action group. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// actionGroupName - the name of the action group. +func (client ActionGroupsClient) Delete(ctx context.Context, resourceGroupName string, actionGroupName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ActionGroupsClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.ActionGroupsClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, actionGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ActionGroupsClient) DeletePreparer(ctx context.Context, resourceGroupName string, actionGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "actionGroupName": autorest.Encode("path", actionGroupName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-06-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.insights/actionGroups/{actionGroupName}", 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 ActionGroupsClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ActionGroupsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// EnableReceiver enable a receiver in an action group. This changes the receiver's status from Disabled to Enabled. +// This operation is only supported for Email or SMS receivers. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// actionGroupName - the name of the action group. +// enableRequest - the receiver to re-enable. +func (client ActionGroupsClient) EnableReceiver(ctx context.Context, resourceGroupName string, actionGroupName string, enableRequest EnableRequest) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ActionGroupsClient.EnableReceiver") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: enableRequest, + Constraints: []validation.Constraint{{Target: "enableRequest.ReceiverName", Name: validation.Null, Rule: true, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.ActionGroupsClient", "EnableReceiver", err.Error()) + } + + req, err := client.EnableReceiverPreparer(ctx, resourceGroupName, actionGroupName, enableRequest) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "EnableReceiver", nil, "Failure preparing request") + return + } + + resp, err := client.EnableReceiverSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "EnableReceiver", resp, "Failure sending request") + return + } + + result, err = client.EnableReceiverResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "EnableReceiver", resp, "Failure responding to request") + return + } + + return +} + +// EnableReceiverPreparer prepares the EnableReceiver request. +func (client ActionGroupsClient) EnableReceiverPreparer(ctx context.Context, resourceGroupName string, actionGroupName string, enableRequest EnableRequest) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "actionGroupName": autorest.Encode("path", actionGroupName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-06-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.insights/actionGroups/{actionGroupName}/subscribe", pathParameters), + autorest.WithJSON(enableRequest), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// EnableReceiverSender sends the EnableReceiver request. The method will close the +// http.Response Body if it receives an error. +func (client ActionGroupsClient) EnableReceiverSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// EnableReceiverResponder handles the response to the EnableReceiver request. The method always +// closes the http.Response Body. +func (client ActionGroupsClient) EnableReceiverResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusConflict), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get get an action group. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// actionGroupName - the name of the action group. +func (client ActionGroupsClient) Get(ctx context.Context, resourceGroupName string, actionGroupName string) (result ActionGroupResource, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ActionGroupsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.ActionGroupsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, actionGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ActionGroupsClient) GetPreparer(ctx context.Context, resourceGroupName string, actionGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "actionGroupName": autorest.Encode("path", actionGroupName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-06-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.insights/actionGroups/{actionGroupName}", 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 ActionGroupsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ActionGroupsClient) GetResponder(resp *http.Response) (result ActionGroupResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByResourceGroup get a list of all action groups in a resource group. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +func (client ActionGroupsClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result ActionGroupList, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ActionGroupsClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.ActionGroupsClient", "ListByResourceGroup", err.Error()) + } + + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "ListByResourceGroup", resp, "Failure responding to request") + return + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client ActionGroupsClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups", 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 ActionGroupsClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client ActionGroupsClient) ListByResourceGroupResponder(resp *http.Response) (result ActionGroupList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListBySubscriptionID get a list of all action groups in a subscription. +func (client ActionGroupsClient) ListBySubscriptionID(ctx context.Context) (result ActionGroupList, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ActionGroupsClient.ListBySubscriptionID") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.ActionGroupsClient", "ListBySubscriptionID", err.Error()) + } + + req, err := client.ListBySubscriptionIDPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "ListBySubscriptionID", nil, "Failure preparing request") + return + } + + resp, err := client.ListBySubscriptionIDSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "ListBySubscriptionID", resp, "Failure sending request") + return + } + + result, err = client.ListBySubscriptionIDResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "ListBySubscriptionID", resp, "Failure responding to request") + return + } + + return +} + +// ListBySubscriptionIDPreparer prepares the ListBySubscriptionID request. +func (client ActionGroupsClient) ListBySubscriptionIDPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/microsoft.insights/actionGroups", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListBySubscriptionIDSender sends the ListBySubscriptionID request. The method will close the +// http.Response Body if it receives an error. +func (client ActionGroupsClient) ListBySubscriptionIDSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListBySubscriptionIDResponder handles the response to the ListBySubscriptionID request. The method always +// closes the http.Response Body. +func (client ActionGroupsClient) ListBySubscriptionIDResponder(resp *http.Response) (result ActionGroupList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Update updates an existing action group's tags. To update other fields use the CreateOrUpdate method. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// actionGroupName - the name of the action group. +// actionGroupPatch - parameters supplied to the operation. +func (client ActionGroupsClient) Update(ctx context.Context, resourceGroupName string, actionGroupName string, actionGroupPatch ActionGroupPatchBody) (result ActionGroupResource, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ActionGroupsClient.Update") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.ActionGroupsClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, actionGroupName, actionGroupPatch) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ActionGroupsClient", "Update", resp, "Failure responding to request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client ActionGroupsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, actionGroupName string, actionGroupPatch ActionGroupPatchBody) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "actionGroupName": autorest.Encode("path", actionGroupName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-06-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.insights/actionGroups/{actionGroupName}", pathParameters), + autorest.WithJSON(actionGroupPatch), + 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 ActionGroupsClient) UpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client ActionGroupsClient) UpdateResponder(resp *http.Response) (result ActionGroupResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/monitor/mgmt/2021-04-01-preview/insights/activitylogalerts.go b/services/preview/monitor/mgmt/2021-04-01-preview/insights/activitylogalerts.go new file mode 100644 index 000000000000..f897b08a6f0c --- /dev/null +++ b/services/preview/monitor/mgmt/2021-04-01-preview/insights/activitylogalerts.go @@ -0,0 +1,545 @@ +package insights + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ActivityLogAlertsClient is the monitor Management Client +type ActivityLogAlertsClient struct { + BaseClient +} + +// NewActivityLogAlertsClient creates an instance of the ActivityLogAlertsClient client. +func NewActivityLogAlertsClient(subscriptionID string) ActivityLogAlertsClient { + return NewActivityLogAlertsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewActivityLogAlertsClientWithBaseURI creates an instance of the ActivityLogAlertsClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewActivityLogAlertsClientWithBaseURI(baseURI string, subscriptionID string) ActivityLogAlertsClient { + return ActivityLogAlertsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate create a new activity log alert or update an existing one. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// activityLogAlertName - the name of the activity log alert. +// activityLogAlert - the activity log alert to create or use for the update. +func (client ActivityLogAlertsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, activityLogAlertName string, activityLogAlert ActivityLogAlertResource) (result ActivityLogAlertResource, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ActivityLogAlertsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: activityLogAlert, + Constraints: []validation.Constraint{{Target: "activityLogAlert.ActivityLogAlert", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "activityLogAlert.ActivityLogAlert.Scopes", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "activityLogAlert.ActivityLogAlert.Condition", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "activityLogAlert.ActivityLogAlert.Condition.AllOf", Name: validation.Null, Rule: true, Chain: nil}}}, + {Target: "activityLogAlert.ActivityLogAlert.Actions", Name: validation.Null, Rule: true, Chain: nil}, + }}}}}); err != nil { + return result, validation.NewError("insights.ActivityLogAlertsClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, activityLogAlertName, activityLogAlert) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ActivityLogAlertsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.ActivityLogAlertsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ActivityLogAlertsClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ActivityLogAlertsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, activityLogAlertName string, activityLogAlert ActivityLogAlertResource) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "activityLogAlertName": autorest.Encode("path", activityLogAlertName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-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.insights/activityLogAlerts/{activityLogAlertName}", pathParameters), + autorest.WithJSON(activityLogAlert), + 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 ActivityLogAlertsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ActivityLogAlertsClient) CreateOrUpdateResponder(resp *http.Response) (result ActivityLogAlertResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete an activity log alert. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// activityLogAlertName - the name of the activity log alert. +func (client ActivityLogAlertsClient) Delete(ctx context.Context, resourceGroupName string, activityLogAlertName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ActivityLogAlertsClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.ActivityLogAlertsClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, activityLogAlertName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ActivityLogAlertsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "insights.ActivityLogAlertsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ActivityLogAlertsClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ActivityLogAlertsClient) DeletePreparer(ctx context.Context, resourceGroupName string, activityLogAlertName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "activityLogAlertName": autorest.Encode("path", activityLogAlertName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-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.insights/activityLogAlerts/{activityLogAlertName}", 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 ActivityLogAlertsClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ActivityLogAlertsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get get an activity log alert. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// activityLogAlertName - the name of the activity log alert. +func (client ActivityLogAlertsClient) Get(ctx context.Context, resourceGroupName string, activityLogAlertName string) (result ActivityLogAlertResource, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ActivityLogAlertsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.ActivityLogAlertsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, activityLogAlertName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ActivityLogAlertsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.ActivityLogAlertsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ActivityLogAlertsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ActivityLogAlertsClient) GetPreparer(ctx context.Context, resourceGroupName string, activityLogAlertName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "activityLogAlertName": autorest.Encode("path", activityLogAlertName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-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.insights/activityLogAlerts/{activityLogAlertName}", 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 ActivityLogAlertsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ActivityLogAlertsClient) GetResponder(resp *http.Response) (result ActivityLogAlertResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByResourceGroup get a list of all activity log alerts in a resource group. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +func (client ActivityLogAlertsClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result ActivityLogAlertList, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ActivityLogAlertsClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.ActivityLogAlertsClient", "ListByResourceGroup", err.Error()) + } + + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ActivityLogAlertsClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.ActivityLogAlertsClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ActivityLogAlertsClient", "ListByResourceGroup", resp, "Failure responding to request") + return + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client ActivityLogAlertsClient) 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 = "2017-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.insights/activityLogAlerts", 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 ActivityLogAlertsClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client ActivityLogAlertsClient) ListByResourceGroupResponder(resp *http.Response) (result ActivityLogAlertList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListBySubscriptionID get a list of all activity log alerts in a subscription. +func (client ActivityLogAlertsClient) ListBySubscriptionID(ctx context.Context) (result ActivityLogAlertList, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ActivityLogAlertsClient.ListBySubscriptionID") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.ActivityLogAlertsClient", "ListBySubscriptionID", err.Error()) + } + + req, err := client.ListBySubscriptionIDPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ActivityLogAlertsClient", "ListBySubscriptionID", nil, "Failure preparing request") + return + } + + resp, err := client.ListBySubscriptionIDSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.ActivityLogAlertsClient", "ListBySubscriptionID", resp, "Failure sending request") + return + } + + result, err = client.ListBySubscriptionIDResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ActivityLogAlertsClient", "ListBySubscriptionID", resp, "Failure responding to request") + return + } + + return +} + +// ListBySubscriptionIDPreparer prepares the ListBySubscriptionID request. +func (client ActivityLogAlertsClient) ListBySubscriptionIDPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/microsoft.insights/activityLogAlerts", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListBySubscriptionIDSender sends the ListBySubscriptionID request. The method will close the +// http.Response Body if it receives an error. +func (client ActivityLogAlertsClient) ListBySubscriptionIDSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListBySubscriptionIDResponder handles the response to the ListBySubscriptionID request. The method always +// closes the http.Response Body. +func (client ActivityLogAlertsClient) ListBySubscriptionIDResponder(resp *http.Response) (result ActivityLogAlertList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Update updates an existing ActivityLogAlertResource's tags. To update other fields use the CreateOrUpdate method. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// activityLogAlertName - the name of the activity log alert. +// activityLogAlertPatch - parameters supplied to the operation. +func (client ActivityLogAlertsClient) Update(ctx context.Context, resourceGroupName string, activityLogAlertName string, activityLogAlertPatch ActivityLogAlertPatchBody) (result ActivityLogAlertResource, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ActivityLogAlertsClient.Update") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.ActivityLogAlertsClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, activityLogAlertName, activityLogAlertPatch) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ActivityLogAlertsClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.ActivityLogAlertsClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ActivityLogAlertsClient", "Update", resp, "Failure responding to request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client ActivityLogAlertsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, activityLogAlertName string, activityLogAlertPatch ActivityLogAlertPatchBody) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "activityLogAlertName": autorest.Encode("path", activityLogAlertName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-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.insights/activityLogAlerts/{activityLogAlertName}", pathParameters), + autorest.WithJSON(activityLogAlertPatch), + 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 ActivityLogAlertsClient) UpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client ActivityLogAlertsClient) UpdateResponder(resp *http.Response) (result ActivityLogAlertResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/monitor/mgmt/2021-04-01-preview/insights/activitylogs.go b/services/preview/monitor/mgmt/2021-04-01-preview/insights/activitylogs.go new file mode 100644 index 000000000000..468cd15e3148 --- /dev/null +++ b/services/preview/monitor/mgmt/2021-04-01-preview/insights/activitylogs.go @@ -0,0 +1,173 @@ +package insights + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ActivityLogsClient is the monitor Management Client +type ActivityLogsClient struct { + BaseClient +} + +// NewActivityLogsClient creates an instance of the ActivityLogsClient client. +func NewActivityLogsClient(subscriptionID string) ActivityLogsClient { + return NewActivityLogsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewActivityLogsClientWithBaseURI creates an instance of the ActivityLogsClient client using a custom endpoint. Use +// this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewActivityLogsClientWithBaseURI(baseURI string, subscriptionID string) ActivityLogsClient { + return ActivityLogsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List provides the list of records from the activity logs. +// Parameters: +// filter - reduces the set of data collected.
This argument is required and it also requires at least the +// start date/time.
The **$filter** argument is very restricted and allows only the following patterns.
- +// *List events for a resource group*: $filter=eventTimestamp ge '2014-07-16T04:36:37.6407898Z' and +// eventTimestamp le '2014-07-20T04:36:37.6407898Z' and resourceGroupName eq 'resourceGroupName'.
- *List +// events for resource*: $filter=eventTimestamp ge '2014-07-16T04:36:37.6407898Z' and eventTimestamp le +// '2014-07-20T04:36:37.6407898Z' and resourceUri eq 'resourceURI'.
- *List events for a subscription in a +// time range*: $filter=eventTimestamp ge '2014-07-16T04:36:37.6407898Z' and eventTimestamp le +// '2014-07-20T04:36:37.6407898Z'.
- *List events for a resource provider*: $filter=eventTimestamp ge +// '2014-07-16T04:36:37.6407898Z' and eventTimestamp le '2014-07-20T04:36:37.6407898Z' and resourceProvider eq +// 'resourceProviderName'.
- *List events for a correlation Id*: $filter=eventTimestamp ge +// '2014-07-16T04:36:37.6407898Z' and eventTimestamp le '2014-07-20T04:36:37.6407898Z' and correlationId eq +// 'correlationID'.

**NOTE**: No other syntax is allowed. +// selectParameter - used to fetch events with only the given properties.
The **$select** argument is a +// comma separated list of property names to be returned. Possible values are: *authorization*, *claims*, +// *correlationId*, *description*, *eventDataId*, *eventName*, *eventTimestamp*, *httpRequest*, *level*, +// *operationId*, *operationName*, *properties*, *resourceGroupName*, *resourceProviderName*, *resourceId*, +// *status*, *submissionTimestamp*, *subStatus*, *subscriptionId* +func (client ActivityLogsClient) List(ctx context.Context, filter string, selectParameter string) (result EventDataCollectionPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ActivityLogsClient.List") + defer func() { + sc := -1 + if result.edc.Response.Response != nil { + sc = result.edc.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.ActivityLogsClient", "List", err.Error()) + } + + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, filter, selectParameter) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ActivityLogsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.edc.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.ActivityLogsClient", "List", resp, "Failure sending request") + return + } + + result.edc, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ActivityLogsClient", "List", resp, "Failure responding to request") + return + } + if result.edc.hasNextLink() && result.edc.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client ActivityLogsClient) ListPreparer(ctx context.Context, filter string, selectParameter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-04-01" + queryParameters := map[string]interface{}{ + "$filter": autorest.Encode("query", filter), + "api-version": APIVersion, + } + if len(selectParameter) > 0 { + queryParameters["$select"] = autorest.Encode("query", selectParameter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/microsoft.insights/eventtypes/management/values", 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 ActivityLogsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client ActivityLogsClient) ListResponder(resp *http.Response) (result EventDataCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client ActivityLogsClient) listNextResults(ctx context.Context, lastResults EventDataCollection) (result EventDataCollection, err error) { + req, err := lastResults.eventDataCollectionPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "insights.ActivityLogsClient", "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, "insights.ActivityLogsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ActivityLogsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client ActivityLogsClient) ListComplete(ctx context.Context, filter string, selectParameter string) (result EventDataCollectionIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ActivityLogsClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx, filter, selectParameter) + return +} diff --git a/services/preview/monitor/mgmt/2021-04-01-preview/insights/alertruleincidents.go b/services/preview/monitor/mgmt/2021-04-01-preview/insights/alertruleincidents.go new file mode 100644 index 000000000000..a7dcd9cba31e --- /dev/null +++ b/services/preview/monitor/mgmt/2021-04-01-preview/insights/alertruleincidents.go @@ -0,0 +1,205 @@ +package insights + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// AlertRuleIncidentsClient is the monitor Management Client +type AlertRuleIncidentsClient struct { + BaseClient +} + +// NewAlertRuleIncidentsClient creates an instance of the AlertRuleIncidentsClient client. +func NewAlertRuleIncidentsClient(subscriptionID string) AlertRuleIncidentsClient { + return NewAlertRuleIncidentsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewAlertRuleIncidentsClientWithBaseURI creates an instance of the AlertRuleIncidentsClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewAlertRuleIncidentsClientWithBaseURI(baseURI string, subscriptionID string) AlertRuleIncidentsClient { + return AlertRuleIncidentsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get gets an incident associated to an alert rule +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// ruleName - the name of the rule. +// incidentName - the name of the incident to retrieve. +func (client AlertRuleIncidentsClient) Get(ctx context.Context, resourceGroupName string, ruleName string, incidentName string) (result Incident, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AlertRuleIncidentsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.AlertRuleIncidentsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, ruleName, incidentName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AlertRuleIncidentsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.AlertRuleIncidentsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AlertRuleIncidentsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client AlertRuleIncidentsClient) GetPreparer(ctx context.Context, resourceGroupName string, ruleName string, incidentName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "incidentName": autorest.Encode("path", incidentName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "ruleName": autorest.Encode("path", ruleName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-03-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.insights/alertrules/{ruleName}/incidents/{incidentName}", 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 AlertRuleIncidentsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client AlertRuleIncidentsClient) GetResponder(resp *http.Response) (result Incident, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAlertRule gets a list of incidents associated to an alert rule +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// ruleName - the name of the rule. +func (client AlertRuleIncidentsClient) ListByAlertRule(ctx context.Context, resourceGroupName string, ruleName string) (result IncidentListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AlertRuleIncidentsClient.ListByAlertRule") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.AlertRuleIncidentsClient", "ListByAlertRule", err.Error()) + } + + req, err := client.ListByAlertRulePreparer(ctx, resourceGroupName, ruleName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AlertRuleIncidentsClient", "ListByAlertRule", nil, "Failure preparing request") + return + } + + resp, err := client.ListByAlertRuleSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.AlertRuleIncidentsClient", "ListByAlertRule", resp, "Failure sending request") + return + } + + result, err = client.ListByAlertRuleResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AlertRuleIncidentsClient", "ListByAlertRule", resp, "Failure responding to request") + return + } + + return +} + +// ListByAlertRulePreparer prepares the ListByAlertRule request. +func (client AlertRuleIncidentsClient) ListByAlertRulePreparer(ctx context.Context, resourceGroupName string, ruleName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "ruleName": autorest.Encode("path", ruleName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-03-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.insights/alertrules/{ruleName}/incidents", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByAlertRuleSender sends the ListByAlertRule request. The method will close the +// http.Response Body if it receives an error. +func (client AlertRuleIncidentsClient) ListByAlertRuleSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByAlertRuleResponder handles the response to the ListByAlertRule request. The method always +// closes the http.Response Body. +func (client AlertRuleIncidentsClient) ListByAlertRuleResponder(resp *http.Response) (result IncidentListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/monitor/mgmt/2021-04-01-preview/insights/alertrules.go b/services/preview/monitor/mgmt/2021-04-01-preview/insights/alertrules.go new file mode 100644 index 000000000000..888ed122e267 --- /dev/null +++ b/services/preview/monitor/mgmt/2021-04-01-preview/insights/alertrules.go @@ -0,0 +1,542 @@ +package insights + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// AlertRulesClient is the monitor Management Client +type AlertRulesClient struct { + BaseClient +} + +// NewAlertRulesClient creates an instance of the AlertRulesClient client. +func NewAlertRulesClient(subscriptionID string) AlertRulesClient { + return NewAlertRulesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewAlertRulesClientWithBaseURI creates an instance of the AlertRulesClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewAlertRulesClientWithBaseURI(baseURI string, subscriptionID string) AlertRulesClient { + return AlertRulesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a classic metric alert rule. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// ruleName - the name of the rule. +// parameters - the parameters of the rule to create or update. +func (client AlertRulesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, ruleName string, parameters AlertRuleResource) (result AlertRuleResource, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AlertRulesClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.AlertRule", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.AlertRule.Name", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.AlertRule.IsEnabled", Name: validation.Null, Rule: true, Chain: nil}, + }}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.AlertRulesClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, ruleName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AlertRulesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.AlertRulesClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AlertRulesClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client AlertRulesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, ruleName string, parameters AlertRuleResource) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "ruleName": autorest.Encode("path", ruleName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-03-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.Insights/alertrules/{ruleName}", 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 AlertRulesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client AlertRulesClient) CreateOrUpdateResponder(resp *http.Response) (result AlertRuleResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a classic metric alert rule +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// ruleName - the name of the rule. +func (client AlertRulesClient) Delete(ctx context.Context, resourceGroupName string, ruleName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AlertRulesClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.AlertRulesClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, ruleName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AlertRulesClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "insights.AlertRulesClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AlertRulesClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client AlertRulesClient) DeletePreparer(ctx context.Context, resourceGroupName string, ruleName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "ruleName": autorest.Encode("path", ruleName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-03-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.Insights/alertrules/{ruleName}", 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 AlertRulesClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client AlertRulesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a classic metric alert rule +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// ruleName - the name of the rule. +func (client AlertRulesClient) Get(ctx context.Context, resourceGroupName string, ruleName string) (result AlertRuleResource, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AlertRulesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.AlertRulesClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, ruleName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AlertRulesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.AlertRulesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AlertRulesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client AlertRulesClient) GetPreparer(ctx context.Context, resourceGroupName string, ruleName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "ruleName": autorest.Encode("path", ruleName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-03-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.Insights/alertrules/{ruleName}", 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 AlertRulesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client AlertRulesClient) GetResponder(resp *http.Response) (result AlertRuleResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByResourceGroup list the classic metric alert rules within a resource group. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +func (client AlertRulesClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result AlertRuleResourceCollection, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AlertRulesClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.AlertRulesClient", "ListByResourceGroup", err.Error()) + } + + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AlertRulesClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.AlertRulesClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AlertRulesClient", "ListByResourceGroup", resp, "Failure responding to request") + return + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client AlertRulesClient) 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 = "2016-03-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.Insights/alertrules", 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 AlertRulesClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client AlertRulesClient) ListByResourceGroupResponder(resp *http.Response) (result AlertRuleResourceCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListBySubscription list the classic metric alert rules within a subscription. +func (client AlertRulesClient) ListBySubscription(ctx context.Context) (result AlertRuleResourceCollection, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AlertRulesClient.ListBySubscription") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.AlertRulesClient", "ListBySubscription", err.Error()) + } + + req, err := client.ListBySubscriptionPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AlertRulesClient", "ListBySubscription", nil, "Failure preparing request") + return + } + + resp, err := client.ListBySubscriptionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.AlertRulesClient", "ListBySubscription", resp, "Failure sending request") + return + } + + result, err = client.ListBySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AlertRulesClient", "ListBySubscription", resp, "Failure responding to request") + return + } + + return +} + +// ListBySubscriptionPreparer prepares the ListBySubscription request. +func (client AlertRulesClient) ListBySubscriptionPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Insights/alertrules", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListBySubscriptionSender sends the ListBySubscription request. The method will close the +// http.Response Body if it receives an error. +func (client AlertRulesClient) ListBySubscriptionSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListBySubscriptionResponder handles the response to the ListBySubscription request. The method always +// closes the http.Response Body. +func (client AlertRulesClient) ListBySubscriptionResponder(resp *http.Response) (result AlertRuleResourceCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Update updates an existing classic metric AlertRuleResource. To update other fields use the CreateOrUpdate method. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// ruleName - the name of the rule. +// alertRulesResource - parameters supplied to the operation. +func (client AlertRulesClient) Update(ctx context.Context, resourceGroupName string, ruleName string, alertRulesResource AlertRuleResourcePatch) (result AlertRuleResource, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AlertRulesClient.Update") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.AlertRulesClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, ruleName, alertRulesResource) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AlertRulesClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.AlertRulesClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AlertRulesClient", "Update", resp, "Failure responding to request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client AlertRulesClient) UpdatePreparer(ctx context.Context, resourceGroupName string, ruleName string, alertRulesResource AlertRuleResourcePatch) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "ruleName": autorest.Encode("path", ruleName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-03-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.Insights/alertrules/{ruleName}", pathParameters), + autorest.WithJSON(alertRulesResource), + 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 AlertRulesClient) UpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client AlertRulesClient) UpdateResponder(resp *http.Response) (result AlertRuleResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/monitor/mgmt/2021-04-01-preview/insights/autoscalesettings.go b/services/preview/monitor/mgmt/2021-04-01-preview/insights/autoscalesettings.go new file mode 100644 index 000000000000..db9b916df1d9 --- /dev/null +++ b/services/preview/monitor/mgmt/2021-04-01-preview/insights/autoscalesettings.go @@ -0,0 +1,627 @@ +package insights + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// AutoscaleSettingsClient is the monitor Management Client +type AutoscaleSettingsClient struct { + BaseClient +} + +// NewAutoscaleSettingsClient creates an instance of the AutoscaleSettingsClient client. +func NewAutoscaleSettingsClient(subscriptionID string) AutoscaleSettingsClient { + return NewAutoscaleSettingsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewAutoscaleSettingsClientWithBaseURI creates an instance of the AutoscaleSettingsClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewAutoscaleSettingsClientWithBaseURI(baseURI string, subscriptionID string) AutoscaleSettingsClient { + return AutoscaleSettingsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates an autoscale setting. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// autoscaleSettingName - the autoscale setting name. +// parameters - parameters supplied to the operation. +func (client AutoscaleSettingsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, autoscaleSettingName string, parameters AutoscaleSettingResource) (result AutoscaleSettingResource, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AutoscaleSettingsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.AutoscaleSetting", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.AutoscaleSetting.Profiles", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.AutoscaleSetting.Profiles", Name: validation.MaxItems, Rule: 20, Chain: nil}}}, + }}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.AutoscaleSettingsClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, autoscaleSettingName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AutoscaleSettingsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.AutoscaleSettingsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AutoscaleSettingsClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client AutoscaleSettingsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, autoscaleSettingName string, parameters AutoscaleSettingResource) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "autoscaleSettingName": autorest.Encode("path", autoscaleSettingName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-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.insights/autoscalesettings/{autoscaleSettingName}", 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 AutoscaleSettingsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client AutoscaleSettingsClient) CreateOrUpdateResponder(resp *http.Response) (result AutoscaleSettingResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes and autoscale setting +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// autoscaleSettingName - the autoscale setting name. +func (client AutoscaleSettingsClient) Delete(ctx context.Context, resourceGroupName string, autoscaleSettingName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AutoscaleSettingsClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.AutoscaleSettingsClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, autoscaleSettingName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AutoscaleSettingsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "insights.AutoscaleSettingsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AutoscaleSettingsClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client AutoscaleSettingsClient) DeletePreparer(ctx context.Context, resourceGroupName string, autoscaleSettingName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "autoscaleSettingName": autorest.Encode("path", autoscaleSettingName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-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.insights/autoscalesettings/{autoscaleSettingName}", 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 AutoscaleSettingsClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client AutoscaleSettingsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets an autoscale setting +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// autoscaleSettingName - the autoscale setting name. +func (client AutoscaleSettingsClient) Get(ctx context.Context, resourceGroupName string, autoscaleSettingName string) (result AutoscaleSettingResource, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AutoscaleSettingsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.AutoscaleSettingsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, autoscaleSettingName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AutoscaleSettingsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.AutoscaleSettingsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AutoscaleSettingsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client AutoscaleSettingsClient) GetPreparer(ctx context.Context, resourceGroupName string, autoscaleSettingName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "autoscaleSettingName": autorest.Encode("path", autoscaleSettingName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-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.insights/autoscalesettings/{autoscaleSettingName}", 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 AutoscaleSettingsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client AutoscaleSettingsClient) GetResponder(resp *http.Response) (result AutoscaleSettingResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByResourceGroup lists the autoscale settings for a resource group +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +func (client AutoscaleSettingsClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result AutoscaleSettingResourceCollectionPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AutoscaleSettingsClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.asrc.Response.Response != nil { + sc = result.asrc.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.AutoscaleSettingsClient", "ListByResourceGroup", err.Error()) + } + + result.fn = client.listByResourceGroupNextResults + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AutoscaleSettingsClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.asrc.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.AutoscaleSettingsClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result.asrc, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AutoscaleSettingsClient", "ListByResourceGroup", resp, "Failure responding to request") + return + } + if result.asrc.hasNextLink() && result.asrc.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client AutoscaleSettingsClient) 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-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.insights/autoscalesettings", 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 AutoscaleSettingsClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client AutoscaleSettingsClient) ListByResourceGroupResponder(resp *http.Response) (result AutoscaleSettingResourceCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByResourceGroupNextResults retrieves the next set of results, if any. +func (client AutoscaleSettingsClient) listByResourceGroupNextResults(ctx context.Context, lastResults AutoscaleSettingResourceCollection) (result AutoscaleSettingResourceCollection, err error) { + req, err := lastResults.autoscaleSettingResourceCollectionPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "insights.AutoscaleSettingsClient", "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, "insights.AutoscaleSettingsClient", "listByResourceGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AutoscaleSettingsClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. +func (client AutoscaleSettingsClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result AutoscaleSettingResourceCollectionIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AutoscaleSettingsClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByResourceGroup(ctx, resourceGroupName) + return +} + +// ListBySubscription lists the autoscale settings for a subscription +func (client AutoscaleSettingsClient) ListBySubscription(ctx context.Context) (result AutoscaleSettingResourceCollectionPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AutoscaleSettingsClient.ListBySubscription") + defer func() { + sc := -1 + if result.asrc.Response.Response != nil { + sc = result.asrc.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.AutoscaleSettingsClient", "ListBySubscription", err.Error()) + } + + result.fn = client.listBySubscriptionNextResults + req, err := client.ListBySubscriptionPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AutoscaleSettingsClient", "ListBySubscription", nil, "Failure preparing request") + return + } + + resp, err := client.ListBySubscriptionSender(req) + if err != nil { + result.asrc.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.AutoscaleSettingsClient", "ListBySubscription", resp, "Failure sending request") + return + } + + result.asrc, err = client.ListBySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AutoscaleSettingsClient", "ListBySubscription", resp, "Failure responding to request") + return + } + if result.asrc.hasNextLink() && result.asrc.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListBySubscriptionPreparer prepares the ListBySubscription request. +func (client AutoscaleSettingsClient) ListBySubscriptionPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/microsoft.insights/autoscalesettings", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListBySubscriptionSender sends the ListBySubscription request. The method will close the +// http.Response Body if it receives an error. +func (client AutoscaleSettingsClient) ListBySubscriptionSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListBySubscriptionResponder handles the response to the ListBySubscription request. The method always +// closes the http.Response Body. +func (client AutoscaleSettingsClient) ListBySubscriptionResponder(resp *http.Response) (result AutoscaleSettingResourceCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listBySubscriptionNextResults retrieves the next set of results, if any. +func (client AutoscaleSettingsClient) listBySubscriptionNextResults(ctx context.Context, lastResults AutoscaleSettingResourceCollection) (result AutoscaleSettingResourceCollection, err error) { + req, err := lastResults.autoscaleSettingResourceCollectionPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "insights.AutoscaleSettingsClient", "listBySubscriptionNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListBySubscriptionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "insights.AutoscaleSettingsClient", "listBySubscriptionNextResults", resp, "Failure sending next results request") + } + result, err = client.ListBySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AutoscaleSettingsClient", "listBySubscriptionNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListBySubscriptionComplete enumerates all values, automatically crossing page boundaries as required. +func (client AutoscaleSettingsClient) ListBySubscriptionComplete(ctx context.Context) (result AutoscaleSettingResourceCollectionIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AutoscaleSettingsClient.ListBySubscription") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListBySubscription(ctx) + return +} + +// Update updates an existing AutoscaleSettingsResource. To update other fields use the CreateOrUpdate method. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// autoscaleSettingName - the autoscale setting name. +// autoscaleSettingResource - parameters supplied to the operation. +func (client AutoscaleSettingsClient) Update(ctx context.Context, resourceGroupName string, autoscaleSettingName string, autoscaleSettingResource AutoscaleSettingResourcePatch) (result AutoscaleSettingResource, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AutoscaleSettingsClient.Update") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.AutoscaleSettingsClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, autoscaleSettingName, autoscaleSettingResource) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AutoscaleSettingsClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.AutoscaleSettingsClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.AutoscaleSettingsClient", "Update", resp, "Failure responding to request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client AutoscaleSettingsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, autoscaleSettingName string, autoscaleSettingResource AutoscaleSettingResourcePatch) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "autoscaleSettingName": autorest.Encode("path", autoscaleSettingName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2015-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.insights/autoscalesettings/{autoscaleSettingName}", pathParameters), + autorest.WithJSON(autoscaleSettingResource), + 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 AutoscaleSettingsClient) UpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client AutoscaleSettingsClient) UpdateResponder(resp *http.Response) (result AutoscaleSettingResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/monitor/mgmt/2021-04-01-preview/insights/baselines.go b/services/preview/monitor/mgmt/2021-04-01-preview/insights/baselines.go new file mode 100644 index 000000000000..337ce4d1fa0f --- /dev/null +++ b/services/preview/monitor/mgmt/2021-04-01-preview/insights/baselines.go @@ -0,0 +1,154 @@ +package insights + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// BaselinesClient is the monitor Management Client +type BaselinesClient struct { + BaseClient +} + +// NewBaselinesClient creates an instance of the BaselinesClient client. +func NewBaselinesClient(subscriptionID string) BaselinesClient { + return NewBaselinesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewBaselinesClientWithBaseURI creates an instance of the BaselinesClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewBaselinesClientWithBaseURI(baseURI string, subscriptionID string) BaselinesClient { + return BaselinesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List **Lists the metric baseline values for a resource**. +// Parameters: +// resourceURI - the identifier of the resource. +// metricnames - the names of the metrics (comma separated) to retrieve. Special case: If a metricname itself +// has a comma in it then use %2 to indicate it. Eg: 'Metric,Name1' should be **'Metric%2Name1'** +// metricnamespace - metric namespace to query metric definitions for. +// timespan - the timespan of the query. It is a string with the following format +// 'startDateTime_ISO/endDateTime_ISO'. +// interval - the interval (i.e. timegrain) of the query. +// aggregation - the list of aggregation types (comma separated) to retrieve. +// sensitivities - the list of sensitivities (comma separated) to retrieve. +// filter - the **$filter** is used to reduce the set of metric data returned. Example: Metric contains +// metadata A, B and C. - Return all time series of C where A = a1 and B = b1 or b2 **$filter=A eq 'a1' and B +// eq 'b1' or B eq 'b2' and C eq '*'** - Invalid variant: **$filter=A eq 'a1' and B eq 'b1' and C eq '*' or B = +// 'b2'** This is invalid because the logical or operator cannot separate two different metadata names. - +// Return all time series where A = a1, B = b1 and C = c1: **$filter=A eq 'a1' and B eq 'b1' and C eq 'c1'** - +// Return all time series where A = a1 **$filter=A eq 'a1' and B eq '*' and C eq '*'**. Special case: When +// dimension name or dimension value uses round brackets. Eg: When dimension name is **dim (test) 1** Instead +// of using $filter= "dim (test) 1 eq '*' " use **$filter= "dim %2528test%2529 1 eq '*' "** When dimension name +// is **dim (test) 3** and dimension value is **dim3 (test) val** Instead of using $filter= "dim (test) 3 eq +// 'dim3 (test) val' " use **$filter= "dim %2528test%2529 3 eq 'dim3 %2528test%2529 val' "** +// resultType - allows retrieving only metadata of the baseline. On data request all information is retrieved. +func (client BaselinesClient) List(ctx context.Context, resourceURI string, metricnames string, metricnamespace string, timespan string, interval *string, aggregation string, sensitivities string, filter string, resultType ResultType) (result MetricBaselinesResponse, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/BaselinesClient.List") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceURI, + Constraints: []validation.Constraint{{Target: "resourceURI", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.BaselinesClient", "List", err.Error()) + } + + req, err := client.ListPreparer(ctx, resourceURI, metricnames, metricnamespace, timespan, interval, aggregation, sensitivities, filter, resultType) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.BaselinesClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.BaselinesClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.BaselinesClient", "List", resp, "Failure responding to request") + return + } + + return +} + +// ListPreparer prepares the List request. +func (client BaselinesClient) ListPreparer(ctx context.Context, resourceURI string, metricnames string, metricnamespace string, timespan string, interval *string, aggregation string, sensitivities string, filter string, resultType ResultType) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceUri": resourceURI, + } + + const APIVersion = "2019-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(metricnames) > 0 { + queryParameters["metricnames"] = autorest.Encode("query", metricnames) + } + if len(metricnamespace) > 0 { + queryParameters["metricnamespace"] = autorest.Encode("query", metricnamespace) + } + if len(timespan) > 0 { + queryParameters["timespan"] = autorest.Encode("query", timespan) + } + if interval != nil { + queryParameters["interval"] = autorest.Encode("query", *interval) + } + if len(aggregation) > 0 { + queryParameters["aggregation"] = autorest.Encode("query", aggregation) + } + if len(sensitivities) > 0 { + queryParameters["sensitivities"] = autorest.Encode("query", sensitivities) + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if len(string(resultType)) > 0 { + queryParameters["resultType"] = autorest.Encode("query", resultType) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{resourceUri}/providers/Microsoft.Insights/metricBaselines", 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 BaselinesClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client BaselinesClient) ListResponder(resp *http.Response) (result MetricBaselinesResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/monitor/mgmt/2021-04-01-preview/insights/client.go b/services/preview/monitor/mgmt/2021-04-01-preview/insights/client.go new file mode 100644 index 000000000000..a777181b0785 --- /dev/null +++ b/services/preview/monitor/mgmt/2021-04-01-preview/insights/client.go @@ -0,0 +1,41 @@ +// Package insights implements the Azure ARM Insights service API version . +// +// Monitor Management Client +package insights + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" +) + +const ( + // DefaultBaseURI is the default URI used for the service Insights + DefaultBaseURI = "https://management.azure.com" +) + +// BaseClient is the base client for Insights. +type BaseClient struct { + autorest.Client + BaseURI string + SubscriptionID string +} + +// New creates an instance of the BaseClient client. +func New(subscriptionID string) BaseClient { + return NewWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewWithBaseURI creates an instance of the BaseClient client using a custom endpoint. Use this when interacting with +// an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { + return BaseClient{ + Client: autorest.NewClientWithUserAgent(UserAgent()), + BaseURI: baseURI, + SubscriptionID: subscriptionID, + } +} diff --git a/services/preview/monitor/mgmt/2021-04-01-preview/insights/datacollectionendpoints.go b/services/preview/monitor/mgmt/2021-04-01-preview/insights/datacollectionendpoints.go new file mode 100644 index 000000000000..7369932edf27 --- /dev/null +++ b/services/preview/monitor/mgmt/2021-04-01-preview/insights/datacollectionendpoints.go @@ -0,0 +1,636 @@ +package insights + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// DataCollectionEndpointsClient is the monitor Management Client +type DataCollectionEndpointsClient struct { + BaseClient +} + +// NewDataCollectionEndpointsClient creates an instance of the DataCollectionEndpointsClient client. +func NewDataCollectionEndpointsClient(subscriptionID string) DataCollectionEndpointsClient { + return NewDataCollectionEndpointsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewDataCollectionEndpointsClientWithBaseURI creates an instance of the DataCollectionEndpointsClient client using a +// custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, +// Azure stack). +func NewDataCollectionEndpointsClientWithBaseURI(baseURI string, subscriptionID string) DataCollectionEndpointsClient { + return DataCollectionEndpointsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Create sends the create request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// dataCollectionEndpointName - the name of the data collection endpoint. The name is case insensitive. +// body - the payload +func (client DataCollectionEndpointsClient) Create(ctx context.Context, resourceGroupName string, dataCollectionEndpointName string, body *DataCollectionEndpointResource) (result DataCollectionEndpointResource, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DataCollectionEndpointsClient.Create") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: body, + Constraints: []validation.Constraint{{Target: "body", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "body.Location", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("insights.DataCollectionEndpointsClient", "Create", err.Error()) + } + + req, err := client.CreatePreparer(ctx, resourceGroupName, dataCollectionEndpointName, body) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DataCollectionEndpointsClient", "Create", nil, "Failure preparing request") + return + } + + resp, err := client.CreateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.DataCollectionEndpointsClient", "Create", resp, "Failure sending request") + return + } + + result, err = client.CreateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DataCollectionEndpointsClient", "Create", resp, "Failure responding to request") + return + } + + return +} + +// CreatePreparer prepares the Create request. +func (client DataCollectionEndpointsClient) CreatePreparer(ctx context.Context, resourceGroupName string, dataCollectionEndpointName string, body *DataCollectionEndpointResource) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "dataCollectionEndpointName": autorest.Encode("path", dataCollectionEndpointName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + body.ID = nil + body.Name = nil + body.Type = nil + body.Etag = nil + body.SystemData = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if body != nil { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithJSON(body)) + } + 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 DataCollectionEndpointsClient) CreateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client DataCollectionEndpointsClient) CreateResponder(resp *http.Response) (result DataCollectionEndpointResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete sends the delete request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// dataCollectionEndpointName - the name of the data collection endpoint. The name is case insensitive. +func (client DataCollectionEndpointsClient) Delete(ctx context.Context, resourceGroupName string, dataCollectionEndpointName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DataCollectionEndpointsClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.DataCollectionEndpointsClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, dataCollectionEndpointName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DataCollectionEndpointsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "insights.DataCollectionEndpointsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DataCollectionEndpointsClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client DataCollectionEndpointsClient) DeletePreparer(ctx context.Context, resourceGroupName string, dataCollectionEndpointName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "dataCollectionEndpointName": autorest.Encode("path", dataCollectionEndpointName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-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.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}", 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 DataCollectionEndpointsClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client DataCollectionEndpointsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get sends the get request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// dataCollectionEndpointName - the name of the data collection endpoint. The name is case insensitive. +func (client DataCollectionEndpointsClient) Get(ctx context.Context, resourceGroupName string, dataCollectionEndpointName string) (result DataCollectionEndpointResource, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DataCollectionEndpointsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.DataCollectionEndpointsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, dataCollectionEndpointName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DataCollectionEndpointsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.DataCollectionEndpointsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DataCollectionEndpointsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client DataCollectionEndpointsClient) GetPreparer(ctx context.Context, resourceGroupName string, dataCollectionEndpointName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "dataCollectionEndpointName": autorest.Encode("path", dataCollectionEndpointName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-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.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}", 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 DataCollectionEndpointsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client DataCollectionEndpointsClient) GetResponder(resp *http.Response) (result DataCollectionEndpointResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByResourceGroup sends the list by resource group request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +func (client DataCollectionEndpointsClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result DataCollectionEndpointResourceListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DataCollectionEndpointsClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.dcerlr.Response.Response != nil { + sc = result.dcerlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.DataCollectionEndpointsClient", "ListByResourceGroup", err.Error()) + } + + result.fn = client.listByResourceGroupNextResults + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DataCollectionEndpointsClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.dcerlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.DataCollectionEndpointsClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result.dcerlr, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DataCollectionEndpointsClient", "ListByResourceGroup", resp, "Failure responding to request") + return + } + if result.dcerlr.hasNextLink() && result.dcerlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client DataCollectionEndpointsClient) 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 = "2021-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.Insights/dataCollectionEndpoints", 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 DataCollectionEndpointsClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client DataCollectionEndpointsClient) ListByResourceGroupResponder(resp *http.Response) (result DataCollectionEndpointResourceListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByResourceGroupNextResults retrieves the next set of results, if any. +func (client DataCollectionEndpointsClient) listByResourceGroupNextResults(ctx context.Context, lastResults DataCollectionEndpointResourceListResult) (result DataCollectionEndpointResourceListResult, err error) { + req, err := lastResults.dataCollectionEndpointResourceListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "insights.DataCollectionEndpointsClient", "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, "insights.DataCollectionEndpointsClient", "listByResourceGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DataCollectionEndpointsClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. +func (client DataCollectionEndpointsClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result DataCollectionEndpointResourceListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DataCollectionEndpointsClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByResourceGroup(ctx, resourceGroupName) + return +} + +// ListBySubscription sends the list by subscription request. +func (client DataCollectionEndpointsClient) ListBySubscription(ctx context.Context) (result DataCollectionEndpointResourceListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DataCollectionEndpointsClient.ListBySubscription") + defer func() { + sc := -1 + if result.dcerlr.Response.Response != nil { + sc = result.dcerlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.DataCollectionEndpointsClient", "ListBySubscription", err.Error()) + } + + result.fn = client.listBySubscriptionNextResults + req, err := client.ListBySubscriptionPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DataCollectionEndpointsClient", "ListBySubscription", nil, "Failure preparing request") + return + } + + resp, err := client.ListBySubscriptionSender(req) + if err != nil { + result.dcerlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.DataCollectionEndpointsClient", "ListBySubscription", resp, "Failure sending request") + return + } + + result.dcerlr, err = client.ListBySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DataCollectionEndpointsClient", "ListBySubscription", resp, "Failure responding to request") + return + } + if result.dcerlr.hasNextLink() && result.dcerlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListBySubscriptionPreparer prepares the ListBySubscription request. +func (client DataCollectionEndpointsClient) ListBySubscriptionPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Insights/dataCollectionEndpoints", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListBySubscriptionSender sends the ListBySubscription request. The method will close the +// http.Response Body if it receives an error. +func (client DataCollectionEndpointsClient) ListBySubscriptionSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListBySubscriptionResponder handles the response to the ListBySubscription request. The method always +// closes the http.Response Body. +func (client DataCollectionEndpointsClient) ListBySubscriptionResponder(resp *http.Response) (result DataCollectionEndpointResourceListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listBySubscriptionNextResults retrieves the next set of results, if any. +func (client DataCollectionEndpointsClient) listBySubscriptionNextResults(ctx context.Context, lastResults DataCollectionEndpointResourceListResult) (result DataCollectionEndpointResourceListResult, err error) { + req, err := lastResults.dataCollectionEndpointResourceListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "insights.DataCollectionEndpointsClient", "listBySubscriptionNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListBySubscriptionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "insights.DataCollectionEndpointsClient", "listBySubscriptionNextResults", resp, "Failure sending next results request") + } + result, err = client.ListBySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DataCollectionEndpointsClient", "listBySubscriptionNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListBySubscriptionComplete enumerates all values, automatically crossing page boundaries as required. +func (client DataCollectionEndpointsClient) ListBySubscriptionComplete(ctx context.Context) (result DataCollectionEndpointResourceListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DataCollectionEndpointsClient.ListBySubscription") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListBySubscription(ctx) + return +} + +// Update sends the update request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// dataCollectionEndpointName - the name of the data collection endpoint. The name is case insensitive. +// body - the payload +func (client DataCollectionEndpointsClient) Update(ctx context.Context, resourceGroupName string, dataCollectionEndpointName string, body *ResourceForUpdate) (result DataCollectionEndpointResource, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DataCollectionEndpointsClient.Update") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.DataCollectionEndpointsClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, dataCollectionEndpointName, body) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DataCollectionEndpointsClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.DataCollectionEndpointsClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DataCollectionEndpointsClient", "Update", resp, "Failure responding to request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client DataCollectionEndpointsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, dataCollectionEndpointName string, body *ResourceForUpdate) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "dataCollectionEndpointName": autorest.Encode("path", dataCollectionEndpointName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-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.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if body != nil { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithJSON(body)) + } + 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 DataCollectionEndpointsClient) UpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client DataCollectionEndpointsClient) UpdateResponder(resp *http.Response) (result DataCollectionEndpointResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/monitor/mgmt/2021-04-01-preview/insights/datacollectionruleassociations.go b/services/preview/monitor/mgmt/2021-04-01-preview/insights/datacollectionruleassociations.go new file mode 100644 index 000000000000..59878dbc8c2f --- /dev/null +++ b/services/preview/monitor/mgmt/2021-04-01-preview/insights/datacollectionruleassociations.go @@ -0,0 +1,534 @@ +package insights + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// DataCollectionRuleAssociationsClient is the monitor Management Client +type DataCollectionRuleAssociationsClient struct { + BaseClient +} + +// NewDataCollectionRuleAssociationsClient creates an instance of the DataCollectionRuleAssociationsClient client. +func NewDataCollectionRuleAssociationsClient(subscriptionID string) DataCollectionRuleAssociationsClient { + return NewDataCollectionRuleAssociationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewDataCollectionRuleAssociationsClientWithBaseURI creates an instance of the DataCollectionRuleAssociationsClient +// client using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI +// (sovereign clouds, Azure stack). +func NewDataCollectionRuleAssociationsClientWithBaseURI(baseURI string, subscriptionID string) DataCollectionRuleAssociationsClient { + return DataCollectionRuleAssociationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Create sends the create request. +// Parameters: +// resourceURI - the identifier of the resource. +// associationName - the name of the association. The name is case insensitive. +// body - the payload +func (client DataCollectionRuleAssociationsClient) Create(ctx context.Context, resourceURI string, associationName string, body *DataCollectionRuleAssociationProxyOnlyResource) (result DataCollectionRuleAssociationProxyOnlyResource, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DataCollectionRuleAssociationsClient.Create") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceURI, + Constraints: []validation.Constraint{{Target: "resourceURI", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.DataCollectionRuleAssociationsClient", "Create", err.Error()) + } + + req, err := client.CreatePreparer(ctx, resourceURI, associationName, body) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DataCollectionRuleAssociationsClient", "Create", nil, "Failure preparing request") + return + } + + resp, err := client.CreateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.DataCollectionRuleAssociationsClient", "Create", resp, "Failure sending request") + return + } + + result, err = client.CreateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DataCollectionRuleAssociationsClient", "Create", resp, "Failure responding to request") + return + } + + return +} + +// CreatePreparer prepares the Create request. +func (client DataCollectionRuleAssociationsClient) CreatePreparer(ctx context.Context, resourceURI string, associationName string, body *DataCollectionRuleAssociationProxyOnlyResource) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "associationName": autorest.Encode("path", associationName), + "resourceUri": resourceURI, + } + + const APIVersion = "2021-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + body.ID = nil + body.Name = nil + body.Type = nil + body.Etag = nil + body.SystemData = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if body != nil { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithJSON(body)) + } + 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 DataCollectionRuleAssociationsClient) CreateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client DataCollectionRuleAssociationsClient) CreateResponder(resp *http.Response) (result DataCollectionRuleAssociationProxyOnlyResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete sends the delete request. +// Parameters: +// resourceURI - the identifier of the resource. +// associationName - the name of the association. The name is case insensitive. +func (client DataCollectionRuleAssociationsClient) Delete(ctx context.Context, resourceURI string, associationName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DataCollectionRuleAssociationsClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceURI, + Constraints: []validation.Constraint{{Target: "resourceURI", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.DataCollectionRuleAssociationsClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceURI, associationName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DataCollectionRuleAssociationsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "insights.DataCollectionRuleAssociationsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DataCollectionRuleAssociationsClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client DataCollectionRuleAssociationsClient) DeletePreparer(ctx context.Context, resourceURI string, associationName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "associationName": autorest.Encode("path", associationName), + "resourceUri": resourceURI, + } + + const APIVersion = "2021-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}", 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 DataCollectionRuleAssociationsClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client DataCollectionRuleAssociationsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get sends the get request. +// Parameters: +// resourceURI - the identifier of the resource. +// associationName - the name of the association. The name is case insensitive. +func (client DataCollectionRuleAssociationsClient) Get(ctx context.Context, resourceURI string, associationName string) (result DataCollectionRuleAssociationProxyOnlyResource, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DataCollectionRuleAssociationsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceURI, + Constraints: []validation.Constraint{{Target: "resourceURI", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.DataCollectionRuleAssociationsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceURI, associationName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DataCollectionRuleAssociationsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.DataCollectionRuleAssociationsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DataCollectionRuleAssociationsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client DataCollectionRuleAssociationsClient) GetPreparer(ctx context.Context, resourceURI string, associationName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "associationName": autorest.Encode("path", associationName), + "resourceUri": resourceURI, + } + + const APIVersion = "2021-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}", 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 DataCollectionRuleAssociationsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client DataCollectionRuleAssociationsClient) GetResponder(resp *http.Response) (result DataCollectionRuleAssociationProxyOnlyResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByResource sends the list by resource request. +// Parameters: +// resourceURI - the identifier of the resource. +func (client DataCollectionRuleAssociationsClient) ListByResource(ctx context.Context, resourceURI string) (result DataCollectionRuleAssociationProxyOnlyResourceListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DataCollectionRuleAssociationsClient.ListByResource") + defer func() { + sc := -1 + if result.dcraporlr.Response.Response != nil { + sc = result.dcraporlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceURI, + Constraints: []validation.Constraint{{Target: "resourceURI", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.DataCollectionRuleAssociationsClient", "ListByResource", err.Error()) + } + + result.fn = client.listByResourceNextResults + req, err := client.ListByResourcePreparer(ctx, resourceURI) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DataCollectionRuleAssociationsClient", "ListByResource", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceSender(req) + if err != nil { + result.dcraporlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.DataCollectionRuleAssociationsClient", "ListByResource", resp, "Failure sending request") + return + } + + result.dcraporlr, err = client.ListByResourceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DataCollectionRuleAssociationsClient", "ListByResource", resp, "Failure responding to request") + return + } + if result.dcraporlr.hasNextLink() && result.dcraporlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByResourcePreparer prepares the ListByResource request. +func (client DataCollectionRuleAssociationsClient) ListByResourcePreparer(ctx context.Context, resourceURI string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceUri": resourceURI, + } + + const APIVersion = "2021-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByResourceSender sends the ListByResource request. The method will close the +// http.Response Body if it receives an error. +func (client DataCollectionRuleAssociationsClient) ListByResourceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListByResourceResponder handles the response to the ListByResource request. The method always +// closes the http.Response Body. +func (client DataCollectionRuleAssociationsClient) ListByResourceResponder(resp *http.Response) (result DataCollectionRuleAssociationProxyOnlyResourceListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByResourceNextResults retrieves the next set of results, if any. +func (client DataCollectionRuleAssociationsClient) listByResourceNextResults(ctx context.Context, lastResults DataCollectionRuleAssociationProxyOnlyResourceListResult) (result DataCollectionRuleAssociationProxyOnlyResourceListResult, err error) { + req, err := lastResults.dataCollectionRuleAssociationProxyOnlyResourceListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "insights.DataCollectionRuleAssociationsClient", "listByResourceNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByResourceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "insights.DataCollectionRuleAssociationsClient", "listByResourceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByResourceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DataCollectionRuleAssociationsClient", "listByResourceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByResourceComplete enumerates all values, automatically crossing page boundaries as required. +func (client DataCollectionRuleAssociationsClient) ListByResourceComplete(ctx context.Context, resourceURI string) (result DataCollectionRuleAssociationProxyOnlyResourceListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DataCollectionRuleAssociationsClient.ListByResource") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByResource(ctx, resourceURI) + return +} + +// ListByRule sends the list by rule request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// dataCollectionRuleName - the name of the data collection rule. The name is case insensitive. +func (client DataCollectionRuleAssociationsClient) ListByRule(ctx context.Context, resourceGroupName string, dataCollectionRuleName string) (result DataCollectionRuleAssociationProxyOnlyResourceListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DataCollectionRuleAssociationsClient.ListByRule") + defer func() { + sc := -1 + if result.dcraporlr.Response.Response != nil { + sc = result.dcraporlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.DataCollectionRuleAssociationsClient", "ListByRule", err.Error()) + } + + result.fn = client.listByRuleNextResults + req, err := client.ListByRulePreparer(ctx, resourceGroupName, dataCollectionRuleName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DataCollectionRuleAssociationsClient", "ListByRule", nil, "Failure preparing request") + return + } + + resp, err := client.ListByRuleSender(req) + if err != nil { + result.dcraporlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.DataCollectionRuleAssociationsClient", "ListByRule", resp, "Failure sending request") + return + } + + result.dcraporlr, err = client.ListByRuleResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DataCollectionRuleAssociationsClient", "ListByRule", resp, "Failure responding to request") + return + } + if result.dcraporlr.hasNextLink() && result.dcraporlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByRulePreparer prepares the ListByRule request. +func (client DataCollectionRuleAssociationsClient) ListByRulePreparer(ctx context.Context, resourceGroupName string, dataCollectionRuleName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "dataCollectionRuleName": autorest.Encode("path", dataCollectionRuleName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-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.Insights/dataCollectionRules/{dataCollectionRuleName}/associations", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByRuleSender sends the ListByRule request. The method will close the +// http.Response Body if it receives an error. +func (client DataCollectionRuleAssociationsClient) ListByRuleSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByRuleResponder handles the response to the ListByRule request. The method always +// closes the http.Response Body. +func (client DataCollectionRuleAssociationsClient) ListByRuleResponder(resp *http.Response) (result DataCollectionRuleAssociationProxyOnlyResourceListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByRuleNextResults retrieves the next set of results, if any. +func (client DataCollectionRuleAssociationsClient) listByRuleNextResults(ctx context.Context, lastResults DataCollectionRuleAssociationProxyOnlyResourceListResult) (result DataCollectionRuleAssociationProxyOnlyResourceListResult, err error) { + req, err := lastResults.dataCollectionRuleAssociationProxyOnlyResourceListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "insights.DataCollectionRuleAssociationsClient", "listByRuleNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByRuleSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "insights.DataCollectionRuleAssociationsClient", "listByRuleNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByRuleResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DataCollectionRuleAssociationsClient", "listByRuleNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByRuleComplete enumerates all values, automatically crossing page boundaries as required. +func (client DataCollectionRuleAssociationsClient) ListByRuleComplete(ctx context.Context, resourceGroupName string, dataCollectionRuleName string) (result DataCollectionRuleAssociationProxyOnlyResourceListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DataCollectionRuleAssociationsClient.ListByRule") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByRule(ctx, resourceGroupName, dataCollectionRuleName) + return +} diff --git a/services/preview/monitor/mgmt/2021-04-01-preview/insights/datacollectionrules.go b/services/preview/monitor/mgmt/2021-04-01-preview/insights/datacollectionrules.go new file mode 100644 index 000000000000..e3baabf0f6b4 --- /dev/null +++ b/services/preview/monitor/mgmt/2021-04-01-preview/insights/datacollectionrules.go @@ -0,0 +1,636 @@ +package insights + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// DataCollectionRulesClient is the monitor Management Client +type DataCollectionRulesClient struct { + BaseClient +} + +// NewDataCollectionRulesClient creates an instance of the DataCollectionRulesClient client. +func NewDataCollectionRulesClient(subscriptionID string) DataCollectionRulesClient { + return NewDataCollectionRulesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewDataCollectionRulesClientWithBaseURI creates an instance of the DataCollectionRulesClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewDataCollectionRulesClientWithBaseURI(baseURI string, subscriptionID string) DataCollectionRulesClient { + return DataCollectionRulesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Create sends the create request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// dataCollectionRuleName - the name of the data collection rule. The name is case insensitive. +// body - the payload +func (client DataCollectionRulesClient) Create(ctx context.Context, resourceGroupName string, dataCollectionRuleName string, body *DataCollectionRuleResource) (result DataCollectionRuleResource, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DataCollectionRulesClient.Create") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: body, + Constraints: []validation.Constraint{{Target: "body", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "body.Location", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("insights.DataCollectionRulesClient", "Create", err.Error()) + } + + req, err := client.CreatePreparer(ctx, resourceGroupName, dataCollectionRuleName, body) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DataCollectionRulesClient", "Create", nil, "Failure preparing request") + return + } + + resp, err := client.CreateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.DataCollectionRulesClient", "Create", resp, "Failure sending request") + return + } + + result, err = client.CreateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DataCollectionRulesClient", "Create", resp, "Failure responding to request") + return + } + + return +} + +// CreatePreparer prepares the Create request. +func (client DataCollectionRulesClient) CreatePreparer(ctx context.Context, resourceGroupName string, dataCollectionRuleName string, body *DataCollectionRuleResource) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "dataCollectionRuleName": autorest.Encode("path", dataCollectionRuleName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + body.ID = nil + body.Name = nil + body.Type = nil + body.Etag = nil + body.SystemData = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if body != nil { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithJSON(body)) + } + 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 DataCollectionRulesClient) CreateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client DataCollectionRulesClient) CreateResponder(resp *http.Response) (result DataCollectionRuleResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete sends the delete request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// dataCollectionRuleName - the name of the data collection rule. The name is case insensitive. +func (client DataCollectionRulesClient) Delete(ctx context.Context, resourceGroupName string, dataCollectionRuleName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DataCollectionRulesClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.DataCollectionRulesClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, dataCollectionRuleName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DataCollectionRulesClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "insights.DataCollectionRulesClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DataCollectionRulesClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client DataCollectionRulesClient) DeletePreparer(ctx context.Context, resourceGroupName string, dataCollectionRuleName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "dataCollectionRuleName": autorest.Encode("path", dataCollectionRuleName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-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.Insights/dataCollectionRules/{dataCollectionRuleName}", 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 DataCollectionRulesClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client DataCollectionRulesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get sends the get request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// dataCollectionRuleName - the name of the data collection rule. The name is case insensitive. +func (client DataCollectionRulesClient) Get(ctx context.Context, resourceGroupName string, dataCollectionRuleName string) (result DataCollectionRuleResource, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DataCollectionRulesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.DataCollectionRulesClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, dataCollectionRuleName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DataCollectionRulesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.DataCollectionRulesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DataCollectionRulesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client DataCollectionRulesClient) GetPreparer(ctx context.Context, resourceGroupName string, dataCollectionRuleName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "dataCollectionRuleName": autorest.Encode("path", dataCollectionRuleName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-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.Insights/dataCollectionRules/{dataCollectionRuleName}", 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 DataCollectionRulesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client DataCollectionRulesClient) GetResponder(resp *http.Response) (result DataCollectionRuleResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByResourceGroup sends the list by resource group request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +func (client DataCollectionRulesClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result DataCollectionRuleResourceListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DataCollectionRulesClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.dcrrlr.Response.Response != nil { + sc = result.dcrrlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.DataCollectionRulesClient", "ListByResourceGroup", err.Error()) + } + + result.fn = client.listByResourceGroupNextResults + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DataCollectionRulesClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.dcrrlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.DataCollectionRulesClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result.dcrrlr, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DataCollectionRulesClient", "ListByResourceGroup", resp, "Failure responding to request") + return + } + if result.dcrrlr.hasNextLink() && result.dcrrlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client DataCollectionRulesClient) 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 = "2021-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.Insights/dataCollectionRules", 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 DataCollectionRulesClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client DataCollectionRulesClient) ListByResourceGroupResponder(resp *http.Response) (result DataCollectionRuleResourceListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByResourceGroupNextResults retrieves the next set of results, if any. +func (client DataCollectionRulesClient) listByResourceGroupNextResults(ctx context.Context, lastResults DataCollectionRuleResourceListResult) (result DataCollectionRuleResourceListResult, err error) { + req, err := lastResults.dataCollectionRuleResourceListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "insights.DataCollectionRulesClient", "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, "insights.DataCollectionRulesClient", "listByResourceGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DataCollectionRulesClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. +func (client DataCollectionRulesClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result DataCollectionRuleResourceListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DataCollectionRulesClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByResourceGroup(ctx, resourceGroupName) + return +} + +// ListBySubscription sends the list by subscription request. +func (client DataCollectionRulesClient) ListBySubscription(ctx context.Context) (result DataCollectionRuleResourceListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DataCollectionRulesClient.ListBySubscription") + defer func() { + sc := -1 + if result.dcrrlr.Response.Response != nil { + sc = result.dcrrlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.DataCollectionRulesClient", "ListBySubscription", err.Error()) + } + + result.fn = client.listBySubscriptionNextResults + req, err := client.ListBySubscriptionPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DataCollectionRulesClient", "ListBySubscription", nil, "Failure preparing request") + return + } + + resp, err := client.ListBySubscriptionSender(req) + if err != nil { + result.dcrrlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.DataCollectionRulesClient", "ListBySubscription", resp, "Failure sending request") + return + } + + result.dcrrlr, err = client.ListBySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DataCollectionRulesClient", "ListBySubscription", resp, "Failure responding to request") + return + } + if result.dcrrlr.hasNextLink() && result.dcrrlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListBySubscriptionPreparer prepares the ListBySubscription request. +func (client DataCollectionRulesClient) ListBySubscriptionPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Insights/dataCollectionRules", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListBySubscriptionSender sends the ListBySubscription request. The method will close the +// http.Response Body if it receives an error. +func (client DataCollectionRulesClient) ListBySubscriptionSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListBySubscriptionResponder handles the response to the ListBySubscription request. The method always +// closes the http.Response Body. +func (client DataCollectionRulesClient) ListBySubscriptionResponder(resp *http.Response) (result DataCollectionRuleResourceListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listBySubscriptionNextResults retrieves the next set of results, if any. +func (client DataCollectionRulesClient) listBySubscriptionNextResults(ctx context.Context, lastResults DataCollectionRuleResourceListResult) (result DataCollectionRuleResourceListResult, err error) { + req, err := lastResults.dataCollectionRuleResourceListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "insights.DataCollectionRulesClient", "listBySubscriptionNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListBySubscriptionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "insights.DataCollectionRulesClient", "listBySubscriptionNextResults", resp, "Failure sending next results request") + } + result, err = client.ListBySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DataCollectionRulesClient", "listBySubscriptionNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListBySubscriptionComplete enumerates all values, automatically crossing page boundaries as required. +func (client DataCollectionRulesClient) ListBySubscriptionComplete(ctx context.Context) (result DataCollectionRuleResourceListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DataCollectionRulesClient.ListBySubscription") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListBySubscription(ctx) + return +} + +// Update sends the update request. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// dataCollectionRuleName - the name of the data collection rule. The name is case insensitive. +// body - the payload +func (client DataCollectionRulesClient) Update(ctx context.Context, resourceGroupName string, dataCollectionRuleName string, body *ResourceForUpdate) (result DataCollectionRuleResource, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DataCollectionRulesClient.Update") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.DataCollectionRulesClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, dataCollectionRuleName, body) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DataCollectionRulesClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.DataCollectionRulesClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DataCollectionRulesClient", "Update", resp, "Failure responding to request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client DataCollectionRulesClient) UpdatePreparer(ctx context.Context, resourceGroupName string, dataCollectionRuleName string, body *ResourceForUpdate) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "dataCollectionRuleName": autorest.Encode("path", dataCollectionRuleName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-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.Insights/dataCollectionRules/{dataCollectionRuleName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if body != nil { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithJSON(body)) + } + 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 DataCollectionRulesClient) UpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client DataCollectionRulesClient) UpdateResponder(resp *http.Response) (result DataCollectionRuleResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/monitor/mgmt/2021-04-01-preview/insights/diagnosticsettings.go b/services/preview/monitor/mgmt/2021-04-01-preview/insights/diagnosticsettings.go new file mode 100644 index 000000000000..0c0ec82dfe29 --- /dev/null +++ b/services/preview/monitor/mgmt/2021-04-01-preview/insights/diagnosticsettings.go @@ -0,0 +1,357 @@ +package insights + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// DiagnosticSettingsClient is the monitor Management Client +type DiagnosticSettingsClient struct { + BaseClient +} + +// NewDiagnosticSettingsClient creates an instance of the DiagnosticSettingsClient client. +func NewDiagnosticSettingsClient(subscriptionID string) DiagnosticSettingsClient { + return NewDiagnosticSettingsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewDiagnosticSettingsClientWithBaseURI creates an instance of the DiagnosticSettingsClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewDiagnosticSettingsClientWithBaseURI(baseURI string, subscriptionID string) DiagnosticSettingsClient { + return DiagnosticSettingsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates diagnostic settings for the specified resource. +// Parameters: +// resourceURI - the identifier of the resource. +// parameters - parameters supplied to the operation. +// name - the name of the diagnostic setting. +func (client DiagnosticSettingsClient) CreateOrUpdate(ctx context.Context, resourceURI string, parameters DiagnosticSettingsResource, name string) (result DiagnosticSettingsResource, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DiagnosticSettingsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceURI, + Constraints: []validation.Constraint{{Target: "resourceURI", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.DiagnosticSettingsClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceURI, parameters, name) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DiagnosticSettingsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.DiagnosticSettingsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DiagnosticSettingsClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client DiagnosticSettingsClient) CreateOrUpdatePreparer(ctx context.Context, resourceURI string, parameters DiagnosticSettingsResource, name string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "name": autorest.Encode("path", name), + "resourceUri": resourceURI, + } + + const APIVersion = "2017-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("/{resourceUri}/providers/microsoft.insights/diagnosticSettings/{name}", 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 DiagnosticSettingsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client DiagnosticSettingsClient) CreateOrUpdateResponder(resp *http.Response) (result DiagnosticSettingsResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes existing diagnostic settings for the specified resource. +// Parameters: +// resourceURI - the identifier of the resource. +// name - the name of the diagnostic setting. +func (client DiagnosticSettingsClient) Delete(ctx context.Context, resourceURI string, name string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DiagnosticSettingsClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceURI, + Constraints: []validation.Constraint{{Target: "resourceURI", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.DiagnosticSettingsClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceURI, name) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DiagnosticSettingsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "insights.DiagnosticSettingsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DiagnosticSettingsClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client DiagnosticSettingsClient) DeletePreparer(ctx context.Context, resourceURI string, name string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "name": autorest.Encode("path", name), + "resourceUri": resourceURI, + } + + const APIVersion = "2017-05-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{resourceUri}/providers/microsoft.insights/diagnosticSettings/{name}", 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 DiagnosticSettingsClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client DiagnosticSettingsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets the active diagnostic settings for the specified resource. +// Parameters: +// resourceURI - the identifier of the resource. +// name - the name of the diagnostic setting. +func (client DiagnosticSettingsClient) Get(ctx context.Context, resourceURI string, name string) (result DiagnosticSettingsResource, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DiagnosticSettingsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceURI, + Constraints: []validation.Constraint{{Target: "resourceURI", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.DiagnosticSettingsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceURI, name) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DiagnosticSettingsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.DiagnosticSettingsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DiagnosticSettingsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client DiagnosticSettingsClient) GetPreparer(ctx context.Context, resourceURI string, name string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "name": autorest.Encode("path", name), + "resourceUri": resourceURI, + } + + const APIVersion = "2017-05-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{resourceUri}/providers/microsoft.insights/diagnosticSettings/{name}", 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 DiagnosticSettingsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client DiagnosticSettingsClient) GetResponder(resp *http.Response) (result DiagnosticSettingsResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List gets the active diagnostic settings list for the specified resource. +// Parameters: +// resourceURI - the identifier of the resource. +func (client DiagnosticSettingsClient) List(ctx context.Context, resourceURI string) (result DiagnosticSettingsResourceCollection, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DiagnosticSettingsClient.List") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceURI, + Constraints: []validation.Constraint{{Target: "resourceURI", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.DiagnosticSettingsClient", "List", err.Error()) + } + + req, err := client.ListPreparer(ctx, resourceURI) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DiagnosticSettingsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.DiagnosticSettingsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DiagnosticSettingsClient", "List", resp, "Failure responding to request") + return + } + + return +} + +// ListPreparer prepares the List request. +func (client DiagnosticSettingsClient) ListPreparer(ctx context.Context, resourceURI string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceUri": resourceURI, + } + + const APIVersion = "2017-05-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{resourceUri}/providers/microsoft.insights/diagnosticSettings", 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 DiagnosticSettingsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client DiagnosticSettingsClient) ListResponder(resp *http.Response) (result DiagnosticSettingsResourceCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/monitor/mgmt/2021-04-01-preview/insights/diagnosticsettingscategory.go b/services/preview/monitor/mgmt/2021-04-01-preview/insights/diagnosticsettingscategory.go new file mode 100644 index 000000000000..bb7a66926c3e --- /dev/null +++ b/services/preview/monitor/mgmt/2021-04-01-preview/insights/diagnosticsettingscategory.go @@ -0,0 +1,193 @@ +package insights + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// DiagnosticSettingsCategoryClient is the monitor Management Client +type DiagnosticSettingsCategoryClient struct { + BaseClient +} + +// NewDiagnosticSettingsCategoryClient creates an instance of the DiagnosticSettingsCategoryClient client. +func NewDiagnosticSettingsCategoryClient(subscriptionID string) DiagnosticSettingsCategoryClient { + return NewDiagnosticSettingsCategoryClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewDiagnosticSettingsCategoryClientWithBaseURI creates an instance of the DiagnosticSettingsCategoryClient client +// using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign +// clouds, Azure stack). +func NewDiagnosticSettingsCategoryClientWithBaseURI(baseURI string, subscriptionID string) DiagnosticSettingsCategoryClient { + return DiagnosticSettingsCategoryClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get gets the diagnostic settings category for the specified resource. +// Parameters: +// resourceURI - the identifier of the resource. +// name - the name of the diagnostic setting. +func (client DiagnosticSettingsCategoryClient) Get(ctx context.Context, resourceURI string, name string) (result DiagnosticSettingsCategoryResource, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DiagnosticSettingsCategoryClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceURI, + Constraints: []validation.Constraint{{Target: "resourceURI", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.DiagnosticSettingsCategoryClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceURI, name) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DiagnosticSettingsCategoryClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.DiagnosticSettingsCategoryClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DiagnosticSettingsCategoryClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client DiagnosticSettingsCategoryClient) GetPreparer(ctx context.Context, resourceURI string, name string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "name": autorest.Encode("path", name), + "resourceUri": resourceURI, + } + + const APIVersion = "2017-05-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{resourceUri}/providers/microsoft.insights/diagnosticSettingsCategories/{name}", 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 DiagnosticSettingsCategoryClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client DiagnosticSettingsCategoryClient) GetResponder(resp *http.Response) (result DiagnosticSettingsCategoryResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List lists the diagnostic settings categories for the specified resource. +// Parameters: +// resourceURI - the identifier of the resource. +func (client DiagnosticSettingsCategoryClient) List(ctx context.Context, resourceURI string) (result DiagnosticSettingsCategoryResourceCollection, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DiagnosticSettingsCategoryClient.List") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceURI, + Constraints: []validation.Constraint{{Target: "resourceURI", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.DiagnosticSettingsCategoryClient", "List", err.Error()) + } + + req, err := client.ListPreparer(ctx, resourceURI) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DiagnosticSettingsCategoryClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.DiagnosticSettingsCategoryClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.DiagnosticSettingsCategoryClient", "List", resp, "Failure responding to request") + return + } + + return +} + +// ListPreparer prepares the List request. +func (client DiagnosticSettingsCategoryClient) ListPreparer(ctx context.Context, resourceURI string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceUri": resourceURI, + } + + const APIVersion = "2017-05-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{resourceUri}/providers/microsoft.insights/diagnosticSettingsCategories", 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 DiagnosticSettingsCategoryClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client DiagnosticSettingsCategoryClient) ListResponder(resp *http.Response) (result DiagnosticSettingsCategoryResourceCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/monitor/mgmt/2021-04-01-preview/insights/enums.go b/services/preview/monitor/mgmt/2021-04-01-preview/insights/enums.go new file mode 100644 index 000000000000..bd101099eb89 --- /dev/null +++ b/services/preview/monitor/mgmt/2021-04-01-preview/insights/enums.go @@ -0,0 +1,989 @@ +package insights + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// AggregationType enumerates the values for aggregation type. +type AggregationType string + +const ( + // AggregationTypeAverage ... + AggregationTypeAverage AggregationType = "Average" + // AggregationTypeCount ... + AggregationTypeCount AggregationType = "Count" + // AggregationTypeMaximum ... + AggregationTypeMaximum AggregationType = "Maximum" + // AggregationTypeMinimum ... + AggregationTypeMinimum AggregationType = "Minimum" + // AggregationTypeNone ... + AggregationTypeNone AggregationType = "None" + // AggregationTypeTotal ... + AggregationTypeTotal AggregationType = "Total" +) + +// PossibleAggregationTypeValues returns an array of possible values for the AggregationType const type. +func PossibleAggregationTypeValues() []AggregationType { + return []AggregationType{AggregationTypeAverage, AggregationTypeCount, AggregationTypeMaximum, AggregationTypeMinimum, AggregationTypeNone, AggregationTypeTotal} +} + +// AggregationTypeEnum enumerates the values for aggregation type enum. +type AggregationTypeEnum string + +const ( + // AggregationTypeEnumAverage ... + AggregationTypeEnumAverage AggregationTypeEnum = "Average" + // AggregationTypeEnumCount ... + AggregationTypeEnumCount AggregationTypeEnum = "Count" + // AggregationTypeEnumMaximum ... + AggregationTypeEnumMaximum AggregationTypeEnum = "Maximum" + // AggregationTypeEnumMinimum ... + AggregationTypeEnumMinimum AggregationTypeEnum = "Minimum" + // AggregationTypeEnumTotal ... + AggregationTypeEnumTotal AggregationTypeEnum = "Total" +) + +// PossibleAggregationTypeEnumValues returns an array of possible values for the AggregationTypeEnum const type. +func PossibleAggregationTypeEnumValues() []AggregationTypeEnum { + return []AggregationTypeEnum{AggregationTypeEnumAverage, AggregationTypeEnumCount, AggregationTypeEnumMaximum, AggregationTypeEnumMinimum, AggregationTypeEnumTotal} +} + +// AlertSeverity enumerates the values for alert severity. +type AlertSeverity string + +const ( + // AlertSeverityFour ... + AlertSeverityFour AlertSeverity = "4" + // AlertSeverityOne ... + AlertSeverityOne AlertSeverity = "1" + // AlertSeverityThree ... + AlertSeverityThree AlertSeverity = "3" + // AlertSeverityTwo ... + AlertSeverityTwo AlertSeverity = "2" + // AlertSeverityZero ... + AlertSeverityZero AlertSeverity = "0" +) + +// PossibleAlertSeverityValues returns an array of possible values for the AlertSeverity const type. +func PossibleAlertSeverityValues() []AlertSeverity { + return []AlertSeverity{AlertSeverityFour, AlertSeverityOne, AlertSeverityThree, AlertSeverityTwo, AlertSeverityZero} +} + +// BaselineSensitivity enumerates the values for baseline sensitivity. +type BaselineSensitivity string + +const ( + // BaselineSensitivityHigh ... + BaselineSensitivityHigh BaselineSensitivity = "High" + // BaselineSensitivityLow ... + BaselineSensitivityLow BaselineSensitivity = "Low" + // BaselineSensitivityMedium ... + BaselineSensitivityMedium BaselineSensitivity = "Medium" +) + +// PossibleBaselineSensitivityValues returns an array of possible values for the BaselineSensitivity const type. +func PossibleBaselineSensitivityValues() []BaselineSensitivity { + return []BaselineSensitivity{BaselineSensitivityHigh, BaselineSensitivityLow, BaselineSensitivityMedium} +} + +// CategoryType enumerates the values for category type. +type CategoryType string + +const ( + // CategoryTypeLogs ... + CategoryTypeLogs CategoryType = "Logs" + // CategoryTypeMetrics ... + CategoryTypeMetrics CategoryType = "Metrics" +) + +// PossibleCategoryTypeValues returns an array of possible values for the CategoryType const type. +func PossibleCategoryTypeValues() []CategoryType { + return []CategoryType{CategoryTypeLogs, CategoryTypeMetrics} +} + +// ComparisonOperationType enumerates the values for comparison operation type. +type ComparisonOperationType string + +const ( + // ComparisonOperationTypeEquals ... + ComparisonOperationTypeEquals ComparisonOperationType = "Equals" + // ComparisonOperationTypeGreaterThan ... + ComparisonOperationTypeGreaterThan ComparisonOperationType = "GreaterThan" + // ComparisonOperationTypeGreaterThanOrEqual ... + ComparisonOperationTypeGreaterThanOrEqual ComparisonOperationType = "GreaterThanOrEqual" + // ComparisonOperationTypeLessThan ... + ComparisonOperationTypeLessThan ComparisonOperationType = "LessThan" + // ComparisonOperationTypeLessThanOrEqual ... + ComparisonOperationTypeLessThanOrEqual ComparisonOperationType = "LessThanOrEqual" + // ComparisonOperationTypeNotEquals ... + ComparisonOperationTypeNotEquals ComparisonOperationType = "NotEquals" +) + +// PossibleComparisonOperationTypeValues returns an array of possible values for the ComparisonOperationType const type. +func PossibleComparisonOperationTypeValues() []ComparisonOperationType { + return []ComparisonOperationType{ComparisonOperationTypeEquals, ComparisonOperationTypeGreaterThan, ComparisonOperationTypeGreaterThanOrEqual, ComparisonOperationTypeLessThan, ComparisonOperationTypeLessThanOrEqual, ComparisonOperationTypeNotEquals} +} + +// ConditionalOperator enumerates the values for conditional operator. +type ConditionalOperator string + +const ( + // ConditionalOperatorEqual ... + ConditionalOperatorEqual ConditionalOperator = "Equal" + // ConditionalOperatorGreaterThan ... + ConditionalOperatorGreaterThan ConditionalOperator = "GreaterThan" + // ConditionalOperatorGreaterThanOrEqual ... + ConditionalOperatorGreaterThanOrEqual ConditionalOperator = "GreaterThanOrEqual" + // ConditionalOperatorLessThan ... + ConditionalOperatorLessThan ConditionalOperator = "LessThan" + // ConditionalOperatorLessThanOrEqual ... + ConditionalOperatorLessThanOrEqual ConditionalOperator = "LessThanOrEqual" +) + +// PossibleConditionalOperatorValues returns an array of possible values for the ConditionalOperator const type. +func PossibleConditionalOperatorValues() []ConditionalOperator { + return []ConditionalOperator{ConditionalOperatorEqual, ConditionalOperatorGreaterThan, ConditionalOperatorGreaterThanOrEqual, ConditionalOperatorLessThan, ConditionalOperatorLessThanOrEqual} +} + +// ConditionOperator enumerates the values for condition operator. +type ConditionOperator string + +const ( + // ConditionOperatorGreaterThan ... + ConditionOperatorGreaterThan ConditionOperator = "GreaterThan" + // ConditionOperatorGreaterThanOrEqual ... + ConditionOperatorGreaterThanOrEqual ConditionOperator = "GreaterThanOrEqual" + // ConditionOperatorLessThan ... + ConditionOperatorLessThan ConditionOperator = "LessThan" + // ConditionOperatorLessThanOrEqual ... + ConditionOperatorLessThanOrEqual ConditionOperator = "LessThanOrEqual" +) + +// PossibleConditionOperatorValues returns an array of possible values for the ConditionOperator const type. +func PossibleConditionOperatorValues() []ConditionOperator { + return []ConditionOperator{ConditionOperatorGreaterThan, ConditionOperatorGreaterThanOrEqual, ConditionOperatorLessThan, ConditionOperatorLessThanOrEqual} +} + +// CreatedByType enumerates the values for created by type. +type CreatedByType string + +const ( + // CreatedByTypeApplication ... + CreatedByTypeApplication CreatedByType = "Application" + // CreatedByTypeKey ... + CreatedByTypeKey CreatedByType = "Key" + // CreatedByTypeManagedIdentity ... + CreatedByTypeManagedIdentity CreatedByType = "ManagedIdentity" + // CreatedByTypeUser ... + CreatedByTypeUser CreatedByType = "User" +) + +// PossibleCreatedByTypeValues returns an array of possible values for the CreatedByType const type. +func PossibleCreatedByTypeValues() []CreatedByType { + return []CreatedByType{CreatedByTypeApplication, CreatedByTypeKey, CreatedByTypeManagedIdentity, CreatedByTypeUser} +} + +// CriterionType enumerates the values for criterion type. +type CriterionType string + +const ( + // CriterionTypeDynamicThresholdCriterion ... + CriterionTypeDynamicThresholdCriterion CriterionType = "DynamicThresholdCriterion" + // CriterionTypeMultiMetricCriteria ... + CriterionTypeMultiMetricCriteria CriterionType = "MultiMetricCriteria" + // CriterionTypeStaticThresholdCriterion ... + CriterionTypeStaticThresholdCriterion CriterionType = "StaticThresholdCriterion" +) + +// PossibleCriterionTypeValues returns an array of possible values for the CriterionType const type. +func PossibleCriterionTypeValues() []CriterionType { + return []CriterionType{CriterionTypeDynamicThresholdCriterion, CriterionTypeMultiMetricCriteria, CriterionTypeStaticThresholdCriterion} +} + +// DataStatus enumerates the values for data status. +type DataStatus string + +const ( + // DataStatusNotPresent ... + DataStatusNotPresent DataStatus = "notPresent" + // DataStatusPresent ... + DataStatusPresent DataStatus = "present" +) + +// PossibleDataStatusValues returns an array of possible values for the DataStatus const type. +func PossibleDataStatusValues() []DataStatus { + return []DataStatus{DataStatusNotPresent, DataStatusPresent} +} + +// DynamicThresholdOperator enumerates the values for dynamic threshold operator. +type DynamicThresholdOperator string + +const ( + // DynamicThresholdOperatorGreaterOrLessThan ... + DynamicThresholdOperatorGreaterOrLessThan DynamicThresholdOperator = "GreaterOrLessThan" + // DynamicThresholdOperatorGreaterThan ... + DynamicThresholdOperatorGreaterThan DynamicThresholdOperator = "GreaterThan" + // DynamicThresholdOperatorLessThan ... + DynamicThresholdOperatorLessThan DynamicThresholdOperator = "LessThan" +) + +// PossibleDynamicThresholdOperatorValues returns an array of possible values for the DynamicThresholdOperator const type. +func PossibleDynamicThresholdOperatorValues() []DynamicThresholdOperator { + return []DynamicThresholdOperator{DynamicThresholdOperatorGreaterOrLessThan, DynamicThresholdOperatorGreaterThan, DynamicThresholdOperatorLessThan} +} + +// DynamicThresholdSensitivity enumerates the values for dynamic threshold sensitivity. +type DynamicThresholdSensitivity string + +const ( + // DynamicThresholdSensitivityHigh ... + DynamicThresholdSensitivityHigh DynamicThresholdSensitivity = "High" + // DynamicThresholdSensitivityLow ... + DynamicThresholdSensitivityLow DynamicThresholdSensitivity = "Low" + // DynamicThresholdSensitivityMedium ... + DynamicThresholdSensitivityMedium DynamicThresholdSensitivity = "Medium" +) + +// PossibleDynamicThresholdSensitivityValues returns an array of possible values for the DynamicThresholdSensitivity const type. +func PossibleDynamicThresholdSensitivityValues() []DynamicThresholdSensitivity { + return []DynamicThresholdSensitivity{DynamicThresholdSensitivityHigh, DynamicThresholdSensitivityLow, DynamicThresholdSensitivityMedium} +} + +// Enabled enumerates the values for enabled. +type Enabled string + +const ( + // EnabledFalse ... + EnabledFalse Enabled = "false" + // EnabledTrue ... + EnabledTrue Enabled = "true" +) + +// PossibleEnabledValues returns an array of possible values for the Enabled const type. +func PossibleEnabledValues() []Enabled { + return []Enabled{EnabledFalse, EnabledTrue} +} + +// EventLevel enumerates the values for event level. +type EventLevel string + +const ( + // EventLevelCritical ... + EventLevelCritical EventLevel = "Critical" + // EventLevelError ... + EventLevelError EventLevel = "Error" + // EventLevelInformational ... + EventLevelInformational EventLevel = "Informational" + // EventLevelVerbose ... + EventLevelVerbose EventLevel = "Verbose" + // EventLevelWarning ... + EventLevelWarning EventLevel = "Warning" +) + +// PossibleEventLevelValues returns an array of possible values for the EventLevel const type. +func PossibleEventLevelValues() []EventLevel { + return []EventLevel{EventLevelCritical, EventLevelError, EventLevelInformational, EventLevelVerbose, EventLevelWarning} +} + +// KnownDataCollectionEndpointProvisioningState enumerates the values for known data collection endpoint +// provisioning state. +type KnownDataCollectionEndpointProvisioningState string + +const ( + // KnownDataCollectionEndpointProvisioningStateCreating ... + KnownDataCollectionEndpointProvisioningStateCreating KnownDataCollectionEndpointProvisioningState = "Creating" + // KnownDataCollectionEndpointProvisioningStateDeleting ... + KnownDataCollectionEndpointProvisioningStateDeleting KnownDataCollectionEndpointProvisioningState = "Deleting" + // KnownDataCollectionEndpointProvisioningStateFailed ... + KnownDataCollectionEndpointProvisioningStateFailed KnownDataCollectionEndpointProvisioningState = "Failed" + // KnownDataCollectionEndpointProvisioningStateSucceeded ... + KnownDataCollectionEndpointProvisioningStateSucceeded KnownDataCollectionEndpointProvisioningState = "Succeeded" + // KnownDataCollectionEndpointProvisioningStateUpdating ... + KnownDataCollectionEndpointProvisioningStateUpdating KnownDataCollectionEndpointProvisioningState = "Updating" +) + +// PossibleKnownDataCollectionEndpointProvisioningStateValues returns an array of possible values for the KnownDataCollectionEndpointProvisioningState const type. +func PossibleKnownDataCollectionEndpointProvisioningStateValues() []KnownDataCollectionEndpointProvisioningState { + return []KnownDataCollectionEndpointProvisioningState{KnownDataCollectionEndpointProvisioningStateCreating, KnownDataCollectionEndpointProvisioningStateDeleting, KnownDataCollectionEndpointProvisioningStateFailed, KnownDataCollectionEndpointProvisioningStateSucceeded, KnownDataCollectionEndpointProvisioningStateUpdating} +} + +// KnownDataCollectionEndpointResourceKind enumerates the values for known data collection endpoint resource +// kind. +type KnownDataCollectionEndpointResourceKind string + +const ( + // KnownDataCollectionEndpointResourceKindLinux ... + KnownDataCollectionEndpointResourceKindLinux KnownDataCollectionEndpointResourceKind = "Linux" + // KnownDataCollectionEndpointResourceKindWindows ... + KnownDataCollectionEndpointResourceKindWindows KnownDataCollectionEndpointResourceKind = "Windows" +) + +// PossibleKnownDataCollectionEndpointResourceKindValues returns an array of possible values for the KnownDataCollectionEndpointResourceKind const type. +func PossibleKnownDataCollectionEndpointResourceKindValues() []KnownDataCollectionEndpointResourceKind { + return []KnownDataCollectionEndpointResourceKind{KnownDataCollectionEndpointResourceKindLinux, KnownDataCollectionEndpointResourceKindWindows} +} + +// KnownDataCollectionRuleAssociationProvisioningState enumerates the values for known data collection rule +// association provisioning state. +type KnownDataCollectionRuleAssociationProvisioningState string + +const ( + // KnownDataCollectionRuleAssociationProvisioningStateCreating ... + KnownDataCollectionRuleAssociationProvisioningStateCreating KnownDataCollectionRuleAssociationProvisioningState = "Creating" + // KnownDataCollectionRuleAssociationProvisioningStateDeleting ... + KnownDataCollectionRuleAssociationProvisioningStateDeleting KnownDataCollectionRuleAssociationProvisioningState = "Deleting" + // KnownDataCollectionRuleAssociationProvisioningStateFailed ... + KnownDataCollectionRuleAssociationProvisioningStateFailed KnownDataCollectionRuleAssociationProvisioningState = "Failed" + // KnownDataCollectionRuleAssociationProvisioningStateSucceeded ... + KnownDataCollectionRuleAssociationProvisioningStateSucceeded KnownDataCollectionRuleAssociationProvisioningState = "Succeeded" + // KnownDataCollectionRuleAssociationProvisioningStateUpdating ... + KnownDataCollectionRuleAssociationProvisioningStateUpdating KnownDataCollectionRuleAssociationProvisioningState = "Updating" +) + +// PossibleKnownDataCollectionRuleAssociationProvisioningStateValues returns an array of possible values for the KnownDataCollectionRuleAssociationProvisioningState const type. +func PossibleKnownDataCollectionRuleAssociationProvisioningStateValues() []KnownDataCollectionRuleAssociationProvisioningState { + return []KnownDataCollectionRuleAssociationProvisioningState{KnownDataCollectionRuleAssociationProvisioningStateCreating, KnownDataCollectionRuleAssociationProvisioningStateDeleting, KnownDataCollectionRuleAssociationProvisioningStateFailed, KnownDataCollectionRuleAssociationProvisioningStateSucceeded, KnownDataCollectionRuleAssociationProvisioningStateUpdating} +} + +// KnownDataCollectionRuleProvisioningState enumerates the values for known data collection rule provisioning +// state. +type KnownDataCollectionRuleProvisioningState string + +const ( + // KnownDataCollectionRuleProvisioningStateCreating ... + KnownDataCollectionRuleProvisioningStateCreating KnownDataCollectionRuleProvisioningState = "Creating" + // KnownDataCollectionRuleProvisioningStateDeleting ... + KnownDataCollectionRuleProvisioningStateDeleting KnownDataCollectionRuleProvisioningState = "Deleting" + // KnownDataCollectionRuleProvisioningStateFailed ... + KnownDataCollectionRuleProvisioningStateFailed KnownDataCollectionRuleProvisioningState = "Failed" + // KnownDataCollectionRuleProvisioningStateSucceeded ... + KnownDataCollectionRuleProvisioningStateSucceeded KnownDataCollectionRuleProvisioningState = "Succeeded" + // KnownDataCollectionRuleProvisioningStateUpdating ... + KnownDataCollectionRuleProvisioningStateUpdating KnownDataCollectionRuleProvisioningState = "Updating" +) + +// PossibleKnownDataCollectionRuleProvisioningStateValues returns an array of possible values for the KnownDataCollectionRuleProvisioningState const type. +func PossibleKnownDataCollectionRuleProvisioningStateValues() []KnownDataCollectionRuleProvisioningState { + return []KnownDataCollectionRuleProvisioningState{KnownDataCollectionRuleProvisioningStateCreating, KnownDataCollectionRuleProvisioningStateDeleting, KnownDataCollectionRuleProvisioningStateFailed, KnownDataCollectionRuleProvisioningStateSucceeded, KnownDataCollectionRuleProvisioningStateUpdating} +} + +// KnownDataCollectionRuleResourceKind enumerates the values for known data collection rule resource kind. +type KnownDataCollectionRuleResourceKind string + +const ( + // KnownDataCollectionRuleResourceKindLinux ... + KnownDataCollectionRuleResourceKindLinux KnownDataCollectionRuleResourceKind = "Linux" + // KnownDataCollectionRuleResourceKindWindows ... + KnownDataCollectionRuleResourceKindWindows KnownDataCollectionRuleResourceKind = "Windows" +) + +// PossibleKnownDataCollectionRuleResourceKindValues returns an array of possible values for the KnownDataCollectionRuleResourceKind const type. +func PossibleKnownDataCollectionRuleResourceKindValues() []KnownDataCollectionRuleResourceKind { + return []KnownDataCollectionRuleResourceKind{KnownDataCollectionRuleResourceKindLinux, KnownDataCollectionRuleResourceKindWindows} +} + +// KnownDataFlowStreams enumerates the values for known data flow streams. +type KnownDataFlowStreams string + +const ( + // KnownDataFlowStreamsMicrosoftEvent ... + KnownDataFlowStreamsMicrosoftEvent KnownDataFlowStreams = "Microsoft-Event" + // KnownDataFlowStreamsMicrosoftInsightsMetrics ... + KnownDataFlowStreamsMicrosoftInsightsMetrics KnownDataFlowStreams = "Microsoft-InsightsMetrics" + // KnownDataFlowStreamsMicrosoftPerf ... + KnownDataFlowStreamsMicrosoftPerf KnownDataFlowStreams = "Microsoft-Perf" + // KnownDataFlowStreamsMicrosoftSyslog ... + KnownDataFlowStreamsMicrosoftSyslog KnownDataFlowStreams = "Microsoft-Syslog" + // KnownDataFlowStreamsMicrosoftWindowsEvent ... + KnownDataFlowStreamsMicrosoftWindowsEvent KnownDataFlowStreams = "Microsoft-WindowsEvent" +) + +// PossibleKnownDataFlowStreamsValues returns an array of possible values for the KnownDataFlowStreams const type. +func PossibleKnownDataFlowStreamsValues() []KnownDataFlowStreams { + return []KnownDataFlowStreams{KnownDataFlowStreamsMicrosoftEvent, KnownDataFlowStreamsMicrosoftInsightsMetrics, KnownDataFlowStreamsMicrosoftPerf, KnownDataFlowStreamsMicrosoftSyslog, KnownDataFlowStreamsMicrosoftWindowsEvent} +} + +// KnownExtensionDataSourceStreams enumerates the values for known extension data source streams. +type KnownExtensionDataSourceStreams string + +const ( + // KnownExtensionDataSourceStreamsMicrosoftEvent ... + KnownExtensionDataSourceStreamsMicrosoftEvent KnownExtensionDataSourceStreams = "Microsoft-Event" + // KnownExtensionDataSourceStreamsMicrosoftInsightsMetrics ... + KnownExtensionDataSourceStreamsMicrosoftInsightsMetrics KnownExtensionDataSourceStreams = "Microsoft-InsightsMetrics" + // KnownExtensionDataSourceStreamsMicrosoftPerf ... + KnownExtensionDataSourceStreamsMicrosoftPerf KnownExtensionDataSourceStreams = "Microsoft-Perf" + // KnownExtensionDataSourceStreamsMicrosoftSyslog ... + KnownExtensionDataSourceStreamsMicrosoftSyslog KnownExtensionDataSourceStreams = "Microsoft-Syslog" + // KnownExtensionDataSourceStreamsMicrosoftWindowsEvent ... + KnownExtensionDataSourceStreamsMicrosoftWindowsEvent KnownExtensionDataSourceStreams = "Microsoft-WindowsEvent" +) + +// PossibleKnownExtensionDataSourceStreamsValues returns an array of possible values for the KnownExtensionDataSourceStreams const type. +func PossibleKnownExtensionDataSourceStreamsValues() []KnownExtensionDataSourceStreams { + return []KnownExtensionDataSourceStreams{KnownExtensionDataSourceStreamsMicrosoftEvent, KnownExtensionDataSourceStreamsMicrosoftInsightsMetrics, KnownExtensionDataSourceStreamsMicrosoftPerf, KnownExtensionDataSourceStreamsMicrosoftSyslog, KnownExtensionDataSourceStreamsMicrosoftWindowsEvent} +} + +// KnownPerfCounterDataSourceStreams enumerates the values for known perf counter data source streams. +type KnownPerfCounterDataSourceStreams string + +const ( + // KnownPerfCounterDataSourceStreamsMicrosoftInsightsMetrics ... + KnownPerfCounterDataSourceStreamsMicrosoftInsightsMetrics KnownPerfCounterDataSourceStreams = "Microsoft-InsightsMetrics" + // KnownPerfCounterDataSourceStreamsMicrosoftPerf ... + KnownPerfCounterDataSourceStreamsMicrosoftPerf KnownPerfCounterDataSourceStreams = "Microsoft-Perf" +) + +// PossibleKnownPerfCounterDataSourceStreamsValues returns an array of possible values for the KnownPerfCounterDataSourceStreams const type. +func PossibleKnownPerfCounterDataSourceStreamsValues() []KnownPerfCounterDataSourceStreams { + return []KnownPerfCounterDataSourceStreams{KnownPerfCounterDataSourceStreamsMicrosoftInsightsMetrics, KnownPerfCounterDataSourceStreamsMicrosoftPerf} +} + +// KnownPublicNetworkAccessOptions enumerates the values for known public network access options. +type KnownPublicNetworkAccessOptions string + +const ( + // KnownPublicNetworkAccessOptionsDisabled ... + KnownPublicNetworkAccessOptionsDisabled KnownPublicNetworkAccessOptions = "Disabled" + // KnownPublicNetworkAccessOptionsEnabled ... + KnownPublicNetworkAccessOptionsEnabled KnownPublicNetworkAccessOptions = "Enabled" +) + +// PossibleKnownPublicNetworkAccessOptionsValues returns an array of possible values for the KnownPublicNetworkAccessOptions const type. +func PossibleKnownPublicNetworkAccessOptionsValues() []KnownPublicNetworkAccessOptions { + return []KnownPublicNetworkAccessOptions{KnownPublicNetworkAccessOptionsDisabled, KnownPublicNetworkAccessOptionsEnabled} +} + +// KnownSyslogDataSourceFacilityNames enumerates the values for known syslog data source facility names. +type KnownSyslogDataSourceFacilityNames string + +const ( + // KnownSyslogDataSourceFacilityNamesAsterisk ... + KnownSyslogDataSourceFacilityNamesAsterisk KnownSyslogDataSourceFacilityNames = "*" + // KnownSyslogDataSourceFacilityNamesAuth ... + KnownSyslogDataSourceFacilityNamesAuth KnownSyslogDataSourceFacilityNames = "auth" + // KnownSyslogDataSourceFacilityNamesAuthpriv ... + KnownSyslogDataSourceFacilityNamesAuthpriv KnownSyslogDataSourceFacilityNames = "authpriv" + // KnownSyslogDataSourceFacilityNamesCron ... + KnownSyslogDataSourceFacilityNamesCron KnownSyslogDataSourceFacilityNames = "cron" + // KnownSyslogDataSourceFacilityNamesDaemon ... + KnownSyslogDataSourceFacilityNamesDaemon KnownSyslogDataSourceFacilityNames = "daemon" + // KnownSyslogDataSourceFacilityNamesKern ... + KnownSyslogDataSourceFacilityNamesKern KnownSyslogDataSourceFacilityNames = "kern" + // KnownSyslogDataSourceFacilityNamesLocal0 ... + KnownSyslogDataSourceFacilityNamesLocal0 KnownSyslogDataSourceFacilityNames = "local0" + // KnownSyslogDataSourceFacilityNamesLocal1 ... + KnownSyslogDataSourceFacilityNamesLocal1 KnownSyslogDataSourceFacilityNames = "local1" + // KnownSyslogDataSourceFacilityNamesLocal2 ... + KnownSyslogDataSourceFacilityNamesLocal2 KnownSyslogDataSourceFacilityNames = "local2" + // KnownSyslogDataSourceFacilityNamesLocal3 ... + KnownSyslogDataSourceFacilityNamesLocal3 KnownSyslogDataSourceFacilityNames = "local3" + // KnownSyslogDataSourceFacilityNamesLocal4 ... + KnownSyslogDataSourceFacilityNamesLocal4 KnownSyslogDataSourceFacilityNames = "local4" + // KnownSyslogDataSourceFacilityNamesLocal5 ... + KnownSyslogDataSourceFacilityNamesLocal5 KnownSyslogDataSourceFacilityNames = "local5" + // KnownSyslogDataSourceFacilityNamesLocal6 ... + KnownSyslogDataSourceFacilityNamesLocal6 KnownSyslogDataSourceFacilityNames = "local6" + // KnownSyslogDataSourceFacilityNamesLocal7 ... + KnownSyslogDataSourceFacilityNamesLocal7 KnownSyslogDataSourceFacilityNames = "local7" + // KnownSyslogDataSourceFacilityNamesLpr ... + KnownSyslogDataSourceFacilityNamesLpr KnownSyslogDataSourceFacilityNames = "lpr" + // KnownSyslogDataSourceFacilityNamesMail ... + KnownSyslogDataSourceFacilityNamesMail KnownSyslogDataSourceFacilityNames = "mail" + // KnownSyslogDataSourceFacilityNamesMark ... + KnownSyslogDataSourceFacilityNamesMark KnownSyslogDataSourceFacilityNames = "mark" + // KnownSyslogDataSourceFacilityNamesNews ... + KnownSyslogDataSourceFacilityNamesNews KnownSyslogDataSourceFacilityNames = "news" + // KnownSyslogDataSourceFacilityNamesSyslog ... + KnownSyslogDataSourceFacilityNamesSyslog KnownSyslogDataSourceFacilityNames = "syslog" + // KnownSyslogDataSourceFacilityNamesUser ... + KnownSyslogDataSourceFacilityNamesUser KnownSyslogDataSourceFacilityNames = "user" + // KnownSyslogDataSourceFacilityNamesUucp ... + KnownSyslogDataSourceFacilityNamesUucp KnownSyslogDataSourceFacilityNames = "uucp" +) + +// PossibleKnownSyslogDataSourceFacilityNamesValues returns an array of possible values for the KnownSyslogDataSourceFacilityNames const type. +func PossibleKnownSyslogDataSourceFacilityNamesValues() []KnownSyslogDataSourceFacilityNames { + return []KnownSyslogDataSourceFacilityNames{KnownSyslogDataSourceFacilityNamesAsterisk, KnownSyslogDataSourceFacilityNamesAuth, KnownSyslogDataSourceFacilityNamesAuthpriv, KnownSyslogDataSourceFacilityNamesCron, KnownSyslogDataSourceFacilityNamesDaemon, KnownSyslogDataSourceFacilityNamesKern, KnownSyslogDataSourceFacilityNamesLocal0, KnownSyslogDataSourceFacilityNamesLocal1, KnownSyslogDataSourceFacilityNamesLocal2, KnownSyslogDataSourceFacilityNamesLocal3, KnownSyslogDataSourceFacilityNamesLocal4, KnownSyslogDataSourceFacilityNamesLocal5, KnownSyslogDataSourceFacilityNamesLocal6, KnownSyslogDataSourceFacilityNamesLocal7, KnownSyslogDataSourceFacilityNamesLpr, KnownSyslogDataSourceFacilityNamesMail, KnownSyslogDataSourceFacilityNamesMark, KnownSyslogDataSourceFacilityNamesNews, KnownSyslogDataSourceFacilityNamesSyslog, KnownSyslogDataSourceFacilityNamesUser, KnownSyslogDataSourceFacilityNamesUucp} +} + +// KnownSyslogDataSourceLogLevels enumerates the values for known syslog data source log levels. +type KnownSyslogDataSourceLogLevels string + +const ( + // KnownSyslogDataSourceLogLevelsAlert ... + KnownSyslogDataSourceLogLevelsAlert KnownSyslogDataSourceLogLevels = "Alert" + // KnownSyslogDataSourceLogLevelsAsterisk ... + KnownSyslogDataSourceLogLevelsAsterisk KnownSyslogDataSourceLogLevels = "*" + // KnownSyslogDataSourceLogLevelsCritical ... + KnownSyslogDataSourceLogLevelsCritical KnownSyslogDataSourceLogLevels = "Critical" + // KnownSyslogDataSourceLogLevelsDebug ... + KnownSyslogDataSourceLogLevelsDebug KnownSyslogDataSourceLogLevels = "Debug" + // KnownSyslogDataSourceLogLevelsEmergency ... + KnownSyslogDataSourceLogLevelsEmergency KnownSyslogDataSourceLogLevels = "Emergency" + // KnownSyslogDataSourceLogLevelsError ... + KnownSyslogDataSourceLogLevelsError KnownSyslogDataSourceLogLevels = "Error" + // KnownSyslogDataSourceLogLevelsInfo ... + KnownSyslogDataSourceLogLevelsInfo KnownSyslogDataSourceLogLevels = "Info" + // KnownSyslogDataSourceLogLevelsNotice ... + KnownSyslogDataSourceLogLevelsNotice KnownSyslogDataSourceLogLevels = "Notice" + // KnownSyslogDataSourceLogLevelsWarning ... + KnownSyslogDataSourceLogLevelsWarning KnownSyslogDataSourceLogLevels = "Warning" +) + +// PossibleKnownSyslogDataSourceLogLevelsValues returns an array of possible values for the KnownSyslogDataSourceLogLevels const type. +func PossibleKnownSyslogDataSourceLogLevelsValues() []KnownSyslogDataSourceLogLevels { + return []KnownSyslogDataSourceLogLevels{KnownSyslogDataSourceLogLevelsAlert, KnownSyslogDataSourceLogLevelsAsterisk, KnownSyslogDataSourceLogLevelsCritical, KnownSyslogDataSourceLogLevelsDebug, KnownSyslogDataSourceLogLevelsEmergency, KnownSyslogDataSourceLogLevelsError, KnownSyslogDataSourceLogLevelsInfo, KnownSyslogDataSourceLogLevelsNotice, KnownSyslogDataSourceLogLevelsWarning} +} + +// KnownSyslogDataSourceStreams enumerates the values for known syslog data source streams. +type KnownSyslogDataSourceStreams string + +const ( + // KnownSyslogDataSourceStreamsMicrosoftSyslog ... + KnownSyslogDataSourceStreamsMicrosoftSyslog KnownSyslogDataSourceStreams = "Microsoft-Syslog" +) + +// PossibleKnownSyslogDataSourceStreamsValues returns an array of possible values for the KnownSyslogDataSourceStreams const type. +func PossibleKnownSyslogDataSourceStreamsValues() []KnownSyslogDataSourceStreams { + return []KnownSyslogDataSourceStreams{KnownSyslogDataSourceStreamsMicrosoftSyslog} +} + +// KnownWindowsEventLogDataSourceStreams enumerates the values for known windows event log data source streams. +type KnownWindowsEventLogDataSourceStreams string + +const ( + // KnownWindowsEventLogDataSourceStreamsMicrosoftEvent ... + KnownWindowsEventLogDataSourceStreamsMicrosoftEvent KnownWindowsEventLogDataSourceStreams = "Microsoft-Event" + // KnownWindowsEventLogDataSourceStreamsMicrosoftWindowsEvent ... + KnownWindowsEventLogDataSourceStreamsMicrosoftWindowsEvent KnownWindowsEventLogDataSourceStreams = "Microsoft-WindowsEvent" +) + +// PossibleKnownWindowsEventLogDataSourceStreamsValues returns an array of possible values for the KnownWindowsEventLogDataSourceStreams const type. +func PossibleKnownWindowsEventLogDataSourceStreamsValues() []KnownWindowsEventLogDataSourceStreams { + return []KnownWindowsEventLogDataSourceStreams{KnownWindowsEventLogDataSourceStreamsMicrosoftEvent, KnownWindowsEventLogDataSourceStreamsMicrosoftWindowsEvent} +} + +// MetricClass enumerates the values for metric class. +type MetricClass string + +const ( + // MetricClassAvailability ... + MetricClassAvailability MetricClass = "Availability" + // MetricClassErrors ... + MetricClassErrors MetricClass = "Errors" + // MetricClassLatency ... + MetricClassLatency MetricClass = "Latency" + // MetricClassSaturation ... + MetricClassSaturation MetricClass = "Saturation" + // MetricClassTransactions ... + MetricClassTransactions MetricClass = "Transactions" +) + +// PossibleMetricClassValues returns an array of possible values for the MetricClass const type. +func PossibleMetricClassValues() []MetricClass { + return []MetricClass{MetricClassAvailability, MetricClassErrors, MetricClassLatency, MetricClassSaturation, MetricClassTransactions} +} + +// MetricStatisticType enumerates the values for metric statistic type. +type MetricStatisticType string + +const ( + // MetricStatisticTypeAverage ... + MetricStatisticTypeAverage MetricStatisticType = "Average" + // MetricStatisticTypeMax ... + MetricStatisticTypeMax MetricStatisticType = "Max" + // MetricStatisticTypeMin ... + MetricStatisticTypeMin MetricStatisticType = "Min" + // MetricStatisticTypeSum ... + MetricStatisticTypeSum MetricStatisticType = "Sum" +) + +// PossibleMetricStatisticTypeValues returns an array of possible values for the MetricStatisticType const type. +func PossibleMetricStatisticTypeValues() []MetricStatisticType { + return []MetricStatisticType{MetricStatisticTypeAverage, MetricStatisticTypeMax, MetricStatisticTypeMin, MetricStatisticTypeSum} +} + +// MetricTriggerType enumerates the values for metric trigger type. +type MetricTriggerType string + +const ( + // MetricTriggerTypeConsecutive ... + MetricTriggerTypeConsecutive MetricTriggerType = "Consecutive" + // MetricTriggerTypeTotal ... + MetricTriggerTypeTotal MetricTriggerType = "Total" +) + +// PossibleMetricTriggerTypeValues returns an array of possible values for the MetricTriggerType const type. +func PossibleMetricTriggerTypeValues() []MetricTriggerType { + return []MetricTriggerType{MetricTriggerTypeConsecutive, MetricTriggerTypeTotal} +} + +// MetricUnit enumerates the values for metric unit. +type MetricUnit string + +const ( + // MetricUnitBitsPerSecond ... + MetricUnitBitsPerSecond MetricUnit = "BitsPerSecond" + // MetricUnitBytes ... + MetricUnitBytes MetricUnit = "Bytes" + // MetricUnitByteSeconds ... + MetricUnitByteSeconds MetricUnit = "ByteSeconds" + // MetricUnitBytesPerSecond ... + MetricUnitBytesPerSecond MetricUnit = "BytesPerSecond" + // MetricUnitCores ... + MetricUnitCores MetricUnit = "Cores" + // MetricUnitCount ... + MetricUnitCount MetricUnit = "Count" + // MetricUnitCountPerSecond ... + MetricUnitCountPerSecond MetricUnit = "CountPerSecond" + // MetricUnitMilliCores ... + MetricUnitMilliCores MetricUnit = "MilliCores" + // MetricUnitMilliSeconds ... + MetricUnitMilliSeconds MetricUnit = "MilliSeconds" + // MetricUnitNanoCores ... + MetricUnitNanoCores MetricUnit = "NanoCores" + // MetricUnitPercent ... + MetricUnitPercent MetricUnit = "Percent" + // MetricUnitSeconds ... + MetricUnitSeconds MetricUnit = "Seconds" + // MetricUnitUnspecified ... + MetricUnitUnspecified MetricUnit = "Unspecified" +) + +// PossibleMetricUnitValues returns an array of possible values for the MetricUnit const type. +func PossibleMetricUnitValues() []MetricUnit { + return []MetricUnit{MetricUnitBitsPerSecond, MetricUnitBytes, MetricUnitByteSeconds, MetricUnitBytesPerSecond, MetricUnitCores, MetricUnitCount, MetricUnitCountPerSecond, MetricUnitMilliCores, MetricUnitMilliSeconds, MetricUnitNanoCores, MetricUnitPercent, MetricUnitSeconds, MetricUnitUnspecified} +} + +// NamespaceClassification enumerates the values for namespace classification. +type NamespaceClassification string + +const ( + // NamespaceClassificationCustom ... + NamespaceClassificationCustom NamespaceClassification = "Custom" + // NamespaceClassificationPlatform ... + NamespaceClassificationPlatform NamespaceClassification = "Platform" + // NamespaceClassificationQos ... + NamespaceClassificationQos NamespaceClassification = "Qos" +) + +// PossibleNamespaceClassificationValues returns an array of possible values for the NamespaceClassification const type. +func PossibleNamespaceClassificationValues() []NamespaceClassification { + return []NamespaceClassification{NamespaceClassificationCustom, NamespaceClassificationPlatform, NamespaceClassificationQos} +} + +// OdataType enumerates the values for odata type. +type OdataType string + +const ( + // OdataTypeMicrosoftAzureManagementInsightsModelsRuleManagementEventDataSource ... + OdataTypeMicrosoftAzureManagementInsightsModelsRuleManagementEventDataSource OdataType = "Microsoft.Azure.Management.Insights.Models.RuleManagementEventDataSource" + // OdataTypeMicrosoftAzureManagementInsightsModelsRuleMetricDataSource ... + OdataTypeMicrosoftAzureManagementInsightsModelsRuleMetricDataSource OdataType = "Microsoft.Azure.Management.Insights.Models.RuleMetricDataSource" + // OdataTypeRuleDataSource ... + OdataTypeRuleDataSource OdataType = "RuleDataSource" +) + +// PossibleOdataTypeValues returns an array of possible values for the OdataType const type. +func PossibleOdataTypeValues() []OdataType { + return []OdataType{OdataTypeMicrosoftAzureManagementInsightsModelsRuleManagementEventDataSource, OdataTypeMicrosoftAzureManagementInsightsModelsRuleMetricDataSource, OdataTypeRuleDataSource} +} + +// OdataTypeBasicAction enumerates the values for odata type basic action. +type OdataTypeBasicAction string + +const ( + // OdataTypeBasicActionOdataTypeAction ... + OdataTypeBasicActionOdataTypeAction OdataTypeBasicAction = "Action" + // OdataTypeBasicActionOdataTypeMicrosoftWindowsAzureManagementMonitoringAlertsModelsMicrosoftAppInsightsNexusDataContractsResourcesScheduledQueryRulesAlertingAction ... + OdataTypeBasicActionOdataTypeMicrosoftWindowsAzureManagementMonitoringAlertsModelsMicrosoftAppInsightsNexusDataContractsResourcesScheduledQueryRulesAlertingAction OdataTypeBasicAction = "Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.AlertingAction" + // OdataTypeBasicActionOdataTypeMicrosoftWindowsAzureManagementMonitoringAlertsModelsMicrosoftAppInsightsNexusDataContractsResourcesScheduledQueryRulesLogToMetricAction ... + OdataTypeBasicActionOdataTypeMicrosoftWindowsAzureManagementMonitoringAlertsModelsMicrosoftAppInsightsNexusDataContractsResourcesScheduledQueryRulesLogToMetricAction OdataTypeBasicAction = "Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.LogToMetricAction" +) + +// PossibleOdataTypeBasicActionValues returns an array of possible values for the OdataTypeBasicAction const type. +func PossibleOdataTypeBasicActionValues() []OdataTypeBasicAction { + return []OdataTypeBasicAction{OdataTypeBasicActionOdataTypeAction, OdataTypeBasicActionOdataTypeMicrosoftWindowsAzureManagementMonitoringAlertsModelsMicrosoftAppInsightsNexusDataContractsResourcesScheduledQueryRulesAlertingAction, OdataTypeBasicActionOdataTypeMicrosoftWindowsAzureManagementMonitoringAlertsModelsMicrosoftAppInsightsNexusDataContractsResourcesScheduledQueryRulesLogToMetricAction} +} + +// OdataTypeBasicMetricAlertCriteria enumerates the values for odata type basic metric alert criteria. +type OdataTypeBasicMetricAlertCriteria string + +const ( + // OdataTypeBasicMetricAlertCriteriaOdataTypeMetricAlertCriteria ... + OdataTypeBasicMetricAlertCriteriaOdataTypeMetricAlertCriteria OdataTypeBasicMetricAlertCriteria = "MetricAlertCriteria" + // OdataTypeBasicMetricAlertCriteriaOdataTypeMicrosoftAzureMonitorMultipleResourceMultipleMetricCriteria ... + OdataTypeBasicMetricAlertCriteriaOdataTypeMicrosoftAzureMonitorMultipleResourceMultipleMetricCriteria OdataTypeBasicMetricAlertCriteria = "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria" + // OdataTypeBasicMetricAlertCriteriaOdataTypeMicrosoftAzureMonitorSingleResourceMultipleMetricCriteria ... + OdataTypeBasicMetricAlertCriteriaOdataTypeMicrosoftAzureMonitorSingleResourceMultipleMetricCriteria OdataTypeBasicMetricAlertCriteria = "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria" + // OdataTypeBasicMetricAlertCriteriaOdataTypeMicrosoftAzureMonitorWebtestLocationAvailabilityCriteria ... + OdataTypeBasicMetricAlertCriteriaOdataTypeMicrosoftAzureMonitorWebtestLocationAvailabilityCriteria OdataTypeBasicMetricAlertCriteria = "Microsoft.Azure.Monitor.WebtestLocationAvailabilityCriteria" +) + +// PossibleOdataTypeBasicMetricAlertCriteriaValues returns an array of possible values for the OdataTypeBasicMetricAlertCriteria const type. +func PossibleOdataTypeBasicMetricAlertCriteriaValues() []OdataTypeBasicMetricAlertCriteria { + return []OdataTypeBasicMetricAlertCriteria{OdataTypeBasicMetricAlertCriteriaOdataTypeMetricAlertCriteria, OdataTypeBasicMetricAlertCriteriaOdataTypeMicrosoftAzureMonitorMultipleResourceMultipleMetricCriteria, OdataTypeBasicMetricAlertCriteriaOdataTypeMicrosoftAzureMonitorSingleResourceMultipleMetricCriteria, OdataTypeBasicMetricAlertCriteriaOdataTypeMicrosoftAzureMonitorWebtestLocationAvailabilityCriteria} +} + +// OdataTypeBasicRuleAction enumerates the values for odata type basic rule action. +type OdataTypeBasicRuleAction string + +const ( + // OdataTypeBasicRuleActionOdataTypeMicrosoftAzureManagementInsightsModelsRuleEmailAction ... + OdataTypeBasicRuleActionOdataTypeMicrosoftAzureManagementInsightsModelsRuleEmailAction OdataTypeBasicRuleAction = "Microsoft.Azure.Management.Insights.Models.RuleEmailAction" + // OdataTypeBasicRuleActionOdataTypeMicrosoftAzureManagementInsightsModelsRuleWebhookAction ... + OdataTypeBasicRuleActionOdataTypeMicrosoftAzureManagementInsightsModelsRuleWebhookAction OdataTypeBasicRuleAction = "Microsoft.Azure.Management.Insights.Models.RuleWebhookAction" + // OdataTypeBasicRuleActionOdataTypeRuleAction ... + OdataTypeBasicRuleActionOdataTypeRuleAction OdataTypeBasicRuleAction = "RuleAction" +) + +// PossibleOdataTypeBasicRuleActionValues returns an array of possible values for the OdataTypeBasicRuleAction const type. +func PossibleOdataTypeBasicRuleActionValues() []OdataTypeBasicRuleAction { + return []OdataTypeBasicRuleAction{OdataTypeBasicRuleActionOdataTypeMicrosoftAzureManagementInsightsModelsRuleEmailAction, OdataTypeBasicRuleActionOdataTypeMicrosoftAzureManagementInsightsModelsRuleWebhookAction, OdataTypeBasicRuleActionOdataTypeRuleAction} +} + +// OdataTypeBasicRuleCondition enumerates the values for odata type basic rule condition. +type OdataTypeBasicRuleCondition string + +const ( + // OdataTypeBasicRuleConditionOdataTypeMicrosoftAzureManagementInsightsModelsLocationThresholdRuleCondition ... + OdataTypeBasicRuleConditionOdataTypeMicrosoftAzureManagementInsightsModelsLocationThresholdRuleCondition OdataTypeBasicRuleCondition = "Microsoft.Azure.Management.Insights.Models.LocationThresholdRuleCondition" + // OdataTypeBasicRuleConditionOdataTypeMicrosoftAzureManagementInsightsModelsManagementEventRuleCondition ... + OdataTypeBasicRuleConditionOdataTypeMicrosoftAzureManagementInsightsModelsManagementEventRuleCondition OdataTypeBasicRuleCondition = "Microsoft.Azure.Management.Insights.Models.ManagementEventRuleCondition" + // OdataTypeBasicRuleConditionOdataTypeMicrosoftAzureManagementInsightsModelsThresholdRuleCondition ... + OdataTypeBasicRuleConditionOdataTypeMicrosoftAzureManagementInsightsModelsThresholdRuleCondition OdataTypeBasicRuleCondition = "Microsoft.Azure.Management.Insights.Models.ThresholdRuleCondition" + // OdataTypeBasicRuleConditionOdataTypeRuleCondition ... + OdataTypeBasicRuleConditionOdataTypeRuleCondition OdataTypeBasicRuleCondition = "RuleCondition" +) + +// PossibleOdataTypeBasicRuleConditionValues returns an array of possible values for the OdataTypeBasicRuleCondition const type. +func PossibleOdataTypeBasicRuleConditionValues() []OdataTypeBasicRuleCondition { + return []OdataTypeBasicRuleCondition{OdataTypeBasicRuleConditionOdataTypeMicrosoftAzureManagementInsightsModelsLocationThresholdRuleCondition, OdataTypeBasicRuleConditionOdataTypeMicrosoftAzureManagementInsightsModelsManagementEventRuleCondition, OdataTypeBasicRuleConditionOdataTypeMicrosoftAzureManagementInsightsModelsThresholdRuleCondition, OdataTypeBasicRuleConditionOdataTypeRuleCondition} +} + +// OnboardingStatus enumerates the values for onboarding status. +type OnboardingStatus string + +const ( + // OnboardingStatusNotOnboarded ... + OnboardingStatusNotOnboarded OnboardingStatus = "notOnboarded" + // OnboardingStatusOnboarded ... + OnboardingStatusOnboarded OnboardingStatus = "onboarded" + // OnboardingStatusUnknown ... + OnboardingStatusUnknown OnboardingStatus = "unknown" +) + +// PossibleOnboardingStatusValues returns an array of possible values for the OnboardingStatus const type. +func PossibleOnboardingStatusValues() []OnboardingStatus { + return []OnboardingStatus{OnboardingStatusNotOnboarded, OnboardingStatusOnboarded, OnboardingStatusUnknown} +} + +// Operator enumerates the values for operator. +type Operator string + +const ( + // OperatorEquals ... + OperatorEquals Operator = "Equals" + // OperatorGreaterThan ... + OperatorGreaterThan Operator = "GreaterThan" + // OperatorGreaterThanOrEqual ... + OperatorGreaterThanOrEqual Operator = "GreaterThanOrEqual" + // OperatorLessThan ... + OperatorLessThan Operator = "LessThan" + // OperatorLessThanOrEqual ... + OperatorLessThanOrEqual Operator = "LessThanOrEqual" + // OperatorNotEquals ... + OperatorNotEquals Operator = "NotEquals" +) + +// PossibleOperatorValues returns an array of possible values for the Operator const type. +func PossibleOperatorValues() []Operator { + return []Operator{OperatorEquals, OperatorGreaterThan, OperatorGreaterThanOrEqual, OperatorLessThan, OperatorLessThanOrEqual, OperatorNotEquals} +} + +// ProvisioningState enumerates the values for provisioning state. +type ProvisioningState string + +const ( + // ProvisioningStateCanceled ... + ProvisioningStateCanceled ProvisioningState = "Canceled" + // ProvisioningStateDeploying ... + ProvisioningStateDeploying ProvisioningState = "Deploying" + // ProvisioningStateFailed ... + ProvisioningStateFailed ProvisioningState = "Failed" + // ProvisioningStateSucceeded ... + ProvisioningStateSucceeded ProvisioningState = "Succeeded" +) + +// PossibleProvisioningStateValues returns an array of possible values for the ProvisioningState const type. +func PossibleProvisioningStateValues() []ProvisioningState { + return []ProvisioningState{ProvisioningStateCanceled, ProvisioningStateDeploying, ProvisioningStateFailed, ProvisioningStateSucceeded} +} + +// QueryType enumerates the values for query type. +type QueryType string + +const ( + // QueryTypeResultCount ... + QueryTypeResultCount QueryType = "ResultCount" +) + +// PossibleQueryTypeValues returns an array of possible values for the QueryType const type. +func PossibleQueryTypeValues() []QueryType { + return []QueryType{QueryTypeResultCount} +} + +// ReceiverStatus enumerates the values for receiver status. +type ReceiverStatus string + +const ( + // ReceiverStatusDisabled ... + ReceiverStatusDisabled ReceiverStatus = "Disabled" + // ReceiverStatusEnabled ... + ReceiverStatusEnabled ReceiverStatus = "Enabled" + // ReceiverStatusNotSpecified ... + ReceiverStatusNotSpecified ReceiverStatus = "NotSpecified" +) + +// PossibleReceiverStatusValues returns an array of possible values for the ReceiverStatus const type. +func PossibleReceiverStatusValues() []ReceiverStatus { + return []ReceiverStatus{ReceiverStatusDisabled, ReceiverStatusEnabled, ReceiverStatusNotSpecified} +} + +// RecurrenceFrequency enumerates the values for recurrence frequency. +type RecurrenceFrequency string + +const ( + // RecurrenceFrequencyDay ... + RecurrenceFrequencyDay RecurrenceFrequency = "Day" + // RecurrenceFrequencyHour ... + RecurrenceFrequencyHour RecurrenceFrequency = "Hour" + // RecurrenceFrequencyMinute ... + RecurrenceFrequencyMinute RecurrenceFrequency = "Minute" + // RecurrenceFrequencyMonth ... + RecurrenceFrequencyMonth RecurrenceFrequency = "Month" + // RecurrenceFrequencyNone ... + RecurrenceFrequencyNone RecurrenceFrequency = "None" + // RecurrenceFrequencySecond ... + RecurrenceFrequencySecond RecurrenceFrequency = "Second" + // RecurrenceFrequencyWeek ... + RecurrenceFrequencyWeek RecurrenceFrequency = "Week" + // RecurrenceFrequencyYear ... + RecurrenceFrequencyYear RecurrenceFrequency = "Year" +) + +// PossibleRecurrenceFrequencyValues returns an array of possible values for the RecurrenceFrequency const type. +func PossibleRecurrenceFrequencyValues() []RecurrenceFrequency { + return []RecurrenceFrequency{RecurrenceFrequencyDay, RecurrenceFrequencyHour, RecurrenceFrequencyMinute, RecurrenceFrequencyMonth, RecurrenceFrequencyNone, RecurrenceFrequencySecond, RecurrenceFrequencyWeek, RecurrenceFrequencyYear} +} + +// ResultType enumerates the values for result type. +type ResultType string + +const ( + // ResultTypeData ... + ResultTypeData ResultType = "Data" + // ResultTypeMetadata ... + ResultTypeMetadata ResultType = "Metadata" +) + +// PossibleResultTypeValues returns an array of possible values for the ResultType const type. +func PossibleResultTypeValues() []ResultType { + return []ResultType{ResultTypeData, ResultTypeMetadata} +} + +// ScaleDirection enumerates the values for scale direction. +type ScaleDirection string + +const ( + // ScaleDirectionDecrease ... + ScaleDirectionDecrease ScaleDirection = "Decrease" + // ScaleDirectionIncrease ... + ScaleDirectionIncrease ScaleDirection = "Increase" + // ScaleDirectionNone ... + ScaleDirectionNone ScaleDirection = "None" +) + +// PossibleScaleDirectionValues returns an array of possible values for the ScaleDirection const type. +func PossibleScaleDirectionValues() []ScaleDirection { + return []ScaleDirection{ScaleDirectionDecrease, ScaleDirectionIncrease, ScaleDirectionNone} +} + +// ScaleRuleMetricDimensionOperationType enumerates the values for scale rule metric dimension operation type. +type ScaleRuleMetricDimensionOperationType string + +const ( + // ScaleRuleMetricDimensionOperationTypeEquals ... + ScaleRuleMetricDimensionOperationTypeEquals ScaleRuleMetricDimensionOperationType = "Equals" + // ScaleRuleMetricDimensionOperationTypeNotEquals ... + ScaleRuleMetricDimensionOperationTypeNotEquals ScaleRuleMetricDimensionOperationType = "NotEquals" +) + +// PossibleScaleRuleMetricDimensionOperationTypeValues returns an array of possible values for the ScaleRuleMetricDimensionOperationType const type. +func PossibleScaleRuleMetricDimensionOperationTypeValues() []ScaleRuleMetricDimensionOperationType { + return []ScaleRuleMetricDimensionOperationType{ScaleRuleMetricDimensionOperationTypeEquals, ScaleRuleMetricDimensionOperationTypeNotEquals} +} + +// ScaleType enumerates the values for scale type. +type ScaleType string + +const ( + // ScaleTypeChangeCount ... + ScaleTypeChangeCount ScaleType = "ChangeCount" + // ScaleTypeExactCount ... + ScaleTypeExactCount ScaleType = "ExactCount" + // ScaleTypePercentChangeCount ... + ScaleTypePercentChangeCount ScaleType = "PercentChangeCount" +) + +// PossibleScaleTypeValues returns an array of possible values for the ScaleType const type. +func PossibleScaleTypeValues() []ScaleType { + return []ScaleType{ScaleTypeChangeCount, ScaleTypeExactCount, ScaleTypePercentChangeCount} +} + +// TimeAggregationOperator enumerates the values for time aggregation operator. +type TimeAggregationOperator string + +const ( + // TimeAggregationOperatorAverage ... + TimeAggregationOperatorAverage TimeAggregationOperator = "Average" + // TimeAggregationOperatorLast ... + TimeAggregationOperatorLast TimeAggregationOperator = "Last" + // TimeAggregationOperatorMaximum ... + TimeAggregationOperatorMaximum TimeAggregationOperator = "Maximum" + // TimeAggregationOperatorMinimum ... + TimeAggregationOperatorMinimum TimeAggregationOperator = "Minimum" + // TimeAggregationOperatorTotal ... + TimeAggregationOperatorTotal TimeAggregationOperator = "Total" +) + +// PossibleTimeAggregationOperatorValues returns an array of possible values for the TimeAggregationOperator const type. +func PossibleTimeAggregationOperatorValues() []TimeAggregationOperator { + return []TimeAggregationOperator{TimeAggregationOperatorAverage, TimeAggregationOperatorLast, TimeAggregationOperatorMaximum, TimeAggregationOperatorMinimum, TimeAggregationOperatorTotal} +} + +// TimeAggregationType enumerates the values for time aggregation type. +type TimeAggregationType string + +const ( + // TimeAggregationTypeAverage ... + TimeAggregationTypeAverage TimeAggregationType = "Average" + // TimeAggregationTypeCount ... + TimeAggregationTypeCount TimeAggregationType = "Count" + // TimeAggregationTypeLast ... + TimeAggregationTypeLast TimeAggregationType = "Last" + // TimeAggregationTypeMaximum ... + TimeAggregationTypeMaximum TimeAggregationType = "Maximum" + // TimeAggregationTypeMinimum ... + TimeAggregationTypeMinimum TimeAggregationType = "Minimum" + // TimeAggregationTypeTotal ... + TimeAggregationTypeTotal TimeAggregationType = "Total" +) + +// PossibleTimeAggregationTypeValues returns an array of possible values for the TimeAggregationType const type. +func PossibleTimeAggregationTypeValues() []TimeAggregationType { + return []TimeAggregationType{TimeAggregationTypeAverage, TimeAggregationTypeCount, TimeAggregationTypeLast, TimeAggregationTypeMaximum, TimeAggregationTypeMinimum, TimeAggregationTypeTotal} +} diff --git a/services/preview/monitor/mgmt/2021-04-01-preview/insights/eventcategories.go b/services/preview/monitor/mgmt/2021-04-01-preview/insights/eventcategories.go new file mode 100644 index 000000000000..86e59b424363 --- /dev/null +++ b/services/preview/monitor/mgmt/2021-04-01-preview/insights/eventcategories.go @@ -0,0 +1,99 @@ +package insights + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// EventCategoriesClient is the monitor Management Client +type EventCategoriesClient struct { + BaseClient +} + +// NewEventCategoriesClient creates an instance of the EventCategoriesClient client. +func NewEventCategoriesClient(subscriptionID string) EventCategoriesClient { + return NewEventCategoriesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewEventCategoriesClientWithBaseURI creates an instance of the EventCategoriesClient client using a custom endpoint. +// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewEventCategoriesClientWithBaseURI(baseURI string, subscriptionID string) EventCategoriesClient { + return EventCategoriesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List get the list of available event categories supported in the Activity Logs Service.
The current list includes +// the following: Administrative, Security, ServiceHealth, Alert, Recommendation, Policy. +func (client EventCategoriesClient) List(ctx context.Context) (result EventCategoryCollection, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/EventCategoriesClient.List") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.EventCategoriesClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.EventCategoriesClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.EventCategoriesClient", "List", resp, "Failure responding to request") + return + } + + return +} + +// ListPreparer prepares the List request. +func (client EventCategoriesClient) ListPreparer(ctx context.Context) (*http.Request, error) { + const APIVersion = "2015-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/microsoft.insights/eventcategories"), + 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 EventCategoriesClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client EventCategoriesClient) ListResponder(resp *http.Response) (result EventCategoryCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/monitor/mgmt/2021-04-01-preview/insights/insightsapi/interfaces.go b/services/preview/monitor/mgmt/2021-04-01-preview/insights/insightsapi/interfaces.go new file mode 100644 index 000000000000..88f2dd9222b8 --- /dev/null +++ b/services/preview/monitor/mgmt/2021-04-01-preview/insights/insightsapi/interfaces.go @@ -0,0 +1,291 @@ +package insightsapi + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/services/preview/monitor/mgmt/2021-04-01-preview/insights" + "github.com/Azure/go-autorest/autorest" +) + +// AutoscaleSettingsClientAPI contains the set of methods on the AutoscaleSettingsClient type. +type AutoscaleSettingsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, autoscaleSettingName string, parameters insights.AutoscaleSettingResource) (result insights.AutoscaleSettingResource, err error) + Delete(ctx context.Context, resourceGroupName string, autoscaleSettingName string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, autoscaleSettingName string) (result insights.AutoscaleSettingResource, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string) (result insights.AutoscaleSettingResourceCollectionPage, err error) + ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result insights.AutoscaleSettingResourceCollectionIterator, err error) + ListBySubscription(ctx context.Context) (result insights.AutoscaleSettingResourceCollectionPage, err error) + ListBySubscriptionComplete(ctx context.Context) (result insights.AutoscaleSettingResourceCollectionIterator, err error) + Update(ctx context.Context, resourceGroupName string, autoscaleSettingName string, autoscaleSettingResource insights.AutoscaleSettingResourcePatch) (result insights.AutoscaleSettingResource, err error) +} + +var _ AutoscaleSettingsClientAPI = (*insights.AutoscaleSettingsClient)(nil) + +// OperationsClientAPI contains the set of methods on the OperationsClient type. +type OperationsClientAPI interface { + List(ctx context.Context) (result insights.OperationListResult, err error) +} + +var _ OperationsClientAPI = (*insights.OperationsClient)(nil) + +// AlertRuleIncidentsClientAPI contains the set of methods on the AlertRuleIncidentsClient type. +type AlertRuleIncidentsClientAPI interface { + Get(ctx context.Context, resourceGroupName string, ruleName string, incidentName string) (result insights.Incident, err error) + ListByAlertRule(ctx context.Context, resourceGroupName string, ruleName string) (result insights.IncidentListResult, err error) +} + +var _ AlertRuleIncidentsClientAPI = (*insights.AlertRuleIncidentsClient)(nil) + +// AlertRulesClientAPI contains the set of methods on the AlertRulesClient type. +type AlertRulesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, ruleName string, parameters insights.AlertRuleResource) (result insights.AlertRuleResource, err error) + Delete(ctx context.Context, resourceGroupName string, ruleName string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, ruleName string) (result insights.AlertRuleResource, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string) (result insights.AlertRuleResourceCollection, err error) + ListBySubscription(ctx context.Context) (result insights.AlertRuleResourceCollection, err error) + Update(ctx context.Context, resourceGroupName string, ruleName string, alertRulesResource insights.AlertRuleResourcePatch) (result insights.AlertRuleResource, err error) +} + +var _ AlertRulesClientAPI = (*insights.AlertRulesClient)(nil) + +// LogProfilesClientAPI contains the set of methods on the LogProfilesClient type. +type LogProfilesClientAPI interface { + CreateOrUpdate(ctx context.Context, logProfileName string, parameters insights.LogProfileResource) (result insights.LogProfileResource, err error) + Delete(ctx context.Context, logProfileName string) (result autorest.Response, err error) + Get(ctx context.Context, logProfileName string) (result insights.LogProfileResource, err error) + List(ctx context.Context) (result insights.LogProfileCollection, err error) + Update(ctx context.Context, logProfileName string, logProfilesResource insights.LogProfileResourcePatch) (result insights.LogProfileResource, err error) +} + +var _ LogProfilesClientAPI = (*insights.LogProfilesClient)(nil) + +// DiagnosticSettingsClientAPI contains the set of methods on the DiagnosticSettingsClient type. +type DiagnosticSettingsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceURI string, parameters insights.DiagnosticSettingsResource, name string) (result insights.DiagnosticSettingsResource, err error) + Delete(ctx context.Context, resourceURI string, name string) (result autorest.Response, err error) + Get(ctx context.Context, resourceURI string, name string) (result insights.DiagnosticSettingsResource, err error) + List(ctx context.Context, resourceURI string) (result insights.DiagnosticSettingsResourceCollection, err error) +} + +var _ DiagnosticSettingsClientAPI = (*insights.DiagnosticSettingsClient)(nil) + +// DiagnosticSettingsCategoryClientAPI contains the set of methods on the DiagnosticSettingsCategoryClient type. +type DiagnosticSettingsCategoryClientAPI interface { + Get(ctx context.Context, resourceURI string, name string) (result insights.DiagnosticSettingsCategoryResource, err error) + List(ctx context.Context, resourceURI string) (result insights.DiagnosticSettingsCategoryResourceCollection, err error) +} + +var _ DiagnosticSettingsCategoryClientAPI = (*insights.DiagnosticSettingsCategoryClient)(nil) + +// ActionGroupsClientAPI contains the set of methods on the ActionGroupsClient type. +type ActionGroupsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, actionGroupName string, actionGroup insights.ActionGroupResource) (result insights.ActionGroupResource, err error) + Delete(ctx context.Context, resourceGroupName string, actionGroupName string) (result autorest.Response, err error) + EnableReceiver(ctx context.Context, resourceGroupName string, actionGroupName string, enableRequest insights.EnableRequest) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, actionGroupName string) (result insights.ActionGroupResource, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string) (result insights.ActionGroupList, err error) + ListBySubscriptionID(ctx context.Context) (result insights.ActionGroupList, err error) + Update(ctx context.Context, resourceGroupName string, actionGroupName string, actionGroupPatch insights.ActionGroupPatchBody) (result insights.ActionGroupResource, err error) +} + +var _ ActionGroupsClientAPI = (*insights.ActionGroupsClient)(nil) + +// ActivityLogsClientAPI contains the set of methods on the ActivityLogsClient type. +type ActivityLogsClientAPI interface { + List(ctx context.Context, filter string, selectParameter string) (result insights.EventDataCollectionPage, err error) + ListComplete(ctx context.Context, filter string, selectParameter string) (result insights.EventDataCollectionIterator, err error) +} + +var _ ActivityLogsClientAPI = (*insights.ActivityLogsClient)(nil) + +// EventCategoriesClientAPI contains the set of methods on the EventCategoriesClient type. +type EventCategoriesClientAPI interface { + List(ctx context.Context) (result insights.EventCategoryCollection, err error) +} + +var _ EventCategoriesClientAPI = (*insights.EventCategoriesClient)(nil) + +// TenantActivityLogsClientAPI contains the set of methods on the TenantActivityLogsClient type. +type TenantActivityLogsClientAPI interface { + List(ctx context.Context, filter string, selectParameter string) (result insights.EventDataCollectionPage, err error) + ListComplete(ctx context.Context, filter string, selectParameter string) (result insights.EventDataCollectionIterator, err error) +} + +var _ TenantActivityLogsClientAPI = (*insights.TenantActivityLogsClient)(nil) + +// MetricDefinitionsClientAPI contains the set of methods on the MetricDefinitionsClient type. +type MetricDefinitionsClientAPI interface { + List(ctx context.Context, resourceURI string, metricnamespace string) (result insights.MetricDefinitionCollection, err error) +} + +var _ MetricDefinitionsClientAPI = (*insights.MetricDefinitionsClient)(nil) + +// MetricsClientAPI contains the set of methods on the MetricsClient type. +type MetricsClientAPI interface { + List(ctx context.Context, resourceURI string, timespan string, interval *string, metricnames string, aggregation string, top *int32, orderby string, filter string, resultType insights.ResultType, metricnamespace string) (result insights.Response, err error) +} + +var _ MetricsClientAPI = (*insights.MetricsClient)(nil) + +// BaselinesClientAPI contains the set of methods on the BaselinesClient type. +type BaselinesClientAPI interface { + List(ctx context.Context, resourceURI string, metricnames string, metricnamespace string, timespan string, interval *string, aggregation string, sensitivities string, filter string, resultType insights.ResultType) (result insights.MetricBaselinesResponse, err error) +} + +var _ BaselinesClientAPI = (*insights.BaselinesClient)(nil) + +// MetricAlertsClientAPI contains the set of methods on the MetricAlertsClient type. +type MetricAlertsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, ruleName string, parameters insights.MetricAlertResource) (result insights.MetricAlertResource, err error) + Delete(ctx context.Context, resourceGroupName string, ruleName string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, ruleName string) (result insights.MetricAlertResource, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string) (result insights.MetricAlertResourceCollection, err error) + ListBySubscription(ctx context.Context) (result insights.MetricAlertResourceCollection, err error) + Update(ctx context.Context, resourceGroupName string, ruleName string, parameters insights.MetricAlertResourcePatch) (result insights.MetricAlertResource, err error) +} + +var _ MetricAlertsClientAPI = (*insights.MetricAlertsClient)(nil) + +// MetricAlertsStatusClientAPI contains the set of methods on the MetricAlertsStatusClient type. +type MetricAlertsStatusClientAPI interface { + List(ctx context.Context, resourceGroupName string, ruleName string) (result insights.MetricAlertStatusCollection, err error) + ListByName(ctx context.Context, resourceGroupName string, ruleName string, statusName string) (result insights.MetricAlertStatusCollection, err error) +} + +var _ MetricAlertsStatusClientAPI = (*insights.MetricAlertsStatusClient)(nil) + +// ScheduledQueryRulesClientAPI contains the set of methods on the ScheduledQueryRulesClient type. +type ScheduledQueryRulesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, ruleName string, parameters insights.LogSearchRuleResource) (result insights.LogSearchRuleResource, err error) + Delete(ctx context.Context, resourceGroupName string, ruleName string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, ruleName string) (result insights.LogSearchRuleResource, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string, filter string) (result insights.LogSearchRuleResourceCollection, err error) + ListBySubscription(ctx context.Context, filter string) (result insights.LogSearchRuleResourceCollection, err error) + Update(ctx context.Context, resourceGroupName string, ruleName string, parameters insights.LogSearchRuleResourcePatch) (result insights.LogSearchRuleResource, err error) +} + +var _ ScheduledQueryRulesClientAPI = (*insights.ScheduledQueryRulesClient)(nil) + +// MetricNamespacesClientAPI contains the set of methods on the MetricNamespacesClient type. +type MetricNamespacesClientAPI interface { + List(ctx context.Context, resourceURI string, startTime string) (result insights.MetricNamespaceCollection, err error) +} + +var _ MetricNamespacesClientAPI = (*insights.MetricNamespacesClient)(nil) + +// VMInsightsClientAPI contains the set of methods on the VMInsightsClient type. +type VMInsightsClientAPI interface { + GetOnboardingStatus(ctx context.Context, resourceURI string) (result insights.VMInsightsOnboardingStatus, err error) +} + +var _ VMInsightsClientAPI = (*insights.VMInsightsClient)(nil) + +// PrivateLinkScopesClientAPI contains the set of methods on the PrivateLinkScopesClient type. +type PrivateLinkScopesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, scopeName string, azureMonitorPrivateLinkScopePayload insights.AzureMonitorPrivateLinkScope) (result insights.AzureMonitorPrivateLinkScope, err error) + Delete(ctx context.Context, resourceGroupName string, scopeName string) (result insights.PrivateLinkScopesDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, scopeName string) (result insights.AzureMonitorPrivateLinkScope, err error) + List(ctx context.Context) (result insights.AzureMonitorPrivateLinkScopeListResultPage, err error) + ListComplete(ctx context.Context) (result insights.AzureMonitorPrivateLinkScopeListResultIterator, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string) (result insights.AzureMonitorPrivateLinkScopeListResultPage, err error) + ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result insights.AzureMonitorPrivateLinkScopeListResultIterator, err error) + UpdateTags(ctx context.Context, resourceGroupName string, scopeName string, privateLinkScopeTags insights.TagsResource) (result insights.AzureMonitorPrivateLinkScope, err error) +} + +var _ PrivateLinkScopesClientAPI = (*insights.PrivateLinkScopesClient)(nil) + +// PrivateLinkScopeOperationStatusClientAPI contains the set of methods on the PrivateLinkScopeOperationStatusClient type. +type PrivateLinkScopeOperationStatusClientAPI interface { + Get(ctx context.Context, asyncOperationID string, resourceGroupName string) (result insights.OperationStatus, err error) +} + +var _ PrivateLinkScopeOperationStatusClientAPI = (*insights.PrivateLinkScopeOperationStatusClient)(nil) + +// PrivateLinkResourcesClientAPI contains the set of methods on the PrivateLinkResourcesClient type. +type PrivateLinkResourcesClientAPI interface { + Get(ctx context.Context, resourceGroupName string, scopeName string, groupName string) (result insights.PrivateLinkResource, err error) + ListByPrivateLinkScope(ctx context.Context, resourceGroupName string, scopeName string) (result insights.PrivateLinkResourceListResultPage, err error) + ListByPrivateLinkScopeComplete(ctx context.Context, resourceGroupName string, scopeName string) (result insights.PrivateLinkResourceListResultIterator, err error) +} + +var _ PrivateLinkResourcesClientAPI = (*insights.PrivateLinkResourcesClient)(nil) + +// PrivateEndpointConnectionsClientAPI contains the set of methods on the PrivateEndpointConnectionsClient type. +type PrivateEndpointConnectionsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, scopeName string, privateEndpointConnectionName string, parameters insights.PrivateEndpointConnection) (result insights.PrivateEndpointConnectionsCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, scopeName string, privateEndpointConnectionName string) (result insights.PrivateEndpointConnectionsDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, scopeName string, privateEndpointConnectionName string) (result insights.PrivateEndpointConnection, err error) + ListByPrivateLinkScope(ctx context.Context, resourceGroupName string, scopeName string) (result insights.PrivateEndpointConnectionListResultPage, err error) + ListByPrivateLinkScopeComplete(ctx context.Context, resourceGroupName string, scopeName string) (result insights.PrivateEndpointConnectionListResultIterator, err error) +} + +var _ PrivateEndpointConnectionsClientAPI = (*insights.PrivateEndpointConnectionsClient)(nil) + +// PrivateLinkScopedResourcesClientAPI contains the set of methods on the PrivateLinkScopedResourcesClient type. +type PrivateLinkScopedResourcesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, scopeName string, name string, parameters insights.ScopedResource) (result insights.PrivateLinkScopedResourcesCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, scopeName string, name string) (result insights.PrivateLinkScopedResourcesDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, scopeName string, name string) (result insights.ScopedResource, err error) + ListByPrivateLinkScope(ctx context.Context, resourceGroupName string, scopeName string) (result insights.ScopedResourceListResultPage, err error) + ListByPrivateLinkScopeComplete(ctx context.Context, resourceGroupName string, scopeName string) (result insights.ScopedResourceListResultIterator, err error) +} + +var _ PrivateLinkScopedResourcesClientAPI = (*insights.PrivateLinkScopedResourcesClient)(nil) + +// ActivityLogAlertsClientAPI contains the set of methods on the ActivityLogAlertsClient type. +type ActivityLogAlertsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, activityLogAlertName string, activityLogAlert insights.ActivityLogAlertResource) (result insights.ActivityLogAlertResource, err error) + Delete(ctx context.Context, resourceGroupName string, activityLogAlertName string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, activityLogAlertName string) (result insights.ActivityLogAlertResource, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string) (result insights.ActivityLogAlertList, err error) + ListBySubscriptionID(ctx context.Context) (result insights.ActivityLogAlertList, err error) + Update(ctx context.Context, resourceGroupName string, activityLogAlertName string, activityLogAlertPatch insights.ActivityLogAlertPatchBody) (result insights.ActivityLogAlertResource, err error) +} + +var _ ActivityLogAlertsClientAPI = (*insights.ActivityLogAlertsClient)(nil) + +// DataCollectionEndpointsClientAPI contains the set of methods on the DataCollectionEndpointsClient type. +type DataCollectionEndpointsClientAPI interface { + Create(ctx context.Context, resourceGroupName string, dataCollectionEndpointName string, body *insights.DataCollectionEndpointResource) (result insights.DataCollectionEndpointResource, err error) + Delete(ctx context.Context, resourceGroupName string, dataCollectionEndpointName string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, dataCollectionEndpointName string) (result insights.DataCollectionEndpointResource, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string) (result insights.DataCollectionEndpointResourceListResultPage, err error) + ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result insights.DataCollectionEndpointResourceListResultIterator, err error) + ListBySubscription(ctx context.Context) (result insights.DataCollectionEndpointResourceListResultPage, err error) + ListBySubscriptionComplete(ctx context.Context) (result insights.DataCollectionEndpointResourceListResultIterator, err error) + Update(ctx context.Context, resourceGroupName string, dataCollectionEndpointName string, body *insights.ResourceForUpdate) (result insights.DataCollectionEndpointResource, err error) +} + +var _ DataCollectionEndpointsClientAPI = (*insights.DataCollectionEndpointsClient)(nil) + +// DataCollectionRuleAssociationsClientAPI contains the set of methods on the DataCollectionRuleAssociationsClient type. +type DataCollectionRuleAssociationsClientAPI interface { + Create(ctx context.Context, resourceURI string, associationName string, body *insights.DataCollectionRuleAssociationProxyOnlyResource) (result insights.DataCollectionRuleAssociationProxyOnlyResource, err error) + Delete(ctx context.Context, resourceURI string, associationName string) (result autorest.Response, err error) + Get(ctx context.Context, resourceURI string, associationName string) (result insights.DataCollectionRuleAssociationProxyOnlyResource, err error) + ListByResource(ctx context.Context, resourceURI string) (result insights.DataCollectionRuleAssociationProxyOnlyResourceListResultPage, err error) + ListByResourceComplete(ctx context.Context, resourceURI string) (result insights.DataCollectionRuleAssociationProxyOnlyResourceListResultIterator, err error) + ListByRule(ctx context.Context, resourceGroupName string, dataCollectionRuleName string) (result insights.DataCollectionRuleAssociationProxyOnlyResourceListResultPage, err error) + ListByRuleComplete(ctx context.Context, resourceGroupName string, dataCollectionRuleName string) (result insights.DataCollectionRuleAssociationProxyOnlyResourceListResultIterator, err error) +} + +var _ DataCollectionRuleAssociationsClientAPI = (*insights.DataCollectionRuleAssociationsClient)(nil) + +// DataCollectionRulesClientAPI contains the set of methods on the DataCollectionRulesClient type. +type DataCollectionRulesClientAPI interface { + Create(ctx context.Context, resourceGroupName string, dataCollectionRuleName string, body *insights.DataCollectionRuleResource) (result insights.DataCollectionRuleResource, err error) + Delete(ctx context.Context, resourceGroupName string, dataCollectionRuleName string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, dataCollectionRuleName string) (result insights.DataCollectionRuleResource, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string) (result insights.DataCollectionRuleResourceListResultPage, err error) + ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result insights.DataCollectionRuleResourceListResultIterator, err error) + ListBySubscription(ctx context.Context) (result insights.DataCollectionRuleResourceListResultPage, err error) + ListBySubscriptionComplete(ctx context.Context) (result insights.DataCollectionRuleResourceListResultIterator, err error) + Update(ctx context.Context, resourceGroupName string, dataCollectionRuleName string, body *insights.ResourceForUpdate) (result insights.DataCollectionRuleResource, err error) +} + +var _ DataCollectionRulesClientAPI = (*insights.DataCollectionRulesClient)(nil) diff --git a/services/preview/monitor/mgmt/2021-04-01-preview/insights/logprofiles.go b/services/preview/monitor/mgmt/2021-04-01-preview/insights/logprofiles.go new file mode 100644 index 000000000000..64fda18dde7c --- /dev/null +++ b/services/preview/monitor/mgmt/2021-04-01-preview/insights/logprofiles.go @@ -0,0 +1,444 @@ +package insights + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// LogProfilesClient is the monitor Management Client +type LogProfilesClient struct { + BaseClient +} + +// NewLogProfilesClient creates an instance of the LogProfilesClient client. +func NewLogProfilesClient(subscriptionID string) LogProfilesClient { + return NewLogProfilesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewLogProfilesClientWithBaseURI creates an instance of the LogProfilesClient client using a custom endpoint. Use +// this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewLogProfilesClientWithBaseURI(baseURI string, subscriptionID string) LogProfilesClient { + return LogProfilesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate create or update a log profile in Azure Monitoring REST API. +// Parameters: +// logProfileName - the name of the log profile. +// parameters - parameters supplied to the operation. +func (client LogProfilesClient) CreateOrUpdate(ctx context.Context, logProfileName string, parameters LogProfileResource) (result LogProfileResource, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LogProfilesClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.LogProfileProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.LogProfileProperties.Locations", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.LogProfileProperties.Categories", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.LogProfileProperties.RetentionPolicy", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.LogProfileProperties.RetentionPolicy.Enabled", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.LogProfileProperties.RetentionPolicy.Days", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.LogProfileProperties.RetentionPolicy.Days", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}, + }}, + }}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.LogProfilesClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, logProfileName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.LogProfilesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.LogProfilesClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.LogProfilesClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client LogProfilesClient) CreateOrUpdatePreparer(ctx context.Context, logProfileName string, parameters LogProfileResource) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "logProfileName": autorest.Encode("path", logProfileName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-03-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}/providers/microsoft.insights/logprofiles/{logProfileName}", 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 LogProfilesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client LogProfilesClient) CreateOrUpdateResponder(resp *http.Response) (result LogProfileResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes the log profile. +// Parameters: +// logProfileName - the name of the log profile. +func (client LogProfilesClient) Delete(ctx context.Context, logProfileName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LogProfilesClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.LogProfilesClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, logProfileName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.LogProfilesClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "insights.LogProfilesClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.LogProfilesClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client LogProfilesClient) DeletePreparer(ctx context.Context, logProfileName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "logProfileName": autorest.Encode("path", logProfileName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/microsoft.insights/logprofiles/{logProfileName}", 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 LogProfilesClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client LogProfilesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets the log profile. +// Parameters: +// logProfileName - the name of the log profile. +func (client LogProfilesClient) Get(ctx context.Context, logProfileName string) (result LogProfileResource, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LogProfilesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.LogProfilesClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, logProfileName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.LogProfilesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.LogProfilesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.LogProfilesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client LogProfilesClient) GetPreparer(ctx context.Context, logProfileName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "logProfileName": autorest.Encode("path", logProfileName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/microsoft.insights/logprofiles/{logProfileName}", 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 LogProfilesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client LogProfilesClient) GetResponder(resp *http.Response) (result LogProfileResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List list the log profiles. +func (client LogProfilesClient) List(ctx context.Context) (result LogProfileCollection, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LogProfilesClient.List") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.LogProfilesClient", "List", err.Error()) + } + + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.LogProfilesClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.LogProfilesClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.LogProfilesClient", "List", resp, "Failure responding to request") + return + } + + return +} + +// ListPreparer prepares the List request. +func (client LogProfilesClient) ListPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/microsoft.insights/logprofiles", 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 LogProfilesClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client LogProfilesClient) ListResponder(resp *http.Response) (result LogProfileCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Update updates an existing LogProfilesResource. To update other fields use the CreateOrUpdate method. +// Parameters: +// logProfileName - the name of the log profile. +// logProfilesResource - parameters supplied to the operation. +func (client LogProfilesClient) Update(ctx context.Context, logProfileName string, logProfilesResource LogProfileResourcePatch) (result LogProfileResource, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LogProfilesClient.Update") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.LogProfilesClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, logProfileName, logProfilesResource) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.LogProfilesClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.LogProfilesClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.LogProfilesClient", "Update", resp, "Failure responding to request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client LogProfilesClient) UpdatePreparer(ctx context.Context, logProfileName string, logProfilesResource LogProfileResourcePatch) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "logProfileName": autorest.Encode("path", logProfileName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-03-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}/providers/microsoft.insights/logprofiles/{logProfileName}", pathParameters), + autorest.WithJSON(logProfilesResource), + 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 LogProfilesClient) UpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client LogProfilesClient) UpdateResponder(resp *http.Response) (result LogProfileResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/monitor/mgmt/2021-04-01-preview/insights/metricalerts.go b/services/preview/monitor/mgmt/2021-04-01-preview/insights/metricalerts.go new file mode 100644 index 000000000000..f9706664d9be --- /dev/null +++ b/services/preview/monitor/mgmt/2021-04-01-preview/insights/metricalerts.go @@ -0,0 +1,545 @@ +package insights + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// MetricAlertsClient is the monitor Management Client +type MetricAlertsClient struct { + BaseClient +} + +// NewMetricAlertsClient creates an instance of the MetricAlertsClient client. +func NewMetricAlertsClient(subscriptionID string) MetricAlertsClient { + return NewMetricAlertsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewMetricAlertsClientWithBaseURI creates an instance of the MetricAlertsClient client using a custom endpoint. Use +// this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewMetricAlertsClientWithBaseURI(baseURI string, subscriptionID string) MetricAlertsClient { + return MetricAlertsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate create or update an metric alert definition. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// ruleName - the name of the rule. +// parameters - the parameters of the rule to create or update. +func (client MetricAlertsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, ruleName string, parameters MetricAlertResource) (result MetricAlertResource, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MetricAlertsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.MetricAlertProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.MetricAlertProperties.Severity", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.MetricAlertProperties.Enabled", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.MetricAlertProperties.Scopes", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.MetricAlertProperties.EvaluationFrequency", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.MetricAlertProperties.WindowSize", Name: validation.Null, Rule: true, Chain: nil}, + }}}}}); err != nil { + return result, validation.NewError("insights.MetricAlertsClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, ruleName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.MetricAlertsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.MetricAlertsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.MetricAlertsClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client MetricAlertsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, ruleName string, parameters MetricAlertResource) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "ruleName": autorest.Encode("path", ruleName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-03-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.Insights/metricAlerts/{ruleName}", 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 MetricAlertsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client MetricAlertsClient) CreateOrUpdateResponder(resp *http.Response) (result MetricAlertResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete an alert rule definition. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// ruleName - the name of the rule. +func (client MetricAlertsClient) Delete(ctx context.Context, resourceGroupName string, ruleName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MetricAlertsClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.MetricAlertsClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, ruleName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.MetricAlertsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "insights.MetricAlertsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.MetricAlertsClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client MetricAlertsClient) DeletePreparer(ctx context.Context, resourceGroupName string, ruleName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "ruleName": autorest.Encode("path", ruleName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-03-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.Insights/metricAlerts/{ruleName}", 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 MetricAlertsClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client MetricAlertsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get retrieve an alert rule definition. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// ruleName - the name of the rule. +func (client MetricAlertsClient) Get(ctx context.Context, resourceGroupName string, ruleName string) (result MetricAlertResource, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MetricAlertsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.MetricAlertsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, ruleName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.MetricAlertsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.MetricAlertsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.MetricAlertsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client MetricAlertsClient) GetPreparer(ctx context.Context, resourceGroupName string, ruleName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "ruleName": autorest.Encode("path", ruleName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-03-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.Insights/metricAlerts/{ruleName}", 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 MetricAlertsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client MetricAlertsClient) GetResponder(resp *http.Response) (result MetricAlertResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByResourceGroup retrieve alert rule definitions in a resource group. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +func (client MetricAlertsClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result MetricAlertResourceCollection, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MetricAlertsClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.MetricAlertsClient", "ListByResourceGroup", err.Error()) + } + + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.MetricAlertsClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.MetricAlertsClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.MetricAlertsClient", "ListByResourceGroup", resp, "Failure responding to request") + return + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client MetricAlertsClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-03-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.Insights/metricAlerts", 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 MetricAlertsClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client MetricAlertsClient) ListByResourceGroupResponder(resp *http.Response) (result MetricAlertResourceCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListBySubscription retrieve alert rule definitions in a subscription. +func (client MetricAlertsClient) ListBySubscription(ctx context.Context) (result MetricAlertResourceCollection, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MetricAlertsClient.ListBySubscription") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.MetricAlertsClient", "ListBySubscription", err.Error()) + } + + req, err := client.ListBySubscriptionPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.MetricAlertsClient", "ListBySubscription", nil, "Failure preparing request") + return + } + + resp, err := client.ListBySubscriptionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.MetricAlertsClient", "ListBySubscription", resp, "Failure sending request") + return + } + + result, err = client.ListBySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.MetricAlertsClient", "ListBySubscription", resp, "Failure responding to request") + return + } + + return +} + +// ListBySubscriptionPreparer prepares the ListBySubscription request. +func (client MetricAlertsClient) ListBySubscriptionPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Insights/metricAlerts", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListBySubscriptionSender sends the ListBySubscription request. The method will close the +// http.Response Body if it receives an error. +func (client MetricAlertsClient) ListBySubscriptionSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListBySubscriptionResponder handles the response to the ListBySubscription request. The method always +// closes the http.Response Body. +func (client MetricAlertsClient) ListBySubscriptionResponder(resp *http.Response) (result MetricAlertResourceCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Update update an metric alert definition. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// ruleName - the name of the rule. +// parameters - the parameters of the rule to update. +func (client MetricAlertsClient) Update(ctx context.Context, resourceGroupName string, ruleName string, parameters MetricAlertResourcePatch) (result MetricAlertResource, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MetricAlertsClient.Update") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.MetricAlertsClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, ruleName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.MetricAlertsClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.MetricAlertsClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.MetricAlertsClient", "Update", resp, "Failure responding to request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client MetricAlertsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, ruleName string, parameters MetricAlertResourcePatch) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "ruleName": autorest.Encode("path", ruleName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-03-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.Insights/metricAlerts/{ruleName}", 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 MetricAlertsClient) UpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client MetricAlertsClient) UpdateResponder(resp *http.Response) (result MetricAlertResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/monitor/mgmt/2021-04-01-preview/insights/metricalertsstatus.go b/services/preview/monitor/mgmt/2021-04-01-preview/insights/metricalertsstatus.go new file mode 100644 index 000000000000..4709142160be --- /dev/null +++ b/services/preview/monitor/mgmt/2021-04-01-preview/insights/metricalertsstatus.go @@ -0,0 +1,205 @@ +package insights + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// MetricAlertsStatusClient is the monitor Management Client +type MetricAlertsStatusClient struct { + BaseClient +} + +// NewMetricAlertsStatusClient creates an instance of the MetricAlertsStatusClient client. +func NewMetricAlertsStatusClient(subscriptionID string) MetricAlertsStatusClient { + return NewMetricAlertsStatusClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewMetricAlertsStatusClientWithBaseURI creates an instance of the MetricAlertsStatusClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewMetricAlertsStatusClientWithBaseURI(baseURI string, subscriptionID string) MetricAlertsStatusClient { + return MetricAlertsStatusClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List retrieve an alert rule status. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// ruleName - the name of the rule. +func (client MetricAlertsStatusClient) List(ctx context.Context, resourceGroupName string, ruleName string) (result MetricAlertStatusCollection, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MetricAlertsStatusClient.List") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.MetricAlertsStatusClient", "List", err.Error()) + } + + req, err := client.ListPreparer(ctx, resourceGroupName, ruleName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.MetricAlertsStatusClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.MetricAlertsStatusClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.MetricAlertsStatusClient", "List", resp, "Failure responding to request") + return + } + + return +} + +// ListPreparer prepares the List request. +func (client MetricAlertsStatusClient) ListPreparer(ctx context.Context, resourceGroupName string, ruleName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "ruleName": autorest.Encode("path", ruleName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-03-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.Insights/metricAlerts/{ruleName}/status", 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 MetricAlertsStatusClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client MetricAlertsStatusClient) ListResponder(resp *http.Response) (result MetricAlertStatusCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByName retrieve an alert rule status. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// ruleName - the name of the rule. +// statusName - the name of the status. +func (client MetricAlertsStatusClient) ListByName(ctx context.Context, resourceGroupName string, ruleName string, statusName string) (result MetricAlertStatusCollection, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MetricAlertsStatusClient.ListByName") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.MetricAlertsStatusClient", "ListByName", err.Error()) + } + + req, err := client.ListByNamePreparer(ctx, resourceGroupName, ruleName, statusName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.MetricAlertsStatusClient", "ListByName", nil, "Failure preparing request") + return + } + + resp, err := client.ListByNameSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.MetricAlertsStatusClient", "ListByName", resp, "Failure sending request") + return + } + + result, err = client.ListByNameResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.MetricAlertsStatusClient", "ListByName", resp, "Failure responding to request") + return + } + + return +} + +// ListByNamePreparer prepares the ListByName request. +func (client MetricAlertsStatusClient) ListByNamePreparer(ctx context.Context, resourceGroupName string, ruleName string, statusName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "ruleName": autorest.Encode("path", ruleName), + "statusName": autorest.Encode("path", statusName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-03-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.Insights/metricAlerts/{ruleName}/status/{statusName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByNameSender sends the ListByName request. The method will close the +// http.Response Body if it receives an error. +func (client MetricAlertsStatusClient) ListByNameSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByNameResponder handles the response to the ListByName request. The method always +// closes the http.Response Body. +func (client MetricAlertsStatusClient) ListByNameResponder(resp *http.Response) (result MetricAlertStatusCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/monitor/mgmt/2021-04-01-preview/insights/metricdefinitions.go b/services/preview/monitor/mgmt/2021-04-01-preview/insights/metricdefinitions.go new file mode 100644 index 000000000000..34383acfb3e7 --- /dev/null +++ b/services/preview/monitor/mgmt/2021-04-01-preview/insights/metricdefinitions.go @@ -0,0 +1,116 @@ +package insights + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// MetricDefinitionsClient is the monitor Management Client +type MetricDefinitionsClient struct { + BaseClient +} + +// NewMetricDefinitionsClient creates an instance of the MetricDefinitionsClient client. +func NewMetricDefinitionsClient(subscriptionID string) MetricDefinitionsClient { + return NewMetricDefinitionsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewMetricDefinitionsClientWithBaseURI creates an instance of the MetricDefinitionsClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewMetricDefinitionsClientWithBaseURI(baseURI string, subscriptionID string) MetricDefinitionsClient { + return MetricDefinitionsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List lists the metric definitions for the resource. +// Parameters: +// resourceURI - the identifier of the resource. +// metricnamespace - metric namespace to query metric definitions for. +func (client MetricDefinitionsClient) List(ctx context.Context, resourceURI string, metricnamespace string) (result MetricDefinitionCollection, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MetricDefinitionsClient.List") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceURI, + Constraints: []validation.Constraint{{Target: "resourceURI", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.MetricDefinitionsClient", "List", err.Error()) + } + + req, err := client.ListPreparer(ctx, resourceURI, metricnamespace) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.MetricDefinitionsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.MetricDefinitionsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.MetricDefinitionsClient", "List", resp, "Failure responding to request") + return + } + + return +} + +// ListPreparer prepares the List request. +func (client MetricDefinitionsClient) ListPreparer(ctx context.Context, resourceURI string, metricnamespace string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceUri": resourceURI, + } + + const APIVersion = "2018-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(metricnamespace) > 0 { + queryParameters["metricnamespace"] = autorest.Encode("query", metricnamespace) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{resourceUri}/providers/Microsoft.Insights/metricDefinitions", 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 MetricDefinitionsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client MetricDefinitionsClient) ListResponder(resp *http.Response) (result MetricDefinitionCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/monitor/mgmt/2021-04-01-preview/insights/metricnamespaces.go b/services/preview/monitor/mgmt/2021-04-01-preview/insights/metricnamespaces.go new file mode 100644 index 000000000000..a1a70c21f9d6 --- /dev/null +++ b/services/preview/monitor/mgmt/2021-04-01-preview/insights/metricnamespaces.go @@ -0,0 +1,116 @@ +package insights + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// MetricNamespacesClient is the monitor Management Client +type MetricNamespacesClient struct { + BaseClient +} + +// NewMetricNamespacesClient creates an instance of the MetricNamespacesClient client. +func NewMetricNamespacesClient(subscriptionID string) MetricNamespacesClient { + return NewMetricNamespacesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewMetricNamespacesClientWithBaseURI creates an instance of the MetricNamespacesClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewMetricNamespacesClientWithBaseURI(baseURI string, subscriptionID string) MetricNamespacesClient { + return MetricNamespacesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List lists the metric namespaces for the resource. +// Parameters: +// resourceURI - the identifier of the resource. +// startTime - the ISO 8601 conform Date start time from which to query for metric namespaces. +func (client MetricNamespacesClient) List(ctx context.Context, resourceURI string, startTime string) (result MetricNamespaceCollection, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MetricNamespacesClient.List") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceURI, + Constraints: []validation.Constraint{{Target: "resourceURI", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.MetricNamespacesClient", "List", err.Error()) + } + + req, err := client.ListPreparer(ctx, resourceURI, startTime) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.MetricNamespacesClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.MetricNamespacesClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.MetricNamespacesClient", "List", resp, "Failure responding to request") + return + } + + return +} + +// ListPreparer prepares the List request. +func (client MetricNamespacesClient) ListPreparer(ctx context.Context, resourceURI string, startTime string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceUri": resourceURI, + } + + const APIVersion = "2017-12-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(startTime) > 0 { + queryParameters["startTime"] = autorest.Encode("query", startTime) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{resourceUri}/providers/microsoft.insights/metricNamespaces", 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 MetricNamespacesClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client MetricNamespacesClient) ListResponder(resp *http.Response) (result MetricNamespaceCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/monitor/mgmt/2021-04-01-preview/insights/metrics.go b/services/preview/monitor/mgmt/2021-04-01-preview/insights/metrics.go new file mode 100644 index 000000000000..297183565d38 --- /dev/null +++ b/services/preview/monitor/mgmt/2021-04-01-preview/insights/metrics.go @@ -0,0 +1,163 @@ +package insights + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// MetricsClient is the monitor Management Client +type MetricsClient struct { + BaseClient +} + +// NewMetricsClient creates an instance of the MetricsClient client. +func NewMetricsClient(subscriptionID string) MetricsClient { + return NewMetricsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewMetricsClientWithBaseURI creates an instance of the MetricsClient client using a custom endpoint. Use this when +// interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewMetricsClientWithBaseURI(baseURI string, subscriptionID string) MetricsClient { + return MetricsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List **Lists the metric values for a resource**. +// Parameters: +// resourceURI - the identifier of the resource. +// timespan - the timespan of the query. It is a string with the following format +// 'startDateTime_ISO/endDateTime_ISO'. +// interval - the interval (i.e. timegrain) of the query. +// metricnames - the names of the metrics (comma separated) to retrieve. Special case: If a metricname itself +// has a comma in it then use %2 to indicate it. Eg: 'Metric,Name1' should be **'Metric%2Name1'** +// aggregation - the list of aggregation types (comma separated) to retrieve. +// top - the maximum number of records to retrieve. +// Valid only if $filter is specified. +// Defaults to 10. +// orderby - the aggregation to use for sorting results and the direction of the sort. +// Only one order can be specified. +// Examples: sum asc. +// filter - the **$filter** is used to reduce the set of metric data returned. Example: Metric contains +// metadata A, B and C. - Return all time series of C where A = a1 and B = b1 or b2 **$filter=A eq 'a1' and B +// eq 'b1' or B eq 'b2' and C eq '*'** - Invalid variant: **$filter=A eq 'a1' and B eq 'b1' and C eq '*' or B = +// 'b2'** This is invalid because the logical or operator cannot separate two different metadata names. - +// Return all time series where A = a1, B = b1 and C = c1: **$filter=A eq 'a1' and B eq 'b1' and C eq 'c1'** - +// Return all time series where A = a1 **$filter=A eq 'a1' and B eq '*' and C eq '*'**. Special case: When +// dimension name or dimension value uses round brackets. Eg: When dimension name is **dim (test) 1** Instead +// of using $filter= "dim (test) 1 eq '*' " use **$filter= "dim %2528test%2529 1 eq '*' "** When dimension name +// is **dim (test) 3** and dimension value is **dim3 (test) val** Instead of using $filter= "dim (test) 3 eq +// 'dim3 (test) val' " use **$filter= "dim %2528test%2529 3 eq 'dim3 %2528test%2529 val' "** +// resultType - reduces the set of data collected. The syntax allowed depends on the operation. See the +// operation's description for details. +// metricnamespace - metric namespace to query metric definitions for. +func (client MetricsClient) List(ctx context.Context, resourceURI string, timespan string, interval *string, metricnames string, aggregation string, top *int32, orderby string, filter string, resultType ResultType, metricnamespace string) (result Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MetricsClient.List") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceURI, + Constraints: []validation.Constraint{{Target: "resourceURI", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.MetricsClient", "List", err.Error()) + } + + req, err := client.ListPreparer(ctx, resourceURI, timespan, interval, metricnames, aggregation, top, orderby, filter, resultType, metricnamespace) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.MetricsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.MetricsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.MetricsClient", "List", resp, "Failure responding to request") + return + } + + return +} + +// ListPreparer prepares the List request. +func (client MetricsClient) ListPreparer(ctx context.Context, resourceURI string, timespan string, interval *string, metricnames string, aggregation string, top *int32, orderby string, filter string, resultType ResultType, metricnamespace string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceUri": resourceURI, + } + + const APIVersion = "2018-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(timespan) > 0 { + queryParameters["timespan"] = autorest.Encode("query", timespan) + } + if interval != nil { + queryParameters["interval"] = autorest.Encode("query", *interval) + } + if len(metricnames) > 0 { + queryParameters["metricnames"] = autorest.Encode("query", metricnames) + } + if len(aggregation) > 0 { + queryParameters["aggregation"] = autorest.Encode("query", aggregation) + } + if top != nil { + queryParameters["top"] = autorest.Encode("query", *top) + } + if len(orderby) > 0 { + queryParameters["orderby"] = autorest.Encode("query", orderby) + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if len(string(resultType)) > 0 { + queryParameters["resultType"] = autorest.Encode("query", resultType) + } + if len(metricnamespace) > 0 { + queryParameters["metricnamespace"] = autorest.Encode("query", metricnamespace) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{resourceUri}/providers/Microsoft.Insights/metrics", 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 MetricsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client MetricsClient) ListResponder(resp *http.Response) (result Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/monitor/mgmt/2021-04-01-preview/insights/models.go b/services/preview/monitor/mgmt/2021-04-01-preview/insights/models.go new file mode 100644 index 000000000000..d82b7cbdb8ef --- /dev/null +++ b/services/preview/monitor/mgmt/2021-04-01-preview/insights/models.go @@ -0,0 +1,8744 @@ +package insights + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "encoding/json" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/date" + "github.com/Azure/go-autorest/autorest/to" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// The package's fully qualified name. +const fqdn = "github.com/Azure/azure-sdk-for-go/services/preview/monitor/mgmt/2021-04-01-preview/insights" + +// BasicAction action descriptor. +type BasicAction interface { + AsAlertingAction() (*AlertingAction, bool) + AsLogToMetricAction() (*LogToMetricAction, bool) + AsAction() (*Action, bool) +} + +// Action action descriptor. +type Action struct { + // OdataType - Possible values include: 'OdataTypeBasicActionOdataTypeAction', 'OdataTypeBasicActionOdataTypeMicrosoftWindowsAzureManagementMonitoringAlertsModelsMicrosoftAppInsightsNexusDataContractsResourcesScheduledQueryRulesAlertingAction', 'OdataTypeBasicActionOdataTypeMicrosoftWindowsAzureManagementMonitoringAlertsModelsMicrosoftAppInsightsNexusDataContractsResourcesScheduledQueryRulesLogToMetricAction' + OdataType OdataTypeBasicAction `json:"odata.type,omitempty"` +} + +func unmarshalBasicAction(body []byte) (BasicAction, error) { + var m map[string]interface{} + err := json.Unmarshal(body, &m) + if err != nil { + return nil, err + } + + switch m["odata.type"] { + case string(OdataTypeBasicActionOdataTypeMicrosoftWindowsAzureManagementMonitoringAlertsModelsMicrosoftAppInsightsNexusDataContractsResourcesScheduledQueryRulesAlertingAction): + var aa AlertingAction + err := json.Unmarshal(body, &aa) + return aa, err + case string(OdataTypeBasicActionOdataTypeMicrosoftWindowsAzureManagementMonitoringAlertsModelsMicrosoftAppInsightsNexusDataContractsResourcesScheduledQueryRulesLogToMetricAction): + var ltma LogToMetricAction + err := json.Unmarshal(body, <ma) + return ltma, err + default: + var a Action + err := json.Unmarshal(body, &a) + return a, err + } +} +func unmarshalBasicActionArray(body []byte) ([]BasicAction, error) { + var rawMessages []*json.RawMessage + err := json.Unmarshal(body, &rawMessages) + if err != nil { + return nil, err + } + + aArray := make([]BasicAction, len(rawMessages)) + + for index, rawMessage := range rawMessages { + a, err := unmarshalBasicAction(*rawMessage) + if err != nil { + return nil, err + } + aArray[index] = a + } + return aArray, nil +} + +// MarshalJSON is the custom marshaler for Action. +func (a Action) MarshalJSON() ([]byte, error) { + a.OdataType = OdataTypeBasicActionOdataTypeAction + objectMap := make(map[string]interface{}) + if a.OdataType != "" { + objectMap["odata.type"] = a.OdataType + } + return json.Marshal(objectMap) +} + +// AsAlertingAction is the BasicAction implementation for Action. +func (a Action) AsAlertingAction() (*AlertingAction, bool) { + return nil, false +} + +// AsLogToMetricAction is the BasicAction implementation for Action. +func (a Action) AsLogToMetricAction() (*LogToMetricAction, bool) { + return nil, false +} + +// AsAction is the BasicAction implementation for Action. +func (a Action) AsAction() (*Action, bool) { + return &a, true +} + +// AsBasicAction is the BasicAction implementation for Action. +func (a Action) AsBasicAction() (BasicAction, bool) { + return &a, true +} + +// ActionGroup an Azure action group. +type ActionGroup struct { + // GroupShortName - The short name of the action group. This will be used in SMS messages. + GroupShortName *string `json:"groupShortName,omitempty"` + // Enabled - Indicates whether this action group is enabled. If an action group is not enabled, then none of its receivers will receive communications. + Enabled *bool `json:"enabled,omitempty"` + // EmailReceivers - The list of email receivers that are part of this action group. + EmailReceivers *[]EmailReceiver `json:"emailReceivers,omitempty"` + // SmsReceivers - The list of SMS receivers that are part of this action group. + SmsReceivers *[]SmsReceiver `json:"smsReceivers,omitempty"` + // WebhookReceivers - The list of webhook receivers that are part of this action group. + WebhookReceivers *[]WebhookReceiver `json:"webhookReceivers,omitempty"` + // ItsmReceivers - The list of ITSM receivers that are part of this action group. + ItsmReceivers *[]ItsmReceiver `json:"itsmReceivers,omitempty"` + // AzureAppPushReceivers - The list of AzureAppPush receivers that are part of this action group. + AzureAppPushReceivers *[]AzureAppPushReceiver `json:"azureAppPushReceivers,omitempty"` + // AutomationRunbookReceivers - The list of AutomationRunbook receivers that are part of this action group. + AutomationRunbookReceivers *[]AutomationRunbookReceiver `json:"automationRunbookReceivers,omitempty"` + // VoiceReceivers - The list of voice receivers that are part of this action group. + VoiceReceivers *[]VoiceReceiver `json:"voiceReceivers,omitempty"` + // LogicAppReceivers - The list of logic app receivers that are part of this action group. + LogicAppReceivers *[]LogicAppReceiver `json:"logicAppReceivers,omitempty"` + // AzureFunctionReceivers - The list of azure function receivers that are part of this action group. + AzureFunctionReceivers *[]AzureFunctionReceiver `json:"azureFunctionReceivers,omitempty"` + // ArmRoleReceivers - The list of ARM role receivers that are part of this action group. Roles are Azure RBAC roles and only built-in roles are supported. + ArmRoleReceivers *[]ArmRoleReceiver `json:"armRoleReceivers,omitempty"` +} + +// ActionGroupList a list of action groups. +type ActionGroupList struct { + autorest.Response `json:"-"` + // Value - The list of action groups. + Value *[]ActionGroupResource `json:"value,omitempty"` + // NextLink - Provides the link to retrieve the next set of elements. + NextLink *string `json:"nextLink,omitempty"` +} + +// ActionGroupPatch an Azure action group for patch operations. +type ActionGroupPatch struct { + // Enabled - Indicates whether this action group is enabled. If an action group is not enabled, then none of its actions will be activated. + Enabled *bool `json:"enabled,omitempty"` +} + +// ActionGroupPatchBody an action group object for the body of patch operations. +type ActionGroupPatchBody struct { + // Tags - Resource tags + Tags map[string]*string `json:"tags"` + // ActionGroupPatch - The action group settings for an update operation. + *ActionGroupPatch `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for ActionGroupPatchBody. +func (agpb ActionGroupPatchBody) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if agpb.Tags != nil { + objectMap["tags"] = agpb.Tags + } + if agpb.ActionGroupPatch != nil { + objectMap["properties"] = agpb.ActionGroupPatch + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ActionGroupPatchBody struct. +func (agpb *ActionGroupPatchBody) UnmarshalJSON(body []byte) error { + 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 + } + agpb.Tags = tags + } + case "properties": + if v != nil { + var actionGroupPatch ActionGroupPatch + err = json.Unmarshal(*v, &actionGroupPatch) + if err != nil { + return err + } + agpb.ActionGroupPatch = &actionGroupPatch + } + } + } + + return nil +} + +// ActionGroupResource an action group resource. +type ActionGroupResource struct { + autorest.Response `json:"-"` + // ActionGroup - The action groups properties of the resource. + *ActionGroup `json:"properties,omitempty"` + // ID - READ-ONLY; Azure resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Azure resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Azure resource type + Type *string `json:"type,omitempty"` + // Kind - READ-ONLY; Azure resource kind + Kind *string `json:"kind,omitempty"` + // Identity - READ-ONLY; Azure resource identity + Identity *string `json:"identity,omitempty"` + // Location - Resource location + Location *string `json:"location,omitempty"` + // Tags - Resource tags + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for ActionGroupResource. +func (agr ActionGroupResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if agr.ActionGroup != nil { + objectMap["properties"] = agr.ActionGroup + } + if agr.Location != nil { + objectMap["location"] = agr.Location + } + if agr.Tags != nil { + objectMap["tags"] = agr.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ActionGroupResource struct. +func (agr *ActionGroupResource) UnmarshalJSON(body []byte) error { + 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 actionGroup ActionGroup + err = json.Unmarshal(*v, &actionGroup) + if err != nil { + return err + } + agr.ActionGroup = &actionGroup + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + agr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + agr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + agr.Type = &typeVar + } + case "kind": + if v != nil { + var kind string + err = json.Unmarshal(*v, &kind) + if err != nil { + return err + } + agr.Kind = &kind + } + case "identity": + if v != nil { + var identity string + err = json.Unmarshal(*v, &identity) + if err != nil { + return err + } + agr.Identity = &identity + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + agr.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + agr.Tags = tags + } + } + } + + return nil +} + +// ActivityLogAlert an Azure activity log alert. +type ActivityLogAlert struct { + // Scopes - A list of resourceIds that will be used as prefixes. The alert will only apply to activityLogs with resourceIds that fall under one of these prefixes. This list must include at least one item. + Scopes *[]string `json:"scopes,omitempty"` + // Enabled - Indicates whether this activity log alert is enabled. If an activity log alert is not enabled, then none of its actions will be activated. + Enabled *bool `json:"enabled,omitempty"` + // Condition - The condition that will cause this alert to activate. + Condition *ActivityLogAlertAllOfCondition `json:"condition,omitempty"` + // Actions - The actions that will activate when the condition is met. + Actions *ActivityLogAlertActionList `json:"actions,omitempty"` + // Description - A description of this activity log alert. + Description *string `json:"description,omitempty"` +} + +// ActivityLogAlertActionGroup a pointer to an Azure Action Group. +type ActivityLogAlertActionGroup struct { + // ActionGroupID - The resourceId of the action group. This cannot be null or empty. + ActionGroupID *string `json:"actionGroupId,omitempty"` + // WebhookProperties - the dictionary of custom properties to include with the post operation. These data are appended to the webhook payload. + WebhookProperties map[string]*string `json:"webhookProperties"` +} + +// MarshalJSON is the custom marshaler for ActivityLogAlertActionGroup. +func (alaag ActivityLogAlertActionGroup) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if alaag.ActionGroupID != nil { + objectMap["actionGroupId"] = alaag.ActionGroupID + } + if alaag.WebhookProperties != nil { + objectMap["webhookProperties"] = alaag.WebhookProperties + } + return json.Marshal(objectMap) +} + +// ActivityLogAlertActionList a list of activity log alert actions. +type ActivityLogAlertActionList struct { + // ActionGroups - The list of activity log alerts. + ActionGroups *[]ActivityLogAlertActionGroup `json:"actionGroups,omitempty"` +} + +// ActivityLogAlertAllOfCondition an Activity Log alert condition that is met when all its member +// conditions are met. +type ActivityLogAlertAllOfCondition struct { + // AllOf - The list of activity log alert conditions. + AllOf *[]ActivityLogAlertLeafCondition `json:"allOf,omitempty"` +} + +// ActivityLogAlertLeafCondition an Activity Log alert condition that is met by comparing an activity log +// field and value. +type ActivityLogAlertLeafCondition struct { + // Field - The name of the field that this condition will examine. The possible values for this field are (case-insensitive): 'resourceId', 'category', 'caller', 'level', 'operationName', 'resourceGroup', 'resourceProvider', 'status', 'subStatus', 'resourceType', or anything beginning with 'properties.'. + Field *string `json:"field,omitempty"` + // Equals - The field value will be compared to this value (case-insensitive) to determine if the condition is met. + Equals *string `json:"equals,omitempty"` +} + +// ActivityLogAlertList a list of activity log alerts. +type ActivityLogAlertList struct { + autorest.Response `json:"-"` + // Value - The list of activity log alerts. + Value *[]ActivityLogAlertResource `json:"value,omitempty"` + // NextLink - Provides the link to retrieve the next set of elements. + NextLink *string `json:"nextLink,omitempty"` +} + +// ActivityLogAlertPatch an Azure activity log alert for patch operations. +type ActivityLogAlertPatch struct { + // Enabled - Indicates whether this activity log alert is enabled. If an activity log alert is not enabled, then none of its actions will be activated. + Enabled *bool `json:"enabled,omitempty"` +} + +// ActivityLogAlertPatchBody an activity log alert object for the body of patch operations. +type ActivityLogAlertPatchBody struct { + // Tags - Resource tags + Tags map[string]*string `json:"tags"` + // ActivityLogAlertPatch - The activity log alert settings for an update operation. + *ActivityLogAlertPatch `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for ActivityLogAlertPatchBody. +func (alapb ActivityLogAlertPatchBody) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if alapb.Tags != nil { + objectMap["tags"] = alapb.Tags + } + if alapb.ActivityLogAlertPatch != nil { + objectMap["properties"] = alapb.ActivityLogAlertPatch + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ActivityLogAlertPatchBody struct. +func (alapb *ActivityLogAlertPatchBody) UnmarshalJSON(body []byte) error { + 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 + } + alapb.Tags = tags + } + case "properties": + if v != nil { + var activityLogAlertPatch ActivityLogAlertPatch + err = json.Unmarshal(*v, &activityLogAlertPatch) + if err != nil { + return err + } + alapb.ActivityLogAlertPatch = &activityLogAlertPatch + } + } + } + + return nil +} + +// ActivityLogAlertResource an activity log alert resource. +type ActivityLogAlertResource struct { + autorest.Response `json:"-"` + // ActivityLogAlert - The activity log alert properties of the resource. + *ActivityLogAlert `json:"properties,omitempty"` + // ID - READ-ONLY; Azure resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Azure resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Azure resource type + Type *string `json:"type,omitempty"` + // Location - Resource location + Location *string `json:"location,omitempty"` + // Tags - Resource tags + Tags map[string]*string `json:"tags"` + // Kind - READ-ONLY; Metadata used by portal/tooling/etc to render different UX experiences for resources of the same type; e.g. ApiApps are a kind of Microsoft.Web/sites type. If supported, the resource provider must validate and persist this value. + Kind *string `json:"kind,omitempty"` + // Etag - READ-ONLY; The etag field is *not* required. If it is provided in the response body, it must also be provided as a header per the normal etag convention. Entity tags are used for comparing two or more entities from the same requested resource. HTTP/1.1 uses entity tags in the etag (section 14.19), If-Match (section 14.24), If-None-Match (section 14.26), and If-Range (section 14.27) header fields. + Etag *string `json:"etag,omitempty"` +} + +// MarshalJSON is the custom marshaler for ActivityLogAlertResource. +func (alar ActivityLogAlertResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if alar.ActivityLogAlert != nil { + objectMap["properties"] = alar.ActivityLogAlert + } + if alar.Location != nil { + objectMap["location"] = alar.Location + } + if alar.Tags != nil { + objectMap["tags"] = alar.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ActivityLogAlertResource struct. +func (alar *ActivityLogAlertResource) UnmarshalJSON(body []byte) error { + 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 activityLogAlert ActivityLogAlert + err = json.Unmarshal(*v, &activityLogAlert) + if err != nil { + return err + } + alar.ActivityLogAlert = &activityLogAlert + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + alar.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + alar.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + alar.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + alar.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + alar.Tags = tags + } + case "kind": + if v != nil { + var kind string + err = json.Unmarshal(*v, &kind) + if err != nil { + return err + } + alar.Kind = &kind + } + case "etag": + if v != nil { + var etag string + err = json.Unmarshal(*v, &etag) + if err != nil { + return err + } + alar.Etag = &etag + } + } + } + + return nil +} + +// AlertingAction specify action need to be taken when rule type is Alert +type AlertingAction struct { + // Severity - Severity of the alert. Possible values include: 'AlertSeverityZero', 'AlertSeverityOne', 'AlertSeverityTwo', 'AlertSeverityThree', 'AlertSeverityFour' + Severity AlertSeverity `json:"severity,omitempty"` + // AznsAction - Azure action group reference. + AznsAction *AzNsActionGroup `json:"aznsAction,omitempty"` + // ThrottlingInMin - time (in minutes) for which Alerts should be throttled or suppressed. + ThrottlingInMin *int32 `json:"throttlingInMin,omitempty"` + // Trigger - The trigger condition that results in the alert rule being. + Trigger *TriggerCondition `json:"trigger,omitempty"` + // OdataType - Possible values include: 'OdataTypeBasicActionOdataTypeAction', 'OdataTypeBasicActionOdataTypeMicrosoftWindowsAzureManagementMonitoringAlertsModelsMicrosoftAppInsightsNexusDataContractsResourcesScheduledQueryRulesAlertingAction', 'OdataTypeBasicActionOdataTypeMicrosoftWindowsAzureManagementMonitoringAlertsModelsMicrosoftAppInsightsNexusDataContractsResourcesScheduledQueryRulesLogToMetricAction' + OdataType OdataTypeBasicAction `json:"odata.type,omitempty"` +} + +// MarshalJSON is the custom marshaler for AlertingAction. +func (aa AlertingAction) MarshalJSON() ([]byte, error) { + aa.OdataType = OdataTypeBasicActionOdataTypeMicrosoftWindowsAzureManagementMonitoringAlertsModelsMicrosoftAppInsightsNexusDataContractsResourcesScheduledQueryRulesAlertingAction + objectMap := make(map[string]interface{}) + if aa.Severity != "" { + objectMap["severity"] = aa.Severity + } + if aa.AznsAction != nil { + objectMap["aznsAction"] = aa.AznsAction + } + if aa.ThrottlingInMin != nil { + objectMap["throttlingInMin"] = aa.ThrottlingInMin + } + if aa.Trigger != nil { + objectMap["trigger"] = aa.Trigger + } + if aa.OdataType != "" { + objectMap["odata.type"] = aa.OdataType + } + return json.Marshal(objectMap) +} + +// AsAlertingAction is the BasicAction implementation for AlertingAction. +func (aa AlertingAction) AsAlertingAction() (*AlertingAction, bool) { + return &aa, true +} + +// AsLogToMetricAction is the BasicAction implementation for AlertingAction. +func (aa AlertingAction) AsLogToMetricAction() (*LogToMetricAction, bool) { + return nil, false +} + +// AsAction is the BasicAction implementation for AlertingAction. +func (aa AlertingAction) AsAction() (*Action, bool) { + return nil, false +} + +// AsBasicAction is the BasicAction implementation for AlertingAction. +func (aa AlertingAction) AsBasicAction() (BasicAction, bool) { + return &aa, true +} + +// AlertRule an alert rule. +type AlertRule struct { + // Name - the name of the alert rule. + Name *string `json:"name,omitempty"` + // Description - the description of the alert rule that will be included in the alert email. + Description *string `json:"description,omitempty"` + // ProvisioningState - the provisioning state. + ProvisioningState *string `json:"provisioningState,omitempty"` + // IsEnabled - the flag that indicates whether the alert rule is enabled. + IsEnabled *bool `json:"isEnabled,omitempty"` + // Condition - the condition that results in the alert rule being activated. + Condition BasicRuleCondition `json:"condition,omitempty"` + // Action - action that is performed when the alert rule becomes active, and when an alert condition is resolved. + Action BasicRuleAction `json:"action,omitempty"` + // Actions - the array of actions that are performed when the alert rule becomes active, and when an alert condition is resolved. + Actions *[]BasicRuleAction `json:"actions,omitempty"` + // LastUpdatedTime - READ-ONLY; Last time the rule was updated in ISO8601 format. + LastUpdatedTime *date.Time `json:"lastUpdatedTime,omitempty"` +} + +// MarshalJSON is the custom marshaler for AlertRule. +func (ar AlertRule) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ar.Name != nil { + objectMap["name"] = ar.Name + } + if ar.Description != nil { + objectMap["description"] = ar.Description + } + if ar.ProvisioningState != nil { + objectMap["provisioningState"] = ar.ProvisioningState + } + if ar.IsEnabled != nil { + objectMap["isEnabled"] = ar.IsEnabled + } + objectMap["condition"] = ar.Condition + objectMap["action"] = ar.Action + if ar.Actions != nil { + objectMap["actions"] = ar.Actions + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for AlertRule struct. +func (ar *AlertRule) UnmarshalJSON(body []byte) error { + 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 + } + ar.Name = &name + } + case "description": + if v != nil { + var description string + err = json.Unmarshal(*v, &description) + if err != nil { + return err + } + ar.Description = &description + } + case "provisioningState": + if v != nil { + var provisioningState string + err = json.Unmarshal(*v, &provisioningState) + if err != nil { + return err + } + ar.ProvisioningState = &provisioningState + } + case "isEnabled": + if v != nil { + var isEnabled bool + err = json.Unmarshal(*v, &isEnabled) + if err != nil { + return err + } + ar.IsEnabled = &isEnabled + } + case "condition": + if v != nil { + condition, err := unmarshalBasicRuleCondition(*v) + if err != nil { + return err + } + ar.Condition = condition + } + case "action": + if v != nil { + action, err := unmarshalBasicRuleAction(*v) + if err != nil { + return err + } + ar.Action = action + } + case "actions": + if v != nil { + actions, err := unmarshalBasicRuleActionArray(*v) + if err != nil { + return err + } + ar.Actions = &actions + } + case "lastUpdatedTime": + if v != nil { + var lastUpdatedTime date.Time + err = json.Unmarshal(*v, &lastUpdatedTime) + if err != nil { + return err + } + ar.LastUpdatedTime = &lastUpdatedTime + } + } + } + + return nil +} + +// AlertRuleResource the alert rule resource. +type AlertRuleResource struct { + autorest.Response `json:"-"` + // AlertRule - The alert rule properties of the resource. + *AlertRule `json:"properties,omitempty"` + // ID - READ-ONLY; Azure resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Azure resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Azure resource type + Type *string `json:"type,omitempty"` + // Location - Resource location + Location *string `json:"location,omitempty"` + // Tags - Resource tags + Tags map[string]*string `json:"tags"` + // Kind - READ-ONLY; Metadata used by portal/tooling/etc to render different UX experiences for resources of the same type; e.g. ApiApps are a kind of Microsoft.Web/sites type. If supported, the resource provider must validate and persist this value. + Kind *string `json:"kind,omitempty"` + // Etag - READ-ONLY; The etag field is *not* required. If it is provided in the response body, it must also be provided as a header per the normal etag convention. Entity tags are used for comparing two or more entities from the same requested resource. HTTP/1.1 uses entity tags in the etag (section 14.19), If-Match (section 14.24), If-None-Match (section 14.26), and If-Range (section 14.27) header fields. + Etag *string `json:"etag,omitempty"` +} + +// MarshalJSON is the custom marshaler for AlertRuleResource. +func (arr AlertRuleResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if arr.AlertRule != nil { + objectMap["properties"] = arr.AlertRule + } + if arr.Location != nil { + objectMap["location"] = arr.Location + } + if arr.Tags != nil { + objectMap["tags"] = arr.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for AlertRuleResource struct. +func (arr *AlertRuleResource) UnmarshalJSON(body []byte) error { + 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 alertRule AlertRule + err = json.Unmarshal(*v, &alertRule) + if err != nil { + return err + } + arr.AlertRule = &alertRule + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + arr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + arr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + arr.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + arr.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + arr.Tags = tags + } + case "kind": + if v != nil { + var kind string + err = json.Unmarshal(*v, &kind) + if err != nil { + return err + } + arr.Kind = &kind + } + case "etag": + if v != nil { + var etag string + err = json.Unmarshal(*v, &etag) + if err != nil { + return err + } + arr.Etag = &etag + } + } + } + + return nil +} + +// AlertRuleResourceCollection represents a collection of alert rule resources. +type AlertRuleResourceCollection struct { + autorest.Response `json:"-"` + // Value - the values for the alert rule resources. + Value *[]AlertRuleResource `json:"value,omitempty"` +} + +// AlertRuleResourcePatch the alert rule object for patch operations. +type AlertRuleResourcePatch struct { + // Tags - Resource tags + Tags map[string]*string `json:"tags"` + // AlertRule - The properties of an alert rule. + *AlertRule `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for AlertRuleResourcePatch. +func (arrp AlertRuleResourcePatch) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if arrp.Tags != nil { + objectMap["tags"] = arrp.Tags + } + if arrp.AlertRule != nil { + objectMap["properties"] = arrp.AlertRule + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for AlertRuleResourcePatch struct. +func (arrp *AlertRuleResourcePatch) UnmarshalJSON(body []byte) error { + 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 + } + arrp.Tags = tags + } + case "properties": + if v != nil { + var alertRule AlertRule + err = json.Unmarshal(*v, &alertRule) + if err != nil { + return err + } + arrp.AlertRule = &alertRule + } + } + } + + return nil +} + +// ArmRoleReceiver an arm role receiver. +type ArmRoleReceiver struct { + // Name - The name of the arm role receiver. Names must be unique across all receivers within an action group. + Name *string `json:"name,omitempty"` + // RoleID - The arm role id. + RoleID *string `json:"roleId,omitempty"` + // UseCommonAlertSchema - Indicates whether to use common alert schema. + UseCommonAlertSchema *bool `json:"useCommonAlertSchema,omitempty"` +} + +// AutomationRunbookReceiver the Azure Automation Runbook notification receiver. +type AutomationRunbookReceiver struct { + // AutomationAccountID - The Azure automation account Id which holds this runbook and authenticate to Azure resource. + AutomationAccountID *string `json:"automationAccountId,omitempty"` + // RunbookName - The name for this runbook. + RunbookName *string `json:"runbookName,omitempty"` + // WebhookResourceID - The resource id for webhook linked to this runbook. + WebhookResourceID *string `json:"webhookResourceId,omitempty"` + // IsGlobalRunbook - Indicates whether this instance is global runbook. + IsGlobalRunbook *bool `json:"isGlobalRunbook,omitempty"` + // Name - Indicates name of the webhook. + Name *string `json:"name,omitempty"` + // ServiceURI - The URI where webhooks should be sent. + ServiceURI *string `json:"serviceUri,omitempty"` + // UseCommonAlertSchema - Indicates whether to use common alert schema. + UseCommonAlertSchema *bool `json:"useCommonAlertSchema,omitempty"` +} + +// AutoscaleNotification autoscale notification. +type AutoscaleNotification struct { + // Operation - the operation associated with the notification and its value must be "scale" + Operation *string `json:"operation,omitempty"` + // Email - the email notification. + Email *EmailNotification `json:"email,omitempty"` + // Webhooks - the collection of webhook notifications. + Webhooks *[]WebhookNotification `json:"webhooks,omitempty"` +} + +// AutoscaleProfile autoscale profile. +type AutoscaleProfile struct { + // Name - the name of the profile. + Name *string `json:"name,omitempty"` + // Capacity - the number of instances that can be used during this profile. + Capacity *ScaleCapacity `json:"capacity,omitempty"` + // Rules - the collection of rules that provide the triggers and parameters for the scaling action. A maximum of 10 rules can be specified. + Rules *[]ScaleRule `json:"rules,omitempty"` + // FixedDate - the specific date-time for the profile. This element is not used if the Recurrence element is used. + FixedDate *TimeWindow `json:"fixedDate,omitempty"` + // Recurrence - the repeating times at which this profile begins. This element is not used if the FixedDate element is used. + Recurrence *Recurrence `json:"recurrence,omitempty"` +} + +// AutoscaleSetting a setting that contains all of the configuration for the automatic scaling of a +// resource. +type AutoscaleSetting struct { + // Profiles - the collection of automatic scaling profiles that specify different scaling parameters for different time periods. A maximum of 20 profiles can be specified. + Profiles *[]AutoscaleProfile `json:"profiles,omitempty"` + // Notifications - the collection of notifications. + Notifications *[]AutoscaleNotification `json:"notifications,omitempty"` + // Enabled - the enabled flag. Specifies whether automatic scaling is enabled for the resource. The default value is 'true'. + Enabled *bool `json:"enabled,omitempty"` + // Name - the name of the autoscale setting. + Name *string `json:"name,omitempty"` + // TargetResourceURI - the resource identifier of the resource that the autoscale setting should be added to. + TargetResourceURI *string `json:"targetResourceUri,omitempty"` +} + +// AutoscaleSettingResource the autoscale setting resource. +type AutoscaleSettingResource struct { + autorest.Response `json:"-"` + // AutoscaleSetting - The autoscale setting of the resource. + *AutoscaleSetting `json:"properties,omitempty"` + // ID - READ-ONLY; Azure resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Azure resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Azure resource type + Type *string `json:"type,omitempty"` + // Location - Resource location + Location *string `json:"location,omitempty"` + // Tags - Resource tags + Tags map[string]*string `json:"tags"` + // Kind - READ-ONLY; Metadata used by portal/tooling/etc to render different UX experiences for resources of the same type; e.g. ApiApps are a kind of Microsoft.Web/sites type. If supported, the resource provider must validate and persist this value. + Kind *string `json:"kind,omitempty"` + // Etag - READ-ONLY; The etag field is *not* required. If it is provided in the response body, it must also be provided as a header per the normal etag convention. Entity tags are used for comparing two or more entities from the same requested resource. HTTP/1.1 uses entity tags in the etag (section 14.19), If-Match (section 14.24), If-None-Match (section 14.26), and If-Range (section 14.27) header fields. + Etag *string `json:"etag,omitempty"` +} + +// MarshalJSON is the custom marshaler for AutoscaleSettingResource. +func (asr AutoscaleSettingResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if asr.AutoscaleSetting != nil { + objectMap["properties"] = asr.AutoscaleSetting + } + if asr.Location != nil { + objectMap["location"] = asr.Location + } + if asr.Tags != nil { + objectMap["tags"] = asr.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for AutoscaleSettingResource struct. +func (asr *AutoscaleSettingResource) UnmarshalJSON(body []byte) error { + 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 autoscaleSetting AutoscaleSetting + err = json.Unmarshal(*v, &autoscaleSetting) + if err != nil { + return err + } + asr.AutoscaleSetting = &autoscaleSetting + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + asr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + asr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + asr.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + asr.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + asr.Tags = tags + } + case "kind": + if v != nil { + var kind string + err = json.Unmarshal(*v, &kind) + if err != nil { + return err + } + asr.Kind = &kind + } + case "etag": + if v != nil { + var etag string + err = json.Unmarshal(*v, &etag) + if err != nil { + return err + } + asr.Etag = &etag + } + } + } + + return nil +} + +// AutoscaleSettingResourceCollection represents a collection of autoscale setting resources. +type AutoscaleSettingResourceCollection struct { + autorest.Response `json:"-"` + // Value - the values for the autoscale setting resources. + Value *[]AutoscaleSettingResource `json:"value,omitempty"` + // NextLink - URL to get the next set of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// AutoscaleSettingResourceCollectionIterator provides access to a complete listing of +// AutoscaleSettingResource values. +type AutoscaleSettingResourceCollectionIterator struct { + i int + page AutoscaleSettingResourceCollectionPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *AutoscaleSettingResourceCollectionIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AutoscaleSettingResourceCollectionIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *AutoscaleSettingResourceCollectionIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter AutoscaleSettingResourceCollectionIterator) 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 AutoscaleSettingResourceCollectionIterator) Response() AutoscaleSettingResourceCollection { + 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 AutoscaleSettingResourceCollectionIterator) Value() AutoscaleSettingResource { + if !iter.page.NotDone() { + return AutoscaleSettingResource{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the AutoscaleSettingResourceCollectionIterator type. +func NewAutoscaleSettingResourceCollectionIterator(page AutoscaleSettingResourceCollectionPage) AutoscaleSettingResourceCollectionIterator { + return AutoscaleSettingResourceCollectionIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (asrc AutoscaleSettingResourceCollection) IsEmpty() bool { + return asrc.Value == nil || len(*asrc.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (asrc AutoscaleSettingResourceCollection) hasNextLink() bool { + return asrc.NextLink != nil && len(*asrc.NextLink) != 0 +} + +// autoscaleSettingResourceCollectionPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (asrc AutoscaleSettingResourceCollection) autoscaleSettingResourceCollectionPreparer(ctx context.Context) (*http.Request, error) { + if !asrc.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(asrc.NextLink))) +} + +// AutoscaleSettingResourceCollectionPage contains a page of AutoscaleSettingResource values. +type AutoscaleSettingResourceCollectionPage struct { + fn func(context.Context, AutoscaleSettingResourceCollection) (AutoscaleSettingResourceCollection, error) + asrc AutoscaleSettingResourceCollection +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *AutoscaleSettingResourceCollectionPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AutoscaleSettingResourceCollectionPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.asrc) + if err != nil { + return err + } + page.asrc = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *AutoscaleSettingResourceCollectionPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page AutoscaleSettingResourceCollectionPage) NotDone() bool { + return !page.asrc.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page AutoscaleSettingResourceCollectionPage) Response() AutoscaleSettingResourceCollection { + return page.asrc +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page AutoscaleSettingResourceCollectionPage) Values() []AutoscaleSettingResource { + if page.asrc.IsEmpty() { + return nil + } + return *page.asrc.Value +} + +// Creates a new instance of the AutoscaleSettingResourceCollectionPage type. +func NewAutoscaleSettingResourceCollectionPage(cur AutoscaleSettingResourceCollection, getNextPage func(context.Context, AutoscaleSettingResourceCollection) (AutoscaleSettingResourceCollection, error)) AutoscaleSettingResourceCollectionPage { + return AutoscaleSettingResourceCollectionPage{ + fn: getNextPage, + asrc: cur, + } +} + +// AutoscaleSettingResourcePatch the autoscale setting object for patch operations. +type AutoscaleSettingResourcePatch struct { + // Tags - Resource tags + Tags map[string]*string `json:"tags"` + // AutoscaleSetting - The autoscale setting properties of the update operation. + *AutoscaleSetting `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for AutoscaleSettingResourcePatch. +func (asrp AutoscaleSettingResourcePatch) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if asrp.Tags != nil { + objectMap["tags"] = asrp.Tags + } + if asrp.AutoscaleSetting != nil { + objectMap["properties"] = asrp.AutoscaleSetting + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for AutoscaleSettingResourcePatch struct. +func (asrp *AutoscaleSettingResourcePatch) UnmarshalJSON(body []byte) error { + 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 + } + asrp.Tags = tags + } + case "properties": + if v != nil { + var autoscaleSetting AutoscaleSetting + err = json.Unmarshal(*v, &autoscaleSetting) + if err != nil { + return err + } + asrp.AutoscaleSetting = &autoscaleSetting + } + } + } + + return nil +} + +// AzNsActionGroup azure action group +type AzNsActionGroup struct { + // ActionGroup - Azure Action Group reference. + ActionGroup *[]string `json:"actionGroup,omitempty"` + // EmailSubject - Custom subject override for all email ids in Azure action group + EmailSubject *string `json:"emailSubject,omitempty"` + // CustomWebhookPayload - Custom payload to be sent for all webhook URI in Azure action group + CustomWebhookPayload *string `json:"customWebhookPayload,omitempty"` +} + +// AzureAppPushReceiver the Azure mobile App push notification receiver. +type AzureAppPushReceiver struct { + // Name - The name of the Azure mobile app push receiver. Names must be unique across all receivers within an action group. + Name *string `json:"name,omitempty"` + // EmailAddress - The email address registered for the Azure mobile app. + EmailAddress *string `json:"emailAddress,omitempty"` +} + +// AzureFunctionReceiver an azure function receiver. +type AzureFunctionReceiver struct { + // Name - The name of the azure function receiver. Names must be unique across all receivers within an action group. + Name *string `json:"name,omitempty"` + // FunctionAppResourceID - The azure resource id of the function app. + FunctionAppResourceID *string `json:"functionAppResourceId,omitempty"` + // FunctionName - The function name in the function app. + FunctionName *string `json:"functionName,omitempty"` + // HTTPTriggerURL - The http trigger url where http request sent to. + HTTPTriggerURL *string `json:"httpTriggerUrl,omitempty"` + // UseCommonAlertSchema - Indicates whether to use common alert schema. + UseCommonAlertSchema *bool `json:"useCommonAlertSchema,omitempty"` +} + +// AzureMonitorMetricsDestination azure Monitor Metrics destination. +type AzureMonitorMetricsDestination struct { + // Name - A friendly name for the destination. + // This name should be unique across all destinations (regardless of type) within the data collection rule. + Name *string `json:"name,omitempty"` +} + +// AzureMonitorPrivateLinkScope an Azure Monitor PrivateLinkScope definition. +type AzureMonitorPrivateLinkScope struct { + autorest.Response `json:"-"` + // AzureMonitorPrivateLinkScopeProperties - Properties that define a Azure Monitor PrivateLinkScope resource. + *AzureMonitorPrivateLinkScopeProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Azure resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Azure resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Azure resource type + Type *string `json:"type,omitempty"` + // Location - Resource location + Location *string `json:"location,omitempty"` + // Tags - Resource tags + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for AzureMonitorPrivateLinkScope. +func (ampls AzureMonitorPrivateLinkScope) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ampls.AzureMonitorPrivateLinkScopeProperties != nil { + objectMap["properties"] = ampls.AzureMonitorPrivateLinkScopeProperties + } + if ampls.Location != nil { + objectMap["location"] = ampls.Location + } + if ampls.Tags != nil { + objectMap["tags"] = ampls.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for AzureMonitorPrivateLinkScope struct. +func (ampls *AzureMonitorPrivateLinkScope) UnmarshalJSON(body []byte) error { + 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 azureMonitorPrivateLinkScopeProperties AzureMonitorPrivateLinkScopeProperties + err = json.Unmarshal(*v, &azureMonitorPrivateLinkScopeProperties) + if err != nil { + return err + } + ampls.AzureMonitorPrivateLinkScopeProperties = &azureMonitorPrivateLinkScopeProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + ampls.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ampls.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ampls.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + ampls.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + ampls.Tags = tags + } + } + } + + return nil +} + +// AzureMonitorPrivateLinkScopeListResult describes the list of Azure Monitor PrivateLinkScope resources. +type AzureMonitorPrivateLinkScopeListResult struct { + autorest.Response `json:"-"` + // Value - List of Azure Monitor PrivateLinkScope definitions. + Value *[]AzureMonitorPrivateLinkScope `json:"value,omitempty"` + // NextLink - The URI to get the next set of Azure Monitor PrivateLinkScope definitions if too many PrivateLinkScopes where returned in the result set. + NextLink *string `json:"nextLink,omitempty"` +} + +// AzureMonitorPrivateLinkScopeListResultIterator provides access to a complete listing of +// AzureMonitorPrivateLinkScope values. +type AzureMonitorPrivateLinkScopeListResultIterator struct { + i int + page AzureMonitorPrivateLinkScopeListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *AzureMonitorPrivateLinkScopeListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AzureMonitorPrivateLinkScopeListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *AzureMonitorPrivateLinkScopeListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter AzureMonitorPrivateLinkScopeListResultIterator) 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 AzureMonitorPrivateLinkScopeListResultIterator) Response() AzureMonitorPrivateLinkScopeListResult { + 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 AzureMonitorPrivateLinkScopeListResultIterator) Value() AzureMonitorPrivateLinkScope { + if !iter.page.NotDone() { + return AzureMonitorPrivateLinkScope{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the AzureMonitorPrivateLinkScopeListResultIterator type. +func NewAzureMonitorPrivateLinkScopeListResultIterator(page AzureMonitorPrivateLinkScopeListResultPage) AzureMonitorPrivateLinkScopeListResultIterator { + return AzureMonitorPrivateLinkScopeListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (amplslr AzureMonitorPrivateLinkScopeListResult) IsEmpty() bool { + return amplslr.Value == nil || len(*amplslr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (amplslr AzureMonitorPrivateLinkScopeListResult) hasNextLink() bool { + return amplslr.NextLink != nil && len(*amplslr.NextLink) != 0 +} + +// azureMonitorPrivateLinkScopeListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (amplslr AzureMonitorPrivateLinkScopeListResult) azureMonitorPrivateLinkScopeListResultPreparer(ctx context.Context) (*http.Request, error) { + if !amplslr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(amplslr.NextLink))) +} + +// AzureMonitorPrivateLinkScopeListResultPage contains a page of AzureMonitorPrivateLinkScope values. +type AzureMonitorPrivateLinkScopeListResultPage struct { + fn func(context.Context, AzureMonitorPrivateLinkScopeListResult) (AzureMonitorPrivateLinkScopeListResult, error) + amplslr AzureMonitorPrivateLinkScopeListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *AzureMonitorPrivateLinkScopeListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AzureMonitorPrivateLinkScopeListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.amplslr) + if err != nil { + return err + } + page.amplslr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *AzureMonitorPrivateLinkScopeListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page AzureMonitorPrivateLinkScopeListResultPage) NotDone() bool { + return !page.amplslr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page AzureMonitorPrivateLinkScopeListResultPage) Response() AzureMonitorPrivateLinkScopeListResult { + return page.amplslr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page AzureMonitorPrivateLinkScopeListResultPage) Values() []AzureMonitorPrivateLinkScope { + if page.amplslr.IsEmpty() { + return nil + } + return *page.amplslr.Value +} + +// Creates a new instance of the AzureMonitorPrivateLinkScopeListResultPage type. +func NewAzureMonitorPrivateLinkScopeListResultPage(cur AzureMonitorPrivateLinkScopeListResult, getNextPage func(context.Context, AzureMonitorPrivateLinkScopeListResult) (AzureMonitorPrivateLinkScopeListResult, error)) AzureMonitorPrivateLinkScopeListResultPage { + return AzureMonitorPrivateLinkScopeListResultPage{ + fn: getNextPage, + amplslr: cur, + } +} + +// AzureMonitorPrivateLinkScopeProperties properties that define a Azure Monitor PrivateLinkScope resource. +type AzureMonitorPrivateLinkScopeProperties struct { + // ProvisioningState - READ-ONLY; Current state of this PrivateLinkScope: whether or not is has been provisioned within the resource group it is defined. Users cannot change this value but are able to read from it. Values will include Provisioning ,Succeeded, Canceled and Failed. + ProvisioningState *string `json:"provisioningState,omitempty"` + // PrivateEndpointConnections - READ-ONLY; List of private endpoint connections. + PrivateEndpointConnections *[]PrivateEndpointConnection `json:"privateEndpointConnections,omitempty"` +} + +// MarshalJSON is the custom marshaler for AzureMonitorPrivateLinkScopeProperties. +func (amplsp AzureMonitorPrivateLinkScopeProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// AzureResource an azure resource object +type AzureResource struct { + // ID - READ-ONLY; Azure resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Azure resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Azure resource type + Type *string `json:"type,omitempty"` + // Kind - READ-ONLY; Azure resource kind + Kind *string `json:"kind,omitempty"` + // Identity - READ-ONLY; Azure resource identity + Identity *string `json:"identity,omitempty"` + // Location - Resource location + Location *string `json:"location,omitempty"` + // Tags - Resource tags + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for AzureResource. +func (ar AzureResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ar.Location != nil { + objectMap["location"] = ar.Location + } + if ar.Tags != nil { + objectMap["tags"] = ar.Tags + } + return json.Marshal(objectMap) +} + +// BaselineMetadata represents a baseline metadata value. +type BaselineMetadata struct { + // Name - Name of the baseline metadata. + Name *string `json:"name,omitempty"` + // Value - Value of the baseline metadata. + Value *string `json:"value,omitempty"` +} + +// ConfigurationAccessEndpointSpec definition of the endpoint used for accessing configuration. +type ConfigurationAccessEndpointSpec struct { + // Endpoint - READ-ONLY; The endpoint. This property is READ-ONLY. + Endpoint *string `json:"endpoint,omitempty"` +} + +// MarshalJSON is the custom marshaler for ConfigurationAccessEndpointSpec. +func (caes ConfigurationAccessEndpointSpec) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// Criteria specifies the criteria for converting log to metric. +type Criteria struct { + // MetricName - Name of the metric + MetricName *string `json:"metricName,omitempty"` + // Dimensions - List of Dimensions for creating metric + Dimensions *[]Dimension `json:"dimensions,omitempty"` +} + +// DataCollectionEndpoint definition of data collection endpoint. +type DataCollectionEndpoint struct { + // Description - Description of the data collection endpoint. + Description *string `json:"description,omitempty"` + // ImmutableID - The immutable ID of this data collection endpoint resource. This property is READ-ONLY. + ImmutableID *string `json:"immutableId,omitempty"` + // ConfigurationAccess - The endpoint used by agents to access their configuration. + ConfigurationAccess *DataCollectionEndpointConfigurationAccess `json:"configurationAccess,omitempty"` + // LogsIngestion - The endpoint used by clients to ingest logs. + LogsIngestion *DataCollectionEndpointLogsIngestion `json:"logsIngestion,omitempty"` + // NetworkAcls - Network access control rules for the endpoints. + NetworkAcls *DataCollectionEndpointNetworkAcls `json:"networkAcls,omitempty"` + // ProvisioningState - READ-ONLY; The resource provisioning state. This property is READ-ONLY. Possible values include: 'KnownDataCollectionEndpointProvisioningStateCreating', 'KnownDataCollectionEndpointProvisioningStateUpdating', 'KnownDataCollectionEndpointProvisioningStateDeleting', 'KnownDataCollectionEndpointProvisioningStateSucceeded', 'KnownDataCollectionEndpointProvisioningStateFailed' + ProvisioningState KnownDataCollectionEndpointProvisioningState `json:"provisioningState,omitempty"` +} + +// MarshalJSON is the custom marshaler for DataCollectionEndpoint. +func (dce DataCollectionEndpoint) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dce.Description != nil { + objectMap["description"] = dce.Description + } + if dce.ImmutableID != nil { + objectMap["immutableId"] = dce.ImmutableID + } + if dce.ConfigurationAccess != nil { + objectMap["configurationAccess"] = dce.ConfigurationAccess + } + if dce.LogsIngestion != nil { + objectMap["logsIngestion"] = dce.LogsIngestion + } + if dce.NetworkAcls != nil { + objectMap["networkAcls"] = dce.NetworkAcls + } + return json.Marshal(objectMap) +} + +// DataCollectionEndpointConfigurationAccess the endpoint used by agents to access their configuration. +type DataCollectionEndpointConfigurationAccess struct { + // Endpoint - READ-ONLY; The endpoint. This property is READ-ONLY. + Endpoint *string `json:"endpoint,omitempty"` +} + +// MarshalJSON is the custom marshaler for DataCollectionEndpointConfigurationAccess. +func (dceA DataCollectionEndpointConfigurationAccess) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// DataCollectionEndpointLogsIngestion the endpoint used by clients to ingest logs. +type DataCollectionEndpointLogsIngestion struct { + // Endpoint - READ-ONLY; The endpoint. This property is READ-ONLY. + Endpoint *string `json:"endpoint,omitempty"` +} + +// MarshalJSON is the custom marshaler for DataCollectionEndpointLogsIngestion. +func (dceI DataCollectionEndpointLogsIngestion) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// DataCollectionEndpointNetworkAcls network access control rules for the endpoints. +type DataCollectionEndpointNetworkAcls struct { + // PublicNetworkAccess - The configuration to set whether network access from public internet to the endpoints are allowed. Possible values include: 'KnownPublicNetworkAccessOptionsEnabled', 'KnownPublicNetworkAccessOptionsDisabled' + PublicNetworkAccess KnownPublicNetworkAccessOptions `json:"publicNetworkAccess,omitempty"` +} + +// DataCollectionEndpointResource definition of ARM tracked top level resource. +type DataCollectionEndpointResource struct { + autorest.Response `json:"-"` + // DataCollectionEndpointResourceProperties - Resource properties. + *DataCollectionEndpointResourceProperties `json:"properties,omitempty"` + // Location - The geo-location where the resource lives. + Location *string `json:"location,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // Kind - The kind of the resource. Possible values include: 'KnownDataCollectionEndpointResourceKindLinux', 'KnownDataCollectionEndpointResourceKindWindows' + Kind KnownDataCollectionEndpointResourceKind `json:"kind,omitempty"` + // ID - READ-ONLY; Fully qualified ID of the resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. + Type *string `json:"type,omitempty"` + // Etag - READ-ONLY; Resource entity tag (ETag). + Etag *string `json:"etag,omitempty"` + // SystemData - READ-ONLY; Metadata pertaining to creation and last modification of the resource. + SystemData *DataCollectionEndpointResourceSystemData `json:"systemData,omitempty"` +} + +// MarshalJSON is the custom marshaler for DataCollectionEndpointResource. +func (dcer DataCollectionEndpointResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dcer.DataCollectionEndpointResourceProperties != nil { + objectMap["properties"] = dcer.DataCollectionEndpointResourceProperties + } + if dcer.Location != nil { + objectMap["location"] = dcer.Location + } + if dcer.Tags != nil { + objectMap["tags"] = dcer.Tags + } + if dcer.Kind != "" { + objectMap["kind"] = dcer.Kind + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for DataCollectionEndpointResource struct. +func (dcer *DataCollectionEndpointResource) UnmarshalJSON(body []byte) error { + 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 dataCollectionEndpointResourceProperties DataCollectionEndpointResourceProperties + err = json.Unmarshal(*v, &dataCollectionEndpointResourceProperties) + if err != nil { + return err + } + dcer.DataCollectionEndpointResourceProperties = &dataCollectionEndpointResourceProperties + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + dcer.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + dcer.Tags = tags + } + case "kind": + if v != nil { + var kind KnownDataCollectionEndpointResourceKind + err = json.Unmarshal(*v, &kind) + if err != nil { + return err + } + dcer.Kind = kind + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + dcer.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + dcer.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + dcer.Type = &typeVar + } + case "etag": + if v != nil { + var etag string + err = json.Unmarshal(*v, &etag) + if err != nil { + return err + } + dcer.Etag = &etag + } + case "systemData": + if v != nil { + var systemData DataCollectionEndpointResourceSystemData + err = json.Unmarshal(*v, &systemData) + if err != nil { + return err + } + dcer.SystemData = &systemData + } + } + } + + return nil +} + +// DataCollectionEndpointResourceListResult a pageable list of resources. +type DataCollectionEndpointResourceListResult struct { + autorest.Response `json:"-"` + // Value - A list of resources. + Value *[]DataCollectionEndpointResource `json:"value,omitempty"` + // NextLink - The URL to use for getting the next set of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// DataCollectionEndpointResourceListResultIterator provides access to a complete listing of +// DataCollectionEndpointResource values. +type DataCollectionEndpointResourceListResultIterator struct { + i int + page DataCollectionEndpointResourceListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *DataCollectionEndpointResourceListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DataCollectionEndpointResourceListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *DataCollectionEndpointResourceListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter DataCollectionEndpointResourceListResultIterator) 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 DataCollectionEndpointResourceListResultIterator) Response() DataCollectionEndpointResourceListResult { + 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 DataCollectionEndpointResourceListResultIterator) Value() DataCollectionEndpointResource { + if !iter.page.NotDone() { + return DataCollectionEndpointResource{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the DataCollectionEndpointResourceListResultIterator type. +func NewDataCollectionEndpointResourceListResultIterator(page DataCollectionEndpointResourceListResultPage) DataCollectionEndpointResourceListResultIterator { + return DataCollectionEndpointResourceListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (dcerlr DataCollectionEndpointResourceListResult) IsEmpty() bool { + return dcerlr.Value == nil || len(*dcerlr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (dcerlr DataCollectionEndpointResourceListResult) hasNextLink() bool { + return dcerlr.NextLink != nil && len(*dcerlr.NextLink) != 0 +} + +// dataCollectionEndpointResourceListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (dcerlr DataCollectionEndpointResourceListResult) dataCollectionEndpointResourceListResultPreparer(ctx context.Context) (*http.Request, error) { + if !dcerlr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(dcerlr.NextLink))) +} + +// DataCollectionEndpointResourceListResultPage contains a page of DataCollectionEndpointResource values. +type DataCollectionEndpointResourceListResultPage struct { + fn func(context.Context, DataCollectionEndpointResourceListResult) (DataCollectionEndpointResourceListResult, error) + dcerlr DataCollectionEndpointResourceListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *DataCollectionEndpointResourceListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DataCollectionEndpointResourceListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.dcerlr) + if err != nil { + return err + } + page.dcerlr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *DataCollectionEndpointResourceListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page DataCollectionEndpointResourceListResultPage) NotDone() bool { + return !page.dcerlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page DataCollectionEndpointResourceListResultPage) Response() DataCollectionEndpointResourceListResult { + return page.dcerlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page DataCollectionEndpointResourceListResultPage) Values() []DataCollectionEndpointResource { + if page.dcerlr.IsEmpty() { + return nil + } + return *page.dcerlr.Value +} + +// Creates a new instance of the DataCollectionEndpointResourceListResultPage type. +func NewDataCollectionEndpointResourceListResultPage(cur DataCollectionEndpointResourceListResult, getNextPage func(context.Context, DataCollectionEndpointResourceListResult) (DataCollectionEndpointResourceListResult, error)) DataCollectionEndpointResourceListResultPage { + return DataCollectionEndpointResourceListResultPage{ + fn: getNextPage, + dcerlr: cur, + } +} + +// DataCollectionEndpointResourceProperties resource properties. +type DataCollectionEndpointResourceProperties struct { + // Description - Description of the data collection endpoint. + Description *string `json:"description,omitempty"` + // ImmutableID - The immutable ID of this data collection endpoint resource. This property is READ-ONLY. + ImmutableID *string `json:"immutableId,omitempty"` + // ConfigurationAccess - The endpoint used by agents to access their configuration. + ConfigurationAccess *DataCollectionEndpointConfigurationAccess `json:"configurationAccess,omitempty"` + // LogsIngestion - The endpoint used by clients to ingest logs. + LogsIngestion *DataCollectionEndpointLogsIngestion `json:"logsIngestion,omitempty"` + // NetworkAcls - Network access control rules for the endpoints. + NetworkAcls *DataCollectionEndpointNetworkAcls `json:"networkAcls,omitempty"` + // ProvisioningState - READ-ONLY; The resource provisioning state. This property is READ-ONLY. Possible values include: 'KnownDataCollectionEndpointProvisioningStateCreating', 'KnownDataCollectionEndpointProvisioningStateUpdating', 'KnownDataCollectionEndpointProvisioningStateDeleting', 'KnownDataCollectionEndpointProvisioningStateSucceeded', 'KnownDataCollectionEndpointProvisioningStateFailed' + ProvisioningState KnownDataCollectionEndpointProvisioningState `json:"provisioningState,omitempty"` +} + +// MarshalJSON is the custom marshaler for DataCollectionEndpointResourceProperties. +func (dcer DataCollectionEndpointResourceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dcer.Description != nil { + objectMap["description"] = dcer.Description + } + if dcer.ImmutableID != nil { + objectMap["immutableId"] = dcer.ImmutableID + } + if dcer.ConfigurationAccess != nil { + objectMap["configurationAccess"] = dcer.ConfigurationAccess + } + if dcer.LogsIngestion != nil { + objectMap["logsIngestion"] = dcer.LogsIngestion + } + if dcer.NetworkAcls != nil { + objectMap["networkAcls"] = dcer.NetworkAcls + } + return json.Marshal(objectMap) +} + +// DataCollectionEndpointResourceSystemData metadata pertaining to creation and last modification of the +// resource. +type DataCollectionEndpointResourceSystemData struct { + // CreatedBy - The identity that created the resource. + CreatedBy *string `json:"createdBy,omitempty"` + // CreatedByType - The type of identity that created the resource. Possible values include: 'CreatedByTypeUser', 'CreatedByTypeApplication', 'CreatedByTypeManagedIdentity', 'CreatedByTypeKey' + CreatedByType CreatedByType `json:"createdByType,omitempty"` + // CreatedAt - The timestamp of resource creation (UTC). + CreatedAt *date.Time `json:"createdAt,omitempty"` + // LastModifiedBy - The identity that last modified the resource. + LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + // LastModifiedByType - The type of identity that last modified the resource. Possible values include: 'CreatedByTypeUser', 'CreatedByTypeApplication', 'CreatedByTypeManagedIdentity', 'CreatedByTypeKey' + LastModifiedByType CreatedByType `json:"lastModifiedByType,omitempty"` + // LastModifiedAt - The timestamp of resource last modification (UTC) + LastModifiedAt *date.Time `json:"lastModifiedAt,omitempty"` +} + +// DataCollectionRule definition of what monitoring data to collect and where that data should be sent. +type DataCollectionRule struct { + // Description - Description of the data collection rule. + Description *string `json:"description,omitempty"` + // ImmutableID - READ-ONLY; The immutable ID of this data collection rule. This property is READ-ONLY. + ImmutableID *string `json:"immutableId,omitempty"` + // DataSources - The specification of data sources. + // This property is optional and can be omitted if the rule is meant to be used via direct calls to the provisioned endpoint. + DataSources *DataCollectionRuleDataSources `json:"dataSources,omitempty"` + // Destinations - The specification of destinations. + Destinations *DataCollectionRuleDestinations `json:"destinations,omitempty"` + // DataFlows - The specification of data flows. + DataFlows *[]DataFlow `json:"dataFlows,omitempty"` + // ProvisioningState - READ-ONLY; The resource provisioning state. Possible values include: 'KnownDataCollectionRuleProvisioningStateCreating', 'KnownDataCollectionRuleProvisioningStateUpdating', 'KnownDataCollectionRuleProvisioningStateDeleting', 'KnownDataCollectionRuleProvisioningStateSucceeded', 'KnownDataCollectionRuleProvisioningStateFailed' + ProvisioningState KnownDataCollectionRuleProvisioningState `json:"provisioningState,omitempty"` +} + +// MarshalJSON is the custom marshaler for DataCollectionRule. +func (dcr DataCollectionRule) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dcr.Description != nil { + objectMap["description"] = dcr.Description + } + if dcr.DataSources != nil { + objectMap["dataSources"] = dcr.DataSources + } + if dcr.Destinations != nil { + objectMap["destinations"] = dcr.Destinations + } + if dcr.DataFlows != nil { + objectMap["dataFlows"] = dcr.DataFlows + } + return json.Marshal(objectMap) +} + +// DataCollectionRuleAssociation definition of association of a data collection rule with a monitored Azure +// resource. +type DataCollectionRuleAssociation struct { + // Description - Description of the association. + Description *string `json:"description,omitempty"` + // DataCollectionRuleID - The resource ID of the data collection rule that is to be associated. + DataCollectionRuleID *string `json:"dataCollectionRuleId,omitempty"` + // DataCollectionEndpointID - The resource ID of the data collection endpoint that is to be associated. + DataCollectionEndpointID *string `json:"dataCollectionEndpointId,omitempty"` + // ProvisioningState - READ-ONLY; The resource provisioning state. Possible values include: 'KnownDataCollectionRuleAssociationProvisioningStateCreating', 'KnownDataCollectionRuleAssociationProvisioningStateUpdating', 'KnownDataCollectionRuleAssociationProvisioningStateDeleting', 'KnownDataCollectionRuleAssociationProvisioningStateSucceeded', 'KnownDataCollectionRuleAssociationProvisioningStateFailed' + ProvisioningState KnownDataCollectionRuleAssociationProvisioningState `json:"provisioningState,omitempty"` +} + +// MarshalJSON is the custom marshaler for DataCollectionRuleAssociation. +func (dcra DataCollectionRuleAssociation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dcra.Description != nil { + objectMap["description"] = dcra.Description + } + if dcra.DataCollectionRuleID != nil { + objectMap["dataCollectionRuleId"] = dcra.DataCollectionRuleID + } + if dcra.DataCollectionEndpointID != nil { + objectMap["dataCollectionEndpointId"] = dcra.DataCollectionEndpointID + } + return json.Marshal(objectMap) +} + +// DataCollectionRuleAssociationProxyOnlyResource definition of generic ARM proxy resource. +type DataCollectionRuleAssociationProxyOnlyResource struct { + autorest.Response `json:"-"` + // DataCollectionRuleAssociationProxyOnlyResourceProperties - Resource properties. + *DataCollectionRuleAssociationProxyOnlyResourceProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Fully qualified ID of the resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. + Type *string `json:"type,omitempty"` + // Etag - READ-ONLY; Resource entity tag (ETag). + Etag *string `json:"etag,omitempty"` + // SystemData - READ-ONLY; Metadata pertaining to creation and last modification of the resource. + SystemData *DataCollectionRuleAssociationProxyOnlyResourceSystemData `json:"systemData,omitempty"` +} + +// MarshalJSON is the custom marshaler for DataCollectionRuleAssociationProxyOnlyResource. +func (dcrapor DataCollectionRuleAssociationProxyOnlyResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dcrapor.DataCollectionRuleAssociationProxyOnlyResourceProperties != nil { + objectMap["properties"] = dcrapor.DataCollectionRuleAssociationProxyOnlyResourceProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for DataCollectionRuleAssociationProxyOnlyResource struct. +func (dcrapor *DataCollectionRuleAssociationProxyOnlyResource) UnmarshalJSON(body []byte) error { + 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 dataCollectionRuleAssociationProxyOnlyResourceProperties DataCollectionRuleAssociationProxyOnlyResourceProperties + err = json.Unmarshal(*v, &dataCollectionRuleAssociationProxyOnlyResourceProperties) + if err != nil { + return err + } + dcrapor.DataCollectionRuleAssociationProxyOnlyResourceProperties = &dataCollectionRuleAssociationProxyOnlyResourceProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + dcrapor.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + dcrapor.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + dcrapor.Type = &typeVar + } + case "etag": + if v != nil { + var etag string + err = json.Unmarshal(*v, &etag) + if err != nil { + return err + } + dcrapor.Etag = &etag + } + case "systemData": + if v != nil { + var systemData DataCollectionRuleAssociationProxyOnlyResourceSystemData + err = json.Unmarshal(*v, &systemData) + if err != nil { + return err + } + dcrapor.SystemData = &systemData + } + } + } + + return nil +} + +// DataCollectionRuleAssociationProxyOnlyResourceListResult a pageable list of resources. +type DataCollectionRuleAssociationProxyOnlyResourceListResult struct { + autorest.Response `json:"-"` + // Value - A list of resources. + Value *[]DataCollectionRuleAssociationProxyOnlyResource `json:"value,omitempty"` + // NextLink - The URL to use for getting the next set of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// DataCollectionRuleAssociationProxyOnlyResourceListResultIterator provides access to a complete listing +// of DataCollectionRuleAssociationProxyOnlyResource values. +type DataCollectionRuleAssociationProxyOnlyResourceListResultIterator struct { + i int + page DataCollectionRuleAssociationProxyOnlyResourceListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *DataCollectionRuleAssociationProxyOnlyResourceListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DataCollectionRuleAssociationProxyOnlyResourceListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *DataCollectionRuleAssociationProxyOnlyResourceListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter DataCollectionRuleAssociationProxyOnlyResourceListResultIterator) 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 DataCollectionRuleAssociationProxyOnlyResourceListResultIterator) Response() DataCollectionRuleAssociationProxyOnlyResourceListResult { + 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 DataCollectionRuleAssociationProxyOnlyResourceListResultIterator) Value() DataCollectionRuleAssociationProxyOnlyResource { + if !iter.page.NotDone() { + return DataCollectionRuleAssociationProxyOnlyResource{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the DataCollectionRuleAssociationProxyOnlyResourceListResultIterator type. +func NewDataCollectionRuleAssociationProxyOnlyResourceListResultIterator(page DataCollectionRuleAssociationProxyOnlyResourceListResultPage) DataCollectionRuleAssociationProxyOnlyResourceListResultIterator { + return DataCollectionRuleAssociationProxyOnlyResourceListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (dcraporlr DataCollectionRuleAssociationProxyOnlyResourceListResult) IsEmpty() bool { + return dcraporlr.Value == nil || len(*dcraporlr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (dcraporlr DataCollectionRuleAssociationProxyOnlyResourceListResult) hasNextLink() bool { + return dcraporlr.NextLink != nil && len(*dcraporlr.NextLink) != 0 +} + +// dataCollectionRuleAssociationProxyOnlyResourceListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (dcraporlr DataCollectionRuleAssociationProxyOnlyResourceListResult) dataCollectionRuleAssociationProxyOnlyResourceListResultPreparer(ctx context.Context) (*http.Request, error) { + if !dcraporlr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(dcraporlr.NextLink))) +} + +// DataCollectionRuleAssociationProxyOnlyResourceListResultPage contains a page of +// DataCollectionRuleAssociationProxyOnlyResource values. +type DataCollectionRuleAssociationProxyOnlyResourceListResultPage struct { + fn func(context.Context, DataCollectionRuleAssociationProxyOnlyResourceListResult) (DataCollectionRuleAssociationProxyOnlyResourceListResult, error) + dcraporlr DataCollectionRuleAssociationProxyOnlyResourceListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *DataCollectionRuleAssociationProxyOnlyResourceListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DataCollectionRuleAssociationProxyOnlyResourceListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.dcraporlr) + if err != nil { + return err + } + page.dcraporlr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *DataCollectionRuleAssociationProxyOnlyResourceListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page DataCollectionRuleAssociationProxyOnlyResourceListResultPage) NotDone() bool { + return !page.dcraporlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page DataCollectionRuleAssociationProxyOnlyResourceListResultPage) Response() DataCollectionRuleAssociationProxyOnlyResourceListResult { + return page.dcraporlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page DataCollectionRuleAssociationProxyOnlyResourceListResultPage) Values() []DataCollectionRuleAssociationProxyOnlyResource { + if page.dcraporlr.IsEmpty() { + return nil + } + return *page.dcraporlr.Value +} + +// Creates a new instance of the DataCollectionRuleAssociationProxyOnlyResourceListResultPage type. +func NewDataCollectionRuleAssociationProxyOnlyResourceListResultPage(cur DataCollectionRuleAssociationProxyOnlyResourceListResult, getNextPage func(context.Context, DataCollectionRuleAssociationProxyOnlyResourceListResult) (DataCollectionRuleAssociationProxyOnlyResourceListResult, error)) DataCollectionRuleAssociationProxyOnlyResourceListResultPage { + return DataCollectionRuleAssociationProxyOnlyResourceListResultPage{ + fn: getNextPage, + dcraporlr: cur, + } +} + +// DataCollectionRuleAssociationProxyOnlyResourceProperties resource properties. +type DataCollectionRuleAssociationProxyOnlyResourceProperties struct { + // Description - Description of the association. + Description *string `json:"description,omitempty"` + // DataCollectionRuleID - The resource ID of the data collection rule that is to be associated. + DataCollectionRuleID *string `json:"dataCollectionRuleId,omitempty"` + // DataCollectionEndpointID - The resource ID of the data collection endpoint that is to be associated. + DataCollectionEndpointID *string `json:"dataCollectionEndpointId,omitempty"` + // ProvisioningState - READ-ONLY; The resource provisioning state. Possible values include: 'KnownDataCollectionRuleAssociationProvisioningStateCreating', 'KnownDataCollectionRuleAssociationProvisioningStateUpdating', 'KnownDataCollectionRuleAssociationProvisioningStateDeleting', 'KnownDataCollectionRuleAssociationProvisioningStateSucceeded', 'KnownDataCollectionRuleAssociationProvisioningStateFailed' + ProvisioningState KnownDataCollectionRuleAssociationProvisioningState `json:"provisioningState,omitempty"` +} + +// MarshalJSON is the custom marshaler for DataCollectionRuleAssociationProxyOnlyResourceProperties. +func (dcrapor DataCollectionRuleAssociationProxyOnlyResourceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dcrapor.Description != nil { + objectMap["description"] = dcrapor.Description + } + if dcrapor.DataCollectionRuleID != nil { + objectMap["dataCollectionRuleId"] = dcrapor.DataCollectionRuleID + } + if dcrapor.DataCollectionEndpointID != nil { + objectMap["dataCollectionEndpointId"] = dcrapor.DataCollectionEndpointID + } + return json.Marshal(objectMap) +} + +// DataCollectionRuleAssociationProxyOnlyResourceSystemData metadata pertaining to creation and last +// modification of the resource. +type DataCollectionRuleAssociationProxyOnlyResourceSystemData struct { + // CreatedBy - The identity that created the resource. + CreatedBy *string `json:"createdBy,omitempty"` + // CreatedByType - The type of identity that created the resource. Possible values include: 'CreatedByTypeUser', 'CreatedByTypeApplication', 'CreatedByTypeManagedIdentity', 'CreatedByTypeKey' + CreatedByType CreatedByType `json:"createdByType,omitempty"` + // CreatedAt - The timestamp of resource creation (UTC). + CreatedAt *date.Time `json:"createdAt,omitempty"` + // LastModifiedBy - The identity that last modified the resource. + LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + // LastModifiedByType - The type of identity that last modified the resource. Possible values include: 'CreatedByTypeUser', 'CreatedByTypeApplication', 'CreatedByTypeManagedIdentity', 'CreatedByTypeKey' + LastModifiedByType CreatedByType `json:"lastModifiedByType,omitempty"` + // LastModifiedAt - The timestamp of resource last modification (UTC) + LastModifiedAt *date.Time `json:"lastModifiedAt,omitempty"` +} + +// DataCollectionRuleDataSources the specification of data sources. +// This property is optional and can be omitted if the rule is meant to be used via direct calls to the +// provisioned endpoint. +type DataCollectionRuleDataSources struct { + // PerformanceCounters - The list of performance counter data source configurations. + PerformanceCounters *[]PerfCounterDataSource `json:"performanceCounters,omitempty"` + // WindowsEventLogs - The list of Windows Event Log data source configurations. + WindowsEventLogs *[]WindowsEventLogDataSource `json:"windowsEventLogs,omitempty"` + // Syslog - The list of Syslog data source configurations. + Syslog *[]SyslogDataSource `json:"syslog,omitempty"` + // Extensions - The list of Azure VM extension data source configurations. + Extensions *[]ExtensionDataSource `json:"extensions,omitempty"` +} + +// DataCollectionRuleDestinations the specification of destinations. +type DataCollectionRuleDestinations struct { + // LogAnalytics - List of Log Analytics destinations. + LogAnalytics *[]LogAnalyticsDestination `json:"logAnalytics,omitempty"` + // AzureMonitorMetrics - Azure Monitor Metrics destination. + AzureMonitorMetrics *DestinationsSpecAzureMonitorMetrics `json:"azureMonitorMetrics,omitempty"` +} + +// DataCollectionRuleResource definition of ARM tracked top level resource. +type DataCollectionRuleResource struct { + autorest.Response `json:"-"` + // DataCollectionRuleResourceProperties - Resource properties. + *DataCollectionRuleResourceProperties `json:"properties,omitempty"` + // Location - The geo-location where the resource lives. + Location *string `json:"location,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // Kind - The kind of the resource. Possible values include: 'KnownDataCollectionRuleResourceKindLinux', 'KnownDataCollectionRuleResourceKindWindows' + Kind KnownDataCollectionRuleResourceKind `json:"kind,omitempty"` + // ID - READ-ONLY; Fully qualified ID of the resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. + Type *string `json:"type,omitempty"` + // Etag - READ-ONLY; Resource entity tag (ETag). + Etag *string `json:"etag,omitempty"` + // SystemData - READ-ONLY; Metadata pertaining to creation and last modification of the resource. + SystemData *DataCollectionRuleResourceSystemData `json:"systemData,omitempty"` +} + +// MarshalJSON is the custom marshaler for DataCollectionRuleResource. +func (dcrr DataCollectionRuleResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dcrr.DataCollectionRuleResourceProperties != nil { + objectMap["properties"] = dcrr.DataCollectionRuleResourceProperties + } + if dcrr.Location != nil { + objectMap["location"] = dcrr.Location + } + if dcrr.Tags != nil { + objectMap["tags"] = dcrr.Tags + } + if dcrr.Kind != "" { + objectMap["kind"] = dcrr.Kind + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for DataCollectionRuleResource struct. +func (dcrr *DataCollectionRuleResource) UnmarshalJSON(body []byte) error { + 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 dataCollectionRuleResourceProperties DataCollectionRuleResourceProperties + err = json.Unmarshal(*v, &dataCollectionRuleResourceProperties) + if err != nil { + return err + } + dcrr.DataCollectionRuleResourceProperties = &dataCollectionRuleResourceProperties + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + dcrr.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + dcrr.Tags = tags + } + case "kind": + if v != nil { + var kind KnownDataCollectionRuleResourceKind + err = json.Unmarshal(*v, &kind) + if err != nil { + return err + } + dcrr.Kind = kind + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + dcrr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + dcrr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + dcrr.Type = &typeVar + } + case "etag": + if v != nil { + var etag string + err = json.Unmarshal(*v, &etag) + if err != nil { + return err + } + dcrr.Etag = &etag + } + case "systemData": + if v != nil { + var systemData DataCollectionRuleResourceSystemData + err = json.Unmarshal(*v, &systemData) + if err != nil { + return err + } + dcrr.SystemData = &systemData + } + } + } + + return nil +} + +// DataCollectionRuleResourceListResult a pageable list of resources. +type DataCollectionRuleResourceListResult struct { + autorest.Response `json:"-"` + // Value - A list of resources. + Value *[]DataCollectionRuleResource `json:"value,omitempty"` + // NextLink - The URL to use for getting the next set of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// DataCollectionRuleResourceListResultIterator provides access to a complete listing of +// DataCollectionRuleResource values. +type DataCollectionRuleResourceListResultIterator struct { + i int + page DataCollectionRuleResourceListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *DataCollectionRuleResourceListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DataCollectionRuleResourceListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *DataCollectionRuleResourceListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter DataCollectionRuleResourceListResultIterator) 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 DataCollectionRuleResourceListResultIterator) Response() DataCollectionRuleResourceListResult { + 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 DataCollectionRuleResourceListResultIterator) Value() DataCollectionRuleResource { + if !iter.page.NotDone() { + return DataCollectionRuleResource{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the DataCollectionRuleResourceListResultIterator type. +func NewDataCollectionRuleResourceListResultIterator(page DataCollectionRuleResourceListResultPage) DataCollectionRuleResourceListResultIterator { + return DataCollectionRuleResourceListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (dcrrlr DataCollectionRuleResourceListResult) IsEmpty() bool { + return dcrrlr.Value == nil || len(*dcrrlr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (dcrrlr DataCollectionRuleResourceListResult) hasNextLink() bool { + return dcrrlr.NextLink != nil && len(*dcrrlr.NextLink) != 0 +} + +// dataCollectionRuleResourceListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (dcrrlr DataCollectionRuleResourceListResult) dataCollectionRuleResourceListResultPreparer(ctx context.Context) (*http.Request, error) { + if !dcrrlr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(dcrrlr.NextLink))) +} + +// DataCollectionRuleResourceListResultPage contains a page of DataCollectionRuleResource values. +type DataCollectionRuleResourceListResultPage struct { + fn func(context.Context, DataCollectionRuleResourceListResult) (DataCollectionRuleResourceListResult, error) + dcrrlr DataCollectionRuleResourceListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *DataCollectionRuleResourceListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DataCollectionRuleResourceListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.dcrrlr) + if err != nil { + return err + } + page.dcrrlr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *DataCollectionRuleResourceListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page DataCollectionRuleResourceListResultPage) NotDone() bool { + return !page.dcrrlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page DataCollectionRuleResourceListResultPage) Response() DataCollectionRuleResourceListResult { + return page.dcrrlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page DataCollectionRuleResourceListResultPage) Values() []DataCollectionRuleResource { + if page.dcrrlr.IsEmpty() { + return nil + } + return *page.dcrrlr.Value +} + +// Creates a new instance of the DataCollectionRuleResourceListResultPage type. +func NewDataCollectionRuleResourceListResultPage(cur DataCollectionRuleResourceListResult, getNextPage func(context.Context, DataCollectionRuleResourceListResult) (DataCollectionRuleResourceListResult, error)) DataCollectionRuleResourceListResultPage { + return DataCollectionRuleResourceListResultPage{ + fn: getNextPage, + dcrrlr: cur, + } +} + +// DataCollectionRuleResourceProperties resource properties. +type DataCollectionRuleResourceProperties struct { + // Description - Description of the data collection rule. + Description *string `json:"description,omitempty"` + // ImmutableID - READ-ONLY; The immutable ID of this data collection rule. This property is READ-ONLY. + ImmutableID *string `json:"immutableId,omitempty"` + // DataSources - The specification of data sources. + // This property is optional and can be omitted if the rule is meant to be used via direct calls to the provisioned endpoint. + DataSources *DataCollectionRuleDataSources `json:"dataSources,omitempty"` + // Destinations - The specification of destinations. + Destinations *DataCollectionRuleDestinations `json:"destinations,omitempty"` + // DataFlows - The specification of data flows. + DataFlows *[]DataFlow `json:"dataFlows,omitempty"` + // ProvisioningState - READ-ONLY; The resource provisioning state. Possible values include: 'KnownDataCollectionRuleProvisioningStateCreating', 'KnownDataCollectionRuleProvisioningStateUpdating', 'KnownDataCollectionRuleProvisioningStateDeleting', 'KnownDataCollectionRuleProvisioningStateSucceeded', 'KnownDataCollectionRuleProvisioningStateFailed' + ProvisioningState KnownDataCollectionRuleProvisioningState `json:"provisioningState,omitempty"` +} + +// MarshalJSON is the custom marshaler for DataCollectionRuleResourceProperties. +func (dcrr DataCollectionRuleResourceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dcrr.Description != nil { + objectMap["description"] = dcrr.Description + } + if dcrr.DataSources != nil { + objectMap["dataSources"] = dcrr.DataSources + } + if dcrr.Destinations != nil { + objectMap["destinations"] = dcrr.Destinations + } + if dcrr.DataFlows != nil { + objectMap["dataFlows"] = dcrr.DataFlows + } + return json.Marshal(objectMap) +} + +// DataCollectionRuleResourceSystemData metadata pertaining to creation and last modification of the +// resource. +type DataCollectionRuleResourceSystemData struct { + // CreatedBy - The identity that created the resource. + CreatedBy *string `json:"createdBy,omitempty"` + // CreatedByType - The type of identity that created the resource. Possible values include: 'CreatedByTypeUser', 'CreatedByTypeApplication', 'CreatedByTypeManagedIdentity', 'CreatedByTypeKey' + CreatedByType CreatedByType `json:"createdByType,omitempty"` + // CreatedAt - The timestamp of resource creation (UTC). + CreatedAt *date.Time `json:"createdAt,omitempty"` + // LastModifiedBy - The identity that last modified the resource. + LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + // LastModifiedByType - The type of identity that last modified the resource. Possible values include: 'CreatedByTypeUser', 'CreatedByTypeApplication', 'CreatedByTypeManagedIdentity', 'CreatedByTypeKey' + LastModifiedByType CreatedByType `json:"lastModifiedByType,omitempty"` + // LastModifiedAt - The timestamp of resource last modification (UTC) + LastModifiedAt *date.Time `json:"lastModifiedAt,omitempty"` +} + +// DataContainer information about a container with data for a given resource. +type DataContainer struct { + // Workspace - Log Analytics workspace information. + Workspace *WorkspaceInfo `json:"workspace,omitempty"` +} + +// DataFlow definition of which streams are sent to which destinations. +type DataFlow struct { + // Streams - List of streams for this data flow. + Streams *[]KnownDataFlowStreams `json:"streams,omitempty"` + // Destinations - List of destinations for this data flow. + Destinations *[]string `json:"destinations,omitempty"` +} + +// DataSourcesSpec specification of data sources that will be collected. +type DataSourcesSpec struct { + // PerformanceCounters - The list of performance counter data source configurations. + PerformanceCounters *[]PerfCounterDataSource `json:"performanceCounters,omitempty"` + // WindowsEventLogs - The list of Windows Event Log data source configurations. + WindowsEventLogs *[]WindowsEventLogDataSource `json:"windowsEventLogs,omitempty"` + // Syslog - The list of Syslog data source configurations. + Syslog *[]SyslogDataSource `json:"syslog,omitempty"` + // Extensions - The list of Azure VM extension data source configurations. + Extensions *[]ExtensionDataSource `json:"extensions,omitempty"` +} + +// DestinationsSpec specification of destinations that can be used in data flows. +type DestinationsSpec struct { + // LogAnalytics - List of Log Analytics destinations. + LogAnalytics *[]LogAnalyticsDestination `json:"logAnalytics,omitempty"` + // AzureMonitorMetrics - Azure Monitor Metrics destination. + AzureMonitorMetrics *DestinationsSpecAzureMonitorMetrics `json:"azureMonitorMetrics,omitempty"` +} + +// DestinationsSpecAzureMonitorMetrics azure Monitor Metrics destination. +type DestinationsSpecAzureMonitorMetrics struct { + // Name - A friendly name for the destination. + // This name should be unique across all destinations (regardless of type) within the data collection rule. + Name *string `json:"name,omitempty"` +} + +// DiagnosticSettings the diagnostic settings. +type DiagnosticSettings struct { + // StorageAccountID - The resource ID of the storage account to which you would like to send Diagnostic Logs. + StorageAccountID *string `json:"storageAccountId,omitempty"` + // ServiceBusRuleID - The service bus rule Id of the diagnostic setting. This is here to maintain backwards compatibility. + ServiceBusRuleID *string `json:"serviceBusRuleId,omitempty"` + // EventHubAuthorizationRuleID - The resource Id for the event hub authorization rule. + EventHubAuthorizationRuleID *string `json:"eventHubAuthorizationRuleId,omitempty"` + // EventHubName - The name of the event hub. If none is specified, the default event hub will be selected. + EventHubName *string `json:"eventHubName,omitempty"` + // Metrics - The list of metric settings. + Metrics *[]MetricSettings `json:"metrics,omitempty"` + // Logs - The list of logs settings. + Logs *[]LogSettings `json:"logs,omitempty"` + // WorkspaceID - The full ARM resource ID of the Log Analytics workspace to which you would like to send Diagnostic Logs. Example: /subscriptions/4b9e8510-67ab-4e9a-95a9-e2f1e570ea9c/resourceGroups/insights-integration/providers/Microsoft.OperationalInsights/workspaces/viruela2 + WorkspaceID *string `json:"workspaceId,omitempty"` + // LogAnalyticsDestinationType - A string indicating whether the export to Log Analytics should use the default destination type, i.e. AzureDiagnostics, or use a destination type constructed as follows: _. Possible values are: Dedicated and null (null is default.) + LogAnalyticsDestinationType *string `json:"logAnalyticsDestinationType,omitempty"` +} + +// DiagnosticSettingsCategory the diagnostic settings Category. +type DiagnosticSettingsCategory struct { + // CategoryType - The type of the diagnostic settings category. Possible values include: 'CategoryTypeMetrics', 'CategoryTypeLogs' + CategoryType CategoryType `json:"categoryType,omitempty"` +} + +// DiagnosticSettingsCategoryResource the diagnostic settings category resource. +type DiagnosticSettingsCategoryResource struct { + autorest.Response `json:"-"` + // DiagnosticSettingsCategory - The properties of a Diagnostic Settings Category. + *DiagnosticSettingsCategory `json:"properties,omitempty"` + // ID - READ-ONLY; Azure resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Azure resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Azure resource type + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for DiagnosticSettingsCategoryResource. +func (dscr DiagnosticSettingsCategoryResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dscr.DiagnosticSettingsCategory != nil { + objectMap["properties"] = dscr.DiagnosticSettingsCategory + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for DiagnosticSettingsCategoryResource struct. +func (dscr *DiagnosticSettingsCategoryResource) UnmarshalJSON(body []byte) error { + 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 diagnosticSettingsCategory DiagnosticSettingsCategory + err = json.Unmarshal(*v, &diagnosticSettingsCategory) + if err != nil { + return err + } + dscr.DiagnosticSettingsCategory = &diagnosticSettingsCategory + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + dscr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + dscr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + dscr.Type = &typeVar + } + } + } + + return nil +} + +// DiagnosticSettingsCategoryResourceCollection represents a collection of diagnostic setting category +// resources. +type DiagnosticSettingsCategoryResourceCollection struct { + autorest.Response `json:"-"` + // Value - The collection of diagnostic settings category resources. + Value *[]DiagnosticSettingsCategoryResource `json:"value,omitempty"` +} + +// DiagnosticSettingsResource the diagnostic setting resource. +type DiagnosticSettingsResource struct { + autorest.Response `json:"-"` + // DiagnosticSettings - Properties of a Diagnostic Settings Resource. + *DiagnosticSettings `json:"properties,omitempty"` + // ID - READ-ONLY; Azure resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Azure resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Azure resource type + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for DiagnosticSettingsResource. +func (dsr DiagnosticSettingsResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dsr.DiagnosticSettings != nil { + objectMap["properties"] = dsr.DiagnosticSettings + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for DiagnosticSettingsResource struct. +func (dsr *DiagnosticSettingsResource) UnmarshalJSON(body []byte) error { + 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 diagnosticSettings DiagnosticSettings + err = json.Unmarshal(*v, &diagnosticSettings) + if err != nil { + return err + } + dsr.DiagnosticSettings = &diagnosticSettings + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + dsr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + dsr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + dsr.Type = &typeVar + } + } + } + + return nil +} + +// DiagnosticSettingsResourceCollection represents a collection of alert rule resources. +type DiagnosticSettingsResourceCollection struct { + autorest.Response `json:"-"` + // Value - The collection of diagnostic settings resources;. + Value *[]DiagnosticSettingsResource `json:"value,omitempty"` +} + +// Dimension specifies the criteria for converting log to metric. +type Dimension struct { + // Name - Name of the dimension + Name *string `json:"name,omitempty"` + // Operator - Operator for dimension values + Operator *string `json:"operator,omitempty"` + // Values - List of dimension values + Values *[]string `json:"values,omitempty"` +} + +// DynamicMetricCriteria criterion for dynamic threshold. +type DynamicMetricCriteria struct { + // Operator - The operator used to compare the metric value against the threshold. Possible values include: 'DynamicThresholdOperatorGreaterThan', 'DynamicThresholdOperatorLessThan', 'DynamicThresholdOperatorGreaterOrLessThan' + Operator DynamicThresholdOperator `json:"operator,omitempty"` + // AlertSensitivity - The extent of deviation required to trigger an alert. This will affect how tight the threshold is to the metric series pattern. Possible values include: 'DynamicThresholdSensitivityLow', 'DynamicThresholdSensitivityMedium', 'DynamicThresholdSensitivityHigh' + AlertSensitivity DynamicThresholdSensitivity `json:"alertSensitivity,omitempty"` + // FailingPeriods - The minimum number of violations required within the selected lookback time window required to raise an alert. + FailingPeriods *DynamicThresholdFailingPeriods `json:"failingPeriods,omitempty"` + // IgnoreDataBefore - Use this option to set the date from which to start learning the metric historical data and calculate the dynamic thresholds (in ISO8601 format) + IgnoreDataBefore *date.Time `json:"ignoreDataBefore,omitempty"` + // AdditionalProperties - Unmatched properties from the message are deserialized this collection + AdditionalProperties map[string]interface{} `json:""` + // Name - Name of the criteria. + Name *string `json:"name,omitempty"` + // MetricName - Name of the metric. + MetricName *string `json:"metricName,omitempty"` + // MetricNamespace - Namespace of the metric. + MetricNamespace *string `json:"metricNamespace,omitempty"` + // TimeAggregation - the criteria time aggregation types. Possible values include: 'AggregationTypeEnumAverage', 'AggregationTypeEnumCount', 'AggregationTypeEnumMinimum', 'AggregationTypeEnumMaximum', 'AggregationTypeEnumTotal' + TimeAggregation AggregationTypeEnum `json:"timeAggregation,omitempty"` + // Dimensions - List of dimension conditions. + Dimensions *[]MetricDimension `json:"dimensions,omitempty"` + // SkipMetricValidation - Allows creating an alert rule on a custom metric that isn't yet emitted, by causing the metric validation to be skipped. + SkipMetricValidation *bool `json:"skipMetricValidation,omitempty"` + // CriterionType - Possible values include: 'CriterionTypeMultiMetricCriteria', 'CriterionTypeStaticThresholdCriterion', 'CriterionTypeDynamicThresholdCriterion' + CriterionType CriterionType `json:"criterionType,omitempty"` +} + +// MarshalJSON is the custom marshaler for DynamicMetricCriteria. +func (dmc DynamicMetricCriteria) MarshalJSON() ([]byte, error) { + dmc.CriterionType = CriterionTypeDynamicThresholdCriterion + objectMap := make(map[string]interface{}) + if dmc.Operator != "" { + objectMap["operator"] = dmc.Operator + } + if dmc.AlertSensitivity != "" { + objectMap["alertSensitivity"] = dmc.AlertSensitivity + } + if dmc.FailingPeriods != nil { + objectMap["failingPeriods"] = dmc.FailingPeriods + } + if dmc.IgnoreDataBefore != nil { + objectMap["ignoreDataBefore"] = dmc.IgnoreDataBefore + } + if dmc.Name != nil { + objectMap["name"] = dmc.Name + } + if dmc.MetricName != nil { + objectMap["metricName"] = dmc.MetricName + } + if dmc.MetricNamespace != nil { + objectMap["metricNamespace"] = dmc.MetricNamespace + } + if dmc.TimeAggregation != "" { + objectMap["timeAggregation"] = dmc.TimeAggregation + } + if dmc.Dimensions != nil { + objectMap["dimensions"] = dmc.Dimensions + } + if dmc.SkipMetricValidation != nil { + objectMap["skipMetricValidation"] = dmc.SkipMetricValidation + } + if dmc.CriterionType != "" { + objectMap["criterionType"] = dmc.CriterionType + } + for k, v := range dmc.AdditionalProperties { + objectMap[k] = v + } + return json.Marshal(objectMap) +} + +// AsMetricCriteria is the BasicMultiMetricCriteria implementation for DynamicMetricCriteria. +func (dmc DynamicMetricCriteria) AsMetricCriteria() (*MetricCriteria, bool) { + return nil, false +} + +// AsDynamicMetricCriteria is the BasicMultiMetricCriteria implementation for DynamicMetricCriteria. +func (dmc DynamicMetricCriteria) AsDynamicMetricCriteria() (*DynamicMetricCriteria, bool) { + return &dmc, true +} + +// AsMultiMetricCriteria is the BasicMultiMetricCriteria implementation for DynamicMetricCriteria. +func (dmc DynamicMetricCriteria) AsMultiMetricCriteria() (*MultiMetricCriteria, bool) { + return nil, false +} + +// AsBasicMultiMetricCriteria is the BasicMultiMetricCriteria implementation for DynamicMetricCriteria. +func (dmc DynamicMetricCriteria) AsBasicMultiMetricCriteria() (BasicMultiMetricCriteria, bool) { + return &dmc, true +} + +// UnmarshalJSON is the custom unmarshaler for DynamicMetricCriteria struct. +func (dmc *DynamicMetricCriteria) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "operator": + if v != nil { + var operator DynamicThresholdOperator + err = json.Unmarshal(*v, &operator) + if err != nil { + return err + } + dmc.Operator = operator + } + case "alertSensitivity": + if v != nil { + var alertSensitivity DynamicThresholdSensitivity + err = json.Unmarshal(*v, &alertSensitivity) + if err != nil { + return err + } + dmc.AlertSensitivity = alertSensitivity + } + case "failingPeriods": + if v != nil { + var failingPeriods DynamicThresholdFailingPeriods + err = json.Unmarshal(*v, &failingPeriods) + if err != nil { + return err + } + dmc.FailingPeriods = &failingPeriods + } + case "ignoreDataBefore": + if v != nil { + var ignoreDataBefore date.Time + err = json.Unmarshal(*v, &ignoreDataBefore) + if err != nil { + return err + } + dmc.IgnoreDataBefore = &ignoreDataBefore + } + default: + if v != nil { + var additionalProperties interface{} + err = json.Unmarshal(*v, &additionalProperties) + if err != nil { + return err + } + if dmc.AdditionalProperties == nil { + dmc.AdditionalProperties = make(map[string]interface{}) + } + dmc.AdditionalProperties[k] = additionalProperties + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + dmc.Name = &name + } + case "metricName": + if v != nil { + var metricName string + err = json.Unmarshal(*v, &metricName) + if err != nil { + return err + } + dmc.MetricName = &metricName + } + case "metricNamespace": + if v != nil { + var metricNamespace string + err = json.Unmarshal(*v, &metricNamespace) + if err != nil { + return err + } + dmc.MetricNamespace = &metricNamespace + } + case "timeAggregation": + if v != nil { + var timeAggregation AggregationTypeEnum + err = json.Unmarshal(*v, &timeAggregation) + if err != nil { + return err + } + dmc.TimeAggregation = timeAggregation + } + case "dimensions": + if v != nil { + var dimensions []MetricDimension + err = json.Unmarshal(*v, &dimensions) + if err != nil { + return err + } + dmc.Dimensions = &dimensions + } + case "skipMetricValidation": + if v != nil { + var skipMetricValidation bool + err = json.Unmarshal(*v, &skipMetricValidation) + if err != nil { + return err + } + dmc.SkipMetricValidation = &skipMetricValidation + } + case "criterionType": + if v != nil { + var criterionType CriterionType + err = json.Unmarshal(*v, &criterionType) + if err != nil { + return err + } + dmc.CriterionType = criterionType + } + } + } + + return nil +} + +// DynamicThresholdFailingPeriods the minimum number of violations required within the selected lookback +// time window required to raise an alert. +type DynamicThresholdFailingPeriods struct { + // NumberOfEvaluationPeriods - The number of aggregated lookback points. The lookback time window is calculated based on the aggregation granularity (windowSize) and the selected number of aggregated points. + NumberOfEvaluationPeriods *float64 `json:"numberOfEvaluationPeriods,omitempty"` + // MinFailingPeriodsToAlert - The number of violations to trigger an alert. Should be smaller or equal to numberOfEvaluationPeriods. + MinFailingPeriodsToAlert *float64 `json:"minFailingPeriodsToAlert,omitempty"` +} + +// EmailNotification email notification of an autoscale event. +type EmailNotification struct { + // SendToSubscriptionAdministrator - a value indicating whether to send email to subscription administrator. + SendToSubscriptionAdministrator *bool `json:"sendToSubscriptionAdministrator,omitempty"` + // SendToSubscriptionCoAdministrators - a value indicating whether to send email to subscription co-administrators. + SendToSubscriptionCoAdministrators *bool `json:"sendToSubscriptionCoAdministrators,omitempty"` + // CustomEmails - the custom e-mails list. This value can be null or empty, in which case this attribute will be ignored. + CustomEmails *[]string `json:"customEmails,omitempty"` +} + +// EmailReceiver an email receiver. +type EmailReceiver struct { + // Name - The name of the email receiver. Names must be unique across all receivers within an action group. + Name *string `json:"name,omitempty"` + // EmailAddress - The email address of this receiver. + EmailAddress *string `json:"emailAddress,omitempty"` + // UseCommonAlertSchema - Indicates whether to use common alert schema. + UseCommonAlertSchema *bool `json:"useCommonAlertSchema,omitempty"` + // Status - READ-ONLY; The receiver status of the e-mail. Possible values include: 'ReceiverStatusNotSpecified', 'ReceiverStatusEnabled', 'ReceiverStatusDisabled' + Status ReceiverStatus `json:"status,omitempty"` +} + +// MarshalJSON is the custom marshaler for EmailReceiver. +func (er EmailReceiver) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if er.Name != nil { + objectMap["name"] = er.Name + } + if er.EmailAddress != nil { + objectMap["emailAddress"] = er.EmailAddress + } + if er.UseCommonAlertSchema != nil { + objectMap["useCommonAlertSchema"] = er.UseCommonAlertSchema + } + return json.Marshal(objectMap) +} + +// EnableRequest describes a receiver that should be resubscribed. +type EnableRequest struct { + // ReceiverName - The name of the receiver to resubscribe. + ReceiverName *string `json:"receiverName,omitempty"` +} + +// Error error details. +type Error struct { + // Code - Error code identifying the specific error. + Code *string `json:"code,omitempty"` + // Message - Error message in the caller's locale. + Message *string `json:"message,omitempty"` +} + +// ErrorAdditionalInfo the resource management error additional info. +type ErrorAdditionalInfo struct { + // Type - READ-ONLY; The additional info type. + Type *string `json:"type,omitempty"` + // Info - READ-ONLY; The additional info. + Info interface{} `json:"info,omitempty"` +} + +// MarshalJSON is the custom marshaler for ErrorAdditionalInfo. +func (eai ErrorAdditionalInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ErrorContract describes the format of Error response. +type ErrorContract struct { + // Error - The error details. + Error *ErrorResponse `json:"error,omitempty"` +} + +// ErrorDetail the error detail. +type ErrorDetail struct { + // Code - READ-ONLY; The error code. + Code *string `json:"code,omitempty"` + // Message - READ-ONLY; The error message. + Message *string `json:"message,omitempty"` + // Target - READ-ONLY; The error target. + Target *string `json:"target,omitempty"` + // Details - READ-ONLY; The error details. + Details *[]ErrorDetail `json:"details,omitempty"` + // AdditionalInfo - READ-ONLY; The error additional info. + AdditionalInfo *[]ErrorAdditionalInfo `json:"additionalInfo,omitempty"` +} + +// MarshalJSON is the custom marshaler for ErrorDetail. +func (ed ErrorDetail) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ErrorResponse describes the format of Error response. +type ErrorResponse struct { + // Code - Error code + Code *string `json:"code,omitempty"` + // Message - Error message indicating why the operation failed. + Message *string `json:"message,omitempty"` +} + +// ErrorResponseCommon the resource management error response. +type ErrorResponseCommon struct { + // Details - READ-ONLY; The error details. + Details *[]ErrorResponseCommon `json:"details,omitempty"` + // AdditionalInfo - READ-ONLY; The error additional info. + AdditionalInfo *[]ErrorAdditionalInfo `json:"additionalInfo,omitempty"` + // Code - Error code + Code *string `json:"code,omitempty"` + // Message - Error message indicating why the operation failed. + Message *string `json:"message,omitempty"` +} + +// MarshalJSON is the custom marshaler for ErrorResponseCommon. +func (erc ErrorResponseCommon) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if erc.Code != nil { + objectMap["code"] = erc.Code + } + if erc.Message != nil { + objectMap["message"] = erc.Message + } + return json.Marshal(objectMap) +} + +// ErrorResponseCommonV2 common error response for all Azure Resource Manager APIs to return error details +// for failed operations. (This also follows the OData error response format.). +type ErrorResponseCommonV2 struct { + // Error - The error object. + Error *ErrorDetail `json:"error,omitempty"` +} + +// EventCategoryCollection a collection of event categories. Currently possible values are: Administrative, +// Security, ServiceHealth, Alert, Recommendation, Policy. +type EventCategoryCollection struct { + autorest.Response `json:"-"` + // Value - the list that includes the Azure event categories. + Value *[]LocalizableString `json:"value,omitempty"` +} + +// EventData the Azure event log entries are of type EventData +type EventData struct { + // Authorization - READ-ONLY; The sender authorization information. + Authorization *SenderAuthorization `json:"authorization,omitempty"` + // Claims - READ-ONLY; key value pairs to identify ARM permissions. + Claims map[string]*string `json:"claims"` + // Caller - READ-ONLY; the email address of the user who has performed the operation, the UPN claim or SPN claim based on availability. + Caller *string `json:"caller,omitempty"` + // Description - READ-ONLY; the description of the event. + Description *string `json:"description,omitempty"` + // ID - READ-ONLY; the Id of this event as required by ARM for RBAC. It contains the EventDataID and a timestamp information. + ID *string `json:"id,omitempty"` + // EventDataID - READ-ONLY; the event data Id. This is a unique identifier for an event. + EventDataID *string `json:"eventDataId,omitempty"` + // CorrelationID - READ-ONLY; the correlation Id, usually a GUID in the string format. The correlation Id is shared among the events that belong to the same uber operation. + CorrelationID *string `json:"correlationId,omitempty"` + // EventName - READ-ONLY; the event name. This value should not be confused with OperationName. For practical purposes, OperationName might be more appealing to end users. + EventName *LocalizableString `json:"eventName,omitempty"` + // Category - READ-ONLY; the event category. + Category *LocalizableString `json:"category,omitempty"` + // HTTPRequest - READ-ONLY; the HTTP request info. Usually includes the 'clientRequestId', 'clientIpAddress' (IP address of the user who initiated the event) and 'method' (HTTP method e.g. PUT). + HTTPRequest *HTTPRequestInfo `json:"httpRequest,omitempty"` + // Level - READ-ONLY; the event level. Possible values include: 'EventLevelCritical', 'EventLevelError', 'EventLevelWarning', 'EventLevelInformational', 'EventLevelVerbose' + Level EventLevel `json:"level,omitempty"` + // ResourceGroupName - READ-ONLY; the resource group name of the impacted resource. + ResourceGroupName *string `json:"resourceGroupName,omitempty"` + // ResourceProviderName - READ-ONLY; the resource provider name of the impacted resource. + ResourceProviderName *LocalizableString `json:"resourceProviderName,omitempty"` + // ResourceID - READ-ONLY; the resource uri that uniquely identifies the resource that caused this event. + ResourceID *string `json:"resourceId,omitempty"` + // ResourceType - READ-ONLY; the resource type + ResourceType *LocalizableString `json:"resourceType,omitempty"` + // OperationID - READ-ONLY; It is usually a GUID shared among the events corresponding to single operation. This value should not be confused with EventName. + OperationID *string `json:"operationId,omitempty"` + // OperationName - READ-ONLY; the operation name. + OperationName *LocalizableString `json:"operationName,omitempty"` + // Properties - READ-ONLY; the set of pairs (usually a Dictionary) that includes details about the event. + Properties map[string]*string `json:"properties"` + // Status - READ-ONLY; a string describing the status of the operation. Some typical values are: Started, In progress, Succeeded, Failed, Resolved. + Status *LocalizableString `json:"status,omitempty"` + // SubStatus - READ-ONLY; the event sub status. Most of the time, when included, this captures the HTTP status code of the REST call. Common values are: OK (HTTP Status Code: 200), Created (HTTP Status Code: 201), Accepted (HTTP Status Code: 202), No Content (HTTP Status Code: 204), Bad Request(HTTP Status Code: 400), Not Found (HTTP Status Code: 404), Conflict (HTTP Status Code: 409), Internal Server Error (HTTP Status Code: 500), Service Unavailable (HTTP Status Code:503), Gateway Timeout (HTTP Status Code: 504) + SubStatus *LocalizableString `json:"subStatus,omitempty"` + // EventTimestamp - READ-ONLY; the timestamp of when the event was generated by the Azure service processing the request corresponding the event. It in ISO 8601 format. + EventTimestamp *date.Time `json:"eventTimestamp,omitempty"` + // SubmissionTimestamp - READ-ONLY; the timestamp of when the event became available for querying via this API. It is in ISO 8601 format. This value should not be confused eventTimestamp. As there might be a delay between the occurrence time of the event, and the time that the event is submitted to the Azure logging infrastructure. + SubmissionTimestamp *date.Time `json:"submissionTimestamp,omitempty"` + // SubscriptionID - READ-ONLY; the Azure subscription Id usually a GUID. + SubscriptionID *string `json:"subscriptionId,omitempty"` + // TenantID - READ-ONLY; the Azure tenant Id + TenantID *string `json:"tenantId,omitempty"` +} + +// MarshalJSON is the custom marshaler for EventData. +func (ed EventData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// EventDataCollection represents collection of events. +type EventDataCollection struct { + autorest.Response `json:"-"` + // Value - this list that includes the Azure audit logs. + Value *[]EventData `json:"value,omitempty"` + // NextLink - Provides the link to retrieve the next set of events. + NextLink *string `json:"nextLink,omitempty"` +} + +// EventDataCollectionIterator provides access to a complete listing of EventData values. +type EventDataCollectionIterator struct { + i int + page EventDataCollectionPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *EventDataCollectionIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/EventDataCollectionIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *EventDataCollectionIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter EventDataCollectionIterator) 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 EventDataCollectionIterator) Response() EventDataCollection { + 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 EventDataCollectionIterator) Value() EventData { + if !iter.page.NotDone() { + return EventData{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the EventDataCollectionIterator type. +func NewEventDataCollectionIterator(page EventDataCollectionPage) EventDataCollectionIterator { + return EventDataCollectionIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (edc EventDataCollection) IsEmpty() bool { + return edc.Value == nil || len(*edc.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (edc EventDataCollection) hasNextLink() bool { + return edc.NextLink != nil && len(*edc.NextLink) != 0 +} + +// eventDataCollectionPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (edc EventDataCollection) eventDataCollectionPreparer(ctx context.Context) (*http.Request, error) { + if !edc.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(edc.NextLink))) +} + +// EventDataCollectionPage contains a page of EventData values. +type EventDataCollectionPage struct { + fn func(context.Context, EventDataCollection) (EventDataCollection, error) + edc EventDataCollection +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *EventDataCollectionPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/EventDataCollectionPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.edc) + if err != nil { + return err + } + page.edc = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *EventDataCollectionPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page EventDataCollectionPage) NotDone() bool { + return !page.edc.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page EventDataCollectionPage) Response() EventDataCollection { + return page.edc +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page EventDataCollectionPage) Values() []EventData { + if page.edc.IsEmpty() { + return nil + } + return *page.edc.Value +} + +// Creates a new instance of the EventDataCollectionPage type. +func NewEventDataCollectionPage(cur EventDataCollection, getNextPage func(context.Context, EventDataCollection) (EventDataCollection, error)) EventDataCollectionPage { + return EventDataCollectionPage{ + fn: getNextPage, + edc: cur, + } +} + +// ExtensionDataSource definition of which data will be collected from a separate VM extension that +// integrates with the Azure Monitor Agent. +// Collected from either Windows and Linux machines, depending on which extension is defined. +type ExtensionDataSource struct { + // Streams - List of streams that this data source will be sent to. + // A stream indicates what schema will be used for this data and usually what table in Log Analytics the data will be sent to. + Streams *[]KnownExtensionDataSourceStreams `json:"streams,omitempty"` + // ExtensionName - The name of the VM extension. + ExtensionName *string `json:"extensionName,omitempty"` + // ExtensionSettings - The extension settings. The format is specific for particular extension. + ExtensionSettings interface{} `json:"extensionSettings,omitempty"` + // InputDataSources - The list of data sources this extension needs data from. + InputDataSources *[]string `json:"inputDataSources,omitempty"` + // Name - A friendly name for the data source. + // This name should be unique across all data sources (regardless of type) within the data collection rule. + Name *string `json:"name,omitempty"` +} + +// HTTPRequestInfo the Http request info. +type HTTPRequestInfo struct { + // ClientRequestID - the client request id. + ClientRequestID *string `json:"clientRequestId,omitempty"` + // ClientIPAddress - the client Ip Address + ClientIPAddress *string `json:"clientIpAddress,omitempty"` + // Method - the Http request method. + Method *string `json:"method,omitempty"` + // URI - the Uri. + URI *string `json:"uri,omitempty"` +} + +// Incident an alert incident indicates the activation status of an alert rule. +type Incident struct { + autorest.Response `json:"-"` + // Name - READ-ONLY; Incident name. + Name *string `json:"name,omitempty"` + // RuleName - READ-ONLY; Rule name that is associated with the incident. + RuleName *string `json:"ruleName,omitempty"` + // IsActive - READ-ONLY; A boolean to indicate whether the incident is active or resolved. + IsActive *bool `json:"isActive,omitempty"` + // ActivatedTime - READ-ONLY; The time at which the incident was activated in ISO8601 format. + ActivatedTime *date.Time `json:"activatedTime,omitempty"` + // ResolvedTime - READ-ONLY; The time at which the incident was resolved in ISO8601 format. If null, it means the incident is still active. + ResolvedTime *date.Time `json:"resolvedTime,omitempty"` +} + +// MarshalJSON is the custom marshaler for Incident. +func (i Incident) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// IncidentListResult the List incidents operation response. +type IncidentListResult struct { + autorest.Response `json:"-"` + // Value - the incident collection. + Value *[]Incident `json:"value,omitempty"` +} + +// ItsmReceiver an Itsm receiver. +type ItsmReceiver struct { + // Name - The name of the Itsm receiver. Names must be unique across all receivers within an action group. + Name *string `json:"name,omitempty"` + // WorkspaceID - OMS LA instance identifier. + WorkspaceID *string `json:"workspaceId,omitempty"` + // ConnectionID - Unique identification of ITSM connection among multiple defined in above workspace. + ConnectionID *string `json:"connectionId,omitempty"` + // TicketConfiguration - JSON blob for the configurations of the ITSM action. CreateMultipleWorkItems option will be part of this blob as well. + TicketConfiguration *string `json:"ticketConfiguration,omitempty"` + // Region - Region in which workspace resides. Supported values:'centralindia','japaneast','southeastasia','australiasoutheast','uksouth','westcentralus','canadacentral','eastus','westeurope' + Region *string `json:"region,omitempty"` +} + +// LocalizableString the localizable string class. +type LocalizableString struct { + // Value - the invariant value. + Value *string `json:"value,omitempty"` + // LocalizedValue - the locale specific value. + LocalizedValue *string `json:"localizedValue,omitempty"` +} + +// LocationThresholdRuleCondition a rule condition based on a certain number of locations failing. +type LocationThresholdRuleCondition struct { + // WindowSize - the period of time (in ISO 8601 duration format) that is used to monitor alert activity based on the threshold. If specified then it must be between 5 minutes and 1 day. + WindowSize *string `json:"windowSize,omitempty"` + // FailedLocationCount - the number of locations that must fail to activate the alert. + FailedLocationCount *int32 `json:"failedLocationCount,omitempty"` + // DataSource - the resource from which the rule collects its data. For this type dataSource will always be of type RuleMetricDataSource. + DataSource BasicRuleDataSource `json:"dataSource,omitempty"` + // OdataType - Possible values include: 'OdataTypeBasicRuleConditionOdataTypeRuleCondition', 'OdataTypeBasicRuleConditionOdataTypeMicrosoftAzureManagementInsightsModelsThresholdRuleCondition', 'OdataTypeBasicRuleConditionOdataTypeMicrosoftAzureManagementInsightsModelsLocationThresholdRuleCondition', 'OdataTypeBasicRuleConditionOdataTypeMicrosoftAzureManagementInsightsModelsManagementEventRuleCondition' + OdataType OdataTypeBasicRuleCondition `json:"odata.type,omitempty"` +} + +// MarshalJSON is the custom marshaler for LocationThresholdRuleCondition. +func (ltrc LocationThresholdRuleCondition) MarshalJSON() ([]byte, error) { + ltrc.OdataType = OdataTypeBasicRuleConditionOdataTypeMicrosoftAzureManagementInsightsModelsLocationThresholdRuleCondition + objectMap := make(map[string]interface{}) + if ltrc.WindowSize != nil { + objectMap["windowSize"] = ltrc.WindowSize + } + if ltrc.FailedLocationCount != nil { + objectMap["failedLocationCount"] = ltrc.FailedLocationCount + } + objectMap["dataSource"] = ltrc.DataSource + if ltrc.OdataType != "" { + objectMap["odata.type"] = ltrc.OdataType + } + return json.Marshal(objectMap) +} + +// AsThresholdRuleCondition is the BasicRuleCondition implementation for LocationThresholdRuleCondition. +func (ltrc LocationThresholdRuleCondition) AsThresholdRuleCondition() (*ThresholdRuleCondition, bool) { + return nil, false +} + +// AsLocationThresholdRuleCondition is the BasicRuleCondition implementation for LocationThresholdRuleCondition. +func (ltrc LocationThresholdRuleCondition) AsLocationThresholdRuleCondition() (*LocationThresholdRuleCondition, bool) { + return <rc, true +} + +// AsManagementEventRuleCondition is the BasicRuleCondition implementation for LocationThresholdRuleCondition. +func (ltrc LocationThresholdRuleCondition) AsManagementEventRuleCondition() (*ManagementEventRuleCondition, bool) { + return nil, false +} + +// AsRuleCondition is the BasicRuleCondition implementation for LocationThresholdRuleCondition. +func (ltrc LocationThresholdRuleCondition) AsRuleCondition() (*RuleCondition, bool) { + return nil, false +} + +// AsBasicRuleCondition is the BasicRuleCondition implementation for LocationThresholdRuleCondition. +func (ltrc LocationThresholdRuleCondition) AsBasicRuleCondition() (BasicRuleCondition, bool) { + return <rc, true +} + +// UnmarshalJSON is the custom unmarshaler for LocationThresholdRuleCondition struct. +func (ltrc *LocationThresholdRuleCondition) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "windowSize": + if v != nil { + var windowSize string + err = json.Unmarshal(*v, &windowSize) + if err != nil { + return err + } + ltrc.WindowSize = &windowSize + } + case "failedLocationCount": + if v != nil { + var failedLocationCount int32 + err = json.Unmarshal(*v, &failedLocationCount) + if err != nil { + return err + } + ltrc.FailedLocationCount = &failedLocationCount + } + case "dataSource": + if v != nil { + dataSource, err := unmarshalBasicRuleDataSource(*v) + if err != nil { + return err + } + ltrc.DataSource = dataSource + } + case "odata.type": + if v != nil { + var odataType OdataTypeBasicRuleCondition + err = json.Unmarshal(*v, &odataType) + if err != nil { + return err + } + ltrc.OdataType = odataType + } + } + } + + return nil +} + +// LogAnalyticsDestination log Analytics destination. +type LogAnalyticsDestination struct { + // WorkspaceResourceID - The resource ID of the Log Analytics workspace. + WorkspaceResourceID *string `json:"workspaceResourceId,omitempty"` + // WorkspaceID - READ-ONLY; The Customer ID of the Log Analytics workspace. + WorkspaceID *string `json:"workspaceId,omitempty"` + // Name - A friendly name for the destination. + // This name should be unique across all destinations (regardless of type) within the data collection rule. + Name *string `json:"name,omitempty"` +} + +// MarshalJSON is the custom marshaler for LogAnalyticsDestination. +func (lad LogAnalyticsDestination) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if lad.WorkspaceResourceID != nil { + objectMap["workspaceResourceId"] = lad.WorkspaceResourceID + } + if lad.Name != nil { + objectMap["name"] = lad.Name + } + return json.Marshal(objectMap) +} + +// LogicAppReceiver a logic app receiver. +type LogicAppReceiver struct { + // Name - The name of the logic app receiver. Names must be unique across all receivers within an action group. + Name *string `json:"name,omitempty"` + // ResourceID - The azure resource id of the logic app receiver. + ResourceID *string `json:"resourceId,omitempty"` + // CallbackURL - The callback url where http request sent to. + CallbackURL *string `json:"callbackUrl,omitempty"` + // UseCommonAlertSchema - Indicates whether to use common alert schema. + UseCommonAlertSchema *bool `json:"useCommonAlertSchema,omitempty"` +} + +// LogMetricTrigger a log metrics trigger descriptor. +type LogMetricTrigger struct { + // ThresholdOperator - Evaluation operation for Metric -'GreaterThan' or 'LessThan' or 'Equal'. Possible values include: 'ConditionalOperatorGreaterThanOrEqual', 'ConditionalOperatorLessThanOrEqual', 'ConditionalOperatorGreaterThan', 'ConditionalOperatorLessThan', 'ConditionalOperatorEqual' + ThresholdOperator ConditionalOperator `json:"thresholdOperator,omitempty"` + // Threshold - The threshold of the metric trigger. + Threshold *float64 `json:"threshold,omitempty"` + // MetricTriggerType - Metric Trigger Type - 'Consecutive' or 'Total'. Possible values include: 'MetricTriggerTypeConsecutive', 'MetricTriggerTypeTotal' + MetricTriggerType MetricTriggerType `json:"metricTriggerType,omitempty"` + // MetricColumn - Evaluation of metric on a particular column + MetricColumn *string `json:"metricColumn,omitempty"` +} + +// LogProfileCollection represents a collection of log profiles. +type LogProfileCollection struct { + autorest.Response `json:"-"` + // Value - the values of the log profiles. + Value *[]LogProfileResource `json:"value,omitempty"` +} + +// LogProfileProperties the log profile properties. +type LogProfileProperties struct { + // StorageAccountID - the resource id of the storage account to which you would like to send the Activity Log. + StorageAccountID *string `json:"storageAccountId,omitempty"` + // ServiceBusRuleID - The service bus rule ID of the service bus namespace in which you would like to have Event Hubs created for streaming the Activity Log. The rule ID is of the format: '{service bus resource ID}/authorizationrules/{key name}'. + ServiceBusRuleID *string `json:"serviceBusRuleId,omitempty"` + // Locations - List of regions for which Activity Log events should be stored or streamed. It is a comma separated list of valid ARM locations including the 'global' location. + Locations *[]string `json:"locations,omitempty"` + // Categories - the categories of the logs. These categories are created as is convenient to the user. Some values are: 'Write', 'Delete', and/or 'Action.' + Categories *[]string `json:"categories,omitempty"` + // RetentionPolicy - the retention policy for the events in the log. + RetentionPolicy *RetentionPolicy `json:"retentionPolicy,omitempty"` +} + +// LogProfileResource the log profile resource. +type LogProfileResource struct { + autorest.Response `json:"-"` + // LogProfileProperties - The log profile properties of the resource. + *LogProfileProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Azure resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Azure resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Azure resource type + Type *string `json:"type,omitempty"` + // Location - Resource location + Location *string `json:"location,omitempty"` + // Tags - Resource tags + Tags map[string]*string `json:"tags"` + // Kind - READ-ONLY; Metadata used by portal/tooling/etc to render different UX experiences for resources of the same type; e.g. ApiApps are a kind of Microsoft.Web/sites type. If supported, the resource provider must validate and persist this value. + Kind *string `json:"kind,omitempty"` + // Etag - READ-ONLY; The etag field is *not* required. If it is provided in the response body, it must also be provided as a header per the normal etag convention. Entity tags are used for comparing two or more entities from the same requested resource. HTTP/1.1 uses entity tags in the etag (section 14.19), If-Match (section 14.24), If-None-Match (section 14.26), and If-Range (section 14.27) header fields. + Etag *string `json:"etag,omitempty"` +} + +// MarshalJSON is the custom marshaler for LogProfileResource. +func (lpr LogProfileResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if lpr.LogProfileProperties != nil { + objectMap["properties"] = lpr.LogProfileProperties + } + if lpr.Location != nil { + objectMap["location"] = lpr.Location + } + if lpr.Tags != nil { + objectMap["tags"] = lpr.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for LogProfileResource struct. +func (lpr *LogProfileResource) UnmarshalJSON(body []byte) error { + 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 logProfileProperties LogProfileProperties + err = json.Unmarshal(*v, &logProfileProperties) + if err != nil { + return err + } + lpr.LogProfileProperties = &logProfileProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + lpr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + lpr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + lpr.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + lpr.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + lpr.Tags = tags + } + case "kind": + if v != nil { + var kind string + err = json.Unmarshal(*v, &kind) + if err != nil { + return err + } + lpr.Kind = &kind + } + case "etag": + if v != nil { + var etag string + err = json.Unmarshal(*v, &etag) + if err != nil { + return err + } + lpr.Etag = &etag + } + } + } + + return nil +} + +// LogProfileResourcePatch the log profile resource for patch operations. +type LogProfileResourcePatch struct { + // Tags - Resource tags + Tags map[string]*string `json:"tags"` + // LogProfileProperties - The log profile properties for an update operation. + *LogProfileProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for LogProfileResourcePatch. +func (lprp LogProfileResourcePatch) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if lprp.Tags != nil { + objectMap["tags"] = lprp.Tags + } + if lprp.LogProfileProperties != nil { + objectMap["properties"] = lprp.LogProfileProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for LogProfileResourcePatch struct. +func (lprp *LogProfileResourcePatch) UnmarshalJSON(body []byte) error { + 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 + } + lprp.Tags = tags + } + case "properties": + if v != nil { + var logProfileProperties LogProfileProperties + err = json.Unmarshal(*v, &logProfileProperties) + if err != nil { + return err + } + lprp.LogProfileProperties = &logProfileProperties + } + } + } + + return nil +} + +// LogSearchRule log Search Rule Definition +type LogSearchRule struct { + // CreatedWithAPIVersion - READ-ONLY; The api-version used when creating this alert rule + CreatedWithAPIVersion *string `json:"createdWithApiVersion,omitempty"` + // IsLegacyLogAnalyticsRule - READ-ONLY; True if alert rule is legacy Log Analytic rule + IsLegacyLogAnalyticsRule *bool `json:"isLegacyLogAnalyticsRule,omitempty"` + // Description - The description of the Log Search rule. + Description *string `json:"description,omitempty"` + // DisplayName - The display name of the alert rule + DisplayName *string `json:"displayName,omitempty"` + // AutoMitigate - The flag that indicates whether the alert should be automatically resolved or not. The default is false. + AutoMitigate *bool `json:"autoMitigate,omitempty"` + // Enabled - The flag which indicates whether the Log Search rule is enabled. Value should be true or false. Possible values include: 'EnabledTrue', 'EnabledFalse' + Enabled Enabled `json:"enabled,omitempty"` + // LastUpdatedTime - READ-ONLY; Last time the rule was updated in IS08601 format. + LastUpdatedTime *date.Time `json:"lastUpdatedTime,omitempty"` + // ProvisioningState - READ-ONLY; Provisioning state of the scheduled query rule. Possible values include: 'ProvisioningStateSucceeded', 'ProvisioningStateDeploying', 'ProvisioningStateCanceled', 'ProvisioningStateFailed' + ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` + // Source - Data Source against which rule will Query Data + Source *Source `json:"source,omitempty"` + // Schedule - Schedule (Frequency, Time Window) for rule. Required for action type - AlertingAction + Schedule *Schedule `json:"schedule,omitempty"` + // Action - Action needs to be taken on rule execution. + Action BasicAction `json:"action,omitempty"` +} + +// MarshalJSON is the custom marshaler for LogSearchRule. +func (lsr LogSearchRule) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if lsr.Description != nil { + objectMap["description"] = lsr.Description + } + if lsr.DisplayName != nil { + objectMap["displayName"] = lsr.DisplayName + } + if lsr.AutoMitigate != nil { + objectMap["autoMitigate"] = lsr.AutoMitigate + } + if lsr.Enabled != "" { + objectMap["enabled"] = lsr.Enabled + } + if lsr.Source != nil { + objectMap["source"] = lsr.Source + } + if lsr.Schedule != nil { + objectMap["schedule"] = lsr.Schedule + } + objectMap["action"] = lsr.Action + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for LogSearchRule struct. +func (lsr *LogSearchRule) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "createdWithApiVersion": + if v != nil { + var createdWithAPIVersion string + err = json.Unmarshal(*v, &createdWithAPIVersion) + if err != nil { + return err + } + lsr.CreatedWithAPIVersion = &createdWithAPIVersion + } + case "isLegacyLogAnalyticsRule": + if v != nil { + var isLegacyLogAnalyticsRule bool + err = json.Unmarshal(*v, &isLegacyLogAnalyticsRule) + if err != nil { + return err + } + lsr.IsLegacyLogAnalyticsRule = &isLegacyLogAnalyticsRule + } + case "description": + if v != nil { + var description string + err = json.Unmarshal(*v, &description) + if err != nil { + return err + } + lsr.Description = &description + } + case "displayName": + if v != nil { + var displayName string + err = json.Unmarshal(*v, &displayName) + if err != nil { + return err + } + lsr.DisplayName = &displayName + } + case "autoMitigate": + if v != nil { + var autoMitigate bool + err = json.Unmarshal(*v, &autoMitigate) + if err != nil { + return err + } + lsr.AutoMitigate = &autoMitigate + } + case "enabled": + if v != nil { + var enabled Enabled + err = json.Unmarshal(*v, &enabled) + if err != nil { + return err + } + lsr.Enabled = enabled + } + case "lastUpdatedTime": + if v != nil { + var lastUpdatedTime date.Time + err = json.Unmarshal(*v, &lastUpdatedTime) + if err != nil { + return err + } + lsr.LastUpdatedTime = &lastUpdatedTime + } + case "provisioningState": + if v != nil { + var provisioningState ProvisioningState + err = json.Unmarshal(*v, &provisioningState) + if err != nil { + return err + } + lsr.ProvisioningState = provisioningState + } + case "source": + if v != nil { + var source Source + err = json.Unmarshal(*v, &source) + if err != nil { + return err + } + lsr.Source = &source + } + case "schedule": + if v != nil { + var schedule Schedule + err = json.Unmarshal(*v, &schedule) + if err != nil { + return err + } + lsr.Schedule = &schedule + } + case "action": + if v != nil { + action, err := unmarshalBasicAction(*v) + if err != nil { + return err + } + lsr.Action = action + } + } + } + + return nil +} + +// LogSearchRulePatch log Search Rule Definition for Patching +type LogSearchRulePatch struct { + // Enabled - The flag which indicates whether the Log Search rule is enabled. Value should be true or false. Possible values include: 'EnabledTrue', 'EnabledFalse' + Enabled Enabled `json:"enabled,omitempty"` +} + +// LogSearchRuleResource the Log Search Rule resource. +type LogSearchRuleResource struct { + autorest.Response `json:"-"` + // LogSearchRule - The rule properties of the resource. + *LogSearchRule `json:"properties,omitempty"` + // ID - READ-ONLY; Azure resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Azure resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Azure resource type + Type *string `json:"type,omitempty"` + // Location - Resource location + Location *string `json:"location,omitempty"` + // Tags - Resource tags + Tags map[string]*string `json:"tags"` + // Kind - READ-ONLY; Metadata used by portal/tooling/etc to render different UX experiences for resources of the same type; e.g. ApiApps are a kind of Microsoft.Web/sites type. If supported, the resource provider must validate and persist this value. + Kind *string `json:"kind,omitempty"` + // Etag - READ-ONLY; The etag field is *not* required. If it is provided in the response body, it must also be provided as a header per the normal etag convention. Entity tags are used for comparing two or more entities from the same requested resource. HTTP/1.1 uses entity tags in the etag (section 14.19), If-Match (section 14.24), If-None-Match (section 14.26), and If-Range (section 14.27) header fields. + Etag *string `json:"etag,omitempty"` +} + +// MarshalJSON is the custom marshaler for LogSearchRuleResource. +func (lsrr LogSearchRuleResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if lsrr.LogSearchRule != nil { + objectMap["properties"] = lsrr.LogSearchRule + } + if lsrr.Location != nil { + objectMap["location"] = lsrr.Location + } + if lsrr.Tags != nil { + objectMap["tags"] = lsrr.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for LogSearchRuleResource struct. +func (lsrr *LogSearchRuleResource) UnmarshalJSON(body []byte) error { + 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 logSearchRule LogSearchRule + err = json.Unmarshal(*v, &logSearchRule) + if err != nil { + return err + } + lsrr.LogSearchRule = &logSearchRule + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + lsrr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + lsrr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + lsrr.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + lsrr.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + lsrr.Tags = tags + } + case "kind": + if v != nil { + var kind string + err = json.Unmarshal(*v, &kind) + if err != nil { + return err + } + lsrr.Kind = &kind + } + case "etag": + if v != nil { + var etag string + err = json.Unmarshal(*v, &etag) + if err != nil { + return err + } + lsrr.Etag = &etag + } + } + } + + return nil +} + +// LogSearchRuleResourceCollection represents a collection of Log Search rule resources. +type LogSearchRuleResourceCollection struct { + autorest.Response `json:"-"` + // Value - The values for the Log Search Rule resources. + Value *[]LogSearchRuleResource `json:"value,omitempty"` +} + +// LogSearchRuleResourcePatch the log search rule resource for patch operations. +type LogSearchRuleResourcePatch struct { + // Tags - Resource tags + Tags map[string]*string `json:"tags"` + // LogSearchRulePatch - The log search rule properties of the resource. + *LogSearchRulePatch `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for LogSearchRuleResourcePatch. +func (lsrrp LogSearchRuleResourcePatch) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if lsrrp.Tags != nil { + objectMap["tags"] = lsrrp.Tags + } + if lsrrp.LogSearchRulePatch != nil { + objectMap["properties"] = lsrrp.LogSearchRulePatch + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for LogSearchRuleResourcePatch struct. +func (lsrrp *LogSearchRuleResourcePatch) UnmarshalJSON(body []byte) error { + 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 + } + lsrrp.Tags = tags + } + case "properties": + if v != nil { + var logSearchRulePatch LogSearchRulePatch + err = json.Unmarshal(*v, &logSearchRulePatch) + if err != nil { + return err + } + lsrrp.LogSearchRulePatch = &logSearchRulePatch + } + } + } + + return nil +} + +// LogSettings part of MultiTenantDiagnosticSettings. Specifies the settings for a particular log. +type LogSettings struct { + // Category - Name of a Diagnostic Log category for a resource type this setting is applied to. To obtain the list of Diagnostic Log categories for a resource, first perform a GET diagnostic settings operation. + Category *string `json:"category,omitempty"` + // Enabled - a value indicating whether this log is enabled. + Enabled *bool `json:"enabled,omitempty"` + // RetentionPolicy - the retention policy for this log. + RetentionPolicy *RetentionPolicy `json:"retentionPolicy,omitempty"` +} + +// LogsIngestionEndpointSpec definition of the endpoint used for ingesting logs. +type LogsIngestionEndpointSpec struct { + // Endpoint - READ-ONLY; The endpoint. This property is READ-ONLY. + Endpoint *string `json:"endpoint,omitempty"` +} + +// MarshalJSON is the custom marshaler for LogsIngestionEndpointSpec. +func (lies LogsIngestionEndpointSpec) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// LogToMetricAction specify action need to be taken when rule type is converting log to metric +type LogToMetricAction struct { + // Criteria - Criteria of Metric + Criteria *[]Criteria `json:"criteria,omitempty"` + // OdataType - Possible values include: 'OdataTypeBasicActionOdataTypeAction', 'OdataTypeBasicActionOdataTypeMicrosoftWindowsAzureManagementMonitoringAlertsModelsMicrosoftAppInsightsNexusDataContractsResourcesScheduledQueryRulesAlertingAction', 'OdataTypeBasicActionOdataTypeMicrosoftWindowsAzureManagementMonitoringAlertsModelsMicrosoftAppInsightsNexusDataContractsResourcesScheduledQueryRulesLogToMetricAction' + OdataType OdataTypeBasicAction `json:"odata.type,omitempty"` +} + +// MarshalJSON is the custom marshaler for LogToMetricAction. +func (ltma LogToMetricAction) MarshalJSON() ([]byte, error) { + ltma.OdataType = OdataTypeBasicActionOdataTypeMicrosoftWindowsAzureManagementMonitoringAlertsModelsMicrosoftAppInsightsNexusDataContractsResourcesScheduledQueryRulesLogToMetricAction + objectMap := make(map[string]interface{}) + if ltma.Criteria != nil { + objectMap["criteria"] = ltma.Criteria + } + if ltma.OdataType != "" { + objectMap["odata.type"] = ltma.OdataType + } + return json.Marshal(objectMap) +} + +// AsAlertingAction is the BasicAction implementation for LogToMetricAction. +func (ltma LogToMetricAction) AsAlertingAction() (*AlertingAction, bool) { + return nil, false +} + +// AsLogToMetricAction is the BasicAction implementation for LogToMetricAction. +func (ltma LogToMetricAction) AsLogToMetricAction() (*LogToMetricAction, bool) { + return <ma, true +} + +// AsAction is the BasicAction implementation for LogToMetricAction. +func (ltma LogToMetricAction) AsAction() (*Action, bool) { + return nil, false +} + +// AsBasicAction is the BasicAction implementation for LogToMetricAction. +func (ltma LogToMetricAction) AsBasicAction() (BasicAction, bool) { + return <ma, true +} + +// ManagementEventAggregationCondition how the data that is collected should be combined over time. +type ManagementEventAggregationCondition struct { + // Operator - the condition operator. Possible values include: 'ConditionOperatorGreaterThan', 'ConditionOperatorGreaterThanOrEqual', 'ConditionOperatorLessThan', 'ConditionOperatorLessThanOrEqual' + Operator ConditionOperator `json:"operator,omitempty"` + // Threshold - The threshold value that activates the alert. + Threshold *float64 `json:"threshold,omitempty"` + // WindowSize - the period of time (in ISO 8601 duration format) that is used to monitor alert activity based on the threshold. If specified then it must be between 5 minutes and 1 day. + WindowSize *string `json:"windowSize,omitempty"` +} + +// ManagementEventRuleCondition a management event rule condition. +type ManagementEventRuleCondition struct { + // Aggregation - How the data that is collected should be combined over time and when the alert is activated. Note that for management event alerts aggregation is optional – if it is not provided then any event will cause the alert to activate. + Aggregation *ManagementEventAggregationCondition `json:"aggregation,omitempty"` + // DataSource - the resource from which the rule collects its data. For this type dataSource will always be of type RuleMetricDataSource. + DataSource BasicRuleDataSource `json:"dataSource,omitempty"` + // OdataType - Possible values include: 'OdataTypeBasicRuleConditionOdataTypeRuleCondition', 'OdataTypeBasicRuleConditionOdataTypeMicrosoftAzureManagementInsightsModelsThresholdRuleCondition', 'OdataTypeBasicRuleConditionOdataTypeMicrosoftAzureManagementInsightsModelsLocationThresholdRuleCondition', 'OdataTypeBasicRuleConditionOdataTypeMicrosoftAzureManagementInsightsModelsManagementEventRuleCondition' + OdataType OdataTypeBasicRuleCondition `json:"odata.type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagementEventRuleCondition. +func (merc ManagementEventRuleCondition) MarshalJSON() ([]byte, error) { + merc.OdataType = OdataTypeBasicRuleConditionOdataTypeMicrosoftAzureManagementInsightsModelsManagementEventRuleCondition + objectMap := make(map[string]interface{}) + if merc.Aggregation != nil { + objectMap["aggregation"] = merc.Aggregation + } + objectMap["dataSource"] = merc.DataSource + if merc.OdataType != "" { + objectMap["odata.type"] = merc.OdataType + } + return json.Marshal(objectMap) +} + +// AsThresholdRuleCondition is the BasicRuleCondition implementation for ManagementEventRuleCondition. +func (merc ManagementEventRuleCondition) AsThresholdRuleCondition() (*ThresholdRuleCondition, bool) { + return nil, false +} + +// AsLocationThresholdRuleCondition is the BasicRuleCondition implementation for ManagementEventRuleCondition. +func (merc ManagementEventRuleCondition) AsLocationThresholdRuleCondition() (*LocationThresholdRuleCondition, bool) { + return nil, false +} + +// AsManagementEventRuleCondition is the BasicRuleCondition implementation for ManagementEventRuleCondition. +func (merc ManagementEventRuleCondition) AsManagementEventRuleCondition() (*ManagementEventRuleCondition, bool) { + return &merc, true +} + +// AsRuleCondition is the BasicRuleCondition implementation for ManagementEventRuleCondition. +func (merc ManagementEventRuleCondition) AsRuleCondition() (*RuleCondition, bool) { + return nil, false +} + +// AsBasicRuleCondition is the BasicRuleCondition implementation for ManagementEventRuleCondition. +func (merc ManagementEventRuleCondition) AsBasicRuleCondition() (BasicRuleCondition, bool) { + return &merc, true +} + +// UnmarshalJSON is the custom unmarshaler for ManagementEventRuleCondition struct. +func (merc *ManagementEventRuleCondition) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "aggregation": + if v != nil { + var aggregation ManagementEventAggregationCondition + err = json.Unmarshal(*v, &aggregation) + if err != nil { + return err + } + merc.Aggregation = &aggregation + } + case "dataSource": + if v != nil { + dataSource, err := unmarshalBasicRuleDataSource(*v) + if err != nil { + return err + } + merc.DataSource = dataSource + } + case "odata.type": + if v != nil { + var odataType OdataTypeBasicRuleCondition + err = json.Unmarshal(*v, &odataType) + if err != nil { + return err + } + merc.OdataType = odataType + } + } + } + + return nil +} + +// MetadataValue represents a metric metadata value. +type MetadataValue struct { + // Name - the name of the metadata. + Name *LocalizableString `json:"name,omitempty"` + // Value - the value of the metadata. + Value *string `json:"value,omitempty"` +} + +// Metric the result data of a query. +type Metric struct { + // ID - the metric Id. + ID *string `json:"id,omitempty"` + // Type - the resource type of the metric resource. + Type *string `json:"type,omitempty"` + // Name - the name and the display name of the metric, i.e. it is localizable string. + Name *LocalizableString `json:"name,omitempty"` + // DisplayDescription - Detailed description of this metric. + DisplayDescription *string `json:"displayDescription,omitempty"` + // ErrorCode - 'Success' or the error details on query failures for this metric. + ErrorCode *string `json:"errorCode,omitempty"` + // ErrorMessage - Error message encountered querying this specific metric. + ErrorMessage *string `json:"errorMessage,omitempty"` + // Unit - The unit of the metric. Possible values include: 'MetricUnitCount', 'MetricUnitBytes', 'MetricUnitSeconds', 'MetricUnitCountPerSecond', 'MetricUnitBytesPerSecond', 'MetricUnitPercent', 'MetricUnitMilliSeconds', 'MetricUnitByteSeconds', 'MetricUnitUnspecified', 'MetricUnitCores', 'MetricUnitMilliCores', 'MetricUnitNanoCores', 'MetricUnitBitsPerSecond' + Unit MetricUnit `json:"unit,omitempty"` + // Timeseries - the time series returned when a data query is performed. + Timeseries *[]TimeSeriesElement `json:"timeseries,omitempty"` +} + +// MetricAlertAction an alert action. +type MetricAlertAction struct { + // ActionGroupID - the id of the action group to use. + ActionGroupID *string `json:"actionGroupId,omitempty"` + // WebHookProperties - This field allows specifying custom properties, which would be appended to the alert payload sent as input to the webhook. + WebHookProperties map[string]*string `json:"webHookProperties"` +} + +// MarshalJSON is the custom marshaler for MetricAlertAction. +func (maa MetricAlertAction) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if maa.ActionGroupID != nil { + objectMap["actionGroupId"] = maa.ActionGroupID + } + if maa.WebHookProperties != nil { + objectMap["webHookProperties"] = maa.WebHookProperties + } + return json.Marshal(objectMap) +} + +// BasicMetricAlertCriteria the rule criteria that defines the conditions of the alert rule. +type BasicMetricAlertCriteria interface { + AsMetricAlertSingleResourceMultipleMetricCriteria() (*MetricAlertSingleResourceMultipleMetricCriteria, bool) + AsWebtestLocationAvailabilityCriteria() (*WebtestLocationAvailabilityCriteria, bool) + AsMetricAlertMultipleResourceMultipleMetricCriteria() (*MetricAlertMultipleResourceMultipleMetricCriteria, bool) + AsMetricAlertCriteria() (*MetricAlertCriteria, bool) +} + +// MetricAlertCriteria the rule criteria that defines the conditions of the alert rule. +type MetricAlertCriteria struct { + // AdditionalProperties - Unmatched properties from the message are deserialized this collection + AdditionalProperties map[string]interface{} `json:""` + // OdataType - Possible values include: 'OdataTypeBasicMetricAlertCriteriaOdataTypeMetricAlertCriteria', 'OdataTypeBasicMetricAlertCriteriaOdataTypeMicrosoftAzureMonitorSingleResourceMultipleMetricCriteria', 'OdataTypeBasicMetricAlertCriteriaOdataTypeMicrosoftAzureMonitorWebtestLocationAvailabilityCriteria', 'OdataTypeBasicMetricAlertCriteriaOdataTypeMicrosoftAzureMonitorMultipleResourceMultipleMetricCriteria' + OdataType OdataTypeBasicMetricAlertCriteria `json:"odata.type,omitempty"` +} + +func unmarshalBasicMetricAlertCriteria(body []byte) (BasicMetricAlertCriteria, error) { + var m map[string]interface{} + err := json.Unmarshal(body, &m) + if err != nil { + return nil, err + } + + switch m["odata.type"] { + case string(OdataTypeBasicMetricAlertCriteriaOdataTypeMicrosoftAzureMonitorSingleResourceMultipleMetricCriteria): + var masrmmc MetricAlertSingleResourceMultipleMetricCriteria + err := json.Unmarshal(body, &masrmmc) + return masrmmc, err + case string(OdataTypeBasicMetricAlertCriteriaOdataTypeMicrosoftAzureMonitorWebtestLocationAvailabilityCriteria): + var wlac WebtestLocationAvailabilityCriteria + err := json.Unmarshal(body, &wlac) + return wlac, err + case string(OdataTypeBasicMetricAlertCriteriaOdataTypeMicrosoftAzureMonitorMultipleResourceMultipleMetricCriteria): + var mamrmmc MetricAlertMultipleResourceMultipleMetricCriteria + err := json.Unmarshal(body, &mamrmmc) + return mamrmmc, err + default: + var mac MetricAlertCriteria + err := json.Unmarshal(body, &mac) + return mac, err + } +} +func unmarshalBasicMetricAlertCriteriaArray(body []byte) ([]BasicMetricAlertCriteria, error) { + var rawMessages []*json.RawMessage + err := json.Unmarshal(body, &rawMessages) + if err != nil { + return nil, err + } + + macArray := make([]BasicMetricAlertCriteria, len(rawMessages)) + + for index, rawMessage := range rawMessages { + mac, err := unmarshalBasicMetricAlertCriteria(*rawMessage) + if err != nil { + return nil, err + } + macArray[index] = mac + } + return macArray, nil +} + +// MarshalJSON is the custom marshaler for MetricAlertCriteria. +func (mac MetricAlertCriteria) MarshalJSON() ([]byte, error) { + mac.OdataType = OdataTypeBasicMetricAlertCriteriaOdataTypeMetricAlertCriteria + objectMap := make(map[string]interface{}) + if mac.OdataType != "" { + objectMap["odata.type"] = mac.OdataType + } + for k, v := range mac.AdditionalProperties { + objectMap[k] = v + } + return json.Marshal(objectMap) +} + +// AsMetricAlertSingleResourceMultipleMetricCriteria is the BasicMetricAlertCriteria implementation for MetricAlertCriteria. +func (mac MetricAlertCriteria) AsMetricAlertSingleResourceMultipleMetricCriteria() (*MetricAlertSingleResourceMultipleMetricCriteria, bool) { + return nil, false +} + +// AsWebtestLocationAvailabilityCriteria is the BasicMetricAlertCriteria implementation for MetricAlertCriteria. +func (mac MetricAlertCriteria) AsWebtestLocationAvailabilityCriteria() (*WebtestLocationAvailabilityCriteria, bool) { + return nil, false +} + +// AsMetricAlertMultipleResourceMultipleMetricCriteria is the BasicMetricAlertCriteria implementation for MetricAlertCriteria. +func (mac MetricAlertCriteria) AsMetricAlertMultipleResourceMultipleMetricCriteria() (*MetricAlertMultipleResourceMultipleMetricCriteria, bool) { + return nil, false +} + +// AsMetricAlertCriteria is the BasicMetricAlertCriteria implementation for MetricAlertCriteria. +func (mac MetricAlertCriteria) AsMetricAlertCriteria() (*MetricAlertCriteria, bool) { + return &mac, true +} + +// AsBasicMetricAlertCriteria is the BasicMetricAlertCriteria implementation for MetricAlertCriteria. +func (mac MetricAlertCriteria) AsBasicMetricAlertCriteria() (BasicMetricAlertCriteria, bool) { + return &mac, true +} + +// UnmarshalJSON is the custom unmarshaler for MetricAlertCriteria struct. +func (mac *MetricAlertCriteria) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + default: + if v != nil { + var additionalProperties interface{} + err = json.Unmarshal(*v, &additionalProperties) + if err != nil { + return err + } + if mac.AdditionalProperties == nil { + mac.AdditionalProperties = make(map[string]interface{}) + } + mac.AdditionalProperties[k] = additionalProperties + } + case "odata.type": + if v != nil { + var odataType OdataTypeBasicMetricAlertCriteria + err = json.Unmarshal(*v, &odataType) + if err != nil { + return err + } + mac.OdataType = odataType + } + } + } + + return nil +} + +// MetricAlertMultipleResourceMultipleMetricCriteria specifies the metric alert criteria for multiple +// resource that has multiple metric criteria. +type MetricAlertMultipleResourceMultipleMetricCriteria struct { + // AllOf - the list of multiple metric criteria for this 'all of' operation. + AllOf *[]BasicMultiMetricCriteria `json:"allOf,omitempty"` + // AdditionalProperties - Unmatched properties from the message are deserialized this collection + AdditionalProperties map[string]interface{} `json:""` + // OdataType - Possible values include: 'OdataTypeBasicMetricAlertCriteriaOdataTypeMetricAlertCriteria', 'OdataTypeBasicMetricAlertCriteriaOdataTypeMicrosoftAzureMonitorSingleResourceMultipleMetricCriteria', 'OdataTypeBasicMetricAlertCriteriaOdataTypeMicrosoftAzureMonitorWebtestLocationAvailabilityCriteria', 'OdataTypeBasicMetricAlertCriteriaOdataTypeMicrosoftAzureMonitorMultipleResourceMultipleMetricCriteria' + OdataType OdataTypeBasicMetricAlertCriteria `json:"odata.type,omitempty"` +} + +// MarshalJSON is the custom marshaler for MetricAlertMultipleResourceMultipleMetricCriteria. +func (mamrmmc MetricAlertMultipleResourceMultipleMetricCriteria) MarshalJSON() ([]byte, error) { + mamrmmc.OdataType = OdataTypeBasicMetricAlertCriteriaOdataTypeMicrosoftAzureMonitorMultipleResourceMultipleMetricCriteria + objectMap := make(map[string]interface{}) + if mamrmmc.AllOf != nil { + objectMap["allOf"] = mamrmmc.AllOf + } + if mamrmmc.OdataType != "" { + objectMap["odata.type"] = mamrmmc.OdataType + } + for k, v := range mamrmmc.AdditionalProperties { + objectMap[k] = v + } + return json.Marshal(objectMap) +} + +// AsMetricAlertSingleResourceMultipleMetricCriteria is the BasicMetricAlertCriteria implementation for MetricAlertMultipleResourceMultipleMetricCriteria. +func (mamrmmc MetricAlertMultipleResourceMultipleMetricCriteria) AsMetricAlertSingleResourceMultipleMetricCriteria() (*MetricAlertSingleResourceMultipleMetricCriteria, bool) { + return nil, false +} + +// AsWebtestLocationAvailabilityCriteria is the BasicMetricAlertCriteria implementation for MetricAlertMultipleResourceMultipleMetricCriteria. +func (mamrmmc MetricAlertMultipleResourceMultipleMetricCriteria) AsWebtestLocationAvailabilityCriteria() (*WebtestLocationAvailabilityCriteria, bool) { + return nil, false +} + +// AsMetricAlertMultipleResourceMultipleMetricCriteria is the BasicMetricAlertCriteria implementation for MetricAlertMultipleResourceMultipleMetricCriteria. +func (mamrmmc MetricAlertMultipleResourceMultipleMetricCriteria) AsMetricAlertMultipleResourceMultipleMetricCriteria() (*MetricAlertMultipleResourceMultipleMetricCriteria, bool) { + return &mamrmmc, true +} + +// AsMetricAlertCriteria is the BasicMetricAlertCriteria implementation for MetricAlertMultipleResourceMultipleMetricCriteria. +func (mamrmmc MetricAlertMultipleResourceMultipleMetricCriteria) AsMetricAlertCriteria() (*MetricAlertCriteria, bool) { + return nil, false +} + +// AsBasicMetricAlertCriteria is the BasicMetricAlertCriteria implementation for MetricAlertMultipleResourceMultipleMetricCriteria. +func (mamrmmc MetricAlertMultipleResourceMultipleMetricCriteria) AsBasicMetricAlertCriteria() (BasicMetricAlertCriteria, bool) { + return &mamrmmc, true +} + +// UnmarshalJSON is the custom unmarshaler for MetricAlertMultipleResourceMultipleMetricCriteria struct. +func (mamrmmc *MetricAlertMultipleResourceMultipleMetricCriteria) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "allOf": + if v != nil { + allOf, err := unmarshalBasicMultiMetricCriteriaArray(*v) + if err != nil { + return err + } + mamrmmc.AllOf = &allOf + } + default: + if v != nil { + var additionalProperties interface{} + err = json.Unmarshal(*v, &additionalProperties) + if err != nil { + return err + } + if mamrmmc.AdditionalProperties == nil { + mamrmmc.AdditionalProperties = make(map[string]interface{}) + } + mamrmmc.AdditionalProperties[k] = additionalProperties + } + case "odata.type": + if v != nil { + var odataType OdataTypeBasicMetricAlertCriteria + err = json.Unmarshal(*v, &odataType) + if err != nil { + return err + } + mamrmmc.OdataType = odataType + } + } + } + + return nil +} + +// MetricAlertProperties an alert rule. +type MetricAlertProperties struct { + // Description - the description of the metric alert that will be included in the alert email. + Description *string `json:"description,omitempty"` + // Severity - Alert severity {0, 1, 2, 3, 4} + Severity *int32 `json:"severity,omitempty"` + // Enabled - the flag that indicates whether the metric alert is enabled. + Enabled *bool `json:"enabled,omitempty"` + // Scopes - the list of resource id's that this metric alert is scoped to. + Scopes *[]string `json:"scopes,omitempty"` + // EvaluationFrequency - how often the metric alert is evaluated represented in ISO 8601 duration format. + EvaluationFrequency *string `json:"evaluationFrequency,omitempty"` + // WindowSize - the period of time (in ISO 8601 duration format) that is used to monitor alert activity based on the threshold. + WindowSize *string `json:"windowSize,omitempty"` + // TargetResourceType - the resource type of the target resource(s) on which the alert is created/updated. Mandatory if the scope contains a subscription, resource group, or more than one resource. + TargetResourceType *string `json:"targetResourceType,omitempty"` + // TargetResourceRegion - the region of the target resource(s) on which the alert is created/updated. Mandatory if the scope contains a subscription, resource group, or more than one resource. + TargetResourceRegion *string `json:"targetResourceRegion,omitempty"` + // Criteria - defines the specific alert criteria information. + Criteria BasicMetricAlertCriteria `json:"criteria,omitempty"` + // AutoMitigate - the flag that indicates whether the alert should be auto resolved or not. The default is true. + AutoMitigate *bool `json:"autoMitigate,omitempty"` + // Actions - the array of actions that are performed when the alert rule becomes active, and when an alert condition is resolved. + Actions *[]MetricAlertAction `json:"actions,omitempty"` + // LastUpdatedTime - READ-ONLY; Last time the rule was updated in ISO8601 format. + LastUpdatedTime *date.Time `json:"lastUpdatedTime,omitempty"` + // IsMigrated - READ-ONLY; the value indicating whether this alert rule is migrated. + IsMigrated *bool `json:"isMigrated,omitempty"` +} + +// MarshalJSON is the custom marshaler for MetricAlertProperties. +func (mapVar MetricAlertProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mapVar.Description != nil { + objectMap["description"] = mapVar.Description + } + if mapVar.Severity != nil { + objectMap["severity"] = mapVar.Severity + } + if mapVar.Enabled != nil { + objectMap["enabled"] = mapVar.Enabled + } + if mapVar.Scopes != nil { + objectMap["scopes"] = mapVar.Scopes + } + if mapVar.EvaluationFrequency != nil { + objectMap["evaluationFrequency"] = mapVar.EvaluationFrequency + } + if mapVar.WindowSize != nil { + objectMap["windowSize"] = mapVar.WindowSize + } + if mapVar.TargetResourceType != nil { + objectMap["targetResourceType"] = mapVar.TargetResourceType + } + if mapVar.TargetResourceRegion != nil { + objectMap["targetResourceRegion"] = mapVar.TargetResourceRegion + } + objectMap["criteria"] = mapVar.Criteria + if mapVar.AutoMitigate != nil { + objectMap["autoMitigate"] = mapVar.AutoMitigate + } + if mapVar.Actions != nil { + objectMap["actions"] = mapVar.Actions + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for MetricAlertProperties struct. +func (mapVar *MetricAlertProperties) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "description": + if v != nil { + var description string + err = json.Unmarshal(*v, &description) + if err != nil { + return err + } + mapVar.Description = &description + } + case "severity": + if v != nil { + var severity int32 + err = json.Unmarshal(*v, &severity) + if err != nil { + return err + } + mapVar.Severity = &severity + } + case "enabled": + if v != nil { + var enabled bool + err = json.Unmarshal(*v, &enabled) + if err != nil { + return err + } + mapVar.Enabled = &enabled + } + case "scopes": + if v != nil { + var scopes []string + err = json.Unmarshal(*v, &scopes) + if err != nil { + return err + } + mapVar.Scopes = &scopes + } + case "evaluationFrequency": + if v != nil { + var evaluationFrequency string + err = json.Unmarshal(*v, &evaluationFrequency) + if err != nil { + return err + } + mapVar.EvaluationFrequency = &evaluationFrequency + } + case "windowSize": + if v != nil { + var windowSize string + err = json.Unmarshal(*v, &windowSize) + if err != nil { + return err + } + mapVar.WindowSize = &windowSize + } + case "targetResourceType": + if v != nil { + var targetResourceType string + err = json.Unmarshal(*v, &targetResourceType) + if err != nil { + return err + } + mapVar.TargetResourceType = &targetResourceType + } + case "targetResourceRegion": + if v != nil { + var targetResourceRegion string + err = json.Unmarshal(*v, &targetResourceRegion) + if err != nil { + return err + } + mapVar.TargetResourceRegion = &targetResourceRegion + } + case "criteria": + if v != nil { + criteria, err := unmarshalBasicMetricAlertCriteria(*v) + if err != nil { + return err + } + mapVar.Criteria = criteria + } + case "autoMitigate": + if v != nil { + var autoMitigate bool + err = json.Unmarshal(*v, &autoMitigate) + if err != nil { + return err + } + mapVar.AutoMitigate = &autoMitigate + } + case "actions": + if v != nil { + var actions []MetricAlertAction + err = json.Unmarshal(*v, &actions) + if err != nil { + return err + } + mapVar.Actions = &actions + } + case "lastUpdatedTime": + if v != nil { + var lastUpdatedTime date.Time + err = json.Unmarshal(*v, &lastUpdatedTime) + if err != nil { + return err + } + mapVar.LastUpdatedTime = &lastUpdatedTime + } + case "isMigrated": + if v != nil { + var isMigrated bool + err = json.Unmarshal(*v, &isMigrated) + if err != nil { + return err + } + mapVar.IsMigrated = &isMigrated + } + } + } + + return nil +} + +// MetricAlertPropertiesPatch an alert rule properties for patch. +type MetricAlertPropertiesPatch struct { + // Description - the description of the metric alert that will be included in the alert email. + Description *string `json:"description,omitempty"` + // Severity - Alert severity {0, 1, 2, 3, 4} + Severity *int32 `json:"severity,omitempty"` + // Enabled - the flag that indicates whether the metric alert is enabled. + Enabled *bool `json:"enabled,omitempty"` + // Scopes - the list of resource id's that this metric alert is scoped to. + Scopes *[]string `json:"scopes,omitempty"` + // EvaluationFrequency - how often the metric alert is evaluated represented in ISO 8601 duration format. + EvaluationFrequency *string `json:"evaluationFrequency,omitempty"` + // WindowSize - the period of time (in ISO 8601 duration format) that is used to monitor alert activity based on the threshold. + WindowSize *string `json:"windowSize,omitempty"` + // TargetResourceType - the resource type of the target resource(s) on which the alert is created/updated. Mandatory for MultipleResourceMultipleMetricCriteria. + TargetResourceType *string `json:"targetResourceType,omitempty"` + // TargetResourceRegion - the region of the target resource(s) on which the alert is created/updated. Mandatory for MultipleResourceMultipleMetricCriteria. + TargetResourceRegion *string `json:"targetResourceRegion,omitempty"` + // Criteria - defines the specific alert criteria information. + Criteria BasicMetricAlertCriteria `json:"criteria,omitempty"` + // AutoMitigate - the flag that indicates whether the alert should be auto resolved or not. The default is true. + AutoMitigate *bool `json:"autoMitigate,omitempty"` + // Actions - the array of actions that are performed when the alert rule becomes active, and when an alert condition is resolved. + Actions *[]MetricAlertAction `json:"actions,omitempty"` + // LastUpdatedTime - READ-ONLY; Last time the rule was updated in ISO8601 format. + LastUpdatedTime *date.Time `json:"lastUpdatedTime,omitempty"` + // IsMigrated - READ-ONLY; the value indicating whether this alert rule is migrated. + IsMigrated *bool `json:"isMigrated,omitempty"` +} + +// MarshalJSON is the custom marshaler for MetricAlertPropertiesPatch. +func (mapp MetricAlertPropertiesPatch) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mapp.Description != nil { + objectMap["description"] = mapp.Description + } + if mapp.Severity != nil { + objectMap["severity"] = mapp.Severity + } + if mapp.Enabled != nil { + objectMap["enabled"] = mapp.Enabled + } + if mapp.Scopes != nil { + objectMap["scopes"] = mapp.Scopes + } + if mapp.EvaluationFrequency != nil { + objectMap["evaluationFrequency"] = mapp.EvaluationFrequency + } + if mapp.WindowSize != nil { + objectMap["windowSize"] = mapp.WindowSize + } + if mapp.TargetResourceType != nil { + objectMap["targetResourceType"] = mapp.TargetResourceType + } + if mapp.TargetResourceRegion != nil { + objectMap["targetResourceRegion"] = mapp.TargetResourceRegion + } + objectMap["criteria"] = mapp.Criteria + if mapp.AutoMitigate != nil { + objectMap["autoMitigate"] = mapp.AutoMitigate + } + if mapp.Actions != nil { + objectMap["actions"] = mapp.Actions + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for MetricAlertPropertiesPatch struct. +func (mapp *MetricAlertPropertiesPatch) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "description": + if v != nil { + var description string + err = json.Unmarshal(*v, &description) + if err != nil { + return err + } + mapp.Description = &description + } + case "severity": + if v != nil { + var severity int32 + err = json.Unmarshal(*v, &severity) + if err != nil { + return err + } + mapp.Severity = &severity + } + case "enabled": + if v != nil { + var enabled bool + err = json.Unmarshal(*v, &enabled) + if err != nil { + return err + } + mapp.Enabled = &enabled + } + case "scopes": + if v != nil { + var scopes []string + err = json.Unmarshal(*v, &scopes) + if err != nil { + return err + } + mapp.Scopes = &scopes + } + case "evaluationFrequency": + if v != nil { + var evaluationFrequency string + err = json.Unmarshal(*v, &evaluationFrequency) + if err != nil { + return err + } + mapp.EvaluationFrequency = &evaluationFrequency + } + case "windowSize": + if v != nil { + var windowSize string + err = json.Unmarshal(*v, &windowSize) + if err != nil { + return err + } + mapp.WindowSize = &windowSize + } + case "targetResourceType": + if v != nil { + var targetResourceType string + err = json.Unmarshal(*v, &targetResourceType) + if err != nil { + return err + } + mapp.TargetResourceType = &targetResourceType + } + case "targetResourceRegion": + if v != nil { + var targetResourceRegion string + err = json.Unmarshal(*v, &targetResourceRegion) + if err != nil { + return err + } + mapp.TargetResourceRegion = &targetResourceRegion + } + case "criteria": + if v != nil { + criteria, err := unmarshalBasicMetricAlertCriteria(*v) + if err != nil { + return err + } + mapp.Criteria = criteria + } + case "autoMitigate": + if v != nil { + var autoMitigate bool + err = json.Unmarshal(*v, &autoMitigate) + if err != nil { + return err + } + mapp.AutoMitigate = &autoMitigate + } + case "actions": + if v != nil { + var actions []MetricAlertAction + err = json.Unmarshal(*v, &actions) + if err != nil { + return err + } + mapp.Actions = &actions + } + case "lastUpdatedTime": + if v != nil { + var lastUpdatedTime date.Time + err = json.Unmarshal(*v, &lastUpdatedTime) + if err != nil { + return err + } + mapp.LastUpdatedTime = &lastUpdatedTime + } + case "isMigrated": + if v != nil { + var isMigrated bool + err = json.Unmarshal(*v, &isMigrated) + if err != nil { + return err + } + mapp.IsMigrated = &isMigrated + } + } + } + + return nil +} + +// MetricAlertResource the metric alert resource. +type MetricAlertResource struct { + autorest.Response `json:"-"` + // MetricAlertProperties - The alert rule properties of the resource. + *MetricAlertProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Azure resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Azure resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Azure resource type + Type *string `json:"type,omitempty"` + // Location - Resource location + Location *string `json:"location,omitempty"` + // Tags - Resource tags + Tags map[string]*string `json:"tags"` + // Kind - READ-ONLY; Metadata used by portal/tooling/etc to render different UX experiences for resources of the same type; e.g. ApiApps are a kind of Microsoft.Web/sites type. If supported, the resource provider must validate and persist this value. + Kind *string `json:"kind,omitempty"` + // Etag - READ-ONLY; The etag field is *not* required. If it is provided in the response body, it must also be provided as a header per the normal etag convention. Entity tags are used for comparing two or more entities from the same requested resource. HTTP/1.1 uses entity tags in the etag (section 14.19), If-Match (section 14.24), If-None-Match (section 14.26), and If-Range (section 14.27) header fields. + Etag *string `json:"etag,omitempty"` +} + +// MarshalJSON is the custom marshaler for MetricAlertResource. +func (mar MetricAlertResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mar.MetricAlertProperties != nil { + objectMap["properties"] = mar.MetricAlertProperties + } + if mar.Location != nil { + objectMap["location"] = mar.Location + } + if mar.Tags != nil { + objectMap["tags"] = mar.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for MetricAlertResource struct. +func (mar *MetricAlertResource) UnmarshalJSON(body []byte) error { + 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 metricAlertProperties MetricAlertProperties + err = json.Unmarshal(*v, &metricAlertProperties) + if err != nil { + return err + } + mar.MetricAlertProperties = &metricAlertProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + mar.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + mar.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + mar.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + mar.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + mar.Tags = tags + } + case "kind": + if v != nil { + var kind string + err = json.Unmarshal(*v, &kind) + if err != nil { + return err + } + mar.Kind = &kind + } + case "etag": + if v != nil { + var etag string + err = json.Unmarshal(*v, &etag) + if err != nil { + return err + } + mar.Etag = &etag + } + } + } + + return nil +} + +// MetricAlertResourceCollection represents a collection of alert rule resources. +type MetricAlertResourceCollection struct { + autorest.Response `json:"-"` + // Value - the values for the alert rule resources. + Value *[]MetricAlertResource `json:"value,omitempty"` +} + +// MetricAlertResourcePatch the metric alert resource for patch operations. +type MetricAlertResourcePatch struct { + // Tags - Resource tags + Tags map[string]*string `json:"tags"` + // MetricAlertPropertiesPatch - The alert rule properties of the resource. + *MetricAlertPropertiesPatch `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for MetricAlertResourcePatch. +func (marp MetricAlertResourcePatch) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if marp.Tags != nil { + objectMap["tags"] = marp.Tags + } + if marp.MetricAlertPropertiesPatch != nil { + objectMap["properties"] = marp.MetricAlertPropertiesPatch + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for MetricAlertResourcePatch struct. +func (marp *MetricAlertResourcePatch) UnmarshalJSON(body []byte) error { + 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 + } + marp.Tags = tags + } + case "properties": + if v != nil { + var metricAlertPropertiesPatch MetricAlertPropertiesPatch + err = json.Unmarshal(*v, &metricAlertPropertiesPatch) + if err != nil { + return err + } + marp.MetricAlertPropertiesPatch = &metricAlertPropertiesPatch + } + } + } + + return nil +} + +// MetricAlertSingleResourceMultipleMetricCriteria specifies the metric alert criteria for a single +// resource that has multiple metric criteria. +type MetricAlertSingleResourceMultipleMetricCriteria struct { + // AllOf - The list of metric criteria for this 'all of' operation. + AllOf *[]MetricCriteria `json:"allOf,omitempty"` + // AdditionalProperties - Unmatched properties from the message are deserialized this collection + AdditionalProperties map[string]interface{} `json:""` + // OdataType - Possible values include: 'OdataTypeBasicMetricAlertCriteriaOdataTypeMetricAlertCriteria', 'OdataTypeBasicMetricAlertCriteriaOdataTypeMicrosoftAzureMonitorSingleResourceMultipleMetricCriteria', 'OdataTypeBasicMetricAlertCriteriaOdataTypeMicrosoftAzureMonitorWebtestLocationAvailabilityCriteria', 'OdataTypeBasicMetricAlertCriteriaOdataTypeMicrosoftAzureMonitorMultipleResourceMultipleMetricCriteria' + OdataType OdataTypeBasicMetricAlertCriteria `json:"odata.type,omitempty"` +} + +// MarshalJSON is the custom marshaler for MetricAlertSingleResourceMultipleMetricCriteria. +func (masrmmc MetricAlertSingleResourceMultipleMetricCriteria) MarshalJSON() ([]byte, error) { + masrmmc.OdataType = OdataTypeBasicMetricAlertCriteriaOdataTypeMicrosoftAzureMonitorSingleResourceMultipleMetricCriteria + objectMap := make(map[string]interface{}) + if masrmmc.AllOf != nil { + objectMap["allOf"] = masrmmc.AllOf + } + if masrmmc.OdataType != "" { + objectMap["odata.type"] = masrmmc.OdataType + } + for k, v := range masrmmc.AdditionalProperties { + objectMap[k] = v + } + return json.Marshal(objectMap) +} + +// AsMetricAlertSingleResourceMultipleMetricCriteria is the BasicMetricAlertCriteria implementation for MetricAlertSingleResourceMultipleMetricCriteria. +func (masrmmc MetricAlertSingleResourceMultipleMetricCriteria) AsMetricAlertSingleResourceMultipleMetricCriteria() (*MetricAlertSingleResourceMultipleMetricCriteria, bool) { + return &masrmmc, true +} + +// AsWebtestLocationAvailabilityCriteria is the BasicMetricAlertCriteria implementation for MetricAlertSingleResourceMultipleMetricCriteria. +func (masrmmc MetricAlertSingleResourceMultipleMetricCriteria) AsWebtestLocationAvailabilityCriteria() (*WebtestLocationAvailabilityCriteria, bool) { + return nil, false +} + +// AsMetricAlertMultipleResourceMultipleMetricCriteria is the BasicMetricAlertCriteria implementation for MetricAlertSingleResourceMultipleMetricCriteria. +func (masrmmc MetricAlertSingleResourceMultipleMetricCriteria) AsMetricAlertMultipleResourceMultipleMetricCriteria() (*MetricAlertMultipleResourceMultipleMetricCriteria, bool) { + return nil, false +} + +// AsMetricAlertCriteria is the BasicMetricAlertCriteria implementation for MetricAlertSingleResourceMultipleMetricCriteria. +func (masrmmc MetricAlertSingleResourceMultipleMetricCriteria) AsMetricAlertCriteria() (*MetricAlertCriteria, bool) { + return nil, false +} + +// AsBasicMetricAlertCriteria is the BasicMetricAlertCriteria implementation for MetricAlertSingleResourceMultipleMetricCriteria. +func (masrmmc MetricAlertSingleResourceMultipleMetricCriteria) AsBasicMetricAlertCriteria() (BasicMetricAlertCriteria, bool) { + return &masrmmc, true +} + +// UnmarshalJSON is the custom unmarshaler for MetricAlertSingleResourceMultipleMetricCriteria struct. +func (masrmmc *MetricAlertSingleResourceMultipleMetricCriteria) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "allOf": + if v != nil { + var allOf []MetricCriteria + err = json.Unmarshal(*v, &allOf) + if err != nil { + return err + } + masrmmc.AllOf = &allOf + } + default: + if v != nil { + var additionalProperties interface{} + err = json.Unmarshal(*v, &additionalProperties) + if err != nil { + return err + } + if masrmmc.AdditionalProperties == nil { + masrmmc.AdditionalProperties = make(map[string]interface{}) + } + masrmmc.AdditionalProperties[k] = additionalProperties + } + case "odata.type": + if v != nil { + var odataType OdataTypeBasicMetricAlertCriteria + err = json.Unmarshal(*v, &odataType) + if err != nil { + return err + } + masrmmc.OdataType = odataType + } + } + } + + return nil +} + +// MetricAlertStatus an alert status. +type MetricAlertStatus struct { + // Name - The status name. + Name *string `json:"name,omitempty"` + // ID - The alert rule arm id. + ID *string `json:"id,omitempty"` + // Type - The extended resource type name. + Type *string `json:"type,omitempty"` + // Properties - The alert status properties of the metric alert status. + Properties *MetricAlertStatusProperties `json:"properties,omitempty"` +} + +// MetricAlertStatusCollection represents a collection of alert rule resources. +type MetricAlertStatusCollection struct { + autorest.Response `json:"-"` + // Value - the values for the alert rule resources. + Value *[]MetricAlertStatus `json:"value,omitempty"` +} + +// MetricAlertStatusProperties an alert status properties. +type MetricAlertStatusProperties struct { + // Dimensions - An object describing the type of the dimensions. + Dimensions map[string]*string `json:"dimensions"` + // Status - status value + Status *string `json:"status,omitempty"` + // Timestamp - UTC time when the status was checked. + Timestamp *date.Time `json:"timestamp,omitempty"` +} + +// MarshalJSON is the custom marshaler for MetricAlertStatusProperties. +func (masp MetricAlertStatusProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if masp.Dimensions != nil { + objectMap["dimensions"] = masp.Dimensions + } + if masp.Status != nil { + objectMap["status"] = masp.Status + } + if masp.Timestamp != nil { + objectMap["timestamp"] = masp.Timestamp + } + return json.Marshal(objectMap) +} + +// MetricAvailability metric availability specifies the time grain (aggregation interval or frequency) and +// the retention period for that time grain. +type MetricAvailability struct { + // TimeGrain - the time grain specifies the aggregation interval for the metric. Expressed as a duration 'PT1M', 'P1D', etc. + TimeGrain *string `json:"timeGrain,omitempty"` + // Retention - the retention period for the metric at the specified timegrain. Expressed as a duration 'PT1M', 'P1D', etc. + Retention *string `json:"retention,omitempty"` +} + +// MetricBaselinesProperties the response to a metric baselines query. +type MetricBaselinesProperties struct { + // Timespan - The timespan for which the data was retrieved. Its value consists of two datetimes concatenated, separated by '/'. This may be adjusted in the future and returned back from what was originally requested. + Timespan *string `json:"timespan,omitempty"` + // Interval - The interval (window size) for which the metric data was returned in. This may be adjusted in the future and returned back from what was originally requested. This is not present if a metadata request was made. + Interval *string `json:"interval,omitempty"` + // Namespace - The namespace of the metrics been queried. + Namespace *string `json:"namespace,omitempty"` + // Baselines - The baseline for each time series that was queried. + Baselines *[]TimeSeriesBaseline `json:"baselines,omitempty"` +} + +// MetricBaselinesResponse a list of metric baselines. +type MetricBaselinesResponse struct { + autorest.Response `json:"-"` + // Value - The list of metric baselines. + Value *[]SingleMetricBaseline `json:"value,omitempty"` +} + +// MetricCriteria criterion to filter metrics. +type MetricCriteria struct { + // Operator - the criteria operator. Possible values include: 'OperatorEquals', 'OperatorNotEquals', 'OperatorGreaterThan', 'OperatorGreaterThanOrEqual', 'OperatorLessThan', 'OperatorLessThanOrEqual' + Operator Operator `json:"operator,omitempty"` + // Threshold - the criteria threshold value that activates the alert. + Threshold *float64 `json:"threshold,omitempty"` + // AdditionalProperties - Unmatched properties from the message are deserialized this collection + AdditionalProperties map[string]interface{} `json:""` + // Name - Name of the criteria. + Name *string `json:"name,omitempty"` + // MetricName - Name of the metric. + MetricName *string `json:"metricName,omitempty"` + // MetricNamespace - Namespace of the metric. + MetricNamespace *string `json:"metricNamespace,omitempty"` + // TimeAggregation - the criteria time aggregation types. Possible values include: 'AggregationTypeEnumAverage', 'AggregationTypeEnumCount', 'AggregationTypeEnumMinimum', 'AggregationTypeEnumMaximum', 'AggregationTypeEnumTotal' + TimeAggregation AggregationTypeEnum `json:"timeAggregation,omitempty"` + // Dimensions - List of dimension conditions. + Dimensions *[]MetricDimension `json:"dimensions,omitempty"` + // SkipMetricValidation - Allows creating an alert rule on a custom metric that isn't yet emitted, by causing the metric validation to be skipped. + SkipMetricValidation *bool `json:"skipMetricValidation,omitempty"` + // CriterionType - Possible values include: 'CriterionTypeMultiMetricCriteria', 'CriterionTypeStaticThresholdCriterion', 'CriterionTypeDynamicThresholdCriterion' + CriterionType CriterionType `json:"criterionType,omitempty"` +} + +// MarshalJSON is the custom marshaler for MetricCriteria. +func (mc MetricCriteria) MarshalJSON() ([]byte, error) { + mc.CriterionType = CriterionTypeStaticThresholdCriterion + objectMap := make(map[string]interface{}) + if mc.Operator != "" { + objectMap["operator"] = mc.Operator + } + if mc.Threshold != nil { + objectMap["threshold"] = mc.Threshold + } + if mc.Name != nil { + objectMap["name"] = mc.Name + } + if mc.MetricName != nil { + objectMap["metricName"] = mc.MetricName + } + if mc.MetricNamespace != nil { + objectMap["metricNamespace"] = mc.MetricNamespace + } + if mc.TimeAggregation != "" { + objectMap["timeAggregation"] = mc.TimeAggregation + } + if mc.Dimensions != nil { + objectMap["dimensions"] = mc.Dimensions + } + if mc.SkipMetricValidation != nil { + objectMap["skipMetricValidation"] = mc.SkipMetricValidation + } + if mc.CriterionType != "" { + objectMap["criterionType"] = mc.CriterionType + } + for k, v := range mc.AdditionalProperties { + objectMap[k] = v + } + return json.Marshal(objectMap) +} + +// AsMetricCriteria is the BasicMultiMetricCriteria implementation for MetricCriteria. +func (mc MetricCriteria) AsMetricCriteria() (*MetricCriteria, bool) { + return &mc, true +} + +// AsDynamicMetricCriteria is the BasicMultiMetricCriteria implementation for MetricCriteria. +func (mc MetricCriteria) AsDynamicMetricCriteria() (*DynamicMetricCriteria, bool) { + return nil, false +} + +// AsMultiMetricCriteria is the BasicMultiMetricCriteria implementation for MetricCriteria. +func (mc MetricCriteria) AsMultiMetricCriteria() (*MultiMetricCriteria, bool) { + return nil, false +} + +// AsBasicMultiMetricCriteria is the BasicMultiMetricCriteria implementation for MetricCriteria. +func (mc MetricCriteria) AsBasicMultiMetricCriteria() (BasicMultiMetricCriteria, bool) { + return &mc, true +} + +// UnmarshalJSON is the custom unmarshaler for MetricCriteria struct. +func (mc *MetricCriteria) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "operator": + if v != nil { + var operator Operator + err = json.Unmarshal(*v, &operator) + if err != nil { + return err + } + mc.Operator = operator + } + case "threshold": + if v != nil { + var threshold float64 + err = json.Unmarshal(*v, &threshold) + if err != nil { + return err + } + mc.Threshold = &threshold + } + default: + if v != nil { + var additionalProperties interface{} + err = json.Unmarshal(*v, &additionalProperties) + if err != nil { + return err + } + if mc.AdditionalProperties == nil { + mc.AdditionalProperties = make(map[string]interface{}) + } + mc.AdditionalProperties[k] = additionalProperties + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + mc.Name = &name + } + case "metricName": + if v != nil { + var metricName string + err = json.Unmarshal(*v, &metricName) + if err != nil { + return err + } + mc.MetricName = &metricName + } + case "metricNamespace": + if v != nil { + var metricNamespace string + err = json.Unmarshal(*v, &metricNamespace) + if err != nil { + return err + } + mc.MetricNamespace = &metricNamespace + } + case "timeAggregation": + if v != nil { + var timeAggregation AggregationTypeEnum + err = json.Unmarshal(*v, &timeAggregation) + if err != nil { + return err + } + mc.TimeAggregation = timeAggregation + } + case "dimensions": + if v != nil { + var dimensions []MetricDimension + err = json.Unmarshal(*v, &dimensions) + if err != nil { + return err + } + mc.Dimensions = &dimensions + } + case "skipMetricValidation": + if v != nil { + var skipMetricValidation bool + err = json.Unmarshal(*v, &skipMetricValidation) + if err != nil { + return err + } + mc.SkipMetricValidation = &skipMetricValidation + } + case "criterionType": + if v != nil { + var criterionType CriterionType + err = json.Unmarshal(*v, &criterionType) + if err != nil { + return err + } + mc.CriterionType = criterionType + } + } + } + + return nil +} + +// MetricDefinition metric definition class specifies the metadata for a metric. +type MetricDefinition struct { + // IsDimensionRequired - Flag to indicate whether the dimension is required. + IsDimensionRequired *bool `json:"isDimensionRequired,omitempty"` + // ResourceID - the resource identifier of the resource that emitted the metric. + ResourceID *string `json:"resourceId,omitempty"` + // Namespace - the namespace the metric belongs to. + Namespace *string `json:"namespace,omitempty"` + // Name - the name and the display name of the metric, i.e. it is a localizable string. + Name *LocalizableString `json:"name,omitempty"` + // DisplayDescription - Detailed description of this metric. + DisplayDescription *string `json:"displayDescription,omitempty"` + // Category - Custom category name for this metric. + Category *string `json:"category,omitempty"` + // MetricClass - The class of the metric. Possible values include: 'MetricClassAvailability', 'MetricClassTransactions', 'MetricClassErrors', 'MetricClassLatency', 'MetricClassSaturation' + MetricClass MetricClass `json:"metricClass,omitempty"` + // Unit - The unit of the metric. Possible values include: 'MetricUnitCount', 'MetricUnitBytes', 'MetricUnitSeconds', 'MetricUnitCountPerSecond', 'MetricUnitBytesPerSecond', 'MetricUnitPercent', 'MetricUnitMilliSeconds', 'MetricUnitByteSeconds', 'MetricUnitUnspecified', 'MetricUnitCores', 'MetricUnitMilliCores', 'MetricUnitNanoCores', 'MetricUnitBitsPerSecond' + Unit MetricUnit `json:"unit,omitempty"` + // PrimaryAggregationType - the primary aggregation type value defining how to use the values for display. Possible values include: 'AggregationTypeNone', 'AggregationTypeAverage', 'AggregationTypeCount', 'AggregationTypeMinimum', 'AggregationTypeMaximum', 'AggregationTypeTotal' + PrimaryAggregationType AggregationType `json:"primaryAggregationType,omitempty"` + // SupportedAggregationTypes - the collection of what aggregation types are supported. + SupportedAggregationTypes *[]AggregationType `json:"supportedAggregationTypes,omitempty"` + // MetricAvailabilities - the collection of what aggregation intervals are available to be queried. + MetricAvailabilities *[]MetricAvailability `json:"metricAvailabilities,omitempty"` + // ID - the resource identifier of the metric definition. + ID *string `json:"id,omitempty"` + // Dimensions - the name and the display name of the dimension, i.e. it is a localizable string. + Dimensions *[]LocalizableString `json:"dimensions,omitempty"` +} + +// MetricDefinitionCollection represents collection of metric definitions. +type MetricDefinitionCollection struct { + autorest.Response `json:"-"` + // Value - the values for the metric definitions. + Value *[]MetricDefinition `json:"value,omitempty"` +} + +// MetricDimension specifies a metric dimension. +type MetricDimension struct { + // Name - Name of the dimension. + Name *string `json:"name,omitempty"` + // Operator - the dimension operator. Only 'Include' and 'Exclude' are supported + Operator *string `json:"operator,omitempty"` + // Values - list of dimension values. + Values *[]string `json:"values,omitempty"` +} + +// MetricNamespace metric namespace class specifies the metadata for a metric namespace. +type MetricNamespace struct { + // ID - The ID of the metric namespace. + ID *string `json:"id,omitempty"` + // Type - The type of the namespace. + Type *string `json:"type,omitempty"` + // Name - The escaped name of the namespace. + Name *string `json:"name,omitempty"` + // Classification - Kind of namespace. Possible values include: 'NamespaceClassificationPlatform', 'NamespaceClassificationCustom', 'NamespaceClassificationQos' + Classification NamespaceClassification `json:"classification,omitempty"` + // Properties - Properties which include the fully qualified namespace name. + Properties *MetricNamespaceName `json:"properties,omitempty"` +} + +// MetricNamespaceCollection represents collection of metric namespaces. +type MetricNamespaceCollection struct { + autorest.Response `json:"-"` + // Value - The values for the metric namespaces. + Value *[]MetricNamespace `json:"value,omitempty"` +} + +// MetricNamespaceName the fully qualified metric namespace name. +type MetricNamespaceName struct { + // MetricNamespaceName - The metric namespace name. + MetricNamespaceName *string `json:"metricNamespaceName,omitempty"` +} + +// MetricSettings part of MultiTenantDiagnosticSettings. Specifies the settings for a particular metric. +type MetricSettings struct { + // TimeGrain - the timegrain of the metric in ISO8601 format. + TimeGrain *string `json:"timeGrain,omitempty"` + // Category - Name of a Diagnostic Metric category for a resource type this setting is applied to. To obtain the list of Diagnostic metric categories for a resource, first perform a GET diagnostic settings operation. + Category *string `json:"category,omitempty"` + // Enabled - a value indicating whether this category is enabled. + Enabled *bool `json:"enabled,omitempty"` + // RetentionPolicy - the retention policy for this category. + RetentionPolicy *RetentionPolicy `json:"retentionPolicy,omitempty"` +} + +// MetricSingleDimension the metric dimension name and value. +type MetricSingleDimension struct { + // Name - Name of the dimension. + Name *string `json:"name,omitempty"` + // Value - Value of the dimension. + Value *string `json:"value,omitempty"` +} + +// MetricTrigger the trigger that results in a scaling action. +type MetricTrigger struct { + // MetricName - the name of the metric that defines what the rule monitors. + MetricName *string `json:"metricName,omitempty"` + // MetricNamespace - the namespace of the metric that defines what the rule monitors. + MetricNamespace *string `json:"metricNamespace,omitempty"` + // MetricResourceURI - the resource identifier of the resource the rule monitors. + MetricResourceURI *string `json:"metricResourceUri,omitempty"` + // TimeGrain - the granularity of metrics the rule monitors. Must be one of the predefined values returned from metric definitions for the metric. Must be between 12 hours and 1 minute. + TimeGrain *string `json:"timeGrain,omitempty"` + // Statistic - the metric statistic type. How the metrics from multiple instances are combined. Possible values include: 'MetricStatisticTypeAverage', 'MetricStatisticTypeMin', 'MetricStatisticTypeMax', 'MetricStatisticTypeSum' + Statistic MetricStatisticType `json:"statistic,omitempty"` + // TimeWindow - the range of time in which instance data is collected. This value must be greater than the delay in metric collection, which can vary from resource-to-resource. Must be between 12 hours and 5 minutes. + TimeWindow *string `json:"timeWindow,omitempty"` + // TimeAggregation - time aggregation type. How the data that is collected should be combined over time. The default value is Average. Possible values include: 'TimeAggregationTypeAverage', 'TimeAggregationTypeMinimum', 'TimeAggregationTypeMaximum', 'TimeAggregationTypeTotal', 'TimeAggregationTypeCount', 'TimeAggregationTypeLast' + TimeAggregation TimeAggregationType `json:"timeAggregation,omitempty"` + // Operator - the operator that is used to compare the metric data and the threshold. Possible values include: 'ComparisonOperationTypeEquals', 'ComparisonOperationTypeNotEquals', 'ComparisonOperationTypeGreaterThan', 'ComparisonOperationTypeGreaterThanOrEqual', 'ComparisonOperationTypeLessThan', 'ComparisonOperationTypeLessThanOrEqual' + Operator ComparisonOperationType `json:"operator,omitempty"` + // Threshold - the threshold of the metric that triggers the scale action. + Threshold *float64 `json:"threshold,omitempty"` + // Dimensions - List of dimension conditions. For example: [{"DimensionName":"AppName","Operator":"Equals","Values":["App1"]},{"DimensionName":"Deployment","Operator":"Equals","Values":["default"]}]. + Dimensions *[]ScaleRuleMetricDimension `json:"dimensions,omitempty"` + // DividePerInstance - a value indicating whether metric should divide per instance. + DividePerInstance *bool `json:"dividePerInstance,omitempty"` +} + +// MetricValue represents a metric value. +type MetricValue struct { + // TimeStamp - the timestamp for the metric value in ISO 8601 format. + TimeStamp *date.Time `json:"timeStamp,omitempty"` + // Average - the average value in the time range. + Average *float64 `json:"average,omitempty"` + // Minimum - the least value in the time range. + Minimum *float64 `json:"minimum,omitempty"` + // Maximum - the greatest value in the time range. + Maximum *float64 `json:"maximum,omitempty"` + // Total - the sum of all of the values in the time range. + Total *float64 `json:"total,omitempty"` + // Count - the number of samples in the time range. Can be used to determine the number of values that contributed to the average value. + Count *float64 `json:"count,omitempty"` +} + +// BasicMultiMetricCriteria the types of conditions for a multi resource alert. +type BasicMultiMetricCriteria interface { + AsMetricCriteria() (*MetricCriteria, bool) + AsDynamicMetricCriteria() (*DynamicMetricCriteria, bool) + AsMultiMetricCriteria() (*MultiMetricCriteria, bool) +} + +// MultiMetricCriteria the types of conditions for a multi resource alert. +type MultiMetricCriteria struct { + // AdditionalProperties - Unmatched properties from the message are deserialized this collection + AdditionalProperties map[string]interface{} `json:""` + // Name - Name of the criteria. + Name *string `json:"name,omitempty"` + // MetricName - Name of the metric. + MetricName *string `json:"metricName,omitempty"` + // MetricNamespace - Namespace of the metric. + MetricNamespace *string `json:"metricNamespace,omitempty"` + // TimeAggregation - the criteria time aggregation types. Possible values include: 'AggregationTypeEnumAverage', 'AggregationTypeEnumCount', 'AggregationTypeEnumMinimum', 'AggregationTypeEnumMaximum', 'AggregationTypeEnumTotal' + TimeAggregation AggregationTypeEnum `json:"timeAggregation,omitempty"` + // Dimensions - List of dimension conditions. + Dimensions *[]MetricDimension `json:"dimensions,omitempty"` + // SkipMetricValidation - Allows creating an alert rule on a custom metric that isn't yet emitted, by causing the metric validation to be skipped. + SkipMetricValidation *bool `json:"skipMetricValidation,omitempty"` + // CriterionType - Possible values include: 'CriterionTypeMultiMetricCriteria', 'CriterionTypeStaticThresholdCriterion', 'CriterionTypeDynamicThresholdCriterion' + CriterionType CriterionType `json:"criterionType,omitempty"` +} + +func unmarshalBasicMultiMetricCriteria(body []byte) (BasicMultiMetricCriteria, error) { + var m map[string]interface{} + err := json.Unmarshal(body, &m) + if err != nil { + return nil, err + } + + switch m["criterionType"] { + case string(CriterionTypeStaticThresholdCriterion): + var mc MetricCriteria + err := json.Unmarshal(body, &mc) + return mc, err + case string(CriterionTypeDynamicThresholdCriterion): + var dmc DynamicMetricCriteria + err := json.Unmarshal(body, &dmc) + return dmc, err + default: + var mmc MultiMetricCriteria + err := json.Unmarshal(body, &mmc) + return mmc, err + } +} +func unmarshalBasicMultiMetricCriteriaArray(body []byte) ([]BasicMultiMetricCriteria, error) { + var rawMessages []*json.RawMessage + err := json.Unmarshal(body, &rawMessages) + if err != nil { + return nil, err + } + + mmcArray := make([]BasicMultiMetricCriteria, len(rawMessages)) + + for index, rawMessage := range rawMessages { + mmc, err := unmarshalBasicMultiMetricCriteria(*rawMessage) + if err != nil { + return nil, err + } + mmcArray[index] = mmc + } + return mmcArray, nil +} + +// MarshalJSON is the custom marshaler for MultiMetricCriteria. +func (mmc MultiMetricCriteria) MarshalJSON() ([]byte, error) { + mmc.CriterionType = CriterionTypeMultiMetricCriteria + objectMap := make(map[string]interface{}) + if mmc.Name != nil { + objectMap["name"] = mmc.Name + } + if mmc.MetricName != nil { + objectMap["metricName"] = mmc.MetricName + } + if mmc.MetricNamespace != nil { + objectMap["metricNamespace"] = mmc.MetricNamespace + } + if mmc.TimeAggregation != "" { + objectMap["timeAggregation"] = mmc.TimeAggregation + } + if mmc.Dimensions != nil { + objectMap["dimensions"] = mmc.Dimensions + } + if mmc.SkipMetricValidation != nil { + objectMap["skipMetricValidation"] = mmc.SkipMetricValidation + } + if mmc.CriterionType != "" { + objectMap["criterionType"] = mmc.CriterionType + } + for k, v := range mmc.AdditionalProperties { + objectMap[k] = v + } + return json.Marshal(objectMap) +} + +// AsMetricCriteria is the BasicMultiMetricCriteria implementation for MultiMetricCriteria. +func (mmc MultiMetricCriteria) AsMetricCriteria() (*MetricCriteria, bool) { + return nil, false +} + +// AsDynamicMetricCriteria is the BasicMultiMetricCriteria implementation for MultiMetricCriteria. +func (mmc MultiMetricCriteria) AsDynamicMetricCriteria() (*DynamicMetricCriteria, bool) { + return nil, false +} + +// AsMultiMetricCriteria is the BasicMultiMetricCriteria implementation for MultiMetricCriteria. +func (mmc MultiMetricCriteria) AsMultiMetricCriteria() (*MultiMetricCriteria, bool) { + return &mmc, true +} + +// AsBasicMultiMetricCriteria is the BasicMultiMetricCriteria implementation for MultiMetricCriteria. +func (mmc MultiMetricCriteria) AsBasicMultiMetricCriteria() (BasicMultiMetricCriteria, bool) { + return &mmc, true +} + +// UnmarshalJSON is the custom unmarshaler for MultiMetricCriteria struct. +func (mmc *MultiMetricCriteria) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + default: + if v != nil { + var additionalProperties interface{} + err = json.Unmarshal(*v, &additionalProperties) + if err != nil { + return err + } + if mmc.AdditionalProperties == nil { + mmc.AdditionalProperties = make(map[string]interface{}) + } + mmc.AdditionalProperties[k] = additionalProperties + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + mmc.Name = &name + } + case "metricName": + if v != nil { + var metricName string + err = json.Unmarshal(*v, &metricName) + if err != nil { + return err + } + mmc.MetricName = &metricName + } + case "metricNamespace": + if v != nil { + var metricNamespace string + err = json.Unmarshal(*v, &metricNamespace) + if err != nil { + return err + } + mmc.MetricNamespace = &metricNamespace + } + case "timeAggregation": + if v != nil { + var timeAggregation AggregationTypeEnum + err = json.Unmarshal(*v, &timeAggregation) + if err != nil { + return err + } + mmc.TimeAggregation = timeAggregation + } + case "dimensions": + if v != nil { + var dimensions []MetricDimension + err = json.Unmarshal(*v, &dimensions) + if err != nil { + return err + } + mmc.Dimensions = &dimensions + } + case "skipMetricValidation": + if v != nil { + var skipMetricValidation bool + err = json.Unmarshal(*v, &skipMetricValidation) + if err != nil { + return err + } + mmc.SkipMetricValidation = &skipMetricValidation + } + case "criterionType": + if v != nil { + var criterionType CriterionType + err = json.Unmarshal(*v, &criterionType) + if err != nil { + return err + } + mmc.CriterionType = criterionType + } + } + } + + return nil +} + +// NetworkRuleSet definition of the network rules. +type NetworkRuleSet struct { + // PublicNetworkAccess - The configuration to set whether network access from public internet to the endpoints are allowed. Possible values include: 'KnownPublicNetworkAccessOptionsEnabled', 'KnownPublicNetworkAccessOptionsDisabled' + PublicNetworkAccess KnownPublicNetworkAccessOptions `json:"publicNetworkAccess,omitempty"` +} + +// Operation microsoft Insights API operation definition. +type Operation struct { + // Name - Operation name: {provider}/{resource}/{operation} + Name *string `json:"name,omitempty"` + // Display - Display metadata associated with the operation. + Display *OperationDisplay `json:"display,omitempty"` +} + +// OperationDisplay display metadata associated with the operation. +type OperationDisplay struct { + // Provider - Service provider: Microsoft.Insights + Provider *string `json:"provider,omitempty"` + // Resource - Resource on which the operation is performed: AlertRules, Autoscale, etc. + Resource *string `json:"resource,omitempty"` + // Operation - Operation type: Read, write, delete, etc. + Operation *string `json:"operation,omitempty"` +} + +// OperationListResult result of the request to list Microsoft.Insights operations. It contains a list of +// operations and a URL link to get the next set of results. +type OperationListResult struct { + autorest.Response `json:"-"` + // Value - List of operations supported by the Microsoft.Insights provider. + Value *[]Operation `json:"value,omitempty"` + // NextLink - URL to get the next set of operation list results if there are any. + NextLink *string `json:"nextLink,omitempty"` +} + +// OperationStatus the status of operation. +type OperationStatus struct { + autorest.Response `json:"-"` + // ID - The operation Id. + ID *string `json:"id,omitempty"` + // Name - The operation name. + Name *string `json:"name,omitempty"` + // StartTime - Start time of the job in standard ISO8601 format. + StartTime *date.Time `json:"startTime,omitempty"` + // EndTime - End time of the job in standard ISO8601 format. + EndTime *date.Time `json:"endTime,omitempty"` + // Status - The status of the operation. + Status *string `json:"status,omitempty"` + // Error - The error detail of the operation if any. + Error *ErrorResponseCommon `json:"error,omitempty"` +} + +// PerfCounterDataSource definition of which performance counters will be collected and how they will be +// collected by this data collection rule. +// Collected from both Windows and Linux machines where the counter is present. +type PerfCounterDataSource struct { + // Streams - List of streams that this data source will be sent to. + // A stream indicates what schema will be used for this data and usually what table in Log Analytics the data will be sent to. + Streams *[]KnownPerfCounterDataSourceStreams `json:"streams,omitempty"` + // SamplingFrequencyInSeconds - The number of seconds between consecutive counter measurements (samples). + SamplingFrequencyInSeconds *int32 `json:"samplingFrequencyInSeconds,omitempty"` + // CounterSpecifiers - A list of specifier names of the performance counters you want to collect. + // Use a wildcard (*) to collect a counter for all instances. + // To get a list of performance counters on Windows, run the command 'typeperf'. + CounterSpecifiers *[]string `json:"counterSpecifiers,omitempty"` + // Name - A friendly name for the data source. + // This name should be unique across all data sources (regardless of type) within the data collection rule. + Name *string `json:"name,omitempty"` +} + +// PrivateEndpointConnection a private endpoint connection +type PrivateEndpointConnection struct { + autorest.Response `json:"-"` + // PrivateEndpointConnectionProperties - Resource properties. + *PrivateEndpointConnectionProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Azure resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Azure resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Azure resource type + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for PrivateEndpointConnection. +func (pec PrivateEndpointConnection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if pec.PrivateEndpointConnectionProperties != nil { + objectMap["properties"] = pec.PrivateEndpointConnectionProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for PrivateEndpointConnection struct. +func (pec *PrivateEndpointConnection) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var privateEndpointConnectionProperties PrivateEndpointConnectionProperties + err = json.Unmarshal(*v, &privateEndpointConnectionProperties) + if err != nil { + return err + } + pec.PrivateEndpointConnectionProperties = &privateEndpointConnectionProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + pec.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + pec.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + pec.Type = &typeVar + } + } + } + + return nil +} + +// PrivateEndpointConnectionListResult a list of private endpoint connections. +type PrivateEndpointConnectionListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]PrivateEndpointConnection `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for PrivateEndpointConnectionListResult. +func (peclr PrivateEndpointConnectionListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// PrivateEndpointConnectionListResultIterator provides access to a complete listing of +// PrivateEndpointConnection values. +type PrivateEndpointConnectionListResultIterator struct { + i int + page PrivateEndpointConnectionListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *PrivateEndpointConnectionListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *PrivateEndpointConnectionListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter PrivateEndpointConnectionListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter PrivateEndpointConnectionListResultIterator) Response() PrivateEndpointConnectionListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter PrivateEndpointConnectionListResultIterator) Value() PrivateEndpointConnection { + if !iter.page.NotDone() { + return PrivateEndpointConnection{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the PrivateEndpointConnectionListResultIterator type. +func NewPrivateEndpointConnectionListResultIterator(page PrivateEndpointConnectionListResultPage) PrivateEndpointConnectionListResultIterator { + return PrivateEndpointConnectionListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (peclr PrivateEndpointConnectionListResult) IsEmpty() bool { + return peclr.Value == nil || len(*peclr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (peclr PrivateEndpointConnectionListResult) hasNextLink() bool { + return peclr.NextLink != nil && len(*peclr.NextLink) != 0 +} + +// privateEndpointConnectionListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (peclr PrivateEndpointConnectionListResult) privateEndpointConnectionListResultPreparer(ctx context.Context) (*http.Request, error) { + if !peclr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(peclr.NextLink))) +} + +// PrivateEndpointConnectionListResultPage contains a page of PrivateEndpointConnection values. +type PrivateEndpointConnectionListResultPage struct { + fn func(context.Context, PrivateEndpointConnectionListResult) (PrivateEndpointConnectionListResult, error) + peclr PrivateEndpointConnectionListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *PrivateEndpointConnectionListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.peclr) + if err != nil { + return err + } + page.peclr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *PrivateEndpointConnectionListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page PrivateEndpointConnectionListResultPage) NotDone() bool { + return !page.peclr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page PrivateEndpointConnectionListResultPage) Response() PrivateEndpointConnectionListResult { + return page.peclr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page PrivateEndpointConnectionListResultPage) Values() []PrivateEndpointConnection { + if page.peclr.IsEmpty() { + return nil + } + return *page.peclr.Value +} + +// Creates a new instance of the PrivateEndpointConnectionListResultPage type. +func NewPrivateEndpointConnectionListResultPage(cur PrivateEndpointConnectionListResult, getNextPage func(context.Context, PrivateEndpointConnectionListResult) (PrivateEndpointConnectionListResult, error)) PrivateEndpointConnectionListResultPage { + return PrivateEndpointConnectionListResultPage{ + fn: getNextPage, + peclr: cur, + } +} + +// PrivateEndpointConnectionProperties properties of a private endpoint connection. +type PrivateEndpointConnectionProperties struct { + // PrivateEndpoint - Private endpoint which the connection belongs to. + PrivateEndpoint *PrivateEndpointProperty `json:"privateEndpoint,omitempty"` + // PrivateLinkServiceConnectionState - Connection state of the private endpoint connection. + PrivateLinkServiceConnectionState *PrivateLinkServiceConnectionStateProperty `json:"privateLinkServiceConnectionState,omitempty"` + // ProvisioningState - READ-ONLY; State of the private endpoint connection. + ProvisioningState *string `json:"provisioningState,omitempty"` +} + +// MarshalJSON is the custom marshaler for PrivateEndpointConnectionProperties. +func (pecp PrivateEndpointConnectionProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if pecp.PrivateEndpoint != nil { + objectMap["privateEndpoint"] = pecp.PrivateEndpoint + } + if pecp.PrivateLinkServiceConnectionState != nil { + objectMap["privateLinkServiceConnectionState"] = pecp.PrivateLinkServiceConnectionState + } + return json.Marshal(objectMap) +} + +// PrivateEndpointConnectionsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results +// of a long-running operation. +type PrivateEndpointConnectionsCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(PrivateEndpointConnectionsClient) (PrivateEndpointConnection, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *PrivateEndpointConnectionsCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for PrivateEndpointConnectionsCreateOrUpdateFuture.Result. +func (future *PrivateEndpointConnectionsCreateOrUpdateFuture) result(client PrivateEndpointConnectionsClient) (pec PrivateEndpointConnection, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.PrivateEndpointConnectionsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + pec.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("insights.PrivateEndpointConnectionsCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if pec.Response.Response, err = future.GetResult(sender); err == nil && pec.Response.Response.StatusCode != http.StatusNoContent { + pec, err = client.CreateOrUpdateResponder(pec.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.PrivateEndpointConnectionsCreateOrUpdateFuture", "Result", pec.Response.Response, "Failure responding to request") + } + } + return +} + +// PrivateEndpointConnectionsDeleteFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type PrivateEndpointConnectionsDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(PrivateEndpointConnectionsClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *PrivateEndpointConnectionsDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for PrivateEndpointConnectionsDeleteFuture.Result. +func (future *PrivateEndpointConnectionsDeleteFuture) result(client PrivateEndpointConnectionsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.PrivateEndpointConnectionsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("insights.PrivateEndpointConnectionsDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// PrivateEndpointProperty private endpoint which the connection belongs to. +type PrivateEndpointProperty struct { + // ID - Resource id of the private endpoint. + ID *string `json:"id,omitempty"` +} + +// PrivateLinkResource a private link resource +type PrivateLinkResource struct { + autorest.Response `json:"-"` + // PrivateLinkResourceProperties - Resource properties. + *PrivateLinkResourceProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Azure resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Azure resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Azure resource type + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for PrivateLinkResource. +func (plr PrivateLinkResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if plr.PrivateLinkResourceProperties != nil { + objectMap["properties"] = plr.PrivateLinkResourceProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for PrivateLinkResource struct. +func (plr *PrivateLinkResource) UnmarshalJSON(body []byte) error { + 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 privateLinkResourceProperties PrivateLinkResourceProperties + err = json.Unmarshal(*v, &privateLinkResourceProperties) + if err != nil { + return err + } + plr.PrivateLinkResourceProperties = &privateLinkResourceProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + plr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + plr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + plr.Type = &typeVar + } + } + } + + return nil +} + +// PrivateLinkResourceListResult a list of private link resources +type PrivateLinkResourceListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]PrivateLinkResource `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for PrivateLinkResourceListResult. +func (plrlr PrivateLinkResourceListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// PrivateLinkResourceListResultIterator provides access to a complete listing of PrivateLinkResource +// values. +type PrivateLinkResourceListResultIterator struct { + i int + page PrivateLinkResourceListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *PrivateLinkResourceListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkResourceListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *PrivateLinkResourceListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter PrivateLinkResourceListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter PrivateLinkResourceListResultIterator) Response() PrivateLinkResourceListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter PrivateLinkResourceListResultIterator) Value() PrivateLinkResource { + if !iter.page.NotDone() { + return PrivateLinkResource{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the PrivateLinkResourceListResultIterator type. +func NewPrivateLinkResourceListResultIterator(page PrivateLinkResourceListResultPage) PrivateLinkResourceListResultIterator { + return PrivateLinkResourceListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (plrlr PrivateLinkResourceListResult) IsEmpty() bool { + return plrlr.Value == nil || len(*plrlr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (plrlr PrivateLinkResourceListResult) hasNextLink() bool { + return plrlr.NextLink != nil && len(*plrlr.NextLink) != 0 +} + +// privateLinkResourceListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (plrlr PrivateLinkResourceListResult) privateLinkResourceListResultPreparer(ctx context.Context) (*http.Request, error) { + if !plrlr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(plrlr.NextLink))) +} + +// PrivateLinkResourceListResultPage contains a page of PrivateLinkResource values. +type PrivateLinkResourceListResultPage struct { + fn func(context.Context, PrivateLinkResourceListResult) (PrivateLinkResourceListResult, error) + plrlr PrivateLinkResourceListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *PrivateLinkResourceListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkResourceListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.plrlr) + if err != nil { + return err + } + page.plrlr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *PrivateLinkResourceListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page PrivateLinkResourceListResultPage) NotDone() bool { + return !page.plrlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page PrivateLinkResourceListResultPage) Response() PrivateLinkResourceListResult { + return page.plrlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page PrivateLinkResourceListResultPage) Values() []PrivateLinkResource { + if page.plrlr.IsEmpty() { + return nil + } + return *page.plrlr.Value +} + +// Creates a new instance of the PrivateLinkResourceListResultPage type. +func NewPrivateLinkResourceListResultPage(cur PrivateLinkResourceListResult, getNextPage func(context.Context, PrivateLinkResourceListResult) (PrivateLinkResourceListResult, error)) PrivateLinkResourceListResultPage { + return PrivateLinkResourceListResultPage{ + fn: getNextPage, + plrlr: cur, + } +} + +// PrivateLinkResourceProperties properties of a private link resource. +type PrivateLinkResourceProperties struct { + // GroupID - READ-ONLY; The private link resource group id. + GroupID *string `json:"groupId,omitempty"` + // RequiredMembers - READ-ONLY; The private link resource required member names. + RequiredMembers *[]string `json:"requiredMembers,omitempty"` +} + +// MarshalJSON is the custom marshaler for PrivateLinkResourceProperties. +func (plrp PrivateLinkResourceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// PrivateLinkScopedResourcesCreateOrUpdateFuture an abstraction for monitoring and retrieving the results +// of a long-running operation. +type PrivateLinkScopedResourcesCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(PrivateLinkScopedResourcesClient) (ScopedResource, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *PrivateLinkScopedResourcesCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for PrivateLinkScopedResourcesCreateOrUpdateFuture.Result. +func (future *PrivateLinkScopedResourcesCreateOrUpdateFuture) result(client PrivateLinkScopedResourcesClient) (sr ScopedResource, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.PrivateLinkScopedResourcesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + sr.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("insights.PrivateLinkScopedResourcesCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if sr.Response.Response, err = future.GetResult(sender); err == nil && sr.Response.Response.StatusCode != http.StatusNoContent { + sr, err = client.CreateOrUpdateResponder(sr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.PrivateLinkScopedResourcesCreateOrUpdateFuture", "Result", sr.Response.Response, "Failure responding to request") + } + } + return +} + +// PrivateLinkScopedResourcesDeleteFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type PrivateLinkScopedResourcesDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(PrivateLinkScopedResourcesClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *PrivateLinkScopedResourcesDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for PrivateLinkScopedResourcesDeleteFuture.Result. +func (future *PrivateLinkScopedResourcesDeleteFuture) result(client PrivateLinkScopedResourcesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.PrivateLinkScopedResourcesDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("insights.PrivateLinkScopedResourcesDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// PrivateLinkScopesDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type PrivateLinkScopesDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(PrivateLinkScopesClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *PrivateLinkScopesDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for PrivateLinkScopesDeleteFuture.Result. +func (future *PrivateLinkScopesDeleteFuture) result(client PrivateLinkScopesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.PrivateLinkScopesDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("insights.PrivateLinkScopesDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// PrivateLinkScopesResource an azure resource object +type PrivateLinkScopesResource struct { + // ID - READ-ONLY; Azure resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Azure resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Azure resource type + Type *string `json:"type,omitempty"` + // Location - Resource location + Location *string `json:"location,omitempty"` + // Tags - Resource tags + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for PrivateLinkScopesResource. +func (plsr PrivateLinkScopesResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if plsr.Location != nil { + objectMap["location"] = plsr.Location + } + if plsr.Tags != nil { + objectMap["tags"] = plsr.Tags + } + return json.Marshal(objectMap) +} + +// PrivateLinkServiceConnectionStateProperty state of the private endpoint connection. +type PrivateLinkServiceConnectionStateProperty struct { + // Status - The private link service connection status. + Status *string `json:"status,omitempty"` + // Description - The private link service connection description. + Description *string `json:"description,omitempty"` + // ActionsRequired - READ-ONLY; The actions required for private link service connection. + ActionsRequired *string `json:"actionsRequired,omitempty"` +} + +// MarshalJSON is the custom marshaler for PrivateLinkServiceConnectionStateProperty. +func (plscsp PrivateLinkServiceConnectionStateProperty) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if plscsp.Status != nil { + objectMap["status"] = plscsp.Status + } + if plscsp.Description != nil { + objectMap["description"] = plscsp.Description + } + return json.Marshal(objectMap) +} + +// ProxyOnlyResource a proxy only azure resource object +type ProxyOnlyResource struct { + // ID - READ-ONLY; Azure resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Azure resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Azure resource type + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ProxyOnlyResource. +func (por ProxyOnlyResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ProxyResource an azure resource object +type ProxyResource struct { + // ID - READ-ONLY; Azure resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Azure resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Azure resource type + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ProxyResource. +func (pr ProxyResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// Recurrence the repeating times at which this profile begins. This element is not used if the FixedDate +// element is used. +type Recurrence struct { + // Frequency - the recurrence frequency. How often the schedule profile should take effect. This value must be Week, meaning each week will have the same set of profiles. For example, to set a daily schedule, set **schedule** to every day of the week. The frequency property specifies that the schedule is repeated weekly. Possible values include: 'RecurrenceFrequencyNone', 'RecurrenceFrequencySecond', 'RecurrenceFrequencyMinute', 'RecurrenceFrequencyHour', 'RecurrenceFrequencyDay', 'RecurrenceFrequencyWeek', 'RecurrenceFrequencyMonth', 'RecurrenceFrequencyYear' + Frequency RecurrenceFrequency `json:"frequency,omitempty"` + // Schedule - the scheduling constraints for when the profile begins. + Schedule *RecurrentSchedule `json:"schedule,omitempty"` +} + +// RecurrentSchedule the scheduling constraints for when the profile begins. +type RecurrentSchedule struct { + // TimeZone - the timezone for the hours of the profile. Some examples of valid time zones are: Dateline Standard Time, UTC-11, Hawaiian Standard Time, Alaskan Standard Time, Pacific Standard Time (Mexico), Pacific Standard Time, US Mountain Standard Time, Mountain Standard Time (Mexico), Mountain Standard Time, Central America Standard Time, Central Standard Time, Central Standard Time (Mexico), Canada Central Standard Time, SA Pacific Standard Time, Eastern Standard Time, US Eastern Standard Time, Venezuela Standard Time, Paraguay Standard Time, Atlantic Standard Time, Central Brazilian Standard Time, SA Western Standard Time, Pacific SA Standard Time, Newfoundland Standard Time, E. South America Standard Time, Argentina Standard Time, SA Eastern Standard Time, Greenland Standard Time, Montevideo Standard Time, Bahia Standard Time, UTC-02, Mid-Atlantic Standard Time, Azores Standard Time, Cape Verde Standard Time, Morocco Standard Time, UTC, GMT Standard Time, Greenwich Standard Time, W. Europe Standard Time, Central Europe Standard Time, Romance Standard Time, Central European Standard Time, W. Central Africa Standard Time, Namibia Standard Time, Jordan Standard Time, GTB Standard Time, Middle East Standard Time, Egypt Standard Time, Syria Standard Time, E. Europe Standard Time, South Africa Standard Time, FLE Standard Time, Turkey Standard Time, Israel Standard Time, Kaliningrad Standard Time, Libya Standard Time, Arabic Standard Time, Arab Standard Time, Belarus Standard Time, Russian Standard Time, E. Africa Standard Time, Iran Standard Time, Arabian Standard Time, Azerbaijan Standard Time, Russia Time Zone 3, Mauritius Standard Time, Georgian Standard Time, Caucasus Standard Time, Afghanistan Standard Time, West Asia Standard Time, Ekaterinburg Standard Time, Pakistan Standard Time, India Standard Time, Sri Lanka Standard Time, Nepal Standard Time, Central Asia Standard Time, Bangladesh Standard Time, N. Central Asia Standard Time, Myanmar Standard Time, SE Asia Standard Time, North Asia Standard Time, China Standard Time, North Asia East Standard Time, Singapore Standard Time, W. Australia Standard Time, Taipei Standard Time, Ulaanbaatar Standard Time, Tokyo Standard Time, Korea Standard Time, Yakutsk Standard Time, Cen. Australia Standard Time, AUS Central Standard Time, E. Australia Standard Time, AUS Eastern Standard Time, West Pacific Standard Time, Tasmania Standard Time, Magadan Standard Time, Vladivostok Standard Time, Russia Time Zone 10, Central Pacific Standard Time, Russia Time Zone 11, New Zealand Standard Time, UTC+12, Fiji Standard Time, Kamchatka Standard Time, Tonga Standard Time, Samoa Standard Time, Line Islands Standard Time + TimeZone *string `json:"timeZone,omitempty"` + // Days - the collection of days that the profile takes effect on. Possible values are Sunday through Saturday. + Days *[]string `json:"days,omitempty"` + // Hours - A collection of hours that the profile takes effect on. Values supported are 0 to 23 on the 24-hour clock (AM/PM times are not supported). + Hours *[]int32 `json:"hours,omitempty"` + // Minutes - A collection of minutes at which the profile takes effect at. + Minutes *[]int32 `json:"minutes,omitempty"` +} + +// Resource an azure resource object +type Resource struct { + // ID - READ-ONLY; Azure resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Azure resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Azure resource type + Type *string `json:"type,omitempty"` + // Location - Resource location + Location *string `json:"location,omitempty"` + // Tags - Resource tags + Tags map[string]*string `json:"tags"` + // Kind - READ-ONLY; Metadata used by portal/tooling/etc to render different UX experiences for resources of the same type; e.g. ApiApps are a kind of Microsoft.Web/sites type. If supported, the resource provider must validate and persist this value. + Kind *string `json:"kind,omitempty"` + // Etag - READ-ONLY; The etag field is *not* required. If it is provided in the response body, it must also be provided as a header per the normal etag convention. Entity tags are used for comparing two or more entities from the same requested resource. HTTP/1.1 uses entity tags in the etag (section 14.19), If-Match (section 14.24), If-None-Match (section 14.26), and If-Range (section 14.27) header fields. + Etag *string `json:"etag,omitempty"` +} + +// MarshalJSON is the custom marshaler for Resource. +func (r Resource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if r.Location != nil { + objectMap["location"] = r.Location + } + if r.Tags != nil { + objectMap["tags"] = r.Tags + } + return json.Marshal(objectMap) +} + +// ResourceForUpdate definition of ARM tracked top level resource properties for update operation. +type ResourceForUpdate struct { + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for ResourceForUpdate. +func (rfu ResourceForUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rfu.Tags != nil { + objectMap["tags"] = rfu.Tags + } + return json.Marshal(objectMap) +} + +// Response the response to a metrics query. +type Response struct { + autorest.Response `json:"-"` + // Cost - The integer value representing the relative cost of the query. + Cost *float64 `json:"cost,omitempty"` + // Timespan - The timespan for which the data was retrieved. Its value consists of two datetimes concatenated, separated by '/'. This may be adjusted in the future and returned back from what was originally requested. + Timespan *string `json:"timespan,omitempty"` + // Interval - The interval (window size) for which the metric data was returned in. This may be adjusted in the future and returned back from what was originally requested. This is not present if a metadata request was made. + Interval *string `json:"interval,omitempty"` + // Namespace - The namespace of the metrics being queried + Namespace *string `json:"namespace,omitempty"` + // Resourceregion - The region of the resource being queried for metrics. + Resourceregion *string `json:"resourceregion,omitempty"` + // Value - the value of the collection. + Value *[]Metric `json:"value,omitempty"` +} + +// ResponseWithError an error response from the API. +type ResponseWithError struct { + // Error - Error information. + Error *Error `json:"error,omitempty"` +} + +// RetentionPolicy specifies the retention policy for the log. +type RetentionPolicy struct { + // Enabled - a value indicating whether the retention policy is enabled. + Enabled *bool `json:"enabled,omitempty"` + // Days - the number of days for the retention in days. A value of 0 will retain the events indefinitely. + Days *int32 `json:"days,omitempty"` +} + +// BasicRuleAction the action that is performed when the alert rule becomes active, and when an alert condition is +// resolved. +type BasicRuleAction interface { + AsRuleEmailAction() (*RuleEmailAction, bool) + AsRuleWebhookAction() (*RuleWebhookAction, bool) + AsRuleAction() (*RuleAction, bool) +} + +// RuleAction the action that is performed when the alert rule becomes active, and when an alert condition is +// resolved. +type RuleAction struct { + // OdataType - Possible values include: 'OdataTypeBasicRuleActionOdataTypeRuleAction', 'OdataTypeBasicRuleActionOdataTypeMicrosoftAzureManagementInsightsModelsRuleEmailAction', 'OdataTypeBasicRuleActionOdataTypeMicrosoftAzureManagementInsightsModelsRuleWebhookAction' + OdataType OdataTypeBasicRuleAction `json:"odata.type,omitempty"` +} + +func unmarshalBasicRuleAction(body []byte) (BasicRuleAction, error) { + var m map[string]interface{} + err := json.Unmarshal(body, &m) + if err != nil { + return nil, err + } + + switch m["odata.type"] { + case string(OdataTypeBasicRuleActionOdataTypeMicrosoftAzureManagementInsightsModelsRuleEmailAction): + var rea RuleEmailAction + err := json.Unmarshal(body, &rea) + return rea, err + case string(OdataTypeBasicRuleActionOdataTypeMicrosoftAzureManagementInsightsModelsRuleWebhookAction): + var rwa RuleWebhookAction + err := json.Unmarshal(body, &rwa) + return rwa, err + default: + var ra RuleAction + err := json.Unmarshal(body, &ra) + return ra, err + } +} +func unmarshalBasicRuleActionArray(body []byte) ([]BasicRuleAction, error) { + var rawMessages []*json.RawMessage + err := json.Unmarshal(body, &rawMessages) + if err != nil { + return nil, err + } + + raArray := make([]BasicRuleAction, len(rawMessages)) + + for index, rawMessage := range rawMessages { + ra, err := unmarshalBasicRuleAction(*rawMessage) + if err != nil { + return nil, err + } + raArray[index] = ra + } + return raArray, nil +} + +// MarshalJSON is the custom marshaler for RuleAction. +func (ra RuleAction) MarshalJSON() ([]byte, error) { + ra.OdataType = OdataTypeBasicRuleActionOdataTypeRuleAction + objectMap := make(map[string]interface{}) + if ra.OdataType != "" { + objectMap["odata.type"] = ra.OdataType + } + return json.Marshal(objectMap) +} + +// AsRuleEmailAction is the BasicRuleAction implementation for RuleAction. +func (ra RuleAction) AsRuleEmailAction() (*RuleEmailAction, bool) { + return nil, false +} + +// AsRuleWebhookAction is the BasicRuleAction implementation for RuleAction. +func (ra RuleAction) AsRuleWebhookAction() (*RuleWebhookAction, bool) { + return nil, false +} + +// AsRuleAction is the BasicRuleAction implementation for RuleAction. +func (ra RuleAction) AsRuleAction() (*RuleAction, bool) { + return &ra, true +} + +// AsBasicRuleAction is the BasicRuleAction implementation for RuleAction. +func (ra RuleAction) AsBasicRuleAction() (BasicRuleAction, bool) { + return &ra, true +} + +// BasicRuleCondition the condition that results in the alert rule being activated. +type BasicRuleCondition interface { + AsThresholdRuleCondition() (*ThresholdRuleCondition, bool) + AsLocationThresholdRuleCondition() (*LocationThresholdRuleCondition, bool) + AsManagementEventRuleCondition() (*ManagementEventRuleCondition, bool) + AsRuleCondition() (*RuleCondition, bool) +} + +// RuleCondition the condition that results in the alert rule being activated. +type RuleCondition struct { + // DataSource - the resource from which the rule collects its data. For this type dataSource will always be of type RuleMetricDataSource. + DataSource BasicRuleDataSource `json:"dataSource,omitempty"` + // OdataType - Possible values include: 'OdataTypeBasicRuleConditionOdataTypeRuleCondition', 'OdataTypeBasicRuleConditionOdataTypeMicrosoftAzureManagementInsightsModelsThresholdRuleCondition', 'OdataTypeBasicRuleConditionOdataTypeMicrosoftAzureManagementInsightsModelsLocationThresholdRuleCondition', 'OdataTypeBasicRuleConditionOdataTypeMicrosoftAzureManagementInsightsModelsManagementEventRuleCondition' + OdataType OdataTypeBasicRuleCondition `json:"odata.type,omitempty"` +} + +func unmarshalBasicRuleCondition(body []byte) (BasicRuleCondition, error) { + var m map[string]interface{} + err := json.Unmarshal(body, &m) + if err != nil { + return nil, err + } + + switch m["odata.type"] { + case string(OdataTypeBasicRuleConditionOdataTypeMicrosoftAzureManagementInsightsModelsThresholdRuleCondition): + var trc ThresholdRuleCondition + err := json.Unmarshal(body, &trc) + return trc, err + case string(OdataTypeBasicRuleConditionOdataTypeMicrosoftAzureManagementInsightsModelsLocationThresholdRuleCondition): + var ltrc LocationThresholdRuleCondition + err := json.Unmarshal(body, <rc) + return ltrc, err + case string(OdataTypeBasicRuleConditionOdataTypeMicrosoftAzureManagementInsightsModelsManagementEventRuleCondition): + var merc ManagementEventRuleCondition + err := json.Unmarshal(body, &merc) + return merc, err + default: + var rc RuleCondition + err := json.Unmarshal(body, &rc) + return rc, err + } +} +func unmarshalBasicRuleConditionArray(body []byte) ([]BasicRuleCondition, error) { + var rawMessages []*json.RawMessage + err := json.Unmarshal(body, &rawMessages) + if err != nil { + return nil, err + } + + rcArray := make([]BasicRuleCondition, len(rawMessages)) + + for index, rawMessage := range rawMessages { + rc, err := unmarshalBasicRuleCondition(*rawMessage) + if err != nil { + return nil, err + } + rcArray[index] = rc + } + return rcArray, nil +} + +// MarshalJSON is the custom marshaler for RuleCondition. +func (rc RuleCondition) MarshalJSON() ([]byte, error) { + rc.OdataType = OdataTypeBasicRuleConditionOdataTypeRuleCondition + objectMap := make(map[string]interface{}) + objectMap["dataSource"] = rc.DataSource + if rc.OdataType != "" { + objectMap["odata.type"] = rc.OdataType + } + return json.Marshal(objectMap) +} + +// AsThresholdRuleCondition is the BasicRuleCondition implementation for RuleCondition. +func (rc RuleCondition) AsThresholdRuleCondition() (*ThresholdRuleCondition, bool) { + return nil, false +} + +// AsLocationThresholdRuleCondition is the BasicRuleCondition implementation for RuleCondition. +func (rc RuleCondition) AsLocationThresholdRuleCondition() (*LocationThresholdRuleCondition, bool) { + return nil, false +} + +// AsManagementEventRuleCondition is the BasicRuleCondition implementation for RuleCondition. +func (rc RuleCondition) AsManagementEventRuleCondition() (*ManagementEventRuleCondition, bool) { + return nil, false +} + +// AsRuleCondition is the BasicRuleCondition implementation for RuleCondition. +func (rc RuleCondition) AsRuleCondition() (*RuleCondition, bool) { + return &rc, true +} + +// AsBasicRuleCondition is the BasicRuleCondition implementation for RuleCondition. +func (rc RuleCondition) AsBasicRuleCondition() (BasicRuleCondition, bool) { + return &rc, true +} + +// UnmarshalJSON is the custom unmarshaler for RuleCondition struct. +func (rc *RuleCondition) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "dataSource": + if v != nil { + dataSource, err := unmarshalBasicRuleDataSource(*v) + if err != nil { + return err + } + rc.DataSource = dataSource + } + case "odata.type": + if v != nil { + var odataType OdataTypeBasicRuleCondition + err = json.Unmarshal(*v, &odataType) + if err != nil { + return err + } + rc.OdataType = odataType + } + } + } + + return nil +} + +// BasicRuleDataSource the resource from which the rule collects its data. +type BasicRuleDataSource interface { + AsRuleMetricDataSource() (*RuleMetricDataSource, bool) + AsRuleManagementEventDataSource() (*RuleManagementEventDataSource, bool) + AsRuleDataSource() (*RuleDataSource, bool) +} + +// RuleDataSource the resource from which the rule collects its data. +type RuleDataSource struct { + // ResourceURI - the resource identifier of the resource the rule monitors. **NOTE**: this property cannot be updated for an existing rule. + ResourceURI *string `json:"resourceUri,omitempty"` + // LegacyResourceID - the legacy resource identifier of the resource the rule monitors. **NOTE**: this property cannot be updated for an existing rule. + LegacyResourceID *string `json:"legacyResourceId,omitempty"` + // ResourceLocation - the location of the resource. + ResourceLocation *string `json:"resourceLocation,omitempty"` + // MetricNamespace - the namespace of the metric. + MetricNamespace *string `json:"metricNamespace,omitempty"` + // OdataType - Possible values include: 'OdataTypeRuleDataSource', 'OdataTypeMicrosoftAzureManagementInsightsModelsRuleMetricDataSource', 'OdataTypeMicrosoftAzureManagementInsightsModelsRuleManagementEventDataSource' + OdataType OdataType `json:"odata.type,omitempty"` +} + +func unmarshalBasicRuleDataSource(body []byte) (BasicRuleDataSource, error) { + var m map[string]interface{} + err := json.Unmarshal(body, &m) + if err != nil { + return nil, err + } + + switch m["odata.type"] { + case string(OdataTypeMicrosoftAzureManagementInsightsModelsRuleMetricDataSource): + var rmds RuleMetricDataSource + err := json.Unmarshal(body, &rmds) + return rmds, err + case string(OdataTypeMicrosoftAzureManagementInsightsModelsRuleManagementEventDataSource): + var rmeds RuleManagementEventDataSource + err := json.Unmarshal(body, &rmeds) + return rmeds, err + default: + var rds RuleDataSource + err := json.Unmarshal(body, &rds) + return rds, err + } +} +func unmarshalBasicRuleDataSourceArray(body []byte) ([]BasicRuleDataSource, error) { + var rawMessages []*json.RawMessage + err := json.Unmarshal(body, &rawMessages) + if err != nil { + return nil, err + } + + rdsArray := make([]BasicRuleDataSource, len(rawMessages)) + + for index, rawMessage := range rawMessages { + rds, err := unmarshalBasicRuleDataSource(*rawMessage) + if err != nil { + return nil, err + } + rdsArray[index] = rds + } + return rdsArray, nil +} + +// MarshalJSON is the custom marshaler for RuleDataSource. +func (rds RuleDataSource) MarshalJSON() ([]byte, error) { + rds.OdataType = OdataTypeRuleDataSource + objectMap := make(map[string]interface{}) + if rds.ResourceURI != nil { + objectMap["resourceUri"] = rds.ResourceURI + } + if rds.LegacyResourceID != nil { + objectMap["legacyResourceId"] = rds.LegacyResourceID + } + if rds.ResourceLocation != nil { + objectMap["resourceLocation"] = rds.ResourceLocation + } + if rds.MetricNamespace != nil { + objectMap["metricNamespace"] = rds.MetricNamespace + } + if rds.OdataType != "" { + objectMap["odata.type"] = rds.OdataType + } + return json.Marshal(objectMap) +} + +// AsRuleMetricDataSource is the BasicRuleDataSource implementation for RuleDataSource. +func (rds RuleDataSource) AsRuleMetricDataSource() (*RuleMetricDataSource, bool) { + return nil, false +} + +// AsRuleManagementEventDataSource is the BasicRuleDataSource implementation for RuleDataSource. +func (rds RuleDataSource) AsRuleManagementEventDataSource() (*RuleManagementEventDataSource, bool) { + return nil, false +} + +// AsRuleDataSource is the BasicRuleDataSource implementation for RuleDataSource. +func (rds RuleDataSource) AsRuleDataSource() (*RuleDataSource, bool) { + return &rds, true +} + +// AsBasicRuleDataSource is the BasicRuleDataSource implementation for RuleDataSource. +func (rds RuleDataSource) AsBasicRuleDataSource() (BasicRuleDataSource, bool) { + return &rds, true +} + +// RuleEmailAction specifies the action to send email when the rule condition is evaluated. The +// discriminator is always RuleEmailAction in this case. +type RuleEmailAction struct { + // SendToServiceOwners - Whether the administrators (service and co-administrators) of the service should be notified when the alert is activated. + SendToServiceOwners *bool `json:"sendToServiceOwners,omitempty"` + // CustomEmails - the list of administrator's custom email addresses to notify of the activation of the alert. + CustomEmails *[]string `json:"customEmails,omitempty"` + // OdataType - Possible values include: 'OdataTypeBasicRuleActionOdataTypeRuleAction', 'OdataTypeBasicRuleActionOdataTypeMicrosoftAzureManagementInsightsModelsRuleEmailAction', 'OdataTypeBasicRuleActionOdataTypeMicrosoftAzureManagementInsightsModelsRuleWebhookAction' + OdataType OdataTypeBasicRuleAction `json:"odata.type,omitempty"` +} + +// MarshalJSON is the custom marshaler for RuleEmailAction. +func (rea RuleEmailAction) MarshalJSON() ([]byte, error) { + rea.OdataType = OdataTypeBasicRuleActionOdataTypeMicrosoftAzureManagementInsightsModelsRuleEmailAction + objectMap := make(map[string]interface{}) + if rea.SendToServiceOwners != nil { + objectMap["sendToServiceOwners"] = rea.SendToServiceOwners + } + if rea.CustomEmails != nil { + objectMap["customEmails"] = rea.CustomEmails + } + if rea.OdataType != "" { + objectMap["odata.type"] = rea.OdataType + } + return json.Marshal(objectMap) +} + +// AsRuleEmailAction is the BasicRuleAction implementation for RuleEmailAction. +func (rea RuleEmailAction) AsRuleEmailAction() (*RuleEmailAction, bool) { + return &rea, true +} + +// AsRuleWebhookAction is the BasicRuleAction implementation for RuleEmailAction. +func (rea RuleEmailAction) AsRuleWebhookAction() (*RuleWebhookAction, bool) { + return nil, false +} + +// AsRuleAction is the BasicRuleAction implementation for RuleEmailAction. +func (rea RuleEmailAction) AsRuleAction() (*RuleAction, bool) { + return nil, false +} + +// AsBasicRuleAction is the BasicRuleAction implementation for RuleEmailAction. +func (rea RuleEmailAction) AsBasicRuleAction() (BasicRuleAction, bool) { + return &rea, true +} + +// RuleManagementEventClaimsDataSource the claims for a rule management event data source. +type RuleManagementEventClaimsDataSource struct { + // EmailAddress - the email address. + EmailAddress *string `json:"emailAddress,omitempty"` +} + +// RuleManagementEventDataSource a rule management event data source. The discriminator fields is always +// RuleManagementEventDataSource in this case. +type RuleManagementEventDataSource struct { + // EventName - the event name. + EventName *string `json:"eventName,omitempty"` + // EventSource - the event source. + EventSource *string `json:"eventSource,omitempty"` + // Level - the level. + Level *string `json:"level,omitempty"` + // OperationName - The name of the operation that should be checked for. If no name is provided, any operation will match. + OperationName *string `json:"operationName,omitempty"` + // ResourceGroupName - the resource group name. + ResourceGroupName *string `json:"resourceGroupName,omitempty"` + // ResourceProviderName - the resource provider name. + ResourceProviderName *string `json:"resourceProviderName,omitempty"` + // Status - The status of the operation that should be checked for. If no status is provided, any status will match. + Status *string `json:"status,omitempty"` + // SubStatus - the substatus. + SubStatus *string `json:"subStatus,omitempty"` + // Claims - the claims. + Claims *RuleManagementEventClaimsDataSource `json:"claims,omitempty"` + // ResourceURI - the resource identifier of the resource the rule monitors. **NOTE**: this property cannot be updated for an existing rule. + ResourceURI *string `json:"resourceUri,omitempty"` + // LegacyResourceID - the legacy resource identifier of the resource the rule monitors. **NOTE**: this property cannot be updated for an existing rule. + LegacyResourceID *string `json:"legacyResourceId,omitempty"` + // ResourceLocation - the location of the resource. + ResourceLocation *string `json:"resourceLocation,omitempty"` + // MetricNamespace - the namespace of the metric. + MetricNamespace *string `json:"metricNamespace,omitempty"` + // OdataType - Possible values include: 'OdataTypeRuleDataSource', 'OdataTypeMicrosoftAzureManagementInsightsModelsRuleMetricDataSource', 'OdataTypeMicrosoftAzureManagementInsightsModelsRuleManagementEventDataSource' + OdataType OdataType `json:"odata.type,omitempty"` +} + +// MarshalJSON is the custom marshaler for RuleManagementEventDataSource. +func (rmeds RuleManagementEventDataSource) MarshalJSON() ([]byte, error) { + rmeds.OdataType = OdataTypeMicrosoftAzureManagementInsightsModelsRuleManagementEventDataSource + objectMap := make(map[string]interface{}) + if rmeds.EventName != nil { + objectMap["eventName"] = rmeds.EventName + } + if rmeds.EventSource != nil { + objectMap["eventSource"] = rmeds.EventSource + } + if rmeds.Level != nil { + objectMap["level"] = rmeds.Level + } + if rmeds.OperationName != nil { + objectMap["operationName"] = rmeds.OperationName + } + if rmeds.ResourceGroupName != nil { + objectMap["resourceGroupName"] = rmeds.ResourceGroupName + } + if rmeds.ResourceProviderName != nil { + objectMap["resourceProviderName"] = rmeds.ResourceProviderName + } + if rmeds.Status != nil { + objectMap["status"] = rmeds.Status + } + if rmeds.SubStatus != nil { + objectMap["subStatus"] = rmeds.SubStatus + } + if rmeds.Claims != nil { + objectMap["claims"] = rmeds.Claims + } + if rmeds.ResourceURI != nil { + objectMap["resourceUri"] = rmeds.ResourceURI + } + if rmeds.LegacyResourceID != nil { + objectMap["legacyResourceId"] = rmeds.LegacyResourceID + } + if rmeds.ResourceLocation != nil { + objectMap["resourceLocation"] = rmeds.ResourceLocation + } + if rmeds.MetricNamespace != nil { + objectMap["metricNamespace"] = rmeds.MetricNamespace + } + if rmeds.OdataType != "" { + objectMap["odata.type"] = rmeds.OdataType + } + return json.Marshal(objectMap) +} + +// AsRuleMetricDataSource is the BasicRuleDataSource implementation for RuleManagementEventDataSource. +func (rmeds RuleManagementEventDataSource) AsRuleMetricDataSource() (*RuleMetricDataSource, bool) { + return nil, false +} + +// AsRuleManagementEventDataSource is the BasicRuleDataSource implementation for RuleManagementEventDataSource. +func (rmeds RuleManagementEventDataSource) AsRuleManagementEventDataSource() (*RuleManagementEventDataSource, bool) { + return &rmeds, true +} + +// AsRuleDataSource is the BasicRuleDataSource implementation for RuleManagementEventDataSource. +func (rmeds RuleManagementEventDataSource) AsRuleDataSource() (*RuleDataSource, bool) { + return nil, false +} + +// AsBasicRuleDataSource is the BasicRuleDataSource implementation for RuleManagementEventDataSource. +func (rmeds RuleManagementEventDataSource) AsBasicRuleDataSource() (BasicRuleDataSource, bool) { + return &rmeds, true +} + +// RuleMetricDataSource a rule metric data source. The discriminator value is always RuleMetricDataSource +// in this case. +type RuleMetricDataSource struct { + // MetricName - the name of the metric that defines what the rule monitors. + MetricName *string `json:"metricName,omitempty"` + // ResourceURI - the resource identifier of the resource the rule monitors. **NOTE**: this property cannot be updated for an existing rule. + ResourceURI *string `json:"resourceUri,omitempty"` + // LegacyResourceID - the legacy resource identifier of the resource the rule monitors. **NOTE**: this property cannot be updated for an existing rule. + LegacyResourceID *string `json:"legacyResourceId,omitempty"` + // ResourceLocation - the location of the resource. + ResourceLocation *string `json:"resourceLocation,omitempty"` + // MetricNamespace - the namespace of the metric. + MetricNamespace *string `json:"metricNamespace,omitempty"` + // OdataType - Possible values include: 'OdataTypeRuleDataSource', 'OdataTypeMicrosoftAzureManagementInsightsModelsRuleMetricDataSource', 'OdataTypeMicrosoftAzureManagementInsightsModelsRuleManagementEventDataSource' + OdataType OdataType `json:"odata.type,omitempty"` +} + +// MarshalJSON is the custom marshaler for RuleMetricDataSource. +func (rmds RuleMetricDataSource) MarshalJSON() ([]byte, error) { + rmds.OdataType = OdataTypeMicrosoftAzureManagementInsightsModelsRuleMetricDataSource + objectMap := make(map[string]interface{}) + if rmds.MetricName != nil { + objectMap["metricName"] = rmds.MetricName + } + if rmds.ResourceURI != nil { + objectMap["resourceUri"] = rmds.ResourceURI + } + if rmds.LegacyResourceID != nil { + objectMap["legacyResourceId"] = rmds.LegacyResourceID + } + if rmds.ResourceLocation != nil { + objectMap["resourceLocation"] = rmds.ResourceLocation + } + if rmds.MetricNamespace != nil { + objectMap["metricNamespace"] = rmds.MetricNamespace + } + if rmds.OdataType != "" { + objectMap["odata.type"] = rmds.OdataType + } + return json.Marshal(objectMap) +} + +// AsRuleMetricDataSource is the BasicRuleDataSource implementation for RuleMetricDataSource. +func (rmds RuleMetricDataSource) AsRuleMetricDataSource() (*RuleMetricDataSource, bool) { + return &rmds, true +} + +// AsRuleManagementEventDataSource is the BasicRuleDataSource implementation for RuleMetricDataSource. +func (rmds RuleMetricDataSource) AsRuleManagementEventDataSource() (*RuleManagementEventDataSource, bool) { + return nil, false +} + +// AsRuleDataSource is the BasicRuleDataSource implementation for RuleMetricDataSource. +func (rmds RuleMetricDataSource) AsRuleDataSource() (*RuleDataSource, bool) { + return nil, false +} + +// AsBasicRuleDataSource is the BasicRuleDataSource implementation for RuleMetricDataSource. +func (rmds RuleMetricDataSource) AsBasicRuleDataSource() (BasicRuleDataSource, bool) { + return &rmds, true +} + +// RuleWebhookAction specifies the action to post to service when the rule condition is evaluated. The +// discriminator is always RuleWebhookAction in this case. +type RuleWebhookAction struct { + // ServiceURI - the service uri to Post the notification when the alert activates or resolves. + ServiceURI *string `json:"serviceUri,omitempty"` + // Properties - the dictionary of custom properties to include with the post operation. These data are appended to the webhook payload. + Properties map[string]*string `json:"properties"` + // OdataType - Possible values include: 'OdataTypeBasicRuleActionOdataTypeRuleAction', 'OdataTypeBasicRuleActionOdataTypeMicrosoftAzureManagementInsightsModelsRuleEmailAction', 'OdataTypeBasicRuleActionOdataTypeMicrosoftAzureManagementInsightsModelsRuleWebhookAction' + OdataType OdataTypeBasicRuleAction `json:"odata.type,omitempty"` +} + +// MarshalJSON is the custom marshaler for RuleWebhookAction. +func (rwa RuleWebhookAction) MarshalJSON() ([]byte, error) { + rwa.OdataType = OdataTypeBasicRuleActionOdataTypeMicrosoftAzureManagementInsightsModelsRuleWebhookAction + objectMap := make(map[string]interface{}) + if rwa.ServiceURI != nil { + objectMap["serviceUri"] = rwa.ServiceURI + } + if rwa.Properties != nil { + objectMap["properties"] = rwa.Properties + } + if rwa.OdataType != "" { + objectMap["odata.type"] = rwa.OdataType + } + return json.Marshal(objectMap) +} + +// AsRuleEmailAction is the BasicRuleAction implementation for RuleWebhookAction. +func (rwa RuleWebhookAction) AsRuleEmailAction() (*RuleEmailAction, bool) { + return nil, false +} + +// AsRuleWebhookAction is the BasicRuleAction implementation for RuleWebhookAction. +func (rwa RuleWebhookAction) AsRuleWebhookAction() (*RuleWebhookAction, bool) { + return &rwa, true +} + +// AsRuleAction is the BasicRuleAction implementation for RuleWebhookAction. +func (rwa RuleWebhookAction) AsRuleAction() (*RuleAction, bool) { + return nil, false +} + +// AsBasicRuleAction is the BasicRuleAction implementation for RuleWebhookAction. +func (rwa RuleWebhookAction) AsBasicRuleAction() (BasicRuleAction, bool) { + return &rwa, true +} + +// ScaleAction the parameters for the scaling action. +type ScaleAction struct { + // Direction - the scale direction. Whether the scaling action increases or decreases the number of instances. Possible values include: 'ScaleDirectionNone', 'ScaleDirectionIncrease', 'ScaleDirectionDecrease' + Direction ScaleDirection `json:"direction,omitempty"` + // Type - the type of action that should occur when the scale rule fires. Possible values include: 'ScaleTypeChangeCount', 'ScaleTypePercentChangeCount', 'ScaleTypeExactCount' + Type ScaleType `json:"type,omitempty"` + // Value - the number of instances that are involved in the scaling action. This value must be 1 or greater. The default value is 1. + Value *string `json:"value,omitempty"` + // Cooldown - the amount of time to wait since the last scaling action before this action occurs. It must be between 1 week and 1 minute in ISO 8601 format. + Cooldown *string `json:"cooldown,omitempty"` +} + +// ScaleCapacity the number of instances that can be used during this profile. +type ScaleCapacity struct { + // Minimum - the minimum number of instances for the resource. + Minimum *string `json:"minimum,omitempty"` + // Maximum - the maximum number of instances for the resource. The actual maximum number of instances is limited by the cores that are available in the subscription. + Maximum *string `json:"maximum,omitempty"` + // Default - the number of instances that will be set if metrics are not available for evaluation. The default is only used if the current instance count is lower than the default. + Default *string `json:"default,omitempty"` +} + +// ScaleRule a rule that provide the triggers and parameters for the scaling action. +type ScaleRule struct { + // MetricTrigger - the trigger that results in a scaling action. + MetricTrigger *MetricTrigger `json:"metricTrigger,omitempty"` + // ScaleAction - the parameters for the scaling action. + ScaleAction *ScaleAction `json:"scaleAction,omitempty"` +} + +// ScaleRuleMetricDimension specifies an auto scale rule metric dimension. +type ScaleRuleMetricDimension struct { + // DimensionName - Name of the dimension. + DimensionName *string `json:"DimensionName,omitempty"` + // Operator - the dimension operator. Only 'Equals' and 'NotEquals' are supported. 'Equals' being equal to any of the values. 'NotEquals' being not equal to all of the values. Possible values include: 'ScaleRuleMetricDimensionOperationTypeEquals', 'ScaleRuleMetricDimensionOperationTypeNotEquals' + Operator ScaleRuleMetricDimensionOperationType `json:"Operator,omitempty"` + // Values - list of dimension values. For example: ["App1","App2"]. + Values *[]string `json:"Values,omitempty"` +} + +// Schedule defines how often to run the search and the time interval. +type Schedule struct { + // FrequencyInMinutes - frequency (in minutes) at which rule condition should be evaluated. + FrequencyInMinutes *int32 `json:"frequencyInMinutes,omitempty"` + // TimeWindowInMinutes - Time window for which data needs to be fetched for query (should be greater than or equal to frequencyInMinutes). + TimeWindowInMinutes *int32 `json:"timeWindowInMinutes,omitempty"` +} + +// ScopedResource a private link scoped resource +type ScopedResource struct { + autorest.Response `json:"-"` + // ScopedResourceProperties - Resource properties. + *ScopedResourceProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Azure resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Azure resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Azure resource type + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ScopedResource. +func (sr ScopedResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sr.ScopedResourceProperties != nil { + objectMap["properties"] = sr.ScopedResourceProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ScopedResource struct. +func (sr *ScopedResource) UnmarshalJSON(body []byte) error { + 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 scopedResourceProperties ScopedResourceProperties + err = json.Unmarshal(*v, &scopedResourceProperties) + if err != nil { + return err + } + sr.ScopedResourceProperties = &scopedResourceProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + sr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + sr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + sr.Type = &typeVar + } + } + } + + return nil +} + +// ScopedResourceListResult a list of scoped resources in a private link scope. +type ScopedResourceListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]ScopedResource `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for ScopedResourceListResult. +func (srlr ScopedResourceListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ScopedResourceListResultIterator provides access to a complete listing of ScopedResource values. +type ScopedResourceListResultIterator struct { + i int + page ScopedResourceListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *ScopedResourceListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ScopedResourceListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ScopedResourceListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ScopedResourceListResultIterator) 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 ScopedResourceListResultIterator) Response() ScopedResourceListResult { + 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 ScopedResourceListResultIterator) Value() ScopedResource { + if !iter.page.NotDone() { + return ScopedResource{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ScopedResourceListResultIterator type. +func NewScopedResourceListResultIterator(page ScopedResourceListResultPage) ScopedResourceListResultIterator { + return ScopedResourceListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (srlr ScopedResourceListResult) IsEmpty() bool { + return srlr.Value == nil || len(*srlr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (srlr ScopedResourceListResult) hasNextLink() bool { + return srlr.NextLink != nil && len(*srlr.NextLink) != 0 +} + +// scopedResourceListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (srlr ScopedResourceListResult) scopedResourceListResultPreparer(ctx context.Context) (*http.Request, error) { + if !srlr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(srlr.NextLink))) +} + +// ScopedResourceListResultPage contains a page of ScopedResource values. +type ScopedResourceListResultPage struct { + fn func(context.Context, ScopedResourceListResult) (ScopedResourceListResult, error) + srlr ScopedResourceListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *ScopedResourceListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ScopedResourceListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.srlr) + if err != nil { + return err + } + page.srlr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *ScopedResourceListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ScopedResourceListResultPage) NotDone() bool { + return !page.srlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ScopedResourceListResultPage) Response() ScopedResourceListResult { + return page.srlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ScopedResourceListResultPage) Values() []ScopedResource { + if page.srlr.IsEmpty() { + return nil + } + return *page.srlr.Value +} + +// Creates a new instance of the ScopedResourceListResultPage type. +func NewScopedResourceListResultPage(cur ScopedResourceListResult, getNextPage func(context.Context, ScopedResourceListResult) (ScopedResourceListResult, error)) ScopedResourceListResultPage { + return ScopedResourceListResultPage{ + fn: getNextPage, + srlr: cur, + } +} + +// ScopedResourceProperties properties of a private link scoped resource. +type ScopedResourceProperties struct { + // LinkedResourceID - The resource id of the scoped Azure monitor resource. + LinkedResourceID *string `json:"linkedResourceId,omitempty"` + // ProvisioningState - READ-ONLY; State of the private endpoint connection. + ProvisioningState *string `json:"provisioningState,omitempty"` +} + +// MarshalJSON is the custom marshaler for ScopedResourceProperties. +func (srp ScopedResourceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if srp.LinkedResourceID != nil { + objectMap["linkedResourceId"] = srp.LinkedResourceID + } + return json.Marshal(objectMap) +} + +// SenderAuthorization the authorization used by the user who has performed the operation that led to this +// event. This captures the RBAC properties of the event. These usually include the 'action', 'role' and +// the 'scope' +type SenderAuthorization struct { + // Action - the permissible actions. For instance: microsoft.support/supporttickets/write + Action *string `json:"action,omitempty"` + // Role - the role of the user. For instance: Subscription Admin + Role *string `json:"role,omitempty"` + // Scope - the scope. + Scope *string `json:"scope,omitempty"` +} + +// SingleBaseline the baseline values for a single sensitivity value. +type SingleBaseline struct { + // Sensitivity - the sensitivity of the baseline. Possible values include: 'BaselineSensitivityLow', 'BaselineSensitivityMedium', 'BaselineSensitivityHigh' + Sensitivity BaselineSensitivity `json:"sensitivity,omitempty"` + // LowThresholds - The low thresholds of the baseline. + LowThresholds *[]float64 `json:"lowThresholds,omitempty"` + // HighThresholds - The high thresholds of the baseline. + HighThresholds *[]float64 `json:"highThresholds,omitempty"` +} + +// SingleMetricBaseline the baseline results of a single metric. +type SingleMetricBaseline struct { + // ID - The metric baseline Id. + ID *string `json:"id,omitempty"` + // Type - The resource type of the metric baseline resource. + Type *string `json:"type,omitempty"` + // Name - The name of the metric for which the baselines were retrieved. + Name *string `json:"name,omitempty"` + // MetricBaselinesProperties - The metric baseline properties of the metric. + *MetricBaselinesProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for SingleMetricBaseline. +func (smb SingleMetricBaseline) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if smb.ID != nil { + objectMap["id"] = smb.ID + } + if smb.Type != nil { + objectMap["type"] = smb.Type + } + if smb.Name != nil { + objectMap["name"] = smb.Name + } + if smb.MetricBaselinesProperties != nil { + objectMap["properties"] = smb.MetricBaselinesProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for SingleMetricBaseline struct. +func (smb *SingleMetricBaseline) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + smb.ID = &ID + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + smb.Type = &typeVar + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + smb.Name = &name + } + case "properties": + if v != nil { + var metricBaselinesProperties MetricBaselinesProperties + err = json.Unmarshal(*v, &metricBaselinesProperties) + if err != nil { + return err + } + smb.MetricBaselinesProperties = &metricBaselinesProperties + } + } + } + + return nil +} + +// SmsReceiver an SMS receiver. +type SmsReceiver struct { + // Name - The name of the SMS receiver. Names must be unique across all receivers within an action group. + Name *string `json:"name,omitempty"` + // CountryCode - The country code of the SMS receiver. + CountryCode *string `json:"countryCode,omitempty"` + // PhoneNumber - The phone number of the SMS receiver. + PhoneNumber *string `json:"phoneNumber,omitempty"` + // Status - READ-ONLY; The status of the receiver. Possible values include: 'ReceiverStatusNotSpecified', 'ReceiverStatusEnabled', 'ReceiverStatusDisabled' + Status ReceiverStatus `json:"status,omitempty"` +} + +// MarshalJSON is the custom marshaler for SmsReceiver. +func (sr SmsReceiver) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sr.Name != nil { + objectMap["name"] = sr.Name + } + if sr.CountryCode != nil { + objectMap["countryCode"] = sr.CountryCode + } + if sr.PhoneNumber != nil { + objectMap["phoneNumber"] = sr.PhoneNumber + } + return json.Marshal(objectMap) +} + +// Source specifies the log search query. +type Source struct { + // Query - Log search query. Required for action type - AlertingAction + Query *string `json:"query,omitempty"` + // AuthorizedResources - List of Resource referred into query + AuthorizedResources *[]string `json:"authorizedResources,omitempty"` + // DataSourceID - The resource uri over which log search query is to be run. + DataSourceID *string `json:"dataSourceId,omitempty"` + // QueryType - Set value to 'ResultCount'. Possible values include: 'QueryTypeResultCount' + QueryType QueryType `json:"queryType,omitempty"` +} + +// SyslogDataSource definition of which syslog data will be collected and how it will be collected. +// Only collected from Linux machines. +type SyslogDataSource struct { + // Streams - List of streams that this data source will be sent to. + // A stream indicates what schema will be used for this data and usually what table in Log Analytics the data will be sent to. + Streams *[]KnownSyslogDataSourceStreams `json:"streams,omitempty"` + // FacilityNames - The list of facility names. + FacilityNames *[]KnownSyslogDataSourceFacilityNames `json:"facilityNames,omitempty"` + // LogLevels - The log levels to collect. + LogLevels *[]KnownSyslogDataSourceLogLevels `json:"logLevels,omitempty"` + // Name - A friendly name for the data source. + // This name should be unique across all data sources (regardless of type) within the data collection rule. + Name *string `json:"name,omitempty"` +} + +// SystemData metadata pertaining to creation and last modification of the resource. +type SystemData struct { + // CreatedBy - The identity that created the resource. + CreatedBy *string `json:"createdBy,omitempty"` + // CreatedByType - The type of identity that created the resource. Possible values include: 'CreatedByTypeUser', 'CreatedByTypeApplication', 'CreatedByTypeManagedIdentity', 'CreatedByTypeKey' + CreatedByType CreatedByType `json:"createdByType,omitempty"` + // CreatedAt - The timestamp of resource creation (UTC). + CreatedAt *date.Time `json:"createdAt,omitempty"` + // LastModifiedBy - The identity that last modified the resource. + LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + // LastModifiedByType - The type of identity that last modified the resource. Possible values include: 'CreatedByTypeUser', 'CreatedByTypeApplication', 'CreatedByTypeManagedIdentity', 'CreatedByTypeKey' + LastModifiedByType CreatedByType `json:"lastModifiedByType,omitempty"` + // LastModifiedAt - The timestamp of resource last modification (UTC) + LastModifiedAt *date.Time `json:"lastModifiedAt,omitempty"` +} + +// TagsResource a container holding only the Tags for a resource, allowing the user to update the tags on a +// PrivateLinkScope instance. +type TagsResource struct { + // Tags - Resource tags + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for TagsResource. +func (tr TagsResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if tr.Tags != nil { + objectMap["tags"] = tr.Tags + } + return json.Marshal(objectMap) +} + +// ThresholdRuleCondition a rule condition based on a metric crossing a threshold. +type ThresholdRuleCondition struct { + // Operator - the operator used to compare the data and the threshold. Possible values include: 'ConditionOperatorGreaterThan', 'ConditionOperatorGreaterThanOrEqual', 'ConditionOperatorLessThan', 'ConditionOperatorLessThanOrEqual' + Operator ConditionOperator `json:"operator,omitempty"` + // Threshold - the threshold value that activates the alert. + Threshold *float64 `json:"threshold,omitempty"` + // WindowSize - the period of time (in ISO 8601 duration format) that is used to monitor alert activity based on the threshold. If specified then it must be between 5 minutes and 1 day. + WindowSize *string `json:"windowSize,omitempty"` + // TimeAggregation - the time aggregation operator. How the data that are collected should be combined over time. The default value is the PrimaryAggregationType of the Metric. Possible values include: 'TimeAggregationOperatorAverage', 'TimeAggregationOperatorMinimum', 'TimeAggregationOperatorMaximum', 'TimeAggregationOperatorTotal', 'TimeAggregationOperatorLast' + TimeAggregation TimeAggregationOperator `json:"timeAggregation,omitempty"` + // DataSource - the resource from which the rule collects its data. For this type dataSource will always be of type RuleMetricDataSource. + DataSource BasicRuleDataSource `json:"dataSource,omitempty"` + // OdataType - Possible values include: 'OdataTypeBasicRuleConditionOdataTypeRuleCondition', 'OdataTypeBasicRuleConditionOdataTypeMicrosoftAzureManagementInsightsModelsThresholdRuleCondition', 'OdataTypeBasicRuleConditionOdataTypeMicrosoftAzureManagementInsightsModelsLocationThresholdRuleCondition', 'OdataTypeBasicRuleConditionOdataTypeMicrosoftAzureManagementInsightsModelsManagementEventRuleCondition' + OdataType OdataTypeBasicRuleCondition `json:"odata.type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ThresholdRuleCondition. +func (trc ThresholdRuleCondition) MarshalJSON() ([]byte, error) { + trc.OdataType = OdataTypeBasicRuleConditionOdataTypeMicrosoftAzureManagementInsightsModelsThresholdRuleCondition + objectMap := make(map[string]interface{}) + if trc.Operator != "" { + objectMap["operator"] = trc.Operator + } + if trc.Threshold != nil { + objectMap["threshold"] = trc.Threshold + } + if trc.WindowSize != nil { + objectMap["windowSize"] = trc.WindowSize + } + if trc.TimeAggregation != "" { + objectMap["timeAggregation"] = trc.TimeAggregation + } + objectMap["dataSource"] = trc.DataSource + if trc.OdataType != "" { + objectMap["odata.type"] = trc.OdataType + } + return json.Marshal(objectMap) +} + +// AsThresholdRuleCondition is the BasicRuleCondition implementation for ThresholdRuleCondition. +func (trc ThresholdRuleCondition) AsThresholdRuleCondition() (*ThresholdRuleCondition, bool) { + return &trc, true +} + +// AsLocationThresholdRuleCondition is the BasicRuleCondition implementation for ThresholdRuleCondition. +func (trc ThresholdRuleCondition) AsLocationThresholdRuleCondition() (*LocationThresholdRuleCondition, bool) { + return nil, false +} + +// AsManagementEventRuleCondition is the BasicRuleCondition implementation for ThresholdRuleCondition. +func (trc ThresholdRuleCondition) AsManagementEventRuleCondition() (*ManagementEventRuleCondition, bool) { + return nil, false +} + +// AsRuleCondition is the BasicRuleCondition implementation for ThresholdRuleCondition. +func (trc ThresholdRuleCondition) AsRuleCondition() (*RuleCondition, bool) { + return nil, false +} + +// AsBasicRuleCondition is the BasicRuleCondition implementation for ThresholdRuleCondition. +func (trc ThresholdRuleCondition) AsBasicRuleCondition() (BasicRuleCondition, bool) { + return &trc, true +} + +// UnmarshalJSON is the custom unmarshaler for ThresholdRuleCondition struct. +func (trc *ThresholdRuleCondition) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "operator": + if v != nil { + var operator ConditionOperator + err = json.Unmarshal(*v, &operator) + if err != nil { + return err + } + trc.Operator = operator + } + case "threshold": + if v != nil { + var threshold float64 + err = json.Unmarshal(*v, &threshold) + if err != nil { + return err + } + trc.Threshold = &threshold + } + case "windowSize": + if v != nil { + var windowSize string + err = json.Unmarshal(*v, &windowSize) + if err != nil { + return err + } + trc.WindowSize = &windowSize + } + case "timeAggregation": + if v != nil { + var timeAggregation TimeAggregationOperator + err = json.Unmarshal(*v, &timeAggregation) + if err != nil { + return err + } + trc.TimeAggregation = timeAggregation + } + case "dataSource": + if v != nil { + dataSource, err := unmarshalBasicRuleDataSource(*v) + if err != nil { + return err + } + trc.DataSource = dataSource + } + case "odata.type": + if v != nil { + var odataType OdataTypeBasicRuleCondition + err = json.Unmarshal(*v, &odataType) + if err != nil { + return err + } + trc.OdataType = odataType + } + } + } + + return nil +} + +// TimeSeriesBaseline the baseline values for a single time series. +type TimeSeriesBaseline struct { + // Aggregation - The aggregation type of the metric. + Aggregation *string `json:"aggregation,omitempty"` + // Dimensions - The dimensions of this time series. + Dimensions *[]MetricSingleDimension `json:"dimensions,omitempty"` + // Timestamps - The list of timestamps of the baselines. + Timestamps *[]date.Time `json:"timestamps,omitempty"` + // Data - The baseline values for each sensitivity. + Data *[]SingleBaseline `json:"data,omitempty"` + // MetadataValues - The baseline metadata values. + MetadataValues *[]BaselineMetadata `json:"metadataValues,omitempty"` +} + +// TimeSeriesElement a time series result type. The discriminator value is always TimeSeries in this case. +type TimeSeriesElement struct { + // Metadatavalues - the metadata values returned if $filter was specified in the call. + Metadatavalues *[]MetadataValue `json:"metadatavalues,omitempty"` + // Data - An array of data points representing the metric values. This is only returned if a result type of data is specified. + Data *[]MetricValue `json:"data,omitempty"` +} + +// TimeWindow a specific date-time for the profile. +type TimeWindow struct { + // TimeZone - the timezone of the start and end times for the profile. Some examples of valid time zones are: Dateline Standard Time, UTC-11, Hawaiian Standard Time, Alaskan Standard Time, Pacific Standard Time (Mexico), Pacific Standard Time, US Mountain Standard Time, Mountain Standard Time (Mexico), Mountain Standard Time, Central America Standard Time, Central Standard Time, Central Standard Time (Mexico), Canada Central Standard Time, SA Pacific Standard Time, Eastern Standard Time, US Eastern Standard Time, Venezuela Standard Time, Paraguay Standard Time, Atlantic Standard Time, Central Brazilian Standard Time, SA Western Standard Time, Pacific SA Standard Time, Newfoundland Standard Time, E. South America Standard Time, Argentina Standard Time, SA Eastern Standard Time, Greenland Standard Time, Montevideo Standard Time, Bahia Standard Time, UTC-02, Mid-Atlantic Standard Time, Azores Standard Time, Cape Verde Standard Time, Morocco Standard Time, UTC, GMT Standard Time, Greenwich Standard Time, W. Europe Standard Time, Central Europe Standard Time, Romance Standard Time, Central European Standard Time, W. Central Africa Standard Time, Namibia Standard Time, Jordan Standard Time, GTB Standard Time, Middle East Standard Time, Egypt Standard Time, Syria Standard Time, E. Europe Standard Time, South Africa Standard Time, FLE Standard Time, Turkey Standard Time, Israel Standard Time, Kaliningrad Standard Time, Libya Standard Time, Arabic Standard Time, Arab Standard Time, Belarus Standard Time, Russian Standard Time, E. Africa Standard Time, Iran Standard Time, Arabian Standard Time, Azerbaijan Standard Time, Russia Time Zone 3, Mauritius Standard Time, Georgian Standard Time, Caucasus Standard Time, Afghanistan Standard Time, West Asia Standard Time, Ekaterinburg Standard Time, Pakistan Standard Time, India Standard Time, Sri Lanka Standard Time, Nepal Standard Time, Central Asia Standard Time, Bangladesh Standard Time, N. Central Asia Standard Time, Myanmar Standard Time, SE Asia Standard Time, North Asia Standard Time, China Standard Time, North Asia East Standard Time, Singapore Standard Time, W. Australia Standard Time, Taipei Standard Time, Ulaanbaatar Standard Time, Tokyo Standard Time, Korea Standard Time, Yakutsk Standard Time, Cen. Australia Standard Time, AUS Central Standard Time, E. Australia Standard Time, AUS Eastern Standard Time, West Pacific Standard Time, Tasmania Standard Time, Magadan Standard Time, Vladivostok Standard Time, Russia Time Zone 10, Central Pacific Standard Time, Russia Time Zone 11, New Zealand Standard Time, UTC+12, Fiji Standard Time, Kamchatka Standard Time, Tonga Standard Time, Samoa Standard Time, Line Islands Standard Time + TimeZone *string `json:"timeZone,omitempty"` + // Start - the start time for the profile in ISO 8601 format. + Start *date.Time `json:"start,omitempty"` + // End - the end time for the profile in ISO 8601 format. + End *date.Time `json:"end,omitempty"` +} + +// TriggerCondition the condition that results in the Log Search rule. +type TriggerCondition struct { + // ThresholdOperator - Evaluation operation for rule - 'GreaterThan' or 'LessThan. Possible values include: 'ConditionalOperatorGreaterThanOrEqual', 'ConditionalOperatorLessThanOrEqual', 'ConditionalOperatorGreaterThan', 'ConditionalOperatorLessThan', 'ConditionalOperatorEqual' + ThresholdOperator ConditionalOperator `json:"thresholdOperator,omitempty"` + // Threshold - Result or count threshold based on which rule should be triggered. + Threshold *float64 `json:"threshold,omitempty"` + // MetricTrigger - Trigger condition for metric query rule + MetricTrigger *LogMetricTrigger `json:"metricTrigger,omitempty"` +} + +// VMInsightsOnboardingStatus VM Insights onboarding status for a resource. +type VMInsightsOnboardingStatus struct { + autorest.Response `json:"-"` + // VMInsightsOnboardingStatusProperties - Resource properties. + *VMInsightsOnboardingStatusProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Azure resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Azure resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Azure resource type + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for VMInsightsOnboardingStatus. +func (vios VMInsightsOnboardingStatus) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if vios.VMInsightsOnboardingStatusProperties != nil { + objectMap["properties"] = vios.VMInsightsOnboardingStatusProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for VMInsightsOnboardingStatus struct. +func (vios *VMInsightsOnboardingStatus) UnmarshalJSON(body []byte) error { + 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 VMInsightsOnboardingStatusProperties VMInsightsOnboardingStatusProperties + err = json.Unmarshal(*v, &VMInsightsOnboardingStatusProperties) + if err != nil { + return err + } + vios.VMInsightsOnboardingStatusProperties = &VMInsightsOnboardingStatusProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + vios.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + vios.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + vios.Type = &typeVar + } + } + } + + return nil +} + +// VMInsightsOnboardingStatusProperties resource properties. +type VMInsightsOnboardingStatusProperties struct { + // ResourceID - Azure Resource Manager identifier of the resource whose onboarding status is being represented. + ResourceID *string `json:"resourceId,omitempty"` + // OnboardingStatus - The onboarding status for the resource. Note that, a higher level scope, e.g., resource group or subscription, is considered onboarded if at least one resource under it is onboarded. Possible values include: 'OnboardingStatusOnboarded', 'OnboardingStatusNotOnboarded', 'OnboardingStatusUnknown' + OnboardingStatus OnboardingStatus `json:"onboardingStatus,omitempty"` + // DataStatus - The status of VM Insights data from the resource. When reported as `present` the data array will contain information about the data containers to which data for the specified resource is being routed. Possible values include: 'DataStatusPresent', 'DataStatusNotPresent' + DataStatus DataStatus `json:"dataStatus,omitempty"` + // Data - Containers that currently store VM Insights data for the specified resource. + Data *[]DataContainer `json:"data,omitempty"` +} + +// VoiceReceiver a voice receiver. +type VoiceReceiver struct { + // Name - The name of the voice receiver. Names must be unique across all receivers within an action group. + Name *string `json:"name,omitempty"` + // CountryCode - The country code of the voice receiver. + CountryCode *string `json:"countryCode,omitempty"` + // PhoneNumber - The phone number of the voice receiver. + PhoneNumber *string `json:"phoneNumber,omitempty"` +} + +// WebhookNotification webhook notification of an autoscale event. +type WebhookNotification struct { + // ServiceURI - the service address to receive the notification. + ServiceURI *string `json:"serviceUri,omitempty"` + // Properties - a property bag of settings. This value can be empty. + Properties map[string]*string `json:"properties"` +} + +// MarshalJSON is the custom marshaler for WebhookNotification. +func (wn WebhookNotification) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if wn.ServiceURI != nil { + objectMap["serviceUri"] = wn.ServiceURI + } + if wn.Properties != nil { + objectMap["properties"] = wn.Properties + } + return json.Marshal(objectMap) +} + +// WebhookReceiver a webhook receiver. +type WebhookReceiver struct { + // Name - The name of the webhook receiver. Names must be unique across all receivers within an action group. + Name *string `json:"name,omitempty"` + // ServiceURI - The URI where webhooks should be sent. + ServiceURI *string `json:"serviceUri,omitempty"` + // UseCommonAlertSchema - Indicates whether to use common alert schema. + UseCommonAlertSchema *bool `json:"useCommonAlertSchema,omitempty"` + // UseAadAuth - Indicates whether or not use AAD authentication. + UseAadAuth *bool `json:"useAadAuth,omitempty"` + // ObjectID - Indicates the webhook app object Id for aad auth. + ObjectID *string `json:"objectId,omitempty"` + // IdentifierURI - Indicates the identifier uri for aad auth. + IdentifierURI *string `json:"identifierUri,omitempty"` + // TenantID - Indicates the tenant id for aad auth. + TenantID *string `json:"tenantId,omitempty"` +} + +// WebtestLocationAvailabilityCriteria specifies the metric alert rule criteria for a web test resource. +type WebtestLocationAvailabilityCriteria struct { + // WebTestID - The Application Insights web test Id. + WebTestID *string `json:"webTestId,omitempty"` + // ComponentID - The Application Insights resource Id. + ComponentID *string `json:"componentId,omitempty"` + // FailedLocationCount - The number of failed locations. + FailedLocationCount *float64 `json:"failedLocationCount,omitempty"` + // AdditionalProperties - Unmatched properties from the message are deserialized this collection + AdditionalProperties map[string]interface{} `json:""` + // OdataType - Possible values include: 'OdataTypeBasicMetricAlertCriteriaOdataTypeMetricAlertCriteria', 'OdataTypeBasicMetricAlertCriteriaOdataTypeMicrosoftAzureMonitorSingleResourceMultipleMetricCriteria', 'OdataTypeBasicMetricAlertCriteriaOdataTypeMicrosoftAzureMonitorWebtestLocationAvailabilityCriteria', 'OdataTypeBasicMetricAlertCriteriaOdataTypeMicrosoftAzureMonitorMultipleResourceMultipleMetricCriteria' + OdataType OdataTypeBasicMetricAlertCriteria `json:"odata.type,omitempty"` +} + +// MarshalJSON is the custom marshaler for WebtestLocationAvailabilityCriteria. +func (wlac WebtestLocationAvailabilityCriteria) MarshalJSON() ([]byte, error) { + wlac.OdataType = OdataTypeBasicMetricAlertCriteriaOdataTypeMicrosoftAzureMonitorWebtestLocationAvailabilityCriteria + objectMap := make(map[string]interface{}) + if wlac.WebTestID != nil { + objectMap["webTestId"] = wlac.WebTestID + } + if wlac.ComponentID != nil { + objectMap["componentId"] = wlac.ComponentID + } + if wlac.FailedLocationCount != nil { + objectMap["failedLocationCount"] = wlac.FailedLocationCount + } + if wlac.OdataType != "" { + objectMap["odata.type"] = wlac.OdataType + } + for k, v := range wlac.AdditionalProperties { + objectMap[k] = v + } + return json.Marshal(objectMap) +} + +// AsMetricAlertSingleResourceMultipleMetricCriteria is the BasicMetricAlertCriteria implementation for WebtestLocationAvailabilityCriteria. +func (wlac WebtestLocationAvailabilityCriteria) AsMetricAlertSingleResourceMultipleMetricCriteria() (*MetricAlertSingleResourceMultipleMetricCriteria, bool) { + return nil, false +} + +// AsWebtestLocationAvailabilityCriteria is the BasicMetricAlertCriteria implementation for WebtestLocationAvailabilityCriteria. +func (wlac WebtestLocationAvailabilityCriteria) AsWebtestLocationAvailabilityCriteria() (*WebtestLocationAvailabilityCriteria, bool) { + return &wlac, true +} + +// AsMetricAlertMultipleResourceMultipleMetricCriteria is the BasicMetricAlertCriteria implementation for WebtestLocationAvailabilityCriteria. +func (wlac WebtestLocationAvailabilityCriteria) AsMetricAlertMultipleResourceMultipleMetricCriteria() (*MetricAlertMultipleResourceMultipleMetricCriteria, bool) { + return nil, false +} + +// AsMetricAlertCriteria is the BasicMetricAlertCriteria implementation for WebtestLocationAvailabilityCriteria. +func (wlac WebtestLocationAvailabilityCriteria) AsMetricAlertCriteria() (*MetricAlertCriteria, bool) { + return nil, false +} + +// AsBasicMetricAlertCriteria is the BasicMetricAlertCriteria implementation for WebtestLocationAvailabilityCriteria. +func (wlac WebtestLocationAvailabilityCriteria) AsBasicMetricAlertCriteria() (BasicMetricAlertCriteria, bool) { + return &wlac, true +} + +// UnmarshalJSON is the custom unmarshaler for WebtestLocationAvailabilityCriteria struct. +func (wlac *WebtestLocationAvailabilityCriteria) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "webTestId": + if v != nil { + var webTestID string + err = json.Unmarshal(*v, &webTestID) + if err != nil { + return err + } + wlac.WebTestID = &webTestID + } + case "componentId": + if v != nil { + var componentID string + err = json.Unmarshal(*v, &componentID) + if err != nil { + return err + } + wlac.ComponentID = &componentID + } + case "failedLocationCount": + if v != nil { + var failedLocationCount float64 + err = json.Unmarshal(*v, &failedLocationCount) + if err != nil { + return err + } + wlac.FailedLocationCount = &failedLocationCount + } + default: + if v != nil { + var additionalProperties interface{} + err = json.Unmarshal(*v, &additionalProperties) + if err != nil { + return err + } + if wlac.AdditionalProperties == nil { + wlac.AdditionalProperties = make(map[string]interface{}) + } + wlac.AdditionalProperties[k] = additionalProperties + } + case "odata.type": + if v != nil { + var odataType OdataTypeBasicMetricAlertCriteria + err = json.Unmarshal(*v, &odataType) + if err != nil { + return err + } + wlac.OdataType = odataType + } + } + } + + return nil +} + +// WindowsEventLogDataSource definition of which Windows Event Log events will be collected and how they +// will be collected. +// Only collected from Windows machines. +type WindowsEventLogDataSource struct { + // Streams - List of streams that this data source will be sent to. + // A stream indicates what schema will be used for this data and usually what table in Log Analytics the data will be sent to. + Streams *[]KnownWindowsEventLogDataSourceStreams `json:"streams,omitempty"` + // XPathQueries - A list of Windows Event Log queries in XPATH format. + XPathQueries *[]string `json:"xPathQueries,omitempty"` + // Name - A friendly name for the data source. + // This name should be unique across all data sources (regardless of type) within the data collection rule. + Name *string `json:"name,omitempty"` +} + +// WorkspaceInfo information about a Log Analytics Workspace. +type WorkspaceInfo struct { + // ID - Azure Resource Manager identifier of the Log Analytics Workspace. + ID *string `json:"id,omitempty"` + // Location - Location of the Log Analytics workspace. + Location *string `json:"location,omitempty"` + // WorkspaceInfoProperties - Resource properties. + *WorkspaceInfoProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for WorkspaceInfo. +func (wi WorkspaceInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if wi.ID != nil { + objectMap["id"] = wi.ID + } + if wi.Location != nil { + objectMap["location"] = wi.Location + } + if wi.WorkspaceInfoProperties != nil { + objectMap["properties"] = wi.WorkspaceInfoProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for WorkspaceInfo struct. +func (wi *WorkspaceInfo) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + wi.ID = &ID + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + wi.Location = &location + } + case "properties": + if v != nil { + var workspaceInfoProperties WorkspaceInfoProperties + err = json.Unmarshal(*v, &workspaceInfoProperties) + if err != nil { + return err + } + wi.WorkspaceInfoProperties = &workspaceInfoProperties + } + } + } + + return nil +} + +// WorkspaceInfoProperties resource properties. +type WorkspaceInfoProperties struct { + // CustomerID - Log Analytics workspace identifier. + CustomerID *string `json:"customerId,omitempty"` +} diff --git a/services/preview/monitor/mgmt/2021-04-01-preview/insights/operations.go b/services/preview/monitor/mgmt/2021-04-01-preview/insights/operations.go new file mode 100644 index 000000000000..3f82351c7f23 --- /dev/null +++ b/services/preview/monitor/mgmt/2021-04-01-preview/insights/operations.go @@ -0,0 +1,98 @@ +package insights + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// OperationsClient is the monitor Management Client +type OperationsClient struct { + BaseClient +} + +// NewOperationsClient creates an instance of the OperationsClient client. +func NewOperationsClient(subscriptionID string) OperationsClient { + return NewOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewOperationsClientWithBaseURI creates an instance of the OperationsClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient { + return OperationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List lists all of the available operations from Microsoft.Insights provider. +func (client OperationsClient) List(ctx context.Context) (result OperationListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.OperationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.OperationsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.OperationsClient", "List", resp, "Failure responding to request") + return + } + + return +} + +// ListPreparer prepares the List request. +func (client OperationsClient) ListPreparer(ctx context.Context) (*http.Request, error) { + const APIVersion = "2015-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/microsoft.insights/operations"), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client OperationsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client OperationsClient) ListResponder(resp *http.Response) (result OperationListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/monitor/mgmt/2021-04-01-preview/insights/privateendpointconnections.go b/services/preview/monitor/mgmt/2021-04-01-preview/insights/privateendpointconnections.go new file mode 100644 index 000000000000..dbbf6b656f55 --- /dev/null +++ b/services/preview/monitor/mgmt/2021-04-01-preview/insights/privateendpointconnections.go @@ -0,0 +1,433 @@ +package insights + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// PrivateEndpointConnectionsClient is the monitor Management Client +type PrivateEndpointConnectionsClient struct { + BaseClient +} + +// NewPrivateEndpointConnectionsClient creates an instance of the PrivateEndpointConnectionsClient client. +func NewPrivateEndpointConnectionsClient(subscriptionID string) PrivateEndpointConnectionsClient { + return NewPrivateEndpointConnectionsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewPrivateEndpointConnectionsClientWithBaseURI creates an instance of the PrivateEndpointConnectionsClient client +// using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign +// clouds, Azure stack). +func NewPrivateEndpointConnectionsClientWithBaseURI(baseURI string, subscriptionID string) PrivateEndpointConnectionsClient { + return PrivateEndpointConnectionsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate approve or reject a private endpoint connection with a given name. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// scopeName - the name of the Azure Monitor PrivateLinkScope resource. +// privateEndpointConnectionName - the name of the private endpoint connection. +func (client PrivateEndpointConnectionsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, scopeName string, privateEndpointConnectionName string, parameters PrivateEndpointConnection) (result PrivateEndpointConnectionsCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.PrivateEndpointConnectionProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.PrivateEndpointConnectionProperties.PrivateLinkServiceConnectionState", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.PrivateEndpointConnectionProperties.PrivateLinkServiceConnectionState.Status", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.PrivateEndpointConnectionProperties.PrivateLinkServiceConnectionState.Description", Name: validation.Null, Rule: true, Chain: nil}, + }}, + }}}}}); err != nil { + return result, validation.NewError("insights.PrivateEndpointConnectionsClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, scopeName, privateEndpointConnectionName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.PrivateEndpointConnectionsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.PrivateEndpointConnectionsClient", "CreateOrUpdate", nil, "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client PrivateEndpointConnectionsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, scopeName string, privateEndpointConnectionName string, parameters PrivateEndpointConnection) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateEndpointConnectionName": autorest.Encode("path", privateEndpointConnectionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "scopeName": autorest.Encode("path", scopeName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-10-17-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.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateEndpointConnectionsClient) CreateOrUpdateSender(req *http.Request) (future PrivateEndpointConnectionsCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client PrivateEndpointConnectionsClient) CreateOrUpdateResponder(resp *http.Response) (result PrivateEndpointConnection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a private endpoint connection with a given name. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// scopeName - the name of the Azure Monitor PrivateLinkScope resource. +// privateEndpointConnectionName - the name of the private endpoint connection. +func (client PrivateEndpointConnectionsClient) Delete(ctx context.Context, resourceGroupName string, scopeName string, privateEndpointConnectionName string) (result PrivateEndpointConnectionsDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.PrivateEndpointConnectionsClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, scopeName, privateEndpointConnectionName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.PrivateEndpointConnectionsClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.PrivateEndpointConnectionsClient", "Delete", nil, "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client PrivateEndpointConnectionsClient) DeletePreparer(ctx context.Context, resourceGroupName string, scopeName string, privateEndpointConnectionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateEndpointConnectionName": autorest.Encode("path", privateEndpointConnectionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "scopeName": autorest.Encode("path", scopeName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-10-17-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.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateEndpointConnectionsClient) DeleteSender(req *http.Request) (future PrivateEndpointConnectionsDeleteFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client PrivateEndpointConnectionsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a private endpoint connection. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// scopeName - the name of the Azure Monitor PrivateLinkScope resource. +// privateEndpointConnectionName - the name of the private endpoint connection. +func (client PrivateEndpointConnectionsClient) Get(ctx context.Context, resourceGroupName string, scopeName string, privateEndpointConnectionName string) (result PrivateEndpointConnection, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.PrivateEndpointConnectionsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, scopeName, privateEndpointConnectionName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.PrivateEndpointConnectionsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.PrivateEndpointConnectionsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.PrivateEndpointConnectionsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client PrivateEndpointConnectionsClient) GetPreparer(ctx context.Context, resourceGroupName string, scopeName string, privateEndpointConnectionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateEndpointConnectionName": autorest.Encode("path", privateEndpointConnectionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "scopeName": autorest.Encode("path", scopeName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-10-17-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateEndpointConnectionsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client PrivateEndpointConnectionsClient) GetResponder(resp *http.Response) (result PrivateEndpointConnection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByPrivateLinkScope gets all private endpoint connections on a private link scope. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// scopeName - the name of the Azure Monitor PrivateLinkScope resource. +func (client PrivateEndpointConnectionsClient) ListByPrivateLinkScope(ctx context.Context, resourceGroupName string, scopeName string) (result PrivateEndpointConnectionListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsClient.ListByPrivateLinkScope") + defer func() { + sc := -1 + if result.peclr.Response.Response != nil { + sc = result.peclr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.PrivateEndpointConnectionsClient", "ListByPrivateLinkScope", err.Error()) + } + + result.fn = client.listByPrivateLinkScopeNextResults + req, err := client.ListByPrivateLinkScopePreparer(ctx, resourceGroupName, scopeName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.PrivateEndpointConnectionsClient", "ListByPrivateLinkScope", nil, "Failure preparing request") + return + } + + resp, err := client.ListByPrivateLinkScopeSender(req) + if err != nil { + result.peclr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.PrivateEndpointConnectionsClient", "ListByPrivateLinkScope", resp, "Failure sending request") + return + } + + result.peclr, err = client.ListByPrivateLinkScopeResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.PrivateEndpointConnectionsClient", "ListByPrivateLinkScope", resp, "Failure responding to request") + return + } + if result.peclr.hasNextLink() && result.peclr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByPrivateLinkScopePreparer prepares the ListByPrivateLinkScope request. +func (client PrivateEndpointConnectionsClient) ListByPrivateLinkScopePreparer(ctx context.Context, resourceGroupName string, scopeName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "scopeName": autorest.Encode("path", scopeName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-10-17-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByPrivateLinkScopeSender sends the ListByPrivateLinkScope request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateEndpointConnectionsClient) ListByPrivateLinkScopeSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByPrivateLinkScopeResponder handles the response to the ListByPrivateLinkScope request. The method always +// closes the http.Response Body. +func (client PrivateEndpointConnectionsClient) ListByPrivateLinkScopeResponder(resp *http.Response) (result PrivateEndpointConnectionListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByPrivateLinkScopeNextResults retrieves the next set of results, if any. +func (client PrivateEndpointConnectionsClient) listByPrivateLinkScopeNextResults(ctx context.Context, lastResults PrivateEndpointConnectionListResult) (result PrivateEndpointConnectionListResult, err error) { + req, err := lastResults.privateEndpointConnectionListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "insights.PrivateEndpointConnectionsClient", "listByPrivateLinkScopeNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByPrivateLinkScopeSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "insights.PrivateEndpointConnectionsClient", "listByPrivateLinkScopeNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByPrivateLinkScopeResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.PrivateEndpointConnectionsClient", "listByPrivateLinkScopeNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByPrivateLinkScopeComplete enumerates all values, automatically crossing page boundaries as required. +func (client PrivateEndpointConnectionsClient) ListByPrivateLinkScopeComplete(ctx context.Context, resourceGroupName string, scopeName string) (result PrivateEndpointConnectionListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsClient.ListByPrivateLinkScope") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByPrivateLinkScope(ctx, resourceGroupName, scopeName) + return +} diff --git a/services/preview/monitor/mgmt/2021-04-01-preview/insights/privatelinkresources.go b/services/preview/monitor/mgmt/2021-04-01-preview/insights/privatelinkresources.go new file mode 100644 index 000000000000..02157f85d6c4 --- /dev/null +++ b/services/preview/monitor/mgmt/2021-04-01-preview/insights/privatelinkresources.go @@ -0,0 +1,247 @@ +package insights + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// PrivateLinkResourcesClient is the monitor Management Client +type PrivateLinkResourcesClient struct { + BaseClient +} + +// NewPrivateLinkResourcesClient creates an instance of the PrivateLinkResourcesClient client. +func NewPrivateLinkResourcesClient(subscriptionID string) PrivateLinkResourcesClient { + return NewPrivateLinkResourcesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewPrivateLinkResourcesClientWithBaseURI creates an instance of the PrivateLinkResourcesClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewPrivateLinkResourcesClientWithBaseURI(baseURI string, subscriptionID string) PrivateLinkResourcesClient { + return PrivateLinkResourcesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get gets the private link resources that need to be created for a Azure Monitor PrivateLinkScope. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// scopeName - the name of the Azure Monitor PrivateLinkScope resource. +// groupName - the name of the private link resource. +func (client PrivateLinkResourcesClient) Get(ctx context.Context, resourceGroupName string, scopeName string, groupName string) (result PrivateLinkResource, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkResourcesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.PrivateLinkResourcesClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, scopeName, groupName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.PrivateLinkResourcesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.PrivateLinkResourcesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.PrivateLinkResourcesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client PrivateLinkResourcesClient) GetPreparer(ctx context.Context, resourceGroupName string, scopeName string, groupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "groupName": autorest.Encode("path", groupName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "scopeName": autorest.Encode("path", scopeName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-10-17-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateLinkResources/{groupName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateLinkResourcesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client PrivateLinkResourcesClient) GetResponder(resp *http.Response) (result PrivateLinkResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByPrivateLinkScope gets the private link resources that need to be created for a Azure Monitor PrivateLinkScope. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// scopeName - the name of the Azure Monitor PrivateLinkScope resource. +func (client PrivateLinkResourcesClient) ListByPrivateLinkScope(ctx context.Context, resourceGroupName string, scopeName string) (result PrivateLinkResourceListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkResourcesClient.ListByPrivateLinkScope") + defer func() { + sc := -1 + if result.plrlr.Response.Response != nil { + sc = result.plrlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.PrivateLinkResourcesClient", "ListByPrivateLinkScope", err.Error()) + } + + result.fn = client.listByPrivateLinkScopeNextResults + req, err := client.ListByPrivateLinkScopePreparer(ctx, resourceGroupName, scopeName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.PrivateLinkResourcesClient", "ListByPrivateLinkScope", nil, "Failure preparing request") + return + } + + resp, err := client.ListByPrivateLinkScopeSender(req) + if err != nil { + result.plrlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.PrivateLinkResourcesClient", "ListByPrivateLinkScope", resp, "Failure sending request") + return + } + + result.plrlr, err = client.ListByPrivateLinkScopeResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.PrivateLinkResourcesClient", "ListByPrivateLinkScope", resp, "Failure responding to request") + return + } + if result.plrlr.hasNextLink() && result.plrlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByPrivateLinkScopePreparer prepares the ListByPrivateLinkScope request. +func (client PrivateLinkResourcesClient) ListByPrivateLinkScopePreparer(ctx context.Context, resourceGroupName string, scopeName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "scopeName": autorest.Encode("path", scopeName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-10-17-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateLinkResources", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByPrivateLinkScopeSender sends the ListByPrivateLinkScope request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateLinkResourcesClient) ListByPrivateLinkScopeSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByPrivateLinkScopeResponder handles the response to the ListByPrivateLinkScope request. The method always +// closes the http.Response Body. +func (client PrivateLinkResourcesClient) ListByPrivateLinkScopeResponder(resp *http.Response) (result PrivateLinkResourceListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByPrivateLinkScopeNextResults retrieves the next set of results, if any. +func (client PrivateLinkResourcesClient) listByPrivateLinkScopeNextResults(ctx context.Context, lastResults PrivateLinkResourceListResult) (result PrivateLinkResourceListResult, err error) { + req, err := lastResults.privateLinkResourceListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "insights.PrivateLinkResourcesClient", "listByPrivateLinkScopeNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByPrivateLinkScopeSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "insights.PrivateLinkResourcesClient", "listByPrivateLinkScopeNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByPrivateLinkScopeResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.PrivateLinkResourcesClient", "listByPrivateLinkScopeNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByPrivateLinkScopeComplete enumerates all values, automatically crossing page boundaries as required. +func (client PrivateLinkResourcesClient) ListByPrivateLinkScopeComplete(ctx context.Context, resourceGroupName string, scopeName string) (result PrivateLinkResourceListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkResourcesClient.ListByPrivateLinkScope") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByPrivateLinkScope(ctx, resourceGroupName, scopeName) + return +} diff --git a/services/preview/monitor/mgmt/2021-04-01-preview/insights/privatelinkscopedresources.go b/services/preview/monitor/mgmt/2021-04-01-preview/insights/privatelinkscopedresources.go new file mode 100644 index 000000000000..9e65301c003d --- /dev/null +++ b/services/preview/monitor/mgmt/2021-04-01-preview/insights/privatelinkscopedresources.go @@ -0,0 +1,426 @@ +package insights + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// PrivateLinkScopedResourcesClient is the monitor Management Client +type PrivateLinkScopedResourcesClient struct { + BaseClient +} + +// NewPrivateLinkScopedResourcesClient creates an instance of the PrivateLinkScopedResourcesClient client. +func NewPrivateLinkScopedResourcesClient(subscriptionID string) PrivateLinkScopedResourcesClient { + return NewPrivateLinkScopedResourcesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewPrivateLinkScopedResourcesClientWithBaseURI creates an instance of the PrivateLinkScopedResourcesClient client +// using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign +// clouds, Azure stack). +func NewPrivateLinkScopedResourcesClientWithBaseURI(baseURI string, subscriptionID string) PrivateLinkScopedResourcesClient { + return PrivateLinkScopedResourcesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate approve or reject a private endpoint connection with a given name. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// scopeName - the name of the Azure Monitor PrivateLinkScope resource. +// name - the name of the scoped resource object. +func (client PrivateLinkScopedResourcesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, scopeName string, name string, parameters ScopedResource) (result PrivateLinkScopedResourcesCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkScopedResourcesClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.PrivateLinkScopedResourcesClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, scopeName, name, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.PrivateLinkScopedResourcesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.PrivateLinkScopedResourcesClient", "CreateOrUpdate", nil, "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client PrivateLinkScopedResourcesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, scopeName string, name string, parameters ScopedResource) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "name": autorest.Encode("path", name), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "scopeName": autorest.Encode("path", scopeName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-10-17-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.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}", 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 PrivateLinkScopedResourcesClient) CreateOrUpdateSender(req *http.Request) (future PrivateLinkScopedResourcesCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client PrivateLinkScopedResourcesClient) CreateOrUpdateResponder(resp *http.Response) (result ScopedResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a private endpoint connection with a given name. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// scopeName - the name of the Azure Monitor PrivateLinkScope resource. +// name - the name of the scoped resource object. +func (client PrivateLinkScopedResourcesClient) Delete(ctx context.Context, resourceGroupName string, scopeName string, name string) (result PrivateLinkScopedResourcesDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkScopedResourcesClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.PrivateLinkScopedResourcesClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, scopeName, name) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.PrivateLinkScopedResourcesClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.PrivateLinkScopedResourcesClient", "Delete", nil, "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client PrivateLinkScopedResourcesClient) DeletePreparer(ctx context.Context, resourceGroupName string, scopeName string, name string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "name": autorest.Encode("path", name), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "scopeName": autorest.Encode("path", scopeName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-10-17-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.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}", 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 PrivateLinkScopedResourcesClient) DeleteSender(req *http.Request) (future PrivateLinkScopedResourcesDeleteFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client PrivateLinkScopedResourcesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a scoped resource in a private link scope. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// scopeName - the name of the Azure Monitor PrivateLinkScope resource. +// name - the name of the scoped resource object. +func (client PrivateLinkScopedResourcesClient) Get(ctx context.Context, resourceGroupName string, scopeName string, name string) (result ScopedResource, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkScopedResourcesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.PrivateLinkScopedResourcesClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, scopeName, name) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.PrivateLinkScopedResourcesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.PrivateLinkScopedResourcesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.PrivateLinkScopedResourcesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client PrivateLinkScopedResourcesClient) GetPreparer(ctx context.Context, resourceGroupName string, scopeName string, name string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "name": autorest.Encode("path", name), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "scopeName": autorest.Encode("path", scopeName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-10-17-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}", 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 PrivateLinkScopedResourcesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client PrivateLinkScopedResourcesClient) GetResponder(resp *http.Response) (result ScopedResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByPrivateLinkScope gets all private endpoint connections on a private link scope. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// scopeName - the name of the Azure Monitor PrivateLinkScope resource. +func (client PrivateLinkScopedResourcesClient) ListByPrivateLinkScope(ctx context.Context, resourceGroupName string, scopeName string) (result ScopedResourceListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkScopedResourcesClient.ListByPrivateLinkScope") + defer func() { + sc := -1 + if result.srlr.Response.Response != nil { + sc = result.srlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.PrivateLinkScopedResourcesClient", "ListByPrivateLinkScope", err.Error()) + } + + result.fn = client.listByPrivateLinkScopeNextResults + req, err := client.ListByPrivateLinkScopePreparer(ctx, resourceGroupName, scopeName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.PrivateLinkScopedResourcesClient", "ListByPrivateLinkScope", nil, "Failure preparing request") + return + } + + resp, err := client.ListByPrivateLinkScopeSender(req) + if err != nil { + result.srlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.PrivateLinkScopedResourcesClient", "ListByPrivateLinkScope", resp, "Failure sending request") + return + } + + result.srlr, err = client.ListByPrivateLinkScopeResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.PrivateLinkScopedResourcesClient", "ListByPrivateLinkScope", resp, "Failure responding to request") + return + } + if result.srlr.hasNextLink() && result.srlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByPrivateLinkScopePreparer prepares the ListByPrivateLinkScope request. +func (client PrivateLinkScopedResourcesClient) ListByPrivateLinkScopePreparer(ctx context.Context, resourceGroupName string, scopeName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "scopeName": autorest.Encode("path", scopeName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-10-17-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByPrivateLinkScopeSender sends the ListByPrivateLinkScope request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateLinkScopedResourcesClient) ListByPrivateLinkScopeSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByPrivateLinkScopeResponder handles the response to the ListByPrivateLinkScope request. The method always +// closes the http.Response Body. +func (client PrivateLinkScopedResourcesClient) ListByPrivateLinkScopeResponder(resp *http.Response) (result ScopedResourceListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByPrivateLinkScopeNextResults retrieves the next set of results, if any. +func (client PrivateLinkScopedResourcesClient) listByPrivateLinkScopeNextResults(ctx context.Context, lastResults ScopedResourceListResult) (result ScopedResourceListResult, err error) { + req, err := lastResults.scopedResourceListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "insights.PrivateLinkScopedResourcesClient", "listByPrivateLinkScopeNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByPrivateLinkScopeSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "insights.PrivateLinkScopedResourcesClient", "listByPrivateLinkScopeNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByPrivateLinkScopeResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.PrivateLinkScopedResourcesClient", "listByPrivateLinkScopeNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByPrivateLinkScopeComplete enumerates all values, automatically crossing page boundaries as required. +func (client PrivateLinkScopedResourcesClient) ListByPrivateLinkScopeComplete(ctx context.Context, resourceGroupName string, scopeName string) (result ScopedResourceListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkScopedResourcesClient.ListByPrivateLinkScope") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByPrivateLinkScope(ctx, resourceGroupName, scopeName) + return +} diff --git a/services/preview/monitor/mgmt/2021-04-01-preview/insights/privatelinkscopeoperationstatus.go b/services/preview/monitor/mgmt/2021-04-01-preview/insights/privatelinkscopeoperationstatus.go new file mode 100644 index 000000000000..a29fa9edf886 --- /dev/null +++ b/services/preview/monitor/mgmt/2021-04-01-preview/insights/privatelinkscopeoperationstatus.go @@ -0,0 +1,118 @@ +package insights + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// PrivateLinkScopeOperationStatusClient is the monitor Management Client +type PrivateLinkScopeOperationStatusClient struct { + BaseClient +} + +// NewPrivateLinkScopeOperationStatusClient creates an instance of the PrivateLinkScopeOperationStatusClient client. +func NewPrivateLinkScopeOperationStatusClient(subscriptionID string) PrivateLinkScopeOperationStatusClient { + return NewPrivateLinkScopeOperationStatusClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewPrivateLinkScopeOperationStatusClientWithBaseURI creates an instance of the PrivateLinkScopeOperationStatusClient +// client using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI +// (sovereign clouds, Azure stack). +func NewPrivateLinkScopeOperationStatusClientWithBaseURI(baseURI string, subscriptionID string) PrivateLinkScopeOperationStatusClient { + return PrivateLinkScopeOperationStatusClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get get the status of an azure asynchronous operation associated with a private link scope operation. +// Parameters: +// asyncOperationID - the operation Id. +// resourceGroupName - the name of the resource group. The name is case insensitive. +func (client PrivateLinkScopeOperationStatusClient) Get(ctx context.Context, asyncOperationID string, resourceGroupName string) (result OperationStatus, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkScopeOperationStatusClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.PrivateLinkScopeOperationStatusClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, asyncOperationID, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.PrivateLinkScopeOperationStatusClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.PrivateLinkScopeOperationStatusClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.PrivateLinkScopeOperationStatusClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client PrivateLinkScopeOperationStatusClient) GetPreparer(ctx context.Context, asyncOperationID string, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "asyncOperationId": autorest.Encode("path", asyncOperationID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-10-17-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopeOperationStatuses/{asyncOperationId}", 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 PrivateLinkScopeOperationStatusClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client PrivateLinkScopeOperationStatusClient) GetResponder(resp *http.Response) (result OperationStatus, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/monitor/mgmt/2021-04-01-preview/insights/privatelinkscopes.go b/services/preview/monitor/mgmt/2021-04-01-preview/insights/privatelinkscopes.go new file mode 100644 index 000000000000..8f123de6c236 --- /dev/null +++ b/services/preview/monitor/mgmt/2021-04-01-preview/insights/privatelinkscopes.go @@ -0,0 +1,628 @@ +package insights + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// PrivateLinkScopesClient is the monitor Management Client +type PrivateLinkScopesClient struct { + BaseClient +} + +// NewPrivateLinkScopesClient creates an instance of the PrivateLinkScopesClient client. +func NewPrivateLinkScopesClient(subscriptionID string) PrivateLinkScopesClient { + return NewPrivateLinkScopesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewPrivateLinkScopesClientWithBaseURI creates an instance of the PrivateLinkScopesClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewPrivateLinkScopesClientWithBaseURI(baseURI string, subscriptionID string) PrivateLinkScopesClient { + return PrivateLinkScopesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates (or updates) a Azure Monitor PrivateLinkScope. Note: You cannot specify a different value for +// InstrumentationKey nor AppId in the Put operation. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// scopeName - the name of the Azure Monitor PrivateLinkScope resource. +// azureMonitorPrivateLinkScopePayload - properties that need to be specified to create or update a Azure +// Monitor PrivateLinkScope. +func (client PrivateLinkScopesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, scopeName string, azureMonitorPrivateLinkScopePayload AzureMonitorPrivateLinkScope) (result AzureMonitorPrivateLinkScope, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkScopesClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: azureMonitorPrivateLinkScopePayload, + Constraints: []validation.Constraint{{Target: "azureMonitorPrivateLinkScopePayload.AzureMonitorPrivateLinkScopeProperties", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.PrivateLinkScopesClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, scopeName, azureMonitorPrivateLinkScopePayload) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.PrivateLinkScopesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.PrivateLinkScopesClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.PrivateLinkScopesClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client PrivateLinkScopesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, scopeName string, azureMonitorPrivateLinkScopePayload AzureMonitorPrivateLinkScope) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "scopeName": autorest.Encode("path", scopeName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-10-17-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.insights/privateLinkScopes/{scopeName}", pathParameters), + autorest.WithJSON(azureMonitorPrivateLinkScopePayload), + 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 PrivateLinkScopesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client PrivateLinkScopesClient) CreateOrUpdateResponder(resp *http.Response) (result AzureMonitorPrivateLinkScope, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a Azure Monitor PrivateLinkScope. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// scopeName - the name of the Azure Monitor PrivateLinkScope resource. +func (client PrivateLinkScopesClient) Delete(ctx context.Context, resourceGroupName string, scopeName string) (result PrivateLinkScopesDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkScopesClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.PrivateLinkScopesClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, scopeName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.PrivateLinkScopesClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.PrivateLinkScopesClient", "Delete", nil, "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client PrivateLinkScopesClient) DeletePreparer(ctx context.Context, resourceGroupName string, scopeName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "scopeName": autorest.Encode("path", scopeName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-10-17-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.insights/privateLinkScopes/{scopeName}", 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 PrivateLinkScopesClient) DeleteSender(req *http.Request) (future PrivateLinkScopesDeleteFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client PrivateLinkScopesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get returns a Azure Monitor PrivateLinkScope. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// scopeName - the name of the Azure Monitor PrivateLinkScope resource. +func (client PrivateLinkScopesClient) Get(ctx context.Context, resourceGroupName string, scopeName string) (result AzureMonitorPrivateLinkScope, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkScopesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.PrivateLinkScopesClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, scopeName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.PrivateLinkScopesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.PrivateLinkScopesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.PrivateLinkScopesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client PrivateLinkScopesClient) GetPreparer(ctx context.Context, resourceGroupName string, scopeName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "scopeName": autorest.Encode("path", scopeName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-10-17-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}", 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 PrivateLinkScopesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client PrivateLinkScopesClient) GetResponder(resp *http.Response) (result AzureMonitorPrivateLinkScope, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List gets a list of all Azure Monitor PrivateLinkScopes within a subscription. +func (client PrivateLinkScopesClient) List(ctx context.Context) (result AzureMonitorPrivateLinkScopeListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkScopesClient.List") + defer func() { + sc := -1 + if result.amplslr.Response.Response != nil { + sc = result.amplslr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.PrivateLinkScopesClient", "List", err.Error()) + } + + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.PrivateLinkScopesClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.amplslr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.PrivateLinkScopesClient", "List", resp, "Failure sending request") + return + } + + result.amplslr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.PrivateLinkScopesClient", "List", resp, "Failure responding to request") + return + } + if result.amplslr.hasNextLink() && result.amplslr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client PrivateLinkScopesClient) ListPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-10-17-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/microsoft.insights/privateLinkScopes", 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 PrivateLinkScopesClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client PrivateLinkScopesClient) ListResponder(resp *http.Response) (result AzureMonitorPrivateLinkScopeListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client PrivateLinkScopesClient) listNextResults(ctx context.Context, lastResults AzureMonitorPrivateLinkScopeListResult) (result AzureMonitorPrivateLinkScopeListResult, err error) { + req, err := lastResults.azureMonitorPrivateLinkScopeListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "insights.PrivateLinkScopesClient", "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, "insights.PrivateLinkScopesClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.PrivateLinkScopesClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client PrivateLinkScopesClient) ListComplete(ctx context.Context) (result AzureMonitorPrivateLinkScopeListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkScopesClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx) + return +} + +// ListByResourceGroup gets a list of Azure Monitor PrivateLinkScopes within a resource group. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +func (client PrivateLinkScopesClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result AzureMonitorPrivateLinkScopeListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkScopesClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.amplslr.Response.Response != nil { + sc = result.amplslr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.PrivateLinkScopesClient", "ListByResourceGroup", err.Error()) + } + + result.fn = client.listByResourceGroupNextResults + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.PrivateLinkScopesClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.amplslr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.PrivateLinkScopesClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result.amplslr, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.PrivateLinkScopesClient", "ListByResourceGroup", resp, "Failure responding to request") + return + } + if result.amplslr.hasNextLink() && result.amplslr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client PrivateLinkScopesClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-10-17-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes", 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 PrivateLinkScopesClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client PrivateLinkScopesClient) ListByResourceGroupResponder(resp *http.Response) (result AzureMonitorPrivateLinkScopeListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByResourceGroupNextResults retrieves the next set of results, if any. +func (client PrivateLinkScopesClient) listByResourceGroupNextResults(ctx context.Context, lastResults AzureMonitorPrivateLinkScopeListResult) (result AzureMonitorPrivateLinkScopeListResult, err error) { + req, err := lastResults.azureMonitorPrivateLinkScopeListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "insights.PrivateLinkScopesClient", "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, "insights.PrivateLinkScopesClient", "listByResourceGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.PrivateLinkScopesClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. +func (client PrivateLinkScopesClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result AzureMonitorPrivateLinkScopeListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkScopesClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByResourceGroup(ctx, resourceGroupName) + return +} + +// UpdateTags updates an existing PrivateLinkScope's tags. To update other fields use the CreateOrUpdate method. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// scopeName - the name of the Azure Monitor PrivateLinkScope resource. +// privateLinkScopeTags - updated tag information to set into the PrivateLinkScope instance. +func (client PrivateLinkScopesClient) UpdateTags(ctx context.Context, resourceGroupName string, scopeName string, privateLinkScopeTags TagsResource) (result AzureMonitorPrivateLinkScope, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkScopesClient.UpdateTags") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.PrivateLinkScopesClient", "UpdateTags", err.Error()) + } + + req, err := client.UpdateTagsPreparer(ctx, resourceGroupName, scopeName, privateLinkScopeTags) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.PrivateLinkScopesClient", "UpdateTags", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateTagsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.PrivateLinkScopesClient", "UpdateTags", resp, "Failure sending request") + return + } + + result, err = client.UpdateTagsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.PrivateLinkScopesClient", "UpdateTags", resp, "Failure responding to request") + return + } + + return +} + +// UpdateTagsPreparer prepares the UpdateTags request. +func (client PrivateLinkScopesClient) UpdateTagsPreparer(ctx context.Context, resourceGroupName string, scopeName string, privateLinkScopeTags TagsResource) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "scopeName": autorest.Encode("path", scopeName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-10-17-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.insights/privateLinkScopes/{scopeName}", pathParameters), + autorest.WithJSON(privateLinkScopeTags), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateTagsSender sends the UpdateTags request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateLinkScopesClient) UpdateTagsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateTagsResponder handles the response to the UpdateTags request. The method always +// closes the http.Response Body. +func (client PrivateLinkScopesClient) UpdateTagsResponder(resp *http.Response) (result AzureMonitorPrivateLinkScope, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/monitor/mgmt/2021-04-01-preview/insights/scheduledqueryrules.go b/services/preview/monitor/mgmt/2021-04-01-preview/insights/scheduledqueryrules.go new file mode 100644 index 000000000000..d619338b4e0d --- /dev/null +++ b/services/preview/monitor/mgmt/2021-04-01-preview/insights/scheduledqueryrules.go @@ -0,0 +1,558 @@ +package insights + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ScheduledQueryRulesClient is the monitor Management Client +type ScheduledQueryRulesClient struct { + BaseClient +} + +// NewScheduledQueryRulesClient creates an instance of the ScheduledQueryRulesClient client. +func NewScheduledQueryRulesClient(subscriptionID string) ScheduledQueryRulesClient { + return NewScheduledQueryRulesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewScheduledQueryRulesClientWithBaseURI creates an instance of the ScheduledQueryRulesClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewScheduledQueryRulesClientWithBaseURI(baseURI string, subscriptionID string) ScheduledQueryRulesClient { + return ScheduledQueryRulesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates an log search rule. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// ruleName - the name of the rule. +// parameters - the parameters of the rule to create or update. +func (client ScheduledQueryRulesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, ruleName string, parameters LogSearchRuleResource) (result LogSearchRuleResource, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ScheduledQueryRulesClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.LogSearchRule", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.LogSearchRule.Source", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.LogSearchRule.Source.DataSourceID", Name: validation.Null, Rule: true, Chain: nil}}}, + {Target: "parameters.LogSearchRule.Schedule", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.LogSearchRule.Schedule.FrequencyInMinutes", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.LogSearchRule.Schedule.TimeWindowInMinutes", Name: validation.Null, Rule: true, Chain: nil}, + }}, + }}}}}); err != nil { + return result, validation.NewError("insights.ScheduledQueryRulesClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, ruleName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ScheduledQueryRulesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.ScheduledQueryRulesClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ScheduledQueryRulesClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ScheduledQueryRulesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, ruleName string, parameters LogSearchRuleResource) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "ruleName": autorest.Encode("path", ruleName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-04-16" + 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.insights/scheduledQueryRules/{ruleName}", 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 ScheduledQueryRulesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ScheduledQueryRulesClient) CreateOrUpdateResponder(resp *http.Response) (result LogSearchRuleResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a Log Search rule +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// ruleName - the name of the rule. +func (client ScheduledQueryRulesClient) Delete(ctx context.Context, resourceGroupName string, ruleName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ScheduledQueryRulesClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.ScheduledQueryRulesClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, ruleName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ScheduledQueryRulesClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "insights.ScheduledQueryRulesClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ScheduledQueryRulesClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ScheduledQueryRulesClient) DeletePreparer(ctx context.Context, resourceGroupName string, ruleName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "ruleName": autorest.Encode("path", ruleName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-04-16" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/scheduledQueryRules/{ruleName}", 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 ScheduledQueryRulesClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ScheduledQueryRulesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets an Log Search rule +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// ruleName - the name of the rule. +func (client ScheduledQueryRulesClient) Get(ctx context.Context, resourceGroupName string, ruleName string) (result LogSearchRuleResource, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ScheduledQueryRulesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.ScheduledQueryRulesClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, ruleName) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ScheduledQueryRulesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.ScheduledQueryRulesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ScheduledQueryRulesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ScheduledQueryRulesClient) GetPreparer(ctx context.Context, resourceGroupName string, ruleName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "ruleName": autorest.Encode("path", ruleName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-04-16" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/scheduledQueryRules/{ruleName}", 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 ScheduledQueryRulesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ScheduledQueryRulesClient) GetResponder(resp *http.Response) (result LogSearchRuleResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByResourceGroup list the Log Search rules within a resource group. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// filter - the filter to apply on the operation. For more information please see +// https://msdn.microsoft.com/en-us/library/azure/dn931934.aspx +func (client ScheduledQueryRulesClient) ListByResourceGroup(ctx context.Context, resourceGroupName string, filter string) (result LogSearchRuleResourceCollection, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ScheduledQueryRulesClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.ScheduledQueryRulesClient", "ListByResourceGroup", err.Error()) + } + + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ScheduledQueryRulesClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.ScheduledQueryRulesClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ScheduledQueryRulesClient", "ListByResourceGroup", resp, "Failure responding to request") + return + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client ScheduledQueryRulesClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-04-16" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/scheduledQueryRules", 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 ScheduledQueryRulesClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client ScheduledQueryRulesClient) ListByResourceGroupResponder(resp *http.Response) (result LogSearchRuleResourceCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListBySubscription list the Log Search rules within a subscription group. +// Parameters: +// filter - the filter to apply on the operation. For more information please see +// https://msdn.microsoft.com/en-us/library/azure/dn931934.aspx +func (client ScheduledQueryRulesClient) ListBySubscription(ctx context.Context, filter string) (result LogSearchRuleResourceCollection, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ScheduledQueryRulesClient.ListBySubscription") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.ScheduledQueryRulesClient", "ListBySubscription", err.Error()) + } + + req, err := client.ListBySubscriptionPreparer(ctx, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ScheduledQueryRulesClient", "ListBySubscription", nil, "Failure preparing request") + return + } + + resp, err := client.ListBySubscriptionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.ScheduledQueryRulesClient", "ListBySubscription", resp, "Failure sending request") + return + } + + result, err = client.ListBySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ScheduledQueryRulesClient", "ListBySubscription", resp, "Failure responding to request") + return + } + + return +} + +// ListBySubscriptionPreparer prepares the ListBySubscription request. +func (client ScheduledQueryRulesClient) ListBySubscriptionPreparer(ctx context.Context, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-04-16" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/microsoft.insights/scheduledQueryRules", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListBySubscriptionSender sends the ListBySubscription request. The method will close the +// http.Response Body if it receives an error. +func (client ScheduledQueryRulesClient) ListBySubscriptionSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListBySubscriptionResponder handles the response to the ListBySubscription request. The method always +// closes the http.Response Body. +func (client ScheduledQueryRulesClient) ListBySubscriptionResponder(resp *http.Response) (result LogSearchRuleResourceCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Update update log search Rule. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// ruleName - the name of the rule. +// parameters - the parameters of the rule to update. +func (client ScheduledQueryRulesClient) Update(ctx context.Context, resourceGroupName string, ruleName string, parameters LogSearchRuleResourcePatch) (result LogSearchRuleResource, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ScheduledQueryRulesClient.Update") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("insights.ScheduledQueryRulesClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, ruleName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ScheduledQueryRulesClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.ScheduledQueryRulesClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ScheduledQueryRulesClient", "Update", resp, "Failure responding to request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client ScheduledQueryRulesClient) UpdatePreparer(ctx context.Context, resourceGroupName string, ruleName string, parameters LogSearchRuleResourcePatch) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "ruleName": autorest.Encode("path", ruleName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-04-16" + 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.insights/scheduledQueryRules/{ruleName}", 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 ScheduledQueryRulesClient) UpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client ScheduledQueryRulesClient) UpdateResponder(resp *http.Response) (result LogSearchRuleResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/monitor/mgmt/2021-04-01-preview/insights/tenantactivitylogs.go b/services/preview/monitor/mgmt/2021-04-01-preview/insights/tenantactivitylogs.go new file mode 100644 index 000000000000..7501f047bb38 --- /dev/null +++ b/services/preview/monitor/mgmt/2021-04-01-preview/insights/tenantactivitylogs.go @@ -0,0 +1,168 @@ +package insights + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// TenantActivityLogsClient is the monitor Management Client +type TenantActivityLogsClient struct { + BaseClient +} + +// NewTenantActivityLogsClient creates an instance of the TenantActivityLogsClient client. +func NewTenantActivityLogsClient(subscriptionID string) TenantActivityLogsClient { + return NewTenantActivityLogsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewTenantActivityLogsClientWithBaseURI creates an instance of the TenantActivityLogsClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewTenantActivityLogsClientWithBaseURI(baseURI string, subscriptionID string) TenantActivityLogsClient { + return TenantActivityLogsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List gets the Activity Logs for the Tenant.
Everything that is applicable to the API to get the Activity Logs for +// the subscription is applicable to this API (the parameters, $filter, etc.).
One thing to point out here is that +// this API does *not* retrieve the logs at the individual subscription of the tenant but only surfaces the logs that +// were generated at the tenant level. +// Parameters: +// filter - reduces the set of data collected.
The **$filter** is very restricted and allows only the +// following patterns.
- List events for a resource group: $filter=eventTimestamp ge '' and +// eventTimestamp le '' and eventChannels eq 'Admin, Operation' and resourceGroupName eq +// ''.
- List events for resource: $filter=eventTimestamp ge '' and +// eventTimestamp le '' and eventChannels eq 'Admin, Operation' and resourceUri eq +// ''.
- List events for a subscription: $filter=eventTimestamp ge '' and +// eventTimestamp le '' and eventChannels eq 'Admin, Operation'.
- List events for a resource +// provider: $filter=eventTimestamp ge '' and eventTimestamp le '' and eventChannels eq +// 'Admin, Operation' and resourceProvider eq ''.
- List events for a correlation Id: +// api-version=2014-04-01&$filter=eventTimestamp ge '2014-07-16T04:36:37.6407898Z' and eventTimestamp le +// '2014-07-20T04:36:37.6407898Z' and eventChannels eq 'Admin, Operation' and correlationId eq +// ''.
**NOTE**: No other syntax is allowed. +// selectParameter - used to fetch events with only the given properties.
The **$select** argument is a +// comma separated list of property names to be returned. Possible values are: *authorization*, *claims*, +// *correlationId*, *description*, *eventDataId*, *eventName*, *eventTimestamp*, *httpRequest*, *level*, +// *operationId*, *operationName*, *properties*, *resourceGroupName*, *resourceProviderName*, *resourceId*, +// *status*, *submissionTimestamp*, *subStatus*, *subscriptionId* +func (client TenantActivityLogsClient) List(ctx context.Context, filter string, selectParameter string) (result EventDataCollectionPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TenantActivityLogsClient.List") + defer func() { + sc := -1 + if result.edc.Response.Response != nil { + sc = result.edc.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, filter, selectParameter) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.TenantActivityLogsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.edc.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.TenantActivityLogsClient", "List", resp, "Failure sending request") + return + } + + result.edc, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.TenantActivityLogsClient", "List", resp, "Failure responding to request") + return + } + if result.edc.hasNextLink() && result.edc.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client TenantActivityLogsClient) ListPreparer(ctx context.Context, filter string, selectParameter string) (*http.Request, error) { + const APIVersion = "2015-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if len(selectParameter) > 0 { + queryParameters["$select"] = autorest.Encode("query", selectParameter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/microsoft.insights/eventtypes/management/values"), + 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 TenantActivityLogsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client TenantActivityLogsClient) ListResponder(resp *http.Response) (result EventDataCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client TenantActivityLogsClient) listNextResults(ctx context.Context, lastResults EventDataCollection) (result EventDataCollection, err error) { + req, err := lastResults.eventDataCollectionPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "insights.TenantActivityLogsClient", "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, "insights.TenantActivityLogsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.TenantActivityLogsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client TenantActivityLogsClient) ListComplete(ctx context.Context, filter string, selectParameter string) (result EventDataCollectionIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TenantActivityLogsClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx, filter, selectParameter) + return +} diff --git a/services/preview/monitor/mgmt/2021-04-01-preview/insights/version.go b/services/preview/monitor/mgmt/2021-04-01-preview/insights/version.go new file mode 100644 index 000000000000..60957f79ddd4 --- /dev/null +++ b/services/preview/monitor/mgmt/2021-04-01-preview/insights/version.go @@ -0,0 +1,19 @@ +package insights + +import "github.com/Azure/azure-sdk-for-go/version" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// UserAgent returns the UserAgent string to use when sending http.Requests. +func UserAgent() string { + return "Azure-SDK-For-Go/" + Version() + " insights/2021-04-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/monitor/mgmt/2021-04-01-preview/insights/vminsights.go b/services/preview/monitor/mgmt/2021-04-01-preview/insights/vminsights.go new file mode 100644 index 000000000000..3787cb6fc53e --- /dev/null +++ b/services/preview/monitor/mgmt/2021-04-01-preview/insights/vminsights.go @@ -0,0 +1,105 @@ +package insights + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// VMInsightsClient is the monitor Management Client +type VMInsightsClient struct { + BaseClient +} + +// NewVMInsightsClient creates an instance of the VMInsightsClient client. +func NewVMInsightsClient(subscriptionID string) VMInsightsClient { + return NewVMInsightsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewVMInsightsClientWithBaseURI creates an instance of the VMInsightsClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewVMInsightsClientWithBaseURI(baseURI string, subscriptionID string) VMInsightsClient { + return VMInsightsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// GetOnboardingStatus retrieves the VM Insights onboarding status for the specified resource or resource scope. +// Parameters: +// resourceURI - the fully qualified Azure Resource manager identifier of the resource, or scope, whose status +// to retrieve. +func (client VMInsightsClient) GetOnboardingStatus(ctx context.Context, resourceURI string) (result VMInsightsOnboardingStatus, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/VMInsightsClient.GetOnboardingStatus") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetOnboardingStatusPreparer(ctx, resourceURI) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.VMInsightsClient", "GetOnboardingStatus", nil, "Failure preparing request") + return + } + + resp, err := client.GetOnboardingStatusSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.VMInsightsClient", "GetOnboardingStatus", resp, "Failure sending request") + return + } + + result, err = client.GetOnboardingStatusResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.VMInsightsClient", "GetOnboardingStatus", resp, "Failure responding to request") + return + } + + return +} + +// GetOnboardingStatusPreparer prepares the GetOnboardingStatus request. +func (client VMInsightsClient) GetOnboardingStatusPreparer(ctx context.Context, resourceURI string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceUri": resourceURI, + } + + const APIVersion = "2018-11-27-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{resourceUri}/providers/Microsoft.Insights/vmInsightsOnboardingStatuses/default", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetOnboardingStatusSender sends the GetOnboardingStatus request. The method will close the +// http.Response Body if it receives an error. +func (client VMInsightsClient) GetOnboardingStatusSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// GetOnboardingStatusResponder handles the response to the GetOnboardingStatus request. The method always +// closes the http.Response Body. +func (client VMInsightsClient) GetOnboardingStatusResponder(resp *http.Response) (result VMInsightsOnboardingStatus, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/CHANGELOG.md b/services/preview/sql/mgmt/v5.0/sql/CHANGELOG.md new file mode 100644 index 000000000000..52911e4cc5e4 --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/CHANGELOG.md @@ -0,0 +1,2 @@ +# Change History + diff --git a/services/preview/sql/mgmt/v5.0/sql/_meta.json b/services/preview/sql/mgmt/v5.0/sql/_meta.json new file mode 100644 index 000000000000..c1fe03a5a532 --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/_meta.json @@ -0,0 +1,11 @@ +{ + "commit": "8dff86df71bee429af84ea4713288ef3cdd1db2f", + "readme": "/_/azure-rest-api-specs/specification/sql/resource-manager/readme.md", + "tag": "package-composite-v5", + "use": "@microsoft.azure/autorest.go@2.1.183", + "repository_url": "https://github.com/Azure/azure-rest-api-specs.git", + "autorest_command": "autorest --use=@microsoft.azure/autorest.go@2.1.183 --tag=package-composite-v5 --go-sdk-folder=/_/azure-sdk-for-go --go --verbose --use-onever --version=V2 --go.license-header=MICROSOFT_MIT_NO_VERSION --enum-prefix /_/azure-rest-api-specs/specification/sql/resource-manager/readme.md", + "additional_properties": { + "additional_options": "--go --verbose --use-onever --version=V2 --go.license-header=MICROSOFT_MIT_NO_VERSION --enum-prefix" + } +} \ No newline at end of file diff --git a/services/preview/sql/mgmt/v5.0/sql/agent.go b/services/preview/sql/mgmt/v5.0/sql/agent.go new file mode 100644 index 000000000000..ed2f5f02d355 --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/agent.go @@ -0,0 +1,189 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// AgentClient 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 AgentClient struct { + BaseClient +} + +// NewAgentClient creates an instance of the AgentClient client. +func NewAgentClient(subscriptionID string) AgentClient { + return NewAgentClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewAgentClientWithBaseURI creates an instance of the AgentClient client using a custom endpoint. Use this when +// interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewAgentClientWithBaseURI(baseURI string, subscriptionID string) AgentClient { + return AgentClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate puts new sql agent configuration to instance. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +func (client AgentClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, managedInstanceName string, parameters AgentConfiguration) (result AgentConfiguration, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AgentClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, managedInstanceName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.AgentClient", "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.AgentClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.AgentClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client AgentClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, parameters AgentConfiguration) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/sqlAgent/current", 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 AgentClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client AgentClient) CreateOrUpdateResponder(resp *http.Response) (result AgentConfiguration, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets current instance sql agent configuration. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +func (client AgentClient) Get(ctx context.Context, resourceGroupName string, managedInstanceName string) (result AgentConfiguration, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AgentClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, managedInstanceName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.AgentClient", "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.AgentClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.AgentClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client AgentClient) GetPreparer(ctx context.Context, resourceGroupName string, managedInstanceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/sqlAgent/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 AgentClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client AgentClient) GetResponder(resp *http.Response) (result AgentConfiguration, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/backupshorttermretentionpolicies.go b/services/preview/sql/mgmt/v5.0/sql/backupshorttermretentionpolicies.go new file mode 100644 index 000000000000..46743cb8e5c3 --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/backupshorttermretentionpolicies.go @@ -0,0 +1,405 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// BackupShortTermRetentionPoliciesClient is the the Azure SQL Database management API provides a RESTful set of web +// services that interact with Azure SQL Database services to manage your databases. The API enables you to create, +// retrieve, update, and delete databases. +type BackupShortTermRetentionPoliciesClient struct { + BaseClient +} + +// NewBackupShortTermRetentionPoliciesClient creates an instance of the BackupShortTermRetentionPoliciesClient client. +func NewBackupShortTermRetentionPoliciesClient(subscriptionID string) BackupShortTermRetentionPoliciesClient { + return NewBackupShortTermRetentionPoliciesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewBackupShortTermRetentionPoliciesClientWithBaseURI creates an instance of the +// BackupShortTermRetentionPoliciesClient client using a custom endpoint. Use this when interacting with an Azure +// cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewBackupShortTermRetentionPoliciesClientWithBaseURI(baseURI string, subscriptionID string) BackupShortTermRetentionPoliciesClient { + return BackupShortTermRetentionPoliciesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate updates a database's short term retention policy. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database. +// parameters - the short term retention policy info. +func (client BackupShortTermRetentionPoliciesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters BackupShortTermRetentionPolicy) (result BackupShortTermRetentionPoliciesCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/BackupShortTermRetentionPoliciesClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, databaseName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.BackupShortTermRetentionPoliciesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.BackupShortTermRetentionPoliciesClient", "CreateOrUpdate", nil, "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client BackupShortTermRetentionPoliciesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters BackupShortTermRetentionPolicy) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "policyName": autorest.Encode("path", "default"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-02-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/backupShortTermRetentionPolicies/{policyName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client BackupShortTermRetentionPoliciesClient) CreateOrUpdateSender(req *http.Request) (future BackupShortTermRetentionPoliciesCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client BackupShortTermRetentionPoliciesClient) CreateOrUpdateResponder(resp *http.Response) (result BackupShortTermRetentionPolicy, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets a database's short term retention policy. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database. +func (client BackupShortTermRetentionPoliciesClient) Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result BackupShortTermRetentionPolicy, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/BackupShortTermRetentionPoliciesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.BackupShortTermRetentionPoliciesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.BackupShortTermRetentionPoliciesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.BackupShortTermRetentionPoliciesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client BackupShortTermRetentionPoliciesClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "policyName": autorest.Encode("path", "default"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-02-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/backupShortTermRetentionPolicies/{policyName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client BackupShortTermRetentionPoliciesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client BackupShortTermRetentionPoliciesClient) GetResponder(resp *http.Response) (result BackupShortTermRetentionPolicy, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByDatabase gets a database's short term retention policy. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database. +func (client BackupShortTermRetentionPoliciesClient) ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result BackupShortTermRetentionPolicyListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/BackupShortTermRetentionPoliciesClient.ListByDatabase") + defer func() { + sc := -1 + if result.bstrplr.Response.Response != nil { + sc = result.bstrplr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByDatabaseNextResults + req, err := client.ListByDatabasePreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.BackupShortTermRetentionPoliciesClient", "ListByDatabase", nil, "Failure preparing request") + return + } + + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.bstrplr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.BackupShortTermRetentionPoliciesClient", "ListByDatabase", resp, "Failure sending request") + return + } + + result.bstrplr, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.BackupShortTermRetentionPoliciesClient", "ListByDatabase", resp, "Failure responding to request") + return + } + if result.bstrplr.hasNextLink() && result.bstrplr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByDatabasePreparer prepares the ListByDatabase request. +func (client BackupShortTermRetentionPoliciesClient) ListByDatabasePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-02-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/backupShortTermRetentionPolicies", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByDatabaseSender sends the ListByDatabase request. The method will close the +// http.Response Body if it receives an error. +func (client BackupShortTermRetentionPoliciesClient) ListByDatabaseSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByDatabaseResponder handles the response to the ListByDatabase request. The method always +// closes the http.Response Body. +func (client BackupShortTermRetentionPoliciesClient) ListByDatabaseResponder(resp *http.Response) (result BackupShortTermRetentionPolicyListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByDatabaseNextResults retrieves the next set of results, if any. +func (client BackupShortTermRetentionPoliciesClient) listByDatabaseNextResults(ctx context.Context, lastResults BackupShortTermRetentionPolicyListResult) (result BackupShortTermRetentionPolicyListResult, err error) { + req, err := lastResults.backupShortTermRetentionPolicyListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.BackupShortTermRetentionPoliciesClient", "listByDatabaseNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.BackupShortTermRetentionPoliciesClient", "listByDatabaseNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.BackupShortTermRetentionPoliciesClient", "listByDatabaseNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByDatabaseComplete enumerates all values, automatically crossing page boundaries as required. +func (client BackupShortTermRetentionPoliciesClient) ListByDatabaseComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result BackupShortTermRetentionPolicyListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/BackupShortTermRetentionPoliciesClient.ListByDatabase") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByDatabase(ctx, resourceGroupName, serverName, databaseName) + return +} + +// Update updates a database's short term retention policy. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database. +// parameters - the short term retention policy info. +func (client BackupShortTermRetentionPoliciesClient) Update(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters BackupShortTermRetentionPolicy) (result BackupShortTermRetentionPoliciesUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/BackupShortTermRetentionPoliciesClient.Update") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.UpdatePreparer(ctx, resourceGroupName, serverName, databaseName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.BackupShortTermRetentionPoliciesClient", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.BackupShortTermRetentionPoliciesClient", "Update", nil, "Failure sending request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client BackupShortTermRetentionPoliciesClient) UpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters BackupShortTermRetentionPolicy) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "policyName": autorest.Encode("path", "default"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-02-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/backupShortTermRetentionPolicies/{policyName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client BackupShortTermRetentionPoliciesClient) UpdateSender(req *http.Request) (future BackupShortTermRetentionPoliciesUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client BackupShortTermRetentionPoliciesClient) UpdateResponder(resp *http.Response) (result BackupShortTermRetentionPolicy, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/capabilities.go b/services/preview/sql/mgmt/v5.0/sql/capabilities.go new file mode 100644 index 000000000000..d73e2b956428 --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/capabilities.go @@ -0,0 +1,111 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// CapabilitiesClient is the the Azure SQL Database management API provides a RESTful set of web services that interact +// with Azure SQL Database services to manage your databases. The API enables you to create, retrieve, update, and +// delete databases. +type CapabilitiesClient struct { + BaseClient +} + +// NewCapabilitiesClient creates an instance of the CapabilitiesClient client. +func NewCapabilitiesClient(subscriptionID string) CapabilitiesClient { + return NewCapabilitiesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewCapabilitiesClientWithBaseURI creates an instance of the CapabilitiesClient client using a custom endpoint. Use +// this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewCapabilitiesClientWithBaseURI(baseURI string, subscriptionID string) CapabilitiesClient { + return CapabilitiesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListByLocation gets the subscription capabilities available for the specified location. +// Parameters: +// locationName - the location name whose capabilities are retrieved. +// include - if specified, restricts the response to only include the selected item. +func (client CapabilitiesClient) ListByLocation(ctx context.Context, locationName string, include CapabilityGroup) (result LocationCapabilities, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CapabilitiesClient.ListByLocation") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListByLocationPreparer(ctx, locationName, include) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.CapabilitiesClient", "ListByLocation", nil, "Failure preparing request") + return + } + + resp, err := client.ListByLocationSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.CapabilitiesClient", "ListByLocation", resp, "Failure sending request") + return + } + + result, err = client.ListByLocationResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.CapabilitiesClient", "ListByLocation", resp, "Failure responding to request") + return + } + + return +} + +// ListByLocationPreparer prepares the ListByLocation request. +func (client CapabilitiesClient) ListByLocationPreparer(ctx context.Context, locationName string, include CapabilityGroup) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "locationName": autorest.Encode("path", locationName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(string(include)) > 0 { + queryParameters["include"] = autorest.Encode("query", include) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/capabilities", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByLocationSender sends the ListByLocation request. The method will close the +// http.Response Body if it receives an error. +func (client CapabilitiesClient) ListByLocationSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByLocationResponder handles the response to the ListByLocation request. The method always +// closes the http.Response Body. +func (client CapabilitiesClient) ListByLocationResponder(resp *http.Response) (result LocationCapabilities, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/client.go b/services/preview/sql/mgmt/v5.0/sql/client.go new file mode 100644 index 000000000000..99340489081a --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/client.go @@ -0,0 +1,42 @@ +// Package sql implements the Azure ARM Sql service API version . +// +// The Azure SQL Database management API provides a RESTful set of web services that interact with Azure SQL Database +// services to manage your databases. The API enables you to create, retrieve, update, and delete databases. +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" +) + +const ( + // DefaultBaseURI is the default URI used for the service Sql + DefaultBaseURI = "https://management.azure.com" +) + +// BaseClient is the base client for Sql. +type BaseClient struct { + autorest.Client + BaseURI string + SubscriptionID string +} + +// New creates an instance of the BaseClient client. +func New(subscriptionID string) BaseClient { + return NewWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewWithBaseURI creates an instance of the BaseClient client using a custom endpoint. Use this when interacting with +// an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { + return BaseClient{ + Client: autorest.NewClientWithUserAgent(UserAgent()), + BaseURI: baseURI, + SubscriptionID: subscriptionID, + } +} diff --git a/services/preview/sql/mgmt/v5.0/sql/databaseadvisors.go b/services/preview/sql/mgmt/v5.0/sql/databaseadvisors.go new file mode 100644 index 000000000000..3b0b7d4fb716 --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/databaseadvisors.go @@ -0,0 +1,284 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// DatabaseAdvisorsClient 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 DatabaseAdvisorsClient struct { + BaseClient +} + +// NewDatabaseAdvisorsClient creates an instance of the DatabaseAdvisorsClient client. +func NewDatabaseAdvisorsClient(subscriptionID string) DatabaseAdvisorsClient { + return NewDatabaseAdvisorsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewDatabaseAdvisorsClientWithBaseURI creates an instance of the DatabaseAdvisorsClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewDatabaseAdvisorsClientWithBaseURI(baseURI string, subscriptionID string) DatabaseAdvisorsClient { + return DatabaseAdvisorsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get gets a database advisor. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database. +// advisorName - the name of the Database Advisor. +func (client DatabaseAdvisorsClient) Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string, advisorName string) (result Advisor, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAdvisorsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, databaseName, advisorName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseAdvisorsClient", "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.DatabaseAdvisorsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseAdvisorsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client DatabaseAdvisorsClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, advisorName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "advisorName": autorest.Encode("path", advisorName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/advisors/{advisorName}", 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 DatabaseAdvisorsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client DatabaseAdvisorsClient) GetResponder(resp *http.Response) (result Advisor, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByDatabase gets a list of database advisors. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database. +// expand - the child resources to include in the response. +func (client DatabaseAdvisorsClient) ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string, expand string) (result ListAdvisor, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAdvisorsClient.ListByDatabase") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListByDatabasePreparer(ctx, resourceGroupName, serverName, databaseName, expand) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseAdvisorsClient", "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.DatabaseAdvisorsClient", "ListByDatabase", resp, "Failure sending request") + return + } + + result, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseAdvisorsClient", "ListByDatabase", resp, "Failure responding to request") + return + } + + return +} + +// ListByDatabasePreparer prepares the ListByDatabase request. +func (client DatabaseAdvisorsClient) ListByDatabasePreparer(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 = "2020-11-01-preview" + 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}/advisors", 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 DatabaseAdvisorsClient) ListByDatabaseSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByDatabaseResponder handles the response to the ListByDatabase request. The method always +// closes the http.Response Body. +func (client DatabaseAdvisorsClient) ListByDatabaseResponder(resp *http.Response) (result ListAdvisor, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Value), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Update updates a database advisor. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database. +// advisorName - the name of the Database Advisor. +// parameters - the requested advisor resource state. +func (client DatabaseAdvisorsClient) Update(ctx context.Context, resourceGroupName string, serverName string, databaseName string, advisorName string, parameters Advisor) (result Advisor, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAdvisorsClient.Update") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.UpdatePreparer(ctx, resourceGroupName, serverName, databaseName, advisorName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseAdvisorsClient", "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.DatabaseAdvisorsClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseAdvisorsClient", "Update", resp, "Failure responding to request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client DatabaseAdvisorsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, advisorName string, parameters Advisor) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "advisorName": autorest.Encode("path", advisorName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + parameters.Kind = nil + parameters.Location = nil + 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}/advisors/{advisorName}", 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 DatabaseAdvisorsClient) UpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client DatabaseAdvisorsClient) UpdateResponder(resp *http.Response) (result Advisor, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/databaseautomatictuning.go b/services/preview/sql/mgmt/v5.0/sql/databaseautomatictuning.go new file mode 100644 index 000000000000..f3c2d82645ec --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/databaseautomatictuning.go @@ -0,0 +1,195 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// DatabaseAutomaticTuningClient is the the Azure SQL Database management API provides a RESTful set of web services +// that interact with Azure SQL Database services to manage your databases. The API enables you to create, retrieve, +// update, and delete databases. +type DatabaseAutomaticTuningClient struct { + BaseClient +} + +// NewDatabaseAutomaticTuningClient creates an instance of the DatabaseAutomaticTuningClient client. +func NewDatabaseAutomaticTuningClient(subscriptionID string) DatabaseAutomaticTuningClient { + return NewDatabaseAutomaticTuningClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewDatabaseAutomaticTuningClientWithBaseURI creates an instance of the DatabaseAutomaticTuningClient client using a +// custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, +// Azure stack). +func NewDatabaseAutomaticTuningClientWithBaseURI(baseURI string, subscriptionID string) DatabaseAutomaticTuningClient { + return DatabaseAutomaticTuningClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get gets a database's automatic tuning. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database. +func (client DatabaseAutomaticTuningClient) Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result DatabaseAutomaticTuning, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAutomaticTuningClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseAutomaticTuningClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.DatabaseAutomaticTuningClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseAutomaticTuningClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client DatabaseAutomaticTuningClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/automaticTuning/current", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client DatabaseAutomaticTuningClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client DatabaseAutomaticTuningClient) GetResponder(resp *http.Response) (result DatabaseAutomaticTuning, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Update update automatic tuning properties for target database. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database. +// parameters - the requested automatic tuning resource state. +func (client DatabaseAutomaticTuningClient) Update(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters DatabaseAutomaticTuning) (result DatabaseAutomaticTuning, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAutomaticTuningClient.Update") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.UpdatePreparer(ctx, resourceGroupName, serverName, databaseName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseAutomaticTuningClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.DatabaseAutomaticTuningClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseAutomaticTuningClient", "Update", resp, "Failure responding to request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client DatabaseAutomaticTuningClient) UpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters DatabaseAutomaticTuning) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/automaticTuning/current", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client DatabaseAutomaticTuningClient) UpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client DatabaseAutomaticTuningClient) UpdateResponder(resp *http.Response) (result DatabaseAutomaticTuning, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/databaseblobauditingpolicies.go b/services/preview/sql/mgmt/v5.0/sql/databaseblobauditingpolicies.go new file mode 100644 index 000000000000..466576ad5f57 --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/databaseblobauditingpolicies.go @@ -0,0 +1,319 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// DatabaseBlobAuditingPoliciesClient is the the Azure SQL Database management API provides a RESTful set of web +// services that interact with Azure SQL Database services to manage your databases. The API enables you to create, +// retrieve, update, and delete databases. +type DatabaseBlobAuditingPoliciesClient struct { + BaseClient +} + +// NewDatabaseBlobAuditingPoliciesClient creates an instance of the DatabaseBlobAuditingPoliciesClient client. +func NewDatabaseBlobAuditingPoliciesClient(subscriptionID string) DatabaseBlobAuditingPoliciesClient { + return NewDatabaseBlobAuditingPoliciesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewDatabaseBlobAuditingPoliciesClientWithBaseURI creates an instance of the DatabaseBlobAuditingPoliciesClient +// client using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI +// (sovereign clouds, Azure stack). +func NewDatabaseBlobAuditingPoliciesClientWithBaseURI(baseURI string, subscriptionID string) DatabaseBlobAuditingPoliciesClient { + return DatabaseBlobAuditingPoliciesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a database's blob auditing policy. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database. +// parameters - the database blob auditing policy. +func (client DatabaseBlobAuditingPoliciesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters DatabaseBlobAuditingPolicy) (result DatabaseBlobAuditingPolicy, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseBlobAuditingPoliciesClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, databaseName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseBlobAuditingPoliciesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.DatabaseBlobAuditingPoliciesClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseBlobAuditingPoliciesClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client DatabaseBlobAuditingPoliciesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters DatabaseBlobAuditingPolicy) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "blobAuditingPolicyName": autorest.Encode("path", "default"), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + parameters.Kind = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/auditingSettings/{blobAuditingPolicyName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client DatabaseBlobAuditingPoliciesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client DatabaseBlobAuditingPoliciesClient) CreateOrUpdateResponder(resp *http.Response) (result DatabaseBlobAuditingPolicy, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets a database's blob auditing policy. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database. +func (client DatabaseBlobAuditingPoliciesClient) Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result DatabaseBlobAuditingPolicy, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseBlobAuditingPoliciesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseBlobAuditingPoliciesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.DatabaseBlobAuditingPoliciesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseBlobAuditingPoliciesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client DatabaseBlobAuditingPoliciesClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "blobAuditingPolicyName": autorest.Encode("path", "default"), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/auditingSettings/{blobAuditingPolicyName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client DatabaseBlobAuditingPoliciesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client DatabaseBlobAuditingPoliciesClient) GetResponder(resp *http.Response) (result DatabaseBlobAuditingPolicy, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByDatabase lists auditing settings of a database. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database. +func (client DatabaseBlobAuditingPoliciesClient) ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result DatabaseBlobAuditingPolicyListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseBlobAuditingPoliciesClient.ListByDatabase") + defer func() { + sc := -1 + if result.dbaplr.Response.Response != nil { + sc = result.dbaplr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByDatabaseNextResults + req, err := client.ListByDatabasePreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseBlobAuditingPoliciesClient", "ListByDatabase", nil, "Failure preparing request") + return + } + + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.dbaplr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.DatabaseBlobAuditingPoliciesClient", "ListByDatabase", resp, "Failure sending request") + return + } + + result.dbaplr, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseBlobAuditingPoliciesClient", "ListByDatabase", resp, "Failure responding to request") + return + } + if result.dbaplr.hasNextLink() && result.dbaplr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByDatabasePreparer prepares the ListByDatabase request. +func (client DatabaseBlobAuditingPoliciesClient) ListByDatabasePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/auditingSettings", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByDatabaseSender sends the ListByDatabase request. The method will close the +// http.Response Body if it receives an error. +func (client DatabaseBlobAuditingPoliciesClient) ListByDatabaseSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByDatabaseResponder handles the response to the ListByDatabase request. The method always +// closes the http.Response Body. +func (client DatabaseBlobAuditingPoliciesClient) ListByDatabaseResponder(resp *http.Response) (result DatabaseBlobAuditingPolicyListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByDatabaseNextResults retrieves the next set of results, if any. +func (client DatabaseBlobAuditingPoliciesClient) listByDatabaseNextResults(ctx context.Context, lastResults DatabaseBlobAuditingPolicyListResult) (result DatabaseBlobAuditingPolicyListResult, err error) { + req, err := lastResults.databaseBlobAuditingPolicyListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.DatabaseBlobAuditingPoliciesClient", "listByDatabaseNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.DatabaseBlobAuditingPoliciesClient", "listByDatabaseNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseBlobAuditingPoliciesClient", "listByDatabaseNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByDatabaseComplete enumerates all values, automatically crossing page boundaries as required. +func (client DatabaseBlobAuditingPoliciesClient) ListByDatabaseComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result DatabaseBlobAuditingPolicyListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseBlobAuditingPoliciesClient.ListByDatabase") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByDatabase(ctx, resourceGroupName, serverName, databaseName) + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/databasecolumns.go b/services/preview/sql/mgmt/v5.0/sql/databasecolumns.go new file mode 100644 index 000000000000..6f62547c2a38 --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/databasecolumns.go @@ -0,0 +1,384 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// DatabaseColumnsClient 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 DatabaseColumnsClient struct { + BaseClient +} + +// NewDatabaseColumnsClient creates an instance of the DatabaseColumnsClient client. +func NewDatabaseColumnsClient(subscriptionID string) DatabaseColumnsClient { + return NewDatabaseColumnsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewDatabaseColumnsClientWithBaseURI creates an instance of the DatabaseColumnsClient client using a custom endpoint. +// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewDatabaseColumnsClientWithBaseURI(baseURI string, subscriptionID string) DatabaseColumnsClient { + return DatabaseColumnsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get get database column +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database. +// schemaName - the name of the schema. +// tableName - the name of the table. +// columnName - the name of the column. +func (client DatabaseColumnsClient) Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string, schemaName string, tableName string, columnName string) (result DatabaseColumn, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseColumnsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, databaseName, schemaName, tableName, columnName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseColumnsClient", "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.DatabaseColumnsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseColumnsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client DatabaseColumnsClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, schemaName string, tableName string, columnName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "columnName": autorest.Encode("path", columnName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "schemaName": autorest.Encode("path", schemaName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "tableName": autorest.Encode("path", tableName), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}", 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 DatabaseColumnsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client DatabaseColumnsClient) GetResponder(resp *http.Response) (result DatabaseColumn, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByDatabase list database columns +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database. +// skiptoken - an opaque token that identifies a starting point in the collection. +func (client DatabaseColumnsClient) ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string, schema []string, table []string, column []string, orderBy []string, skiptoken string) (result DatabaseColumnListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseColumnsClient.ListByDatabase") + defer func() { + sc := -1 + if result.dclr.Response.Response != nil { + sc = result.dclr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByDatabaseNextResults + req, err := client.ListByDatabasePreparer(ctx, resourceGroupName, serverName, databaseName, schema, table, column, orderBy, skiptoken) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseColumnsClient", "ListByDatabase", nil, "Failure preparing request") + return + } + + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.dclr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.DatabaseColumnsClient", "ListByDatabase", resp, "Failure sending request") + return + } + + result.dclr, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseColumnsClient", "ListByDatabase", resp, "Failure responding to request") + return + } + if result.dclr.hasNextLink() && result.dclr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByDatabasePreparer prepares the ListByDatabase request. +func (client DatabaseColumnsClient) ListByDatabasePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, schema []string, table []string, column []string, orderBy []string, skiptoken string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if schema != nil && len(schema) > 0 { + queryParameters["schema"] = schema + } + if table != nil && len(table) > 0 { + queryParameters["table"] = table + } + if column != nil && len(column) > 0 { + queryParameters["column"] = column + } + if orderBy != nil && len(orderBy) > 0 { + queryParameters["orderBy"] = orderBy + } + if len(skiptoken) > 0 { + queryParameters["$skiptoken"] = autorest.Encode("query", skiptoken) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/columns", 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 DatabaseColumnsClient) ListByDatabaseSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByDatabaseResponder handles the response to the ListByDatabase request. The method always +// closes the http.Response Body. +func (client DatabaseColumnsClient) ListByDatabaseResponder(resp *http.Response) (result DatabaseColumnListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByDatabaseNextResults retrieves the next set of results, if any. +func (client DatabaseColumnsClient) listByDatabaseNextResults(ctx context.Context, lastResults DatabaseColumnListResult) (result DatabaseColumnListResult, err error) { + req, err := lastResults.databaseColumnListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.DatabaseColumnsClient", "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.DatabaseColumnsClient", "listByDatabaseNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseColumnsClient", "listByDatabaseNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByDatabaseComplete enumerates all values, automatically crossing page boundaries as required. +func (client DatabaseColumnsClient) ListByDatabaseComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string, schema []string, table []string, column []string, orderBy []string, skiptoken string) (result DatabaseColumnListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseColumnsClient.ListByDatabase") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByDatabase(ctx, resourceGroupName, serverName, databaseName, schema, table, column, orderBy, skiptoken) + return +} + +// ListByTable list database columns +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database. +// schemaName - the name of the schema. +// tableName - the name of the table. +// filter - an OData filter expression that filters elements in the collection. +func (client DatabaseColumnsClient) ListByTable(ctx context.Context, resourceGroupName string, serverName string, databaseName string, schemaName string, tableName string, filter string) (result DatabaseColumnListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseColumnsClient.ListByTable") + defer func() { + sc := -1 + if result.dclr.Response.Response != nil { + sc = result.dclr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByTableNextResults + req, err := client.ListByTablePreparer(ctx, resourceGroupName, serverName, databaseName, schemaName, tableName, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseColumnsClient", "ListByTable", nil, "Failure preparing request") + return + } + + resp, err := client.ListByTableSender(req) + if err != nil { + result.dclr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.DatabaseColumnsClient", "ListByTable", resp, "Failure sending request") + return + } + + result.dclr, err = client.ListByTableResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseColumnsClient", "ListByTable", resp, "Failure responding to request") + return + } + if result.dclr.hasNextLink() && result.dclr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByTablePreparer prepares the ListByTable request. +func (client DatabaseColumnsClient) ListByTablePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, schemaName string, tableName string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "schemaName": autorest.Encode("path", schemaName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "tableName": autorest.Encode("path", tableName), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByTableSender sends the ListByTable request. The method will close the +// http.Response Body if it receives an error. +func (client DatabaseColumnsClient) ListByTableSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByTableResponder handles the response to the ListByTable request. The method always +// closes the http.Response Body. +func (client DatabaseColumnsClient) ListByTableResponder(resp *http.Response) (result DatabaseColumnListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByTableNextResults retrieves the next set of results, if any. +func (client DatabaseColumnsClient) listByTableNextResults(ctx context.Context, lastResults DatabaseColumnListResult) (result DatabaseColumnListResult, err error) { + req, err := lastResults.databaseColumnListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.DatabaseColumnsClient", "listByTableNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByTableSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.DatabaseColumnsClient", "listByTableNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByTableResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseColumnsClient", "listByTableNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByTableComplete enumerates all values, automatically crossing page boundaries as required. +func (client DatabaseColumnsClient) ListByTableComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string, schemaName string, tableName string, filter string) (result DatabaseColumnListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseColumnsClient.ListByTable") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByTable(ctx, resourceGroupName, serverName, databaseName, schemaName, tableName, filter) + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/databaseextensions.go b/services/preview/sql/mgmt/v5.0/sql/databaseextensions.go new file mode 100644 index 000000000000..760cc70ccb78 --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/databaseextensions.go @@ -0,0 +1,330 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// DatabaseExtensionsClient 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 DatabaseExtensionsClient struct { + BaseClient +} + +// NewDatabaseExtensionsClient creates an instance of the DatabaseExtensionsClient client. +func NewDatabaseExtensionsClient(subscriptionID string) DatabaseExtensionsClient { + return NewDatabaseExtensionsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewDatabaseExtensionsClientWithBaseURI creates an instance of the DatabaseExtensionsClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewDatabaseExtensionsClientWithBaseURI(baseURI string, subscriptionID string) DatabaseExtensionsClient { + return DatabaseExtensionsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate perform a database extension operation, like polybase import +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database. +// parameters - the database import request parameters. +func (client DatabaseExtensionsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, extensionName string, parameters DatabaseExtensions) (result DatabaseExtensionsCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseExtensionsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.DatabaseExtensionsProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.DatabaseExtensionsProperties.OperationMode", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.DatabaseExtensionsProperties.StorageKey", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.DatabaseExtensionsProperties.StorageURI", Name: validation.Null, Rule: true, Chain: nil}, + }}}}}); err != nil { + return result, validation.NewError("sql.DatabaseExtensionsClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, databaseName, extensionName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseExtensionsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseExtensionsClient", "CreateOrUpdate", nil, "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client DatabaseExtensionsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, extensionName string, parameters DatabaseExtensions) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "extensionName": autorest.Encode("path", extensionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-02-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.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)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client DatabaseExtensionsClient) CreateOrUpdateSender(req *http.Request) (future DatabaseExtensionsCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client DatabaseExtensionsClient) CreateOrUpdateResponder(resp *http.Response) (result ImportExportExtensionsOperationResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets a database extension. This will return resource not found as it is not supported. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database. +func (client DatabaseExtensionsClient) Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string, extensionName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseExtensionsClient.Get") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, databaseName, extensionName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseExtensionsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "sql.DatabaseExtensionsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseExtensionsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client DatabaseExtensionsClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, extensionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "extensionName": autorest.Encode("path", extensionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-02-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/extensions/{extensionName}", 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 DatabaseExtensionsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client DatabaseExtensionsClient) GetResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// ListByDatabase list database extension. This will return an empty list as it is not supported. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database. +func (client DatabaseExtensionsClient) ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result ImportExportExtensionsOperationListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseExtensionsClient.ListByDatabase") + defer func() { + sc := -1 + if result.ieeolr.Response.Response != nil { + sc = result.ieeolr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByDatabaseNextResults + req, err := client.ListByDatabasePreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseExtensionsClient", "ListByDatabase", nil, "Failure preparing request") + return + } + + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.ieeolr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.DatabaseExtensionsClient", "ListByDatabase", resp, "Failure sending request") + return + } + + result.ieeolr, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseExtensionsClient", "ListByDatabase", resp, "Failure responding to request") + return + } + if result.ieeolr.hasNextLink() && result.ieeolr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByDatabasePreparer prepares the ListByDatabase request. +func (client DatabaseExtensionsClient) ListByDatabasePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-02-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/extensions", 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 DatabaseExtensionsClient) ListByDatabaseSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByDatabaseResponder handles the response to the ListByDatabase request. The method always +// closes the http.Response Body. +func (client DatabaseExtensionsClient) ListByDatabaseResponder(resp *http.Response) (result ImportExportExtensionsOperationListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByDatabaseNextResults retrieves the next set of results, if any. +func (client DatabaseExtensionsClient) listByDatabaseNextResults(ctx context.Context, lastResults ImportExportExtensionsOperationListResult) (result ImportExportExtensionsOperationListResult, err error) { + req, err := lastResults.importExportExtensionsOperationListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.DatabaseExtensionsClient", "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.DatabaseExtensionsClient", "listByDatabaseNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseExtensionsClient", "listByDatabaseNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByDatabaseComplete enumerates all values, automatically crossing page boundaries as required. +func (client DatabaseExtensionsClient) ListByDatabaseComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result ImportExportExtensionsOperationListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseExtensionsClient.ListByDatabase") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByDatabase(ctx, resourceGroupName, serverName, databaseName) + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/databaseoperations.go b/services/preview/sql/mgmt/v5.0/sql/databaseoperations.go new file mode 100644 index 000000000000..0f7c0936fadf --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/databaseoperations.go @@ -0,0 +1,236 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "github.com/gofrs/uuid" + "net/http" +) + +// DatabaseOperationsClient is the the Azure SQL Database management API provides a RESTful set of web services that +// interact with Azure SQL Database services to manage your databases. The API enables you to create, retrieve, update, +// and delete databases. +type DatabaseOperationsClient struct { + BaseClient +} + +// NewDatabaseOperationsClient creates an instance of the DatabaseOperationsClient client. +func NewDatabaseOperationsClient(subscriptionID string) DatabaseOperationsClient { + return NewDatabaseOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewDatabaseOperationsClientWithBaseURI creates an instance of the DatabaseOperationsClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewDatabaseOperationsClientWithBaseURI(baseURI string, subscriptionID string) DatabaseOperationsClient { + return DatabaseOperationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Cancel cancels the asynchronous operation on the database. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database. +// operationID - the operation identifier. +func (client DatabaseOperationsClient) Cancel(ctx context.Context, resourceGroupName string, serverName string, databaseName string, operationID uuid.UUID) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseOperationsClient.Cancel") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CancelPreparer(ctx, resourceGroupName, serverName, databaseName, operationID) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseOperationsClient", "Cancel", nil, "Failure preparing request") + return + } + + resp, err := client.CancelSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "sql.DatabaseOperationsClient", "Cancel", resp, "Failure sending request") + return + } + + result, err = client.CancelResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseOperationsClient", "Cancel", resp, "Failure responding to request") + return + } + + return +} + +// CancelPreparer prepares the Cancel request. +func (client DatabaseOperationsClient) CancelPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, operationID uuid.UUID) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "operationId": autorest.Encode("path", operationID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-02-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/operations/{operationId}/cancel", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CancelSender sends the Cancel request. The method will close the +// http.Response Body if it receives an error. +func (client DatabaseOperationsClient) CancelSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CancelResponder handles the response to the Cancel request. The method always +// closes the http.Response Body. +func (client DatabaseOperationsClient) CancelResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// ListByDatabase gets a list of operations performed on the database. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database. +func (client DatabaseOperationsClient) ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result DatabaseOperationListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseOperationsClient.ListByDatabase") + defer func() { + sc := -1 + if result.dolr.Response.Response != nil { + sc = result.dolr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByDatabaseNextResults + req, err := client.ListByDatabasePreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseOperationsClient", "ListByDatabase", nil, "Failure preparing request") + return + } + + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.dolr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.DatabaseOperationsClient", "ListByDatabase", resp, "Failure sending request") + return + } + + result.dolr, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseOperationsClient", "ListByDatabase", resp, "Failure responding to request") + return + } + if result.dolr.hasNextLink() && result.dolr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByDatabasePreparer prepares the ListByDatabase request. +func (client DatabaseOperationsClient) ListByDatabasePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-02-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/operations", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByDatabaseSender sends the ListByDatabase request. The method will close the +// http.Response Body if it receives an error. +func (client DatabaseOperationsClient) ListByDatabaseSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByDatabaseResponder handles the response to the ListByDatabase request. The method always +// closes the http.Response Body. +func (client DatabaseOperationsClient) ListByDatabaseResponder(resp *http.Response) (result DatabaseOperationListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByDatabaseNextResults retrieves the next set of results, if any. +func (client DatabaseOperationsClient) listByDatabaseNextResults(ctx context.Context, lastResults DatabaseOperationListResult) (result DatabaseOperationListResult, err error) { + req, err := lastResults.databaseOperationListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.DatabaseOperationsClient", "listByDatabaseNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.DatabaseOperationsClient", "listByDatabaseNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseOperationsClient", "listByDatabaseNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByDatabaseComplete enumerates all values, automatically crossing page boundaries as required. +func (client DatabaseOperationsClient) ListByDatabaseComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result DatabaseOperationListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseOperationsClient.ListByDatabase") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByDatabase(ctx, resourceGroupName, serverName, databaseName) + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/databaserecommendedactions.go b/services/preview/sql/mgmt/v5.0/sql/databaserecommendedactions.go new file mode 100644 index 000000000000..ce436e319463 --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/databaserecommendedactions.go @@ -0,0 +1,286 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// DatabaseRecommendedActionsClient 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 DatabaseRecommendedActionsClient struct { + BaseClient +} + +// NewDatabaseRecommendedActionsClient creates an instance of the DatabaseRecommendedActionsClient client. +func NewDatabaseRecommendedActionsClient(subscriptionID string) DatabaseRecommendedActionsClient { + return NewDatabaseRecommendedActionsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewDatabaseRecommendedActionsClientWithBaseURI creates an instance of the DatabaseRecommendedActionsClient client +// using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign +// clouds, Azure stack). +func NewDatabaseRecommendedActionsClientWithBaseURI(baseURI string, subscriptionID string) DatabaseRecommendedActionsClient { + return DatabaseRecommendedActionsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get gets a database recommended action. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database. +// advisorName - the name of the Database Advisor. +// recommendedActionName - the name of Database Recommended Action. +func (client DatabaseRecommendedActionsClient) Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string, advisorName string, recommendedActionName string) (result RecommendedAction, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseRecommendedActionsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, databaseName, advisorName, recommendedActionName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseRecommendedActionsClient", "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.DatabaseRecommendedActionsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseRecommendedActionsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client DatabaseRecommendedActionsClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, advisorName string, recommendedActionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "advisorName": autorest.Encode("path", advisorName), + "databaseName": autorest.Encode("path", databaseName), + "recommendedActionName": autorest.Encode("path", recommendedActionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/advisors/{advisorName}/recommendedActions/{recommendedActionName}", 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 DatabaseRecommendedActionsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client DatabaseRecommendedActionsClient) GetResponder(resp *http.Response) (result RecommendedAction, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByDatabaseAdvisor gets list of Database Recommended Actions. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database. +// advisorName - the name of the Database Advisor. +func (client DatabaseRecommendedActionsClient) ListByDatabaseAdvisor(ctx context.Context, resourceGroupName string, serverName string, databaseName string, advisorName string) (result ListRecommendedAction, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseRecommendedActionsClient.ListByDatabaseAdvisor") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListByDatabaseAdvisorPreparer(ctx, resourceGroupName, serverName, databaseName, advisorName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseRecommendedActionsClient", "ListByDatabaseAdvisor", nil, "Failure preparing request") + return + } + + resp, err := client.ListByDatabaseAdvisorSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.DatabaseRecommendedActionsClient", "ListByDatabaseAdvisor", resp, "Failure sending request") + return + } + + result, err = client.ListByDatabaseAdvisorResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseRecommendedActionsClient", "ListByDatabaseAdvisor", resp, "Failure responding to request") + return + } + + return +} + +// ListByDatabaseAdvisorPreparer prepares the ListByDatabaseAdvisor request. +func (client DatabaseRecommendedActionsClient) ListByDatabaseAdvisorPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, advisorName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "advisorName": autorest.Encode("path", advisorName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/advisors/{advisorName}/recommendedActions", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByDatabaseAdvisorSender sends the ListByDatabaseAdvisor request. The method will close the +// http.Response Body if it receives an error. +func (client DatabaseRecommendedActionsClient) ListByDatabaseAdvisorSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByDatabaseAdvisorResponder handles the response to the ListByDatabaseAdvisor request. The method always +// closes the http.Response Body. +func (client DatabaseRecommendedActionsClient) ListByDatabaseAdvisorResponder(resp *http.Response) (result ListRecommendedAction, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Value), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Update updates a database recommended action. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database. +// advisorName - the name of the Database Advisor. +// recommendedActionName - the name of Database Recommended Action. +// parameters - the requested recommended action resource state. +func (client DatabaseRecommendedActionsClient) Update(ctx context.Context, resourceGroupName string, serverName string, databaseName string, advisorName string, recommendedActionName string, parameters RecommendedAction) (result RecommendedAction, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseRecommendedActionsClient.Update") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.UpdatePreparer(ctx, resourceGroupName, serverName, databaseName, advisorName, recommendedActionName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseRecommendedActionsClient", "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.DatabaseRecommendedActionsClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseRecommendedActionsClient", "Update", resp, "Failure responding to request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client DatabaseRecommendedActionsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, advisorName string, recommendedActionName string, parameters RecommendedAction) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "advisorName": autorest.Encode("path", advisorName), + "databaseName": autorest.Encode("path", databaseName), + "recommendedActionName": autorest.Encode("path", recommendedActionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + parameters.Kind = nil + parameters.Location = nil + 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}/advisors/{advisorName}/recommendedActions/{recommendedActionName}", 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 DatabaseRecommendedActionsClient) UpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client DatabaseRecommendedActionsClient) UpdateResponder(resp *http.Response) (result RecommendedAction, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/databases.go b/services/preview/sql/mgmt/v5.0/sql/databases.go new file mode 100644 index 000000000000..7c9ae6013545 --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/databases.go @@ -0,0 +1,1495 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// DatabasesClient is the the Azure SQL Database management API provides a RESTful set of web services that interact +// with Azure SQL Database services to manage your databases. The API enables you to create, retrieve, update, and +// delete databases. +type DatabasesClient struct { + BaseClient +} + +// NewDatabasesClient creates an instance of the DatabasesClient client. +func NewDatabasesClient(subscriptionID string) DatabasesClient { + return NewDatabasesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewDatabasesClientWithBaseURI creates an instance of the DatabasesClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewDatabasesClientWithBaseURI(baseURI string, subscriptionID string) DatabasesClient { + return DatabasesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates a new database or updates an existing database. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database. +// parameters - the requested database resource state. +func (client DatabasesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters Database) (result DatabasesCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabasesClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.Sku", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.Sku.Name", Name: validation.Null, Rule: true, Chain: nil}}}, + {Target: "parameters.DatabaseProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.DatabaseProperties.CurrentSku", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.DatabaseProperties.CurrentSku.Name", Name: validation.Null, Rule: true, Chain: nil}}}, + }}}}}); err != nil { + return result, validation.NewError("sql.DatabasesClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, databaseName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "CreateOrUpdate", nil, "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 = "2021-02-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + parameters.Kind = nil + parameters.ManagedBy = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client DatabasesClient) CreateOrUpdateSender(req *http.Request) (future DatabasesCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client DatabasesClient) CreateOrUpdateResponder(resp *http.Response) (result Database, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes the database. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database. +func (client DatabasesClient) Delete(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result DatabasesDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabasesClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "Delete", nil, "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 = "2021-02-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client DatabasesClient) DeleteSender(req *http.Request) (future DatabasesDeleteFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client DatabasesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Export exports a database. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database. +// parameters - the database export request parameters. +func (client DatabasesClient) Export(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters ExportDatabaseDefinition) (result DatabasesExportFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabasesClient.Export") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.StorageKey", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.StorageURI", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.AdministratorLogin", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.AdministratorLoginPassword", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewError("sql.DatabasesClient", "Export", err.Error()) + } + + req, err := client.ExportPreparer(ctx, resourceGroupName, serverName, databaseName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "Export", nil, "Failure preparing request") + return + } + + result, err = client.ExportSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "Export", nil, "Failure sending request") + return + } + + return +} + +// ExportPreparer prepares the Export request. +func (client DatabasesClient) ExportPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters ExportDatabaseDefinition) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-02-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}/export", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ExportSender sends the Export request. The method will close the +// http.Response Body if it receives an error. +func (client DatabasesClient) ExportSender(req *http.Request) (future DatabasesExportFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// ExportResponder handles the response to the Export request. The method always +// closes the http.Response Body. +func (client DatabasesClient) ExportResponder(resp *http.Response) (result ImportExportOperationResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Failover failovers a database. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database to failover. +// replicaType - the type of replica to be failed over. +func (client DatabasesClient) Failover(ctx context.Context, resourceGroupName string, serverName string, databaseName string, replicaType ReplicaType) (result DatabasesFailoverFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabasesClient.Failover") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.FailoverPreparer(ctx, resourceGroupName, serverName, databaseName, replicaType) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "Failover", nil, "Failure preparing request") + return + } + + result, err = client.FailoverSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "Failover", nil, "Failure sending request") + return + } + + return +} + +// FailoverPreparer prepares the Failover request. +func (client DatabasesClient) FailoverPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, replicaType ReplicaType) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-02-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(string(replicaType)) > 0 { + queryParameters["replicaType"] = autorest.Encode("query", replicaType) + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/failover", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// FailoverSender sends the Failover request. The method will close the +// http.Response Body if it receives an error. +func (client DatabasesClient) FailoverSender(req *http.Request) (future DatabasesFailoverFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// FailoverResponder handles the response to the Failover request. The method always +// closes the http.Response Body. +func (client DatabasesClient) FailoverResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a database. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database. +func (client DatabasesClient) Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result Database, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabasesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client DatabasesClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-02-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client DatabasesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client DatabasesClient) GetResponder(resp *http.Response) (result Database, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Import imports a bacpac into a new database. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database. +// parameters - the database import request parameters. +func (client DatabasesClient) Import(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters ImportExistingDatabaseDefinition) (result DatabasesImportFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabasesClient.Import") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.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", "Import", err.Error()) + } + + req, err := client.ImportPreparer(ctx, resourceGroupName, serverName, databaseName, 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", nil, "Failure sending request") + return + } + + return +} + +// ImportPreparer prepares the Import request. +func (client DatabasesClient) ImportPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters ImportExistingDatabaseDefinition) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-02-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}/import", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ImportSender sends the Import request. The method will close the +// http.Response Body if it receives an error. +func (client DatabasesClient) ImportSender(req *http.Request) (future DatabasesImportFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// ImportResponder handles the response to the Import request. The method always +// closes the http.Response Body. +func (client DatabasesClient) ImportResponder(resp *http.Response) (result ImportExportOperationResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByElasticPool gets a list of databases in an elastic pool. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// elasticPoolName - the name of the elastic pool. +func (client DatabasesClient) ListByElasticPool(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string) (result DatabaseListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabasesClient.ListByElasticPool") + defer func() { + sc := -1 + if result.dlr.Response.Response != nil { + sc = result.dlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByElasticPoolNextResults + req, err := client.ListByElasticPoolPreparer(ctx, resourceGroupName, serverName, elasticPoolName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "ListByElasticPool", nil, "Failure preparing request") + return + } + + resp, err := client.ListByElasticPoolSender(req) + if err != nil { + result.dlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "ListByElasticPool", resp, "Failure sending request") + return + } + + result.dlr, err = client.ListByElasticPoolResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "ListByElasticPool", resp, "Failure responding to request") + return + } + if result.dlr.hasNextLink() && result.dlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByElasticPoolPreparer prepares the ListByElasticPool request. +func (client DatabasesClient) ListByElasticPoolPreparer(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "elasticPoolName": autorest.Encode("path", elasticPoolName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-02-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}/databases", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByElasticPoolSender sends the ListByElasticPool request. The method will close the +// http.Response Body if it receives an error. +func (client DatabasesClient) ListByElasticPoolSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByElasticPoolResponder handles the response to the ListByElasticPool request. The method always +// closes the http.Response Body. +func (client DatabasesClient) ListByElasticPoolResponder(resp *http.Response) (result DatabaseListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByElasticPoolNextResults retrieves the next set of results, if any. +func (client DatabasesClient) listByElasticPoolNextResults(ctx context.Context, lastResults DatabaseListResult) (result DatabaseListResult, err error) { + req, err := lastResults.databaseListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.DatabasesClient", "listByElasticPoolNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByElasticPoolSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.DatabasesClient", "listByElasticPoolNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByElasticPoolResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "listByElasticPoolNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByElasticPoolComplete enumerates all values, automatically crossing page boundaries as required. +func (client DatabasesClient) ListByElasticPoolComplete(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string) (result DatabaseListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabasesClient.ListByElasticPool") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByElasticPool(ctx, resourceGroupName, serverName, elasticPoolName) + return +} + +// ListByServer gets a list of databases. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +func (client DatabasesClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string, skipToken string) (result DatabaseListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabasesClient.ListByServer") + defer func() { + sc := -1 + if result.dlr.Response.Response != nil { + sc = result.dlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByServerNextResults + req, err := client.ListByServerPreparer(ctx, resourceGroupName, serverName, skipToken) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "ListByServer", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServerSender(req) + if err != nil { + result.dlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "ListByServer", resp, "Failure sending request") + return + } + + result.dlr, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "ListByServer", resp, "Failure responding to request") + return + } + if result.dlr.hasNextLink() && result.dlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServerPreparer prepares the ListByServer request. +func (client DatabasesClient) ListByServerPreparer(ctx context.Context, resourceGroupName string, serverName string, skipToken string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-02-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(skipToken) > 0 { + queryParameters["$skipToken"] = autorest.Encode("query", skipToken) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByServerSender sends the ListByServer request. The method will close the +// http.Response Body if it receives an error. +func (client DatabasesClient) ListByServerSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client DatabasesClient) ListByServerResponder(resp *http.Response) (result DatabaseListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByServerNextResults retrieves the next set of results, if any. +func (client DatabasesClient) listByServerNextResults(ctx context.Context, lastResults DatabaseListResult) (result DatabaseListResult, err error) { + req, err := lastResults.databaseListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.DatabasesClient", "listByServerNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByServerSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.DatabasesClient", "listByServerNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "listByServerNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServerComplete enumerates all values, automatically crossing page boundaries as required. +func (client DatabasesClient) ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string, skipToken string) (result DatabaseListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabasesClient.ListByServer") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByServer(ctx, resourceGroupName, serverName, skipToken) + return +} + +// ListInaccessibleByServer gets a list of inaccessible databases in a logical server +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +func (client DatabasesClient) ListInaccessibleByServer(ctx context.Context, resourceGroupName string, serverName string) (result DatabaseListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabasesClient.ListInaccessibleByServer") + defer func() { + sc := -1 + if result.dlr.Response.Response != nil { + sc = result.dlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listInaccessibleByServerNextResults + req, err := client.ListInaccessibleByServerPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "ListInaccessibleByServer", nil, "Failure preparing request") + return + } + + resp, err := client.ListInaccessibleByServerSender(req) + if err != nil { + result.dlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "ListInaccessibleByServer", resp, "Failure sending request") + return + } + + result.dlr, err = client.ListInaccessibleByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "ListInaccessibleByServer", resp, "Failure responding to request") + return + } + if result.dlr.hasNextLink() && result.dlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListInaccessibleByServerPreparer prepares the ListInaccessibleByServer request. +func (client DatabasesClient) ListInaccessibleByServerPreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-02-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/inaccessibleDatabases", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListInaccessibleByServerSender sends the ListInaccessibleByServer request. The method will close the +// http.Response Body if it receives an error. +func (client DatabasesClient) ListInaccessibleByServerSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListInaccessibleByServerResponder handles the response to the ListInaccessibleByServer request. The method always +// closes the http.Response Body. +func (client DatabasesClient) ListInaccessibleByServerResponder(resp *http.Response) (result DatabaseListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listInaccessibleByServerNextResults retrieves the next set of results, if any. +func (client DatabasesClient) listInaccessibleByServerNextResults(ctx context.Context, lastResults DatabaseListResult) (result DatabaseListResult, err error) { + req, err := lastResults.databaseListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.DatabasesClient", "listInaccessibleByServerNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListInaccessibleByServerSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.DatabasesClient", "listInaccessibleByServerNextResults", resp, "Failure sending next results request") + } + result, err = client.ListInaccessibleByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "listInaccessibleByServerNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListInaccessibleByServerComplete enumerates all values, automatically crossing page boundaries as required. +func (client DatabasesClient) ListInaccessibleByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result DatabaseListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabasesClient.ListInaccessibleByServer") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListInaccessibleByServer(ctx, resourceGroupName, serverName) + return +} + +// ListMetricDefinitions returns database metric definitions. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database. +func (client DatabasesClient) ListMetricDefinitions(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result MetricDefinitionListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabasesClient.ListMetricDefinitions") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListMetricDefinitionsPreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "ListMetricDefinitions", nil, "Failure preparing request") + return + } + + resp, err := client.ListMetricDefinitionsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "ListMetricDefinitions", resp, "Failure sending request") + return + } + + result, err = client.ListMetricDefinitionsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "ListMetricDefinitions", resp, "Failure responding to request") + return + } + + return +} + +// ListMetricDefinitionsPreparer prepares the ListMetricDefinitions request. +func (client DatabasesClient) ListMetricDefinitionsPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/metricDefinitions", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListMetricDefinitionsSender sends the ListMetricDefinitions request. The method will close the +// http.Response Body if it receives an error. +func (client DatabasesClient) ListMetricDefinitionsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListMetricDefinitionsResponder handles the response to the ListMetricDefinitions request. The method always +// closes the http.Response Body. +func (client DatabasesClient) ListMetricDefinitionsResponder(resp *http.Response) (result MetricDefinitionListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListMetrics returns database metrics. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database. +// filter - an OData filter expression that describes a subset of metrics to return. +func (client DatabasesClient) ListMetrics(ctx context.Context, resourceGroupName string, serverName string, databaseName string, filter string) (result MetricListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabasesClient.ListMetrics") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListMetricsPreparer(ctx, resourceGroupName, serverName, databaseName, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "ListMetrics", nil, "Failure preparing request") + return + } + + resp, err := client.ListMetricsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "ListMetrics", resp, "Failure sending request") + return + } + + result, err = client.ListMetricsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "ListMetrics", resp, "Failure responding to request") + return + } + + return +} + +// ListMetricsPreparer prepares the ListMetrics request. +func (client DatabasesClient) ListMetricsPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + queryParameters := map[string]interface{}{ + "$filter": autorest.Encode("query", filter), + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/metrics", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListMetricsSender sends the ListMetrics request. The method will close the +// http.Response Body if it receives an error. +func (client DatabasesClient) ListMetricsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListMetricsResponder handles the response to the ListMetrics request. The method always +// closes the http.Response Body. +func (client DatabasesClient) ListMetricsResponder(resp *http.Response) (result MetricListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Pause pauses a database. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database to be paused. +func (client DatabasesClient) Pause(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result DatabasesPauseFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabasesClient.Pause") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.PausePreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "Pause", nil, "Failure preparing request") + return + } + + result, err = client.PauseSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "Pause", nil, "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 = "2021-02-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/pause", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// PauseSender sends the Pause request. The method will close the +// http.Response Body if it receives an error. +func (client DatabasesClient) PauseSender(req *http.Request) (future DatabasesPauseFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// PauseResponder handles the response to the Pause request. The method always +// closes the http.Response Body. +func (client DatabasesClient) PauseResponder(resp *http.Response) (result Database, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Rename renames a database. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database to rename. +// parameters - the resource move definition for renaming this database. +func (client DatabasesClient) Rename(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters ResourceMoveDefinition) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabasesClient.Rename") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.ID", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewError("sql.DatabasesClient", "Rename", err.Error()) + } + + req, err := client.RenamePreparer(ctx, resourceGroupName, serverName, databaseName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "Rename", nil, "Failure preparing request") + return + } + + resp, err := client.RenameSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "Rename", resp, "Failure sending request") + return + } + + result, err = client.RenameResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "Rename", resp, "Failure responding to request") + return + } + + return +} + +// RenamePreparer prepares the Rename request. +func (client DatabasesClient) RenamePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters ResourceMoveDefinition) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-02-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/move", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// RenameSender sends the Rename request. The method will close the +// http.Response Body if it receives an error. +func (client DatabasesClient) RenameSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// RenameResponder handles the response to the Rename request. The method always +// closes the http.Response Body. +func (client DatabasesClient) RenameResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Resume resumes a database. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database to be resumed. +func (client DatabasesClient) Resume(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result DatabasesResumeFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabasesClient.Resume") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ResumePreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "Resume", nil, "Failure preparing request") + return + } + + result, err = client.ResumeSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "Resume", nil, "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 = "2021-02-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/resume", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ResumeSender sends the Resume request. The method will close the +// http.Response Body if it receives an error. +func (client DatabasesClient) ResumeSender(req *http.Request) (future DatabasesResumeFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// ResumeResponder handles the response to the Resume request. The method always +// closes the http.Response Body. +func (client DatabasesClient) ResumeResponder(resp *http.Response) (result Database, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Update updates an existing database. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database. +// parameters - the requested database resource state. +func (client DatabasesClient) Update(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters DatabaseUpdate) (result DatabasesUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabasesClient.Update") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.UpdatePreparer(ctx, resourceGroupName, serverName, databaseName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "Update", nil, "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 = "2021-02-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client DatabasesClient) UpdateSender(req *http.Request) (future DatabasesUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client DatabasesClient) UpdateResponder(resp *http.Response) (result Database, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// UpgradeDataWarehouse upgrades a data warehouse. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database to be upgraded. +func (client DatabasesClient) UpgradeDataWarehouse(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result DatabasesUpgradeDataWarehouseFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabasesClient.UpgradeDataWarehouse") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.UpgradeDataWarehousePreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "UpgradeDataWarehouse", nil, "Failure preparing request") + return + } + + result, err = client.UpgradeDataWarehouseSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesClient", "UpgradeDataWarehouse", nil, "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 = "2021-02-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/upgradeDataWarehouse", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpgradeDataWarehouseSender sends the UpgradeDataWarehouse request. The method will close the +// http.Response Body if it receives an error. +func (client DatabasesClient) UpgradeDataWarehouseSender(req *http.Request) (future DatabasesUpgradeDataWarehouseFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// UpgradeDataWarehouseResponder handles the response to the UpgradeDataWarehouse request. The method always +// closes the http.Response Body. +func (client DatabasesClient) UpgradeDataWarehouseResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/databaseschemas.go b/services/preview/sql/mgmt/v5.0/sql/databaseschemas.go new file mode 100644 index 000000000000..ad05f10846f0 --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/databaseschemas.go @@ -0,0 +1,239 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// DatabaseSchemasClient 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 DatabaseSchemasClient struct { + BaseClient +} + +// NewDatabaseSchemasClient creates an instance of the DatabaseSchemasClient client. +func NewDatabaseSchemasClient(subscriptionID string) DatabaseSchemasClient { + return NewDatabaseSchemasClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewDatabaseSchemasClientWithBaseURI creates an instance of the DatabaseSchemasClient client using a custom endpoint. +// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewDatabaseSchemasClientWithBaseURI(baseURI string, subscriptionID string) DatabaseSchemasClient { + return DatabaseSchemasClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get get database schema +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database. +// schemaName - the name of the schema. +func (client DatabaseSchemasClient) Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string, schemaName string) (result DatabaseSchema, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseSchemasClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, databaseName, schemaName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseSchemasClient", "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.DatabaseSchemasClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseSchemasClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client DatabaseSchemasClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, schemaName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "schemaName": autorest.Encode("path", schemaName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/schemas/{schemaName}", 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 DatabaseSchemasClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client DatabaseSchemasClient) GetResponder(resp *http.Response) (result DatabaseSchema, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByDatabase list database schemas +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database. +// filter - an OData filter expression that filters elements in the collection. +func (client DatabaseSchemasClient) ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string, filter string) (result DatabaseSchemaListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseSchemasClient.ListByDatabase") + defer func() { + sc := -1 + if result.dslr.Response.Response != nil { + sc = result.dslr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByDatabaseNextResults + req, err := client.ListByDatabasePreparer(ctx, resourceGroupName, serverName, databaseName, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseSchemasClient", "ListByDatabase", nil, "Failure preparing request") + return + } + + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.dslr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.DatabaseSchemasClient", "ListByDatabase", resp, "Failure sending request") + return + } + + result.dslr, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseSchemasClient", "ListByDatabase", resp, "Failure responding to request") + return + } + if result.dslr.hasNextLink() && result.dslr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByDatabasePreparer prepares the ListByDatabase request. +func (client DatabaseSchemasClient) ListByDatabasePreparer(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 = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/schemas", 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 DatabaseSchemasClient) ListByDatabaseSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByDatabaseResponder handles the response to the ListByDatabase request. The method always +// closes the http.Response Body. +func (client DatabaseSchemasClient) ListByDatabaseResponder(resp *http.Response) (result DatabaseSchemaListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByDatabaseNextResults retrieves the next set of results, if any. +func (client DatabaseSchemasClient) listByDatabaseNextResults(ctx context.Context, lastResults DatabaseSchemaListResult) (result DatabaseSchemaListResult, err error) { + req, err := lastResults.databaseSchemaListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.DatabaseSchemasClient", "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.DatabaseSchemasClient", "listByDatabaseNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseSchemasClient", "listByDatabaseNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByDatabaseComplete enumerates all values, automatically crossing page boundaries as required. +func (client DatabaseSchemasClient) ListByDatabaseComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string, filter string) (result DatabaseSchemaListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseSchemasClient.ListByDatabase") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByDatabase(ctx, resourceGroupName, serverName, databaseName, filter) + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/databasesecurityalertpolicies.go b/services/preview/sql/mgmt/v5.0/sql/databasesecurityalertpolicies.go new file mode 100644 index 000000000000..deace584057c --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/databasesecurityalertpolicies.go @@ -0,0 +1,319 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// DatabaseSecurityAlertPoliciesClient 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 DatabaseSecurityAlertPoliciesClient struct { + BaseClient +} + +// NewDatabaseSecurityAlertPoliciesClient creates an instance of the DatabaseSecurityAlertPoliciesClient client. +func NewDatabaseSecurityAlertPoliciesClient(subscriptionID string) DatabaseSecurityAlertPoliciesClient { + return NewDatabaseSecurityAlertPoliciesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewDatabaseSecurityAlertPoliciesClientWithBaseURI creates an instance of the DatabaseSecurityAlertPoliciesClient +// client using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI +// (sovereign clouds, Azure stack). +func NewDatabaseSecurityAlertPoliciesClientWithBaseURI(baseURI string, subscriptionID string) DatabaseSecurityAlertPoliciesClient { + return DatabaseSecurityAlertPoliciesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a database's security alert policy. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database for which the security alert policy is defined. +// parameters - the database security alert policy. +func (client DatabaseSecurityAlertPoliciesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters DatabaseSecurityAlertPolicy) (result DatabaseSecurityAlertPolicy, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseSecurityAlertPoliciesClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, databaseName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseSecurityAlertPoliciesClient", "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.DatabaseSecurityAlertPoliciesClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseSecurityAlertPoliciesClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client DatabaseSecurityAlertPoliciesClient) 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 = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + parameters.SystemData = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/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 DatabaseSecurityAlertPoliciesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client DatabaseSecurityAlertPoliciesClient) CreateOrUpdateResponder(resp *http.Response) (result DatabaseSecurityAlertPolicy, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets a database's security alert policy. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database for which the security alert policy is defined. +func (client DatabaseSecurityAlertPoliciesClient) Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result DatabaseSecurityAlertPolicy, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseSecurityAlertPoliciesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseSecurityAlertPoliciesClient", "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.DatabaseSecurityAlertPoliciesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseSecurityAlertPoliciesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client DatabaseSecurityAlertPoliciesClient) 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 = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/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 DatabaseSecurityAlertPoliciesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client DatabaseSecurityAlertPoliciesClient) GetResponder(resp *http.Response) (result DatabaseSecurityAlertPolicy, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByDatabase gets a list of database's security alert policies. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database for which the security alert policy is defined. +func (client DatabaseSecurityAlertPoliciesClient) ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result DatabaseSecurityAlertListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseSecurityAlertPoliciesClient.ListByDatabase") + defer func() { + sc := -1 + if result.dsalr.Response.Response != nil { + sc = result.dsalr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByDatabaseNextResults + req, err := client.ListByDatabasePreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseSecurityAlertPoliciesClient", "ListByDatabase", nil, "Failure preparing request") + return + } + + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.dsalr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.DatabaseSecurityAlertPoliciesClient", "ListByDatabase", resp, "Failure sending request") + return + } + + result.dsalr, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseSecurityAlertPoliciesClient", "ListByDatabase", resp, "Failure responding to request") + return + } + if result.dsalr.hasNextLink() && result.dsalr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByDatabasePreparer prepares the ListByDatabase request. +func (client DatabaseSecurityAlertPoliciesClient) ListByDatabasePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/securityAlertPolicies", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByDatabaseSender sends the ListByDatabase request. The method will close the +// http.Response Body if it receives an error. +func (client DatabaseSecurityAlertPoliciesClient) ListByDatabaseSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByDatabaseResponder handles the response to the ListByDatabase request. The method always +// closes the http.Response Body. +func (client DatabaseSecurityAlertPoliciesClient) ListByDatabaseResponder(resp *http.Response) (result DatabaseSecurityAlertListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByDatabaseNextResults retrieves the next set of results, if any. +func (client DatabaseSecurityAlertPoliciesClient) listByDatabaseNextResults(ctx context.Context, lastResults DatabaseSecurityAlertListResult) (result DatabaseSecurityAlertListResult, err error) { + req, err := lastResults.databaseSecurityAlertListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.DatabaseSecurityAlertPoliciesClient", "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.DatabaseSecurityAlertPoliciesClient", "listByDatabaseNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseSecurityAlertPoliciesClient", "listByDatabaseNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByDatabaseComplete enumerates all values, automatically crossing page boundaries as required. +func (client DatabaseSecurityAlertPoliciesClient) ListByDatabaseComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result DatabaseSecurityAlertListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseSecurityAlertPoliciesClient.ListByDatabase") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByDatabase(ctx, resourceGroupName, serverName, databaseName) + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/databasetables.go b/services/preview/sql/mgmt/v5.0/sql/databasetables.go new file mode 100644 index 000000000000..96d0b5cd23b5 --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/databasetables.go @@ -0,0 +1,243 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// DatabaseTablesClient 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 DatabaseTablesClient struct { + BaseClient +} + +// NewDatabaseTablesClient creates an instance of the DatabaseTablesClient client. +func NewDatabaseTablesClient(subscriptionID string) DatabaseTablesClient { + return NewDatabaseTablesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewDatabaseTablesClientWithBaseURI creates an instance of the DatabaseTablesClient client using a custom endpoint. +// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewDatabaseTablesClientWithBaseURI(baseURI string, subscriptionID string) DatabaseTablesClient { + return DatabaseTablesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get get database table +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database. +// schemaName - the name of the schema. +// tableName - the name of the table. +func (client DatabaseTablesClient) Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string, schemaName string, tableName string) (result DatabaseTable, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseTablesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, databaseName, schemaName, tableName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseTablesClient", "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.DatabaseTablesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseTablesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client DatabaseTablesClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, schemaName string, tableName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "schemaName": autorest.Encode("path", schemaName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "tableName": autorest.Encode("path", tableName), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}", 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 DatabaseTablesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client DatabaseTablesClient) GetResponder(resp *http.Response) (result DatabaseTable, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListBySchema list database tables +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database. +// schemaName - the name of the schema. +// filter - an OData filter expression that filters elements in the collection. +func (client DatabaseTablesClient) ListBySchema(ctx context.Context, resourceGroupName string, serverName string, databaseName string, schemaName string, filter string) (result DatabaseTableListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseTablesClient.ListBySchema") + defer func() { + sc := -1 + if result.dtlr.Response.Response != nil { + sc = result.dtlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listBySchemaNextResults + req, err := client.ListBySchemaPreparer(ctx, resourceGroupName, serverName, databaseName, schemaName, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseTablesClient", "ListBySchema", nil, "Failure preparing request") + return + } + + resp, err := client.ListBySchemaSender(req) + if err != nil { + result.dtlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.DatabaseTablesClient", "ListBySchema", resp, "Failure sending request") + return + } + + result.dtlr, err = client.ListBySchemaResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseTablesClient", "ListBySchema", resp, "Failure responding to request") + return + } + if result.dtlr.hasNextLink() && result.dtlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListBySchemaPreparer prepares the ListBySchema request. +func (client DatabaseTablesClient) ListBySchemaPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, schemaName string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "schemaName": autorest.Encode("path", schemaName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/schemas/{schemaName}/tables", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListBySchemaSender sends the ListBySchema request. The method will close the +// http.Response Body if it receives an error. +func (client DatabaseTablesClient) ListBySchemaSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListBySchemaResponder handles the response to the ListBySchema request. The method always +// closes the http.Response Body. +func (client DatabaseTablesClient) ListBySchemaResponder(resp *http.Response) (result DatabaseTableListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listBySchemaNextResults retrieves the next set of results, if any. +func (client DatabaseTablesClient) listBySchemaNextResults(ctx context.Context, lastResults DatabaseTableListResult) (result DatabaseTableListResult, err error) { + req, err := lastResults.databaseTableListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.DatabaseTablesClient", "listBySchemaNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListBySchemaSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.DatabaseTablesClient", "listBySchemaNextResults", resp, "Failure sending next results request") + } + result, err = client.ListBySchemaResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseTablesClient", "listBySchemaNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListBySchemaComplete enumerates all values, automatically crossing page boundaries as required. +func (client DatabaseTablesClient) ListBySchemaComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string, schemaName string, filter string) (result DatabaseTableListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseTablesClient.ListBySchema") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListBySchema(ctx, resourceGroupName, serverName, databaseName, schemaName, filter) + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/databaseusages.go b/services/preview/sql/mgmt/v5.0/sql/databaseusages.go new file mode 100644 index 000000000000..ac477ef39045 --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/databaseusages.go @@ -0,0 +1,154 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// DatabaseUsagesClient is the the Azure SQL Database management API provides a RESTful set of web services that +// interact with Azure SQL Database services to manage your databases. The API enables you to create, retrieve, update, +// and delete databases. +type DatabaseUsagesClient struct { + BaseClient +} + +// NewDatabaseUsagesClient creates an instance of the DatabaseUsagesClient client. +func NewDatabaseUsagesClient(subscriptionID string) DatabaseUsagesClient { + return NewDatabaseUsagesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewDatabaseUsagesClientWithBaseURI creates an instance of the DatabaseUsagesClient client using a custom endpoint. +// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewDatabaseUsagesClientWithBaseURI(baseURI string, subscriptionID string) DatabaseUsagesClient { + return DatabaseUsagesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListByDatabase gets database usages. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database. +func (client DatabaseUsagesClient) ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result DatabaseUsageListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseUsagesClient.ListByDatabase") + defer func() { + sc := -1 + if result.dulr.Response.Response != nil { + sc = result.dulr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByDatabaseNextResults + req, err := client.ListByDatabasePreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseUsagesClient", "ListByDatabase", nil, "Failure preparing request") + return + } + + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.dulr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.DatabaseUsagesClient", "ListByDatabase", resp, "Failure sending request") + return + } + + result.dulr, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseUsagesClient", "ListByDatabase", resp, "Failure responding to request") + return + } + if result.dulr.hasNextLink() && result.dulr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByDatabasePreparer prepares the ListByDatabase request. +func (client DatabaseUsagesClient) ListByDatabasePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-02-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/usages", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByDatabaseSender sends the ListByDatabase request. The method will close the +// http.Response Body if it receives an error. +func (client DatabaseUsagesClient) ListByDatabaseSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByDatabaseResponder handles the response to the ListByDatabase request. The method always +// closes the http.Response Body. +func (client DatabaseUsagesClient) ListByDatabaseResponder(resp *http.Response) (result DatabaseUsageListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByDatabaseNextResults retrieves the next set of results, if any. +func (client DatabaseUsagesClient) listByDatabaseNextResults(ctx context.Context, lastResults DatabaseUsageListResult) (result DatabaseUsageListResult, err error) { + req, err := lastResults.databaseUsageListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.DatabaseUsagesClient", "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.DatabaseUsagesClient", "listByDatabaseNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseUsagesClient", "listByDatabaseNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByDatabaseComplete enumerates all values, automatically crossing page boundaries as required. +func (client DatabaseUsagesClient) ListByDatabaseComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result DatabaseUsageListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseUsagesClient.ListByDatabase") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByDatabase(ctx, resourceGroupName, serverName, databaseName) + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/databasevulnerabilityassessmentrulebaselines.go b/services/preview/sql/mgmt/v5.0/sql/databasevulnerabilityassessmentrulebaselines.go new file mode 100644 index 000000000000..3573d0bc58b4 --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/databasevulnerabilityassessmentrulebaselines.go @@ -0,0 +1,300 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// DatabaseVulnerabilityAssessmentRuleBaselinesClient is the the Azure SQL Database management API provides a RESTful +// set of web services that interact with Azure SQL Database services to manage your databases. The API enables you to +// create, retrieve, update, and delete databases. +type DatabaseVulnerabilityAssessmentRuleBaselinesClient struct { + BaseClient +} + +// NewDatabaseVulnerabilityAssessmentRuleBaselinesClient creates an instance of the +// DatabaseVulnerabilityAssessmentRuleBaselinesClient client. +func NewDatabaseVulnerabilityAssessmentRuleBaselinesClient(subscriptionID string) DatabaseVulnerabilityAssessmentRuleBaselinesClient { + return NewDatabaseVulnerabilityAssessmentRuleBaselinesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewDatabaseVulnerabilityAssessmentRuleBaselinesClientWithBaseURI creates an instance of the +// DatabaseVulnerabilityAssessmentRuleBaselinesClient client using a custom endpoint. Use this when interacting with +// an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewDatabaseVulnerabilityAssessmentRuleBaselinesClientWithBaseURI(baseURI string, subscriptionID string) DatabaseVulnerabilityAssessmentRuleBaselinesClient { + return DatabaseVulnerabilityAssessmentRuleBaselinesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a database's vulnerability assessment rule baseline. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database for which the vulnerability assessment rule baseline is defined. +// ruleID - the vulnerability assessment rule ID. +// baselineName - the name of the vulnerability assessment rule baseline (default implies a baseline on a +// database level rule and master for server level rule). +// parameters - the requested rule baseline resource. +func (client DatabaseVulnerabilityAssessmentRuleBaselinesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, ruleID string, baselineName VulnerabilityAssessmentPolicyBaselineName, parameters DatabaseVulnerabilityAssessmentRuleBaseline) (result DatabaseVulnerabilityAssessmentRuleBaseline, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseVulnerabilityAssessmentRuleBaselinesClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.DatabaseVulnerabilityAssessmentRuleBaselineProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.DatabaseVulnerabilityAssessmentRuleBaselineProperties.BaselineResults", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("sql.DatabaseVulnerabilityAssessmentRuleBaselinesClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, databaseName, ruleID, baselineName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseVulnerabilityAssessmentRuleBaselinesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.DatabaseVulnerabilityAssessmentRuleBaselinesClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseVulnerabilityAssessmentRuleBaselinesClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client DatabaseVulnerabilityAssessmentRuleBaselinesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, ruleID string, baselineName VulnerabilityAssessmentPolicyBaselineName, parameters DatabaseVulnerabilityAssessmentRuleBaseline) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "baselineName": autorest.Encode("path", baselineName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "ruleId": autorest.Encode("path", ruleID), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vulnerabilityAssessmentName": autorest.Encode("path", "default"), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/rules/{ruleId}/baselines/{baselineName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client DatabaseVulnerabilityAssessmentRuleBaselinesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client DatabaseVulnerabilityAssessmentRuleBaselinesClient) CreateOrUpdateResponder(resp *http.Response) (result DatabaseVulnerabilityAssessmentRuleBaseline, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete removes the database's vulnerability assessment rule baseline. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database for which the vulnerability assessment rule baseline is defined. +// ruleID - the vulnerability assessment rule ID. +// baselineName - the name of the vulnerability assessment rule baseline (default implies a baseline on a +// database level rule and master for server level rule). +func (client DatabaseVulnerabilityAssessmentRuleBaselinesClient) Delete(ctx context.Context, resourceGroupName string, serverName string, databaseName string, ruleID string, baselineName VulnerabilityAssessmentPolicyBaselineName) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseVulnerabilityAssessmentRuleBaselinesClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, serverName, databaseName, ruleID, baselineName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseVulnerabilityAssessmentRuleBaselinesClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "sql.DatabaseVulnerabilityAssessmentRuleBaselinesClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseVulnerabilityAssessmentRuleBaselinesClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client DatabaseVulnerabilityAssessmentRuleBaselinesClient) DeletePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, ruleID string, baselineName VulnerabilityAssessmentPolicyBaselineName) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "baselineName": autorest.Encode("path", baselineName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "ruleId": autorest.Encode("path", ruleID), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vulnerabilityAssessmentName": autorest.Encode("path", "default"), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/rules/{ruleId}/baselines/{baselineName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client DatabaseVulnerabilityAssessmentRuleBaselinesClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client DatabaseVulnerabilityAssessmentRuleBaselinesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a database's vulnerability assessment rule baseline. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database for which the vulnerability assessment rule baseline is defined. +// ruleID - the vulnerability assessment rule ID. +// baselineName - the name of the vulnerability assessment rule baseline (default implies a baseline on a +// database level rule and master for server level rule). +func (client DatabaseVulnerabilityAssessmentRuleBaselinesClient) Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string, ruleID string, baselineName VulnerabilityAssessmentPolicyBaselineName) (result DatabaseVulnerabilityAssessmentRuleBaseline, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseVulnerabilityAssessmentRuleBaselinesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, databaseName, ruleID, baselineName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseVulnerabilityAssessmentRuleBaselinesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.DatabaseVulnerabilityAssessmentRuleBaselinesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseVulnerabilityAssessmentRuleBaselinesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client DatabaseVulnerabilityAssessmentRuleBaselinesClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, ruleID string, baselineName VulnerabilityAssessmentPolicyBaselineName) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "baselineName": autorest.Encode("path", baselineName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "ruleId": autorest.Encode("path", ruleID), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vulnerabilityAssessmentName": autorest.Encode("path", "default"), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/rules/{ruleId}/baselines/{baselineName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client DatabaseVulnerabilityAssessmentRuleBaselinesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client DatabaseVulnerabilityAssessmentRuleBaselinesClient) GetResponder(resp *http.Response) (result DatabaseVulnerabilityAssessmentRuleBaseline, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/databasevulnerabilityassessments.go b/services/preview/sql/mgmt/v5.0/sql/databasevulnerabilityassessments.go new file mode 100644 index 000000000000..032fea0a4929 --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/databasevulnerabilityassessments.go @@ -0,0 +1,397 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// DatabaseVulnerabilityAssessmentsClient is the the Azure SQL Database management API provides a RESTful set of web +// services that interact with Azure SQL Database services to manage your databases. The API enables you to create, +// retrieve, update, and delete databases. +type DatabaseVulnerabilityAssessmentsClient struct { + BaseClient +} + +// NewDatabaseVulnerabilityAssessmentsClient creates an instance of the DatabaseVulnerabilityAssessmentsClient client. +func NewDatabaseVulnerabilityAssessmentsClient(subscriptionID string) DatabaseVulnerabilityAssessmentsClient { + return NewDatabaseVulnerabilityAssessmentsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewDatabaseVulnerabilityAssessmentsClientWithBaseURI creates an instance of the +// DatabaseVulnerabilityAssessmentsClient client using a custom endpoint. Use this when interacting with an Azure +// cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewDatabaseVulnerabilityAssessmentsClientWithBaseURI(baseURI string, subscriptionID string) DatabaseVulnerabilityAssessmentsClient { + return DatabaseVulnerabilityAssessmentsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates the database's vulnerability assessment. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database for which the vulnerability assessment is defined. +// parameters - the requested resource. +func (client DatabaseVulnerabilityAssessmentsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters DatabaseVulnerabilityAssessment) (result DatabaseVulnerabilityAssessment, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseVulnerabilityAssessmentsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, databaseName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseVulnerabilityAssessmentsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.DatabaseVulnerabilityAssessmentsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseVulnerabilityAssessmentsClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client DatabaseVulnerabilityAssessmentsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters DatabaseVulnerabilityAssessment) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vulnerabilityAssessmentName": autorest.Encode("path", "default"), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client DatabaseVulnerabilityAssessmentsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client DatabaseVulnerabilityAssessmentsClient) CreateOrUpdateResponder(resp *http.Response) (result DatabaseVulnerabilityAssessment, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete removes the database's vulnerability assessment. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database for which the vulnerability assessment is defined. +func (client DatabaseVulnerabilityAssessmentsClient) Delete(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseVulnerabilityAssessmentsClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseVulnerabilityAssessmentsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "sql.DatabaseVulnerabilityAssessmentsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseVulnerabilityAssessmentsClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client DatabaseVulnerabilityAssessmentsClient) DeletePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vulnerabilityAssessmentName": autorest.Encode("path", "default"), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client DatabaseVulnerabilityAssessmentsClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client DatabaseVulnerabilityAssessmentsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets the database's vulnerability assessment. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database for which the vulnerability assessment is defined. +func (client DatabaseVulnerabilityAssessmentsClient) Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result DatabaseVulnerabilityAssessment, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseVulnerabilityAssessmentsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseVulnerabilityAssessmentsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.DatabaseVulnerabilityAssessmentsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseVulnerabilityAssessmentsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client DatabaseVulnerabilityAssessmentsClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vulnerabilityAssessmentName": autorest.Encode("path", "default"), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client DatabaseVulnerabilityAssessmentsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client DatabaseVulnerabilityAssessmentsClient) GetResponder(resp *http.Response) (result DatabaseVulnerabilityAssessment, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByDatabase lists the vulnerability assessment policies associated with a database. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database for which the vulnerability assessment policies are defined. +func (client DatabaseVulnerabilityAssessmentsClient) ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result DatabaseVulnerabilityAssessmentListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseVulnerabilityAssessmentsClient.ListByDatabase") + defer func() { + sc := -1 + if result.dvalr.Response.Response != nil { + sc = result.dvalr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByDatabaseNextResults + req, err := client.ListByDatabasePreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseVulnerabilityAssessmentsClient", "ListByDatabase", nil, "Failure preparing request") + return + } + + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.dvalr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.DatabaseVulnerabilityAssessmentsClient", "ListByDatabase", resp, "Failure sending request") + return + } + + result.dvalr, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseVulnerabilityAssessmentsClient", "ListByDatabase", resp, "Failure responding to request") + return + } + if result.dvalr.hasNextLink() && result.dvalr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByDatabasePreparer prepares the ListByDatabase request. +func (client DatabaseVulnerabilityAssessmentsClient) ListByDatabasePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByDatabaseSender sends the ListByDatabase request. The method will close the +// http.Response Body if it receives an error. +func (client DatabaseVulnerabilityAssessmentsClient) ListByDatabaseSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByDatabaseResponder handles the response to the ListByDatabase request. The method always +// closes the http.Response Body. +func (client DatabaseVulnerabilityAssessmentsClient) ListByDatabaseResponder(resp *http.Response) (result DatabaseVulnerabilityAssessmentListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByDatabaseNextResults retrieves the next set of results, if any. +func (client DatabaseVulnerabilityAssessmentsClient) listByDatabaseNextResults(ctx context.Context, lastResults DatabaseVulnerabilityAssessmentListResult) (result DatabaseVulnerabilityAssessmentListResult, err error) { + req, err := lastResults.databaseVulnerabilityAssessmentListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.DatabaseVulnerabilityAssessmentsClient", "listByDatabaseNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.DatabaseVulnerabilityAssessmentsClient", "listByDatabaseNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseVulnerabilityAssessmentsClient", "listByDatabaseNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByDatabaseComplete enumerates all values, automatically crossing page boundaries as required. +func (client DatabaseVulnerabilityAssessmentsClient) ListByDatabaseComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result DatabaseVulnerabilityAssessmentListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseVulnerabilityAssessmentsClient.ListByDatabase") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByDatabase(ctx, resourceGroupName, serverName, databaseName) + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/databasevulnerabilityassessmentscans.go b/services/preview/sql/mgmt/v5.0/sql/databasevulnerabilityassessmentscans.go new file mode 100644 index 000000000000..782bbd724d29 --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/databasevulnerabilityassessmentscans.go @@ -0,0 +1,404 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// DatabaseVulnerabilityAssessmentScansClient is the the Azure SQL Database management API provides a RESTful set of +// web services that interact with Azure SQL Database services to manage your databases. The API enables you to create, +// retrieve, update, and delete databases. +type DatabaseVulnerabilityAssessmentScansClient struct { + BaseClient +} + +// NewDatabaseVulnerabilityAssessmentScansClient creates an instance of the DatabaseVulnerabilityAssessmentScansClient +// client. +func NewDatabaseVulnerabilityAssessmentScansClient(subscriptionID string) DatabaseVulnerabilityAssessmentScansClient { + return NewDatabaseVulnerabilityAssessmentScansClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewDatabaseVulnerabilityAssessmentScansClientWithBaseURI creates an instance of the +// DatabaseVulnerabilityAssessmentScansClient client using a custom endpoint. Use this when interacting with an Azure +// cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewDatabaseVulnerabilityAssessmentScansClientWithBaseURI(baseURI string, subscriptionID string) DatabaseVulnerabilityAssessmentScansClient { + return DatabaseVulnerabilityAssessmentScansClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Export convert an existing scan result to a human readable format. If already exists nothing happens +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the scanned database. +// scanID - the vulnerability assessment scan Id. +func (client DatabaseVulnerabilityAssessmentScansClient) Export(ctx context.Context, resourceGroupName string, serverName string, databaseName string, scanID string) (result DatabaseVulnerabilityAssessmentScansExport, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseVulnerabilityAssessmentScansClient.Export") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ExportPreparer(ctx, resourceGroupName, serverName, databaseName, scanID) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseVulnerabilityAssessmentScansClient", "Export", nil, "Failure preparing request") + return + } + + resp, err := client.ExportSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.DatabaseVulnerabilityAssessmentScansClient", "Export", resp, "Failure sending request") + return + } + + result, err = client.ExportResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseVulnerabilityAssessmentScansClient", "Export", resp, "Failure responding to request") + return + } + + return +} + +// ExportPreparer prepares the Export request. +func (client DatabaseVulnerabilityAssessmentScansClient) ExportPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, scanID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "scanId": autorest.Encode("path", scanID), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vulnerabilityAssessmentName": autorest.Encode("path", "default"), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}/export", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ExportSender sends the Export request. The method will close the +// http.Response Body if it receives an error. +func (client DatabaseVulnerabilityAssessmentScansClient) ExportSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ExportResponder handles the response to the Export request. The method always +// closes the http.Response Body. +func (client DatabaseVulnerabilityAssessmentScansClient) ExportResponder(resp *http.Response) (result DatabaseVulnerabilityAssessmentScansExport, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets a vulnerability assessment scan record of a database. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database. +// scanID - the vulnerability assessment scan Id of the scan to retrieve. +func (client DatabaseVulnerabilityAssessmentScansClient) Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string, scanID string) (result VulnerabilityAssessmentScanRecord, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseVulnerabilityAssessmentScansClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, databaseName, scanID) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseVulnerabilityAssessmentScansClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.DatabaseVulnerabilityAssessmentScansClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseVulnerabilityAssessmentScansClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client DatabaseVulnerabilityAssessmentScansClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, scanID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "scanId": autorest.Encode("path", scanID), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vulnerabilityAssessmentName": autorest.Encode("path", "default"), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client DatabaseVulnerabilityAssessmentScansClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client DatabaseVulnerabilityAssessmentScansClient) GetResponder(resp *http.Response) (result VulnerabilityAssessmentScanRecord, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// InitiateScan executes a Vulnerability Assessment database scan. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database. +// scanID - the vulnerability assessment scan Id of the scan to retrieve. +func (client DatabaseVulnerabilityAssessmentScansClient) InitiateScan(ctx context.Context, resourceGroupName string, serverName string, databaseName string, scanID string) (result DatabaseVulnerabilityAssessmentScansInitiateScanFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseVulnerabilityAssessmentScansClient.InitiateScan") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.InitiateScanPreparer(ctx, resourceGroupName, serverName, databaseName, scanID) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseVulnerabilityAssessmentScansClient", "InitiateScan", nil, "Failure preparing request") + return + } + + result, err = client.InitiateScanSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseVulnerabilityAssessmentScansClient", "InitiateScan", nil, "Failure sending request") + return + } + + return +} + +// InitiateScanPreparer prepares the InitiateScan request. +func (client DatabaseVulnerabilityAssessmentScansClient) InitiateScanPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, scanID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "scanId": autorest.Encode("path", scanID), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vulnerabilityAssessmentName": autorest.Encode("path", "default"), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}/initiateScan", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// InitiateScanSender sends the InitiateScan request. The method will close the +// http.Response Body if it receives an error. +func (client DatabaseVulnerabilityAssessmentScansClient) InitiateScanSender(req *http.Request) (future DatabaseVulnerabilityAssessmentScansInitiateScanFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// InitiateScanResponder handles the response to the InitiateScan request. The method always +// closes the http.Response Body. +func (client DatabaseVulnerabilityAssessmentScansClient) InitiateScanResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + +// ListByDatabase lists the vulnerability assessment scans of a database. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database. +func (client DatabaseVulnerabilityAssessmentScansClient) ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result VulnerabilityAssessmentScanRecordListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseVulnerabilityAssessmentScansClient.ListByDatabase") + defer func() { + sc := -1 + if result.vasrlr.Response.Response != nil { + sc = result.vasrlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByDatabaseNextResults + req, err := client.ListByDatabasePreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseVulnerabilityAssessmentScansClient", "ListByDatabase", nil, "Failure preparing request") + return + } + + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.vasrlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.DatabaseVulnerabilityAssessmentScansClient", "ListByDatabase", resp, "Failure sending request") + return + } + + result.vasrlr, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseVulnerabilityAssessmentScansClient", "ListByDatabase", resp, "Failure responding to request") + return + } + if result.vasrlr.hasNextLink() && result.vasrlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByDatabasePreparer prepares the ListByDatabase request. +func (client DatabaseVulnerabilityAssessmentScansClient) ListByDatabasePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vulnerabilityAssessmentName": autorest.Encode("path", "default"), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByDatabaseSender sends the ListByDatabase request. The method will close the +// http.Response Body if it receives an error. +func (client DatabaseVulnerabilityAssessmentScansClient) ListByDatabaseSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByDatabaseResponder handles the response to the ListByDatabase request. The method always +// closes the http.Response Body. +func (client DatabaseVulnerabilityAssessmentScansClient) ListByDatabaseResponder(resp *http.Response) (result VulnerabilityAssessmentScanRecordListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByDatabaseNextResults retrieves the next set of results, if any. +func (client DatabaseVulnerabilityAssessmentScansClient) listByDatabaseNextResults(ctx context.Context, lastResults VulnerabilityAssessmentScanRecordListResult) (result VulnerabilityAssessmentScanRecordListResult, err error) { + req, err := lastResults.vulnerabilityAssessmentScanRecordListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.DatabaseVulnerabilityAssessmentScansClient", "listByDatabaseNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.DatabaseVulnerabilityAssessmentScansClient", "listByDatabaseNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseVulnerabilityAssessmentScansClient", "listByDatabaseNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByDatabaseComplete enumerates all values, automatically crossing page boundaries as required. +func (client DatabaseVulnerabilityAssessmentScansClient) ListByDatabaseComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result VulnerabilityAssessmentScanRecordListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseVulnerabilityAssessmentScansClient.ListByDatabase") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByDatabase(ctx, resourceGroupName, serverName, databaseName) + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/datamaskingpolicies.go b/services/preview/sql/mgmt/v5.0/sql/datamaskingpolicies.go new file mode 100644 index 000000000000..bd6726530f7e --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/datamaskingpolicies.go @@ -0,0 +1,199 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// DataMaskingPoliciesClient is the the Azure SQL Database management API provides a RESTful set of web services that +// interact with Azure SQL Database services to manage your databases. The API enables you to create, retrieve, update, +// and delete databases. +type DataMaskingPoliciesClient struct { + BaseClient +} + +// NewDataMaskingPoliciesClient creates an instance of the DataMaskingPoliciesClient client. +func NewDataMaskingPoliciesClient(subscriptionID string) DataMaskingPoliciesClient { + return NewDataMaskingPoliciesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewDataMaskingPoliciesClientWithBaseURI creates an instance of the DataMaskingPoliciesClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewDataMaskingPoliciesClientWithBaseURI(baseURI string, subscriptionID string) DataMaskingPoliciesClient { + return DataMaskingPoliciesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a database data masking policy +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database. +// parameters - parameters for creating or updating a data masking policy. +func (client DataMaskingPoliciesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters DataMaskingPolicy) (result DataMaskingPolicy, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DataMaskingPoliciesClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, databaseName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DataMaskingPoliciesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.DataMaskingPoliciesClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DataMaskingPoliciesClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client DataMaskingPoliciesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters DataMaskingPolicy) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "dataMaskingPolicyName": autorest.Encode("path", "Default"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + parameters.Location = nil + parameters.Kind = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/dataMaskingPolicies/{dataMaskingPolicyName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client DataMaskingPoliciesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client DataMaskingPoliciesClient) CreateOrUpdateResponder(resp *http.Response) (result DataMaskingPolicy, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets a database data masking policy. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database. +func (client DataMaskingPoliciesClient) Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result DataMaskingPolicy, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DataMaskingPoliciesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DataMaskingPoliciesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.DataMaskingPoliciesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DataMaskingPoliciesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client DataMaskingPoliciesClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "dataMaskingPolicyName": autorest.Encode("path", "Default"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/dataMaskingPolicies/{dataMaskingPolicyName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client DataMaskingPoliciesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client DataMaskingPoliciesClient) GetResponder(resp *http.Response) (result DataMaskingPolicy, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/datamaskingrules.go b/services/preview/sql/mgmt/v5.0/sql/datamaskingrules.go new file mode 100644 index 000000000000..eae0c8e07f66 --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/datamaskingrules.go @@ -0,0 +1,212 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// DataMaskingRulesClient is the the Azure SQL Database management API provides a RESTful set of web services that +// interact with Azure SQL Database services to manage your databases. The API enables you to create, retrieve, update, +// and delete databases. +type DataMaskingRulesClient struct { + BaseClient +} + +// NewDataMaskingRulesClient creates an instance of the DataMaskingRulesClient client. +func NewDataMaskingRulesClient(subscriptionID string) DataMaskingRulesClient { + return NewDataMaskingRulesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewDataMaskingRulesClientWithBaseURI creates an instance of the DataMaskingRulesClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewDataMaskingRulesClientWithBaseURI(baseURI string, subscriptionID string) DataMaskingRulesClient { + return DataMaskingRulesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a database data masking rule. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database. +// dataMaskingRuleName - the name of the data masking rule. +// parameters - the required parameters for creating or updating a data masking rule. +func (client DataMaskingRulesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, dataMaskingRuleName string, parameters DataMaskingRule) (result DataMaskingRule, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DataMaskingRulesClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.DataMaskingRuleProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.DataMaskingRuleProperties.SchemaName", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.DataMaskingRuleProperties.TableName", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.DataMaskingRuleProperties.ColumnName", Name: validation.Null, Rule: true, Chain: nil}, + }}}}}); err != nil { + return result, validation.NewError("sql.DataMaskingRulesClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, databaseName, dataMaskingRuleName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DataMaskingRulesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.DataMaskingRulesClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DataMaskingRulesClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client DataMaskingRulesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, dataMaskingRuleName string, parameters DataMaskingRule) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "dataMaskingPolicyName": autorest.Encode("path", "Default"), + "dataMaskingRuleName": autorest.Encode("path", dataMaskingRuleName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + parameters.Location = nil + parameters.Kind = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/dataMaskingPolicies/{dataMaskingPolicyName}/rules/{dataMaskingRuleName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client DataMaskingRulesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client DataMaskingRulesClient) CreateOrUpdateResponder(resp *http.Response) (result DataMaskingRule, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByDatabase gets a list of database data masking rules. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database. +func (client DataMaskingRulesClient) ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result DataMaskingRuleListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DataMaskingRulesClient.ListByDatabase") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListByDatabasePreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DataMaskingRulesClient", "ListByDatabase", nil, "Failure preparing request") + return + } + + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.DataMaskingRulesClient", "ListByDatabase", resp, "Failure sending request") + return + } + + result, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DataMaskingRulesClient", "ListByDatabase", resp, "Failure responding to request") + return + } + + return +} + +// ListByDatabasePreparer prepares the ListByDatabase request. +func (client DataMaskingRulesClient) ListByDatabasePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "dataMaskingPolicyName": autorest.Encode("path", "Default"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/dataMaskingPolicies/{dataMaskingPolicyName}/rules", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByDatabaseSender sends the ListByDatabase request. The method will close the +// http.Response Body if it receives an error. +func (client DataMaskingRulesClient) ListByDatabaseSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByDatabaseResponder handles the response to the ListByDatabase request. The method always +// closes the http.Response Body. +func (client DataMaskingRulesClient) ListByDatabaseResponder(resp *http.Response) (result DataMaskingRuleListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/datawarehouseuseractivities.go b/services/preview/sql/mgmt/v5.0/sql/datawarehouseuseractivities.go new file mode 100644 index 000000000000..da2d6cf7c8e9 --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/datawarehouseuseractivities.go @@ -0,0 +1,235 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// 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 +// using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign +// clouds, Azure stack). +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 +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database. +func (client DataWarehouseUserActivitiesClient) Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result DataWarehouseUserActivities, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DataWarehouseUserActivitiesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.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 + } + + 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 = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/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 client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client DataWarehouseUserActivitiesClient) GetResponder(resp *http.Response) (result DataWarehouseUserActivities, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByDatabase list the user activities of a data warehouse which includes running and suspended queries +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database. +func (client DataWarehouseUserActivitiesClient) ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result DataWarehouseUserActivitiesListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DataWarehouseUserActivitiesClient.ListByDatabase") + defer func() { + sc := -1 + if result.dwualr.Response.Response != nil { + sc = result.dwualr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByDatabaseNextResults + req, err := client.ListByDatabasePreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DataWarehouseUserActivitiesClient", "ListByDatabase", nil, "Failure preparing request") + return + } + + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.dwualr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.DataWarehouseUserActivitiesClient", "ListByDatabase", resp, "Failure sending request") + return + } + + result.dwualr, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DataWarehouseUserActivitiesClient", "ListByDatabase", resp, "Failure responding to request") + return + } + if result.dwualr.hasNextLink() && result.dwualr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByDatabasePreparer prepares the ListByDatabase request. +func (client DataWarehouseUserActivitiesClient) ListByDatabasePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/dataWarehouseUserActivities", 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 DataWarehouseUserActivitiesClient) ListByDatabaseSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByDatabaseResponder handles the response to the ListByDatabase request. The method always +// closes the http.Response Body. +func (client DataWarehouseUserActivitiesClient) ListByDatabaseResponder(resp *http.Response) (result DataWarehouseUserActivitiesListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByDatabaseNextResults retrieves the next set of results, if any. +func (client DataWarehouseUserActivitiesClient) listByDatabaseNextResults(ctx context.Context, lastResults DataWarehouseUserActivitiesListResult) (result DataWarehouseUserActivitiesListResult, err error) { + req, err := lastResults.dataWarehouseUserActivitiesListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.DataWarehouseUserActivitiesClient", "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.DataWarehouseUserActivitiesClient", "listByDatabaseNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DataWarehouseUserActivitiesClient", "listByDatabaseNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByDatabaseComplete enumerates all values, automatically crossing page boundaries as required. +func (client DataWarehouseUserActivitiesClient) ListByDatabaseComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result DataWarehouseUserActivitiesListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DataWarehouseUserActivitiesClient.ListByDatabase") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByDatabase(ctx, resourceGroupName, serverName, databaseName) + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/deletedservers.go b/services/preview/sql/mgmt/v5.0/sql/deletedservers.go new file mode 100644 index 000000000000..f46da4190dc0 --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/deletedservers.go @@ -0,0 +1,416 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// DeletedServersClient 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 DeletedServersClient struct { + BaseClient +} + +// NewDeletedServersClient creates an instance of the DeletedServersClient client. +func NewDeletedServersClient(subscriptionID string) DeletedServersClient { + return NewDeletedServersClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewDeletedServersClientWithBaseURI creates an instance of the DeletedServersClient client using a custom endpoint. +// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewDeletedServersClientWithBaseURI(baseURI string, subscriptionID string) DeletedServersClient { + return DeletedServersClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get gets a deleted server. +// Parameters: +// locationName - the name of the region where the resource is located. +// deletedServerName - the name of the deleted server. +func (client DeletedServersClient) Get(ctx context.Context, locationName string, deletedServerName string) (result DeletedServer, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DeletedServersClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, locationName, deletedServerName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DeletedServersClient", "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.DeletedServersClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DeletedServersClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client DeletedServersClient) GetPreparer(ctx context.Context, locationName string, deletedServerName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "deletedServerName": autorest.Encode("path", deletedServerName), + "locationName": autorest.Encode("path", locationName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/deletedServers/{deletedServerName}", 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 DeletedServersClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client DeletedServersClient) GetResponder(resp *http.Response) (result DeletedServer, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List gets a list of all deleted servers in a subscription. +func (client DeletedServersClient) List(ctx context.Context) (result DeletedServerListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DeletedServersClient.List") + defer func() { + sc := -1 + if result.dslr.Response.Response != nil { + sc = result.dslr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DeletedServersClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.dslr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.DeletedServersClient", "List", resp, "Failure sending request") + return + } + + result.dslr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DeletedServersClient", "List", resp, "Failure responding to request") + return + } + if result.dslr.hasNextLink() && result.dslr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client DeletedServersClient) ListPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Sql/deletedServers", 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 DeletedServersClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client DeletedServersClient) ListResponder(resp *http.Response) (result DeletedServerListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client DeletedServersClient) listNextResults(ctx context.Context, lastResults DeletedServerListResult) (result DeletedServerListResult, err error) { + req, err := lastResults.deletedServerListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.DeletedServersClient", "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.DeletedServersClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DeletedServersClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client DeletedServersClient) ListComplete(ctx context.Context) (result DeletedServerListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DeletedServersClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx) + return +} + +// ListByLocation gets a list of deleted servers for a location. +// Parameters: +// locationName - the name of the region where the resource is located. +func (client DeletedServersClient) ListByLocation(ctx context.Context, locationName string) (result DeletedServerListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DeletedServersClient.ListByLocation") + defer func() { + sc := -1 + if result.dslr.Response.Response != nil { + sc = result.dslr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByLocationNextResults + req, err := client.ListByLocationPreparer(ctx, locationName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DeletedServersClient", "ListByLocation", nil, "Failure preparing request") + return + } + + resp, err := client.ListByLocationSender(req) + if err != nil { + result.dslr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.DeletedServersClient", "ListByLocation", resp, "Failure sending request") + return + } + + result.dslr, err = client.ListByLocationResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DeletedServersClient", "ListByLocation", resp, "Failure responding to request") + return + } + if result.dslr.hasNextLink() && result.dslr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByLocationPreparer prepares the ListByLocation request. +func (client DeletedServersClient) ListByLocationPreparer(ctx context.Context, locationName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "locationName": autorest.Encode("path", locationName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/deletedServers", 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 DeletedServersClient) ListByLocationSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByLocationResponder handles the response to the ListByLocation request. The method always +// closes the http.Response Body. +func (client DeletedServersClient) ListByLocationResponder(resp *http.Response) (result DeletedServerListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByLocationNextResults retrieves the next set of results, if any. +func (client DeletedServersClient) listByLocationNextResults(ctx context.Context, lastResults DeletedServerListResult) (result DeletedServerListResult, err error) { + req, err := lastResults.deletedServerListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.DeletedServersClient", "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.DeletedServersClient", "listByLocationNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByLocationResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DeletedServersClient", "listByLocationNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByLocationComplete enumerates all values, automatically crossing page boundaries as required. +func (client DeletedServersClient) ListByLocationComplete(ctx context.Context, locationName string) (result DeletedServerListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DeletedServersClient.ListByLocation") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByLocation(ctx, locationName) + return +} + +// Recover recovers a deleted server. +// Parameters: +// locationName - the name of the region where the resource is located. +// deletedServerName - the name of the deleted server. +func (client DeletedServersClient) Recover(ctx context.Context, locationName string, deletedServerName string) (result DeletedServersRecoverFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DeletedServersClient.Recover") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.RecoverPreparer(ctx, locationName, deletedServerName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DeletedServersClient", "Recover", nil, "Failure preparing request") + return + } + + result, err = client.RecoverSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DeletedServersClient", "Recover", nil, "Failure sending request") + return + } + + return +} + +// RecoverPreparer prepares the Recover request. +func (client DeletedServersClient) RecoverPreparer(ctx context.Context, locationName string, deletedServerName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "deletedServerName": autorest.Encode("path", deletedServerName), + "locationName": autorest.Encode("path", locationName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/deletedServers/{deletedServerName}/recover", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// RecoverSender sends the Recover request. The method will close the +// http.Response Body if it receives an error. +func (client DeletedServersClient) RecoverSender(req *http.Request) (future DeletedServersRecoverFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// RecoverResponder handles the response to the Recover request. The method always +// closes the http.Response Body. +func (client DeletedServersClient) RecoverResponder(resp *http.Response) (result DeletedServer, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/elasticpoolactivities.go b/services/preview/sql/mgmt/v5.0/sql/elasticpoolactivities.go new file mode 100644 index 000000000000..441f57b95c41 --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/elasticpoolactivities.go @@ -0,0 +1,113 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ElasticPoolActivitiesClient is the the Azure SQL Database management API provides a RESTful set of web services that +// interact with Azure SQL Database services to manage your databases. The API enables you to create, retrieve, update, +// and delete databases. +type ElasticPoolActivitiesClient struct { + BaseClient +} + +// NewElasticPoolActivitiesClient creates an instance of the ElasticPoolActivitiesClient client. +func NewElasticPoolActivitiesClient(subscriptionID string) ElasticPoolActivitiesClient { + return NewElasticPoolActivitiesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewElasticPoolActivitiesClientWithBaseURI creates an instance of the ElasticPoolActivitiesClient client using a +// custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, +// Azure stack). +func NewElasticPoolActivitiesClientWithBaseURI(baseURI string, subscriptionID string) ElasticPoolActivitiesClient { + return ElasticPoolActivitiesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListByElasticPool returns elastic pool activities. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// elasticPoolName - the name of the elastic pool for which to get the current activity. +func (client ElasticPoolActivitiesClient) ListByElasticPool(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string) (result ElasticPoolActivityListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ElasticPoolActivitiesClient.ListByElasticPool") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListByElasticPoolPreparer(ctx, resourceGroupName, serverName, elasticPoolName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolActivitiesClient", "ListByElasticPool", nil, "Failure preparing request") + return + } + + resp, err := client.ListByElasticPoolSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ElasticPoolActivitiesClient", "ListByElasticPool", resp, "Failure sending request") + return + } + + result, err = client.ListByElasticPoolResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolActivitiesClient", "ListByElasticPool", resp, "Failure responding to request") + return + } + + return +} + +// ListByElasticPoolPreparer prepares the ListByElasticPool request. +func (client ElasticPoolActivitiesClient) ListByElasticPoolPreparer(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "elasticPoolName": autorest.Encode("path", elasticPoolName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}/elasticPoolActivity", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByElasticPoolSender sends the ListByElasticPool request. The method will close the +// http.Response Body if it receives an error. +func (client ElasticPoolActivitiesClient) ListByElasticPoolSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByElasticPoolResponder handles the response to the ListByElasticPool request. The method always +// closes the http.Response Body. +func (client ElasticPoolActivitiesClient) ListByElasticPoolResponder(resp *http.Response) (result ElasticPoolActivityListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/elasticpooldatabaseactivities.go b/services/preview/sql/mgmt/v5.0/sql/elasticpooldatabaseactivities.go new file mode 100644 index 000000000000..ea65995b62c9 --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/elasticpooldatabaseactivities.go @@ -0,0 +1,113 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ElasticPoolDatabaseActivitiesClient is the the Azure SQL Database management API provides a RESTful set of web +// services that interact with Azure SQL Database services to manage your databases. The API enables you to create, +// retrieve, update, and delete databases. +type ElasticPoolDatabaseActivitiesClient struct { + BaseClient +} + +// NewElasticPoolDatabaseActivitiesClient creates an instance of the ElasticPoolDatabaseActivitiesClient client. +func NewElasticPoolDatabaseActivitiesClient(subscriptionID string) ElasticPoolDatabaseActivitiesClient { + return NewElasticPoolDatabaseActivitiesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewElasticPoolDatabaseActivitiesClientWithBaseURI creates an instance of the ElasticPoolDatabaseActivitiesClient +// client using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI +// (sovereign clouds, Azure stack). +func NewElasticPoolDatabaseActivitiesClientWithBaseURI(baseURI string, subscriptionID string) ElasticPoolDatabaseActivitiesClient { + return ElasticPoolDatabaseActivitiesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListByElasticPool returns activity on databases inside of an elastic pool. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// elasticPoolName - the name of the elastic pool. +func (client ElasticPoolDatabaseActivitiesClient) ListByElasticPool(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string) (result ElasticPoolDatabaseActivityListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ElasticPoolDatabaseActivitiesClient.ListByElasticPool") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListByElasticPoolPreparer(ctx, resourceGroupName, serverName, elasticPoolName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolDatabaseActivitiesClient", "ListByElasticPool", nil, "Failure preparing request") + return + } + + resp, err := client.ListByElasticPoolSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ElasticPoolDatabaseActivitiesClient", "ListByElasticPool", resp, "Failure sending request") + return + } + + result, err = client.ListByElasticPoolResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolDatabaseActivitiesClient", "ListByElasticPool", resp, "Failure responding to request") + return + } + + return +} + +// ListByElasticPoolPreparer prepares the ListByElasticPool request. +func (client ElasticPoolDatabaseActivitiesClient) ListByElasticPoolPreparer(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "elasticPoolName": autorest.Encode("path", elasticPoolName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}/elasticPoolDatabaseActivity", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByElasticPoolSender sends the ListByElasticPool request. The method will close the +// http.Response Body if it receives an error. +func (client ElasticPoolDatabaseActivitiesClient) ListByElasticPoolSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByElasticPoolResponder handles the response to the ListByElasticPool request. The method always +// closes the http.Response Body. +func (client ElasticPoolDatabaseActivitiesClient) ListByElasticPoolResponder(resp *http.Response) (result ElasticPoolDatabaseActivityListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/elasticpooloperations.go b/services/preview/sql/mgmt/v5.0/sql/elasticpooloperations.go new file mode 100644 index 000000000000..f62ad9a48122 --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/elasticpooloperations.go @@ -0,0 +1,234 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "github.com/gofrs/uuid" + "net/http" +) + +// ElasticPoolOperationsClient is the the Azure SQL Database management API provides a RESTful set of web services that +// interact with Azure SQL Database services to manage your databases. The API enables you to create, retrieve, update, +// and delete databases. +type ElasticPoolOperationsClient struct { + BaseClient +} + +// NewElasticPoolOperationsClient creates an instance of the ElasticPoolOperationsClient client. +func NewElasticPoolOperationsClient(subscriptionID string) ElasticPoolOperationsClient { + return NewElasticPoolOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewElasticPoolOperationsClientWithBaseURI creates an instance of the ElasticPoolOperationsClient client using a +// custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, +// Azure stack). +func NewElasticPoolOperationsClientWithBaseURI(baseURI string, subscriptionID string) ElasticPoolOperationsClient { + return ElasticPoolOperationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Cancel cancels the asynchronous operation on the elastic pool. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// operationID - the operation identifier. +func (client ElasticPoolOperationsClient) Cancel(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string, operationID uuid.UUID) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ElasticPoolOperationsClient.Cancel") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CancelPreparer(ctx, resourceGroupName, serverName, elasticPoolName, operationID) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolOperationsClient", "Cancel", nil, "Failure preparing request") + return + } + + resp, err := client.CancelSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "sql.ElasticPoolOperationsClient", "Cancel", resp, "Failure sending request") + return + } + + result, err = client.CancelResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolOperationsClient", "Cancel", resp, "Failure responding to request") + return + } + + return +} + +// CancelPreparer prepares the Cancel request. +func (client ElasticPoolOperationsClient) CancelPreparer(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string, operationID uuid.UUID) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "elasticPoolName": autorest.Encode("path", elasticPoolName), + "operationId": autorest.Encode("path", operationID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}/operations/{operationId}/cancel", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CancelSender sends the Cancel request. The method will close the +// http.Response Body if it receives an error. +func (client ElasticPoolOperationsClient) CancelSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CancelResponder handles the response to the Cancel request. The method always +// closes the http.Response Body. +func (client ElasticPoolOperationsClient) CancelResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// ListByElasticPool gets a list of operations performed on the elastic pool. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +func (client ElasticPoolOperationsClient) ListByElasticPool(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string) (result ElasticPoolOperationListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ElasticPoolOperationsClient.ListByElasticPool") + defer func() { + sc := -1 + if result.epolr.Response.Response != nil { + sc = result.epolr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByElasticPoolNextResults + req, err := client.ListByElasticPoolPreparer(ctx, resourceGroupName, serverName, elasticPoolName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolOperationsClient", "ListByElasticPool", nil, "Failure preparing request") + return + } + + resp, err := client.ListByElasticPoolSender(req) + if err != nil { + result.epolr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ElasticPoolOperationsClient", "ListByElasticPool", resp, "Failure sending request") + return + } + + result.epolr, err = client.ListByElasticPoolResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolOperationsClient", "ListByElasticPool", resp, "Failure responding to request") + return + } + if result.epolr.hasNextLink() && result.epolr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByElasticPoolPreparer prepares the ListByElasticPool request. +func (client ElasticPoolOperationsClient) ListByElasticPoolPreparer(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "elasticPoolName": autorest.Encode("path", elasticPoolName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}/operations", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByElasticPoolSender sends the ListByElasticPool request. The method will close the +// http.Response Body if it receives an error. +func (client ElasticPoolOperationsClient) ListByElasticPoolSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByElasticPoolResponder handles the response to the ListByElasticPool request. The method always +// closes the http.Response Body. +func (client ElasticPoolOperationsClient) ListByElasticPoolResponder(resp *http.Response) (result ElasticPoolOperationListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByElasticPoolNextResults retrieves the next set of results, if any. +func (client ElasticPoolOperationsClient) listByElasticPoolNextResults(ctx context.Context, lastResults ElasticPoolOperationListResult) (result ElasticPoolOperationListResult, err error) { + req, err := lastResults.elasticPoolOperationListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.ElasticPoolOperationsClient", "listByElasticPoolNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByElasticPoolSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.ElasticPoolOperationsClient", "listByElasticPoolNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByElasticPoolResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolOperationsClient", "listByElasticPoolNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByElasticPoolComplete enumerates all values, automatically crossing page boundaries as required. +func (client ElasticPoolOperationsClient) ListByElasticPoolComplete(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string) (result ElasticPoolOperationListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ElasticPoolOperationsClient.ListByElasticPool") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByElasticPool(ctx, resourceGroupName, serverName, elasticPoolName) + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/elasticpools.go b/services/preview/sql/mgmt/v5.0/sql/elasticpools.go new file mode 100644 index 000000000000..af459a9a70e3 --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/elasticpools.go @@ -0,0 +1,732 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ElasticPoolsClient is the the Azure SQL Database management API provides a RESTful set of web services that interact +// with Azure SQL Database services to manage your databases. The API enables you to create, retrieve, update, and +// delete databases. +type ElasticPoolsClient struct { + BaseClient +} + +// NewElasticPoolsClient creates an instance of the ElasticPoolsClient client. +func NewElasticPoolsClient(subscriptionID string) ElasticPoolsClient { + return NewElasticPoolsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewElasticPoolsClientWithBaseURI creates an instance of the ElasticPoolsClient client using a custom endpoint. Use +// this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewElasticPoolsClientWithBaseURI(baseURI string, subscriptionID string) ElasticPoolsClient { + return ElasticPoolsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates an elastic pool. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// elasticPoolName - the name of the elastic pool. +// parameters - the elastic pool parameters. +func (client ElasticPoolsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string, parameters ElasticPool) (result ElasticPoolsCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ElasticPoolsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.Sku", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.Sku.Name", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("sql.ElasticPoolsClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, elasticPoolName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "CreateOrUpdate", nil, "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 = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + parameters.Kind = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client ElasticPoolsClient) CreateOrUpdateSender(req *http.Request) (future ElasticPoolsCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ElasticPoolsClient) CreateOrUpdateResponder(resp *http.Response) (result ElasticPool, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes an elastic pool. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// elasticPoolName - the name of the elastic pool. +func (client ElasticPoolsClient) Delete(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string) (result ElasticPoolsDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ElasticPoolsClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, serverName, elasticPoolName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "Delete", nil, "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 = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client ElasticPoolsClient) DeleteSender(req *http.Request) (future ElasticPoolsDeleteFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ElasticPoolsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Failover failovers an elastic pool. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// elasticPoolName - the name of the elastic pool to failover. +func (client ElasticPoolsClient) Failover(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string) (result ElasticPoolsFailoverFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ElasticPoolsClient.Failover") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.FailoverPreparer(ctx, resourceGroupName, serverName, elasticPoolName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "Failover", nil, "Failure preparing request") + return + } + + result, err = client.FailoverSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "Failover", nil, "Failure sending request") + return + } + + return +} + +// FailoverPreparer prepares the Failover request. +func (client ElasticPoolsClient) FailoverPreparer(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "elasticPoolName": autorest.Encode("path", elasticPoolName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}/failover", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// FailoverSender sends the Failover request. The method will close the +// http.Response Body if it receives an error. +func (client ElasticPoolsClient) FailoverSender(req *http.Request) (future ElasticPoolsFailoverFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// FailoverResponder handles the response to the Failover request. The method always +// closes the http.Response Body. +func (client ElasticPoolsClient) FailoverResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets an elastic pool. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// elasticPoolName - the name of the elastic pool. +func (client ElasticPoolsClient) Get(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string) (result ElasticPool, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ElasticPoolsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, elasticPoolName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ElasticPoolsClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "elasticPoolName": autorest.Encode("path", elasticPoolName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ElasticPoolsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ElasticPoolsClient) GetResponder(resp *http.Response) (result ElasticPool, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer gets all elastic pools in a server. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// skip - the number of elements in the collection to skip. +func (client ElasticPoolsClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string, skip *int32) (result ElasticPoolListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ElasticPoolsClient.ListByServer") + defer func() { + sc := -1 + if result.eplr.Response.Response != nil { + sc = result.eplr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByServerNextResults + req, err := client.ListByServerPreparer(ctx, resourceGroupName, serverName, skip) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "ListByServer", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServerSender(req) + if err != nil { + result.eplr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "ListByServer", resp, "Failure sending request") + return + } + + result.eplr, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "ListByServer", resp, "Failure responding to request") + return + } + if result.eplr.hasNextLink() && result.eplr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServerPreparer prepares the ListByServer request. +func (client ElasticPoolsClient) ListByServerPreparer(ctx context.Context, resourceGroupName string, serverName string, skip *int32) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if skip != nil { + queryParameters["$skip"] = autorest.Encode("query", *skip) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByServerSender sends the ListByServer request. The method will close the +// http.Response Body if it receives an error. +func (client ElasticPoolsClient) ListByServerSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client ElasticPoolsClient) ListByServerResponder(resp *http.Response) (result ElasticPoolListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByServerNextResults retrieves the next set of results, if any. +func (client ElasticPoolsClient) listByServerNextResults(ctx context.Context, lastResults ElasticPoolListResult) (result ElasticPoolListResult, err error) { + req, err := lastResults.elasticPoolListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "listByServerNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByServerSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "listByServerNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "listByServerNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServerComplete enumerates all values, automatically crossing page boundaries as required. +func (client ElasticPoolsClient) ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string, skip *int32) (result ElasticPoolListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ElasticPoolsClient.ListByServer") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByServer(ctx, resourceGroupName, serverName, skip) + return +} + +// ListMetricDefinitions returns elastic pool metric definitions. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// elasticPoolName - the name of the elastic pool. +func (client ElasticPoolsClient) ListMetricDefinitions(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string) (result MetricDefinitionListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ElasticPoolsClient.ListMetricDefinitions") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListMetricDefinitionsPreparer(ctx, resourceGroupName, serverName, elasticPoolName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "ListMetricDefinitions", nil, "Failure preparing request") + return + } + + resp, err := client.ListMetricDefinitionsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "ListMetricDefinitions", resp, "Failure sending request") + return + } + + result, err = client.ListMetricDefinitionsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "ListMetricDefinitions", resp, "Failure responding to request") + return + } + + return +} + +// ListMetricDefinitionsPreparer prepares the ListMetricDefinitions request. +func (client ElasticPoolsClient) ListMetricDefinitionsPreparer(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "elasticPoolName": autorest.Encode("path", elasticPoolName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}/metricDefinitions", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListMetricDefinitionsSender sends the ListMetricDefinitions request. The method will close the +// http.Response Body if it receives an error. +func (client ElasticPoolsClient) ListMetricDefinitionsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListMetricDefinitionsResponder handles the response to the ListMetricDefinitions request. The method always +// closes the http.Response Body. +func (client ElasticPoolsClient) ListMetricDefinitionsResponder(resp *http.Response) (result MetricDefinitionListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListMetrics returns elastic pool metrics. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// elasticPoolName - the name of the elastic pool. +// filter - an OData filter expression that describes a subset of metrics to return. +func (client ElasticPoolsClient) ListMetrics(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string, filter string) (result MetricListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ElasticPoolsClient.ListMetrics") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListMetricsPreparer(ctx, resourceGroupName, serverName, elasticPoolName, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "ListMetrics", nil, "Failure preparing request") + return + } + + resp, err := client.ListMetricsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "ListMetrics", resp, "Failure sending request") + return + } + + result, err = client.ListMetricsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "ListMetrics", resp, "Failure responding to request") + return + } + + return +} + +// ListMetricsPreparer prepares the ListMetrics request. +func (client ElasticPoolsClient) ListMetricsPreparer(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "elasticPoolName": autorest.Encode("path", elasticPoolName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + queryParameters := map[string]interface{}{ + "$filter": autorest.Encode("query", filter), + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}/metrics", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListMetricsSender sends the ListMetrics request. The method will close the +// http.Response Body if it receives an error. +func (client ElasticPoolsClient) ListMetricsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListMetricsResponder handles the response to the ListMetrics request. The method always +// closes the http.Response Body. +func (client ElasticPoolsClient) ListMetricsResponder(resp *http.Response) (result MetricListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Update updates an elastic pool. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// elasticPoolName - the name of the elastic pool. +// parameters - the elastic pool update parameters. +func (client ElasticPoolsClient) Update(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string, parameters ElasticPoolUpdate) (result ElasticPoolsUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ElasticPoolsClient.Update") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.UpdatePreparer(ctx, resourceGroupName, serverName, elasticPoolName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsClient", "Update", nil, "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 = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client ElasticPoolsClient) UpdateSender(req *http.Request) (future ElasticPoolsUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client ElasticPoolsClient) UpdateResponder(resp *http.Response) (result ElasticPool, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/encryptionprotectors.go b/services/preview/sql/mgmt/v5.0/sql/encryptionprotectors.go new file mode 100644 index 000000000000..9e9cbb35aef7 --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/encryptionprotectors.go @@ -0,0 +1,395 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// EncryptionProtectorsClient is the the Azure SQL Database management API provides a RESTful set of web services that +// interact with Azure SQL Database services to manage your databases. The API enables you to create, retrieve, update, +// and delete databases. +type EncryptionProtectorsClient struct { + BaseClient +} + +// NewEncryptionProtectorsClient creates an instance of the EncryptionProtectorsClient client. +func NewEncryptionProtectorsClient(subscriptionID string) EncryptionProtectorsClient { + return NewEncryptionProtectorsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewEncryptionProtectorsClientWithBaseURI creates an instance of the EncryptionProtectorsClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewEncryptionProtectorsClientWithBaseURI(baseURI string, subscriptionID string) EncryptionProtectorsClient { + return EncryptionProtectorsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate updates an existing encryption protector. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// parameters - the requested encryption protector resource state. +func (client EncryptionProtectorsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, parameters EncryptionProtector) (result EncryptionProtectorsCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/EncryptionProtectorsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.EncryptionProtectorsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.EncryptionProtectorsClient", "CreateOrUpdate", nil, "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 = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + parameters.Kind = nil + parameters.Location = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/encryptionProtector/{encryptionProtectorName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client EncryptionProtectorsClient) CreateOrUpdateSender(req *http.Request) (future EncryptionProtectorsCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client EncryptionProtectorsClient) CreateOrUpdateResponder(resp *http.Response) (result EncryptionProtector, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets a server encryption protector. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +func (client EncryptionProtectorsClient) Get(ctx context.Context, resourceGroupName string, serverName string) (result EncryptionProtector, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/EncryptionProtectorsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.EncryptionProtectorsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.EncryptionProtectorsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.EncryptionProtectorsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client EncryptionProtectorsClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "encryptionProtectorName": autorest.Encode("path", "current"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/encryptionProtector/{encryptionProtectorName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client EncryptionProtectorsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client EncryptionProtectorsClient) GetResponder(resp *http.Response) (result EncryptionProtector, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer gets a list of server encryption protectors +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +func (client EncryptionProtectorsClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result EncryptionProtectorListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/EncryptionProtectorsClient.ListByServer") + defer func() { + sc := -1 + if result.eplr.Response.Response != nil { + sc = result.eplr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByServerNextResults + req, err := client.ListByServerPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.EncryptionProtectorsClient", "ListByServer", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServerSender(req) + if err != nil { + result.eplr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.EncryptionProtectorsClient", "ListByServer", resp, "Failure sending request") + return + } + + result.eplr, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.EncryptionProtectorsClient", "ListByServer", resp, "Failure responding to request") + return + } + if result.eplr.hasNextLink() && result.eplr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServerPreparer prepares the ListByServer request. +func (client EncryptionProtectorsClient) ListByServerPreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/encryptionProtector", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByServerSender sends the ListByServer request. The method will close the +// http.Response Body if it receives an error. +func (client EncryptionProtectorsClient) ListByServerSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client EncryptionProtectorsClient) ListByServerResponder(resp *http.Response) (result EncryptionProtectorListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByServerNextResults retrieves the next set of results, if any. +func (client EncryptionProtectorsClient) listByServerNextResults(ctx context.Context, lastResults EncryptionProtectorListResult) (result EncryptionProtectorListResult, err error) { + req, err := lastResults.encryptionProtectorListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.EncryptionProtectorsClient", "listByServerNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByServerSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.EncryptionProtectorsClient", "listByServerNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.EncryptionProtectorsClient", "listByServerNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServerComplete enumerates all values, automatically crossing page boundaries as required. +func (client EncryptionProtectorsClient) ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result EncryptionProtectorListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/EncryptionProtectorsClient.ListByServer") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByServer(ctx, resourceGroupName, serverName) + return +} + +// Revalidate revalidates an existing encryption protector. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +func (client EncryptionProtectorsClient) Revalidate(ctx context.Context, resourceGroupName string, serverName string) (result EncryptionProtectorsRevalidateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/EncryptionProtectorsClient.Revalidate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.RevalidatePreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.EncryptionProtectorsClient", "Revalidate", nil, "Failure preparing request") + return + } + + result, err = client.RevalidateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.EncryptionProtectorsClient", "Revalidate", nil, "Failure sending request") + return + } + + return +} + +// RevalidatePreparer prepares the Revalidate request. +func (client EncryptionProtectorsClient) RevalidatePreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "encryptionProtectorName": autorest.Encode("path", "current"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/encryptionProtector/{encryptionProtectorName}/revalidate", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// RevalidateSender sends the Revalidate request. The method will close the +// http.Response Body if it receives an error. +func (client EncryptionProtectorsClient) RevalidateSender(req *http.Request) (future EncryptionProtectorsRevalidateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// RevalidateResponder handles the response to the Revalidate request. The method always +// closes the http.Response Body. +func (client EncryptionProtectorsClient) RevalidateResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/enums.go b/services/preview/sql/mgmt/v5.0/sql/enums.go new file mode 100644 index 000000000000..d9231c128e95 --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/enums.go @@ -0,0 +1,2328 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// AdministratorType enumerates the values for administrator type. +type AdministratorType string + +const ( + // AdministratorTypeActiveDirectory ... + AdministratorTypeActiveDirectory AdministratorType = "ActiveDirectory" +) + +// PossibleAdministratorTypeValues returns an array of possible values for the AdministratorType const type. +func PossibleAdministratorTypeValues() []AdministratorType { + return []AdministratorType{AdministratorTypeActiveDirectory} +} + +// AdvisorStatus enumerates the values for advisor status. +type AdvisorStatus string + +const ( + // AdvisorStatusGA ... + AdvisorStatusGA AdvisorStatus = "GA" + // AdvisorStatusLimitedPublicPreview ... + AdvisorStatusLimitedPublicPreview AdvisorStatus = "LimitedPublicPreview" + // AdvisorStatusPrivatePreview ... + AdvisorStatusPrivatePreview AdvisorStatus = "PrivatePreview" + // AdvisorStatusPublicPreview ... + AdvisorStatusPublicPreview AdvisorStatus = "PublicPreview" +) + +// PossibleAdvisorStatusValues returns an array of possible values for the AdvisorStatus const type. +func PossibleAdvisorStatusValues() []AdvisorStatus { + return []AdvisorStatus{AdvisorStatusGA, AdvisorStatusLimitedPublicPreview, AdvisorStatusPrivatePreview, AdvisorStatusPublicPreview} +} + +// AggregationFunctionType enumerates the values for aggregation function type. +type AggregationFunctionType string + +const ( + // AggregationFunctionTypeAvg ... + AggregationFunctionTypeAvg AggregationFunctionType = "avg" + // AggregationFunctionTypeMax ... + AggregationFunctionTypeMax AggregationFunctionType = "max" + // AggregationFunctionTypeMin ... + AggregationFunctionTypeMin AggregationFunctionType = "min" + // AggregationFunctionTypeStdev ... + AggregationFunctionTypeStdev AggregationFunctionType = "stdev" + // AggregationFunctionTypeSum ... + AggregationFunctionTypeSum AggregationFunctionType = "sum" +) + +// PossibleAggregationFunctionTypeValues returns an array of possible values for the AggregationFunctionType const type. +func PossibleAggregationFunctionTypeValues() []AggregationFunctionType { + return []AggregationFunctionType{AggregationFunctionTypeAvg, AggregationFunctionTypeMax, AggregationFunctionTypeMin, AggregationFunctionTypeStdev, AggregationFunctionTypeSum} +} + +// AutoExecuteStatus enumerates the values for auto execute status. +type AutoExecuteStatus string + +const ( + // AutoExecuteStatusDefault ... + AutoExecuteStatusDefault AutoExecuteStatus = "Default" + // AutoExecuteStatusDisabled ... + AutoExecuteStatusDisabled AutoExecuteStatus = "Disabled" + // AutoExecuteStatusEnabled ... + AutoExecuteStatusEnabled AutoExecuteStatus = "Enabled" +) + +// PossibleAutoExecuteStatusValues returns an array of possible values for the AutoExecuteStatus const type. +func PossibleAutoExecuteStatusValues() []AutoExecuteStatus { + return []AutoExecuteStatus{AutoExecuteStatusDefault, AutoExecuteStatusDisabled, AutoExecuteStatusEnabled} +} + +// AutoExecuteStatusInheritedFrom enumerates the values for auto execute status inherited from. +type AutoExecuteStatusInheritedFrom string + +const ( + // AutoExecuteStatusInheritedFromDatabase ... + AutoExecuteStatusInheritedFromDatabase AutoExecuteStatusInheritedFrom = "Database" + // AutoExecuteStatusInheritedFromDefault ... + AutoExecuteStatusInheritedFromDefault AutoExecuteStatusInheritedFrom = "Default" + // AutoExecuteStatusInheritedFromElasticPool ... + AutoExecuteStatusInheritedFromElasticPool AutoExecuteStatusInheritedFrom = "ElasticPool" + // AutoExecuteStatusInheritedFromServer ... + AutoExecuteStatusInheritedFromServer AutoExecuteStatusInheritedFrom = "Server" + // AutoExecuteStatusInheritedFromSubscription ... + AutoExecuteStatusInheritedFromSubscription AutoExecuteStatusInheritedFrom = "Subscription" +) + +// PossibleAutoExecuteStatusInheritedFromValues returns an array of possible values for the AutoExecuteStatusInheritedFrom const type. +func PossibleAutoExecuteStatusInheritedFromValues() []AutoExecuteStatusInheritedFrom { + return []AutoExecuteStatusInheritedFrom{AutoExecuteStatusInheritedFromDatabase, AutoExecuteStatusInheritedFromDefault, AutoExecuteStatusInheritedFromElasticPool, AutoExecuteStatusInheritedFromServer, AutoExecuteStatusInheritedFromSubscription} +} + +// AutomaticTuningDisabledReason enumerates the values for automatic tuning disabled reason. +type AutomaticTuningDisabledReason string + +const ( + // AutomaticTuningDisabledReasonAutoConfigured ... + AutomaticTuningDisabledReasonAutoConfigured AutomaticTuningDisabledReason = "AutoConfigured" + // AutomaticTuningDisabledReasonDefault ... + AutomaticTuningDisabledReasonDefault AutomaticTuningDisabledReason = "Default" + // AutomaticTuningDisabledReasonDisabled ... + AutomaticTuningDisabledReasonDisabled AutomaticTuningDisabledReason = "Disabled" + // AutomaticTuningDisabledReasonInheritedFromServer ... + AutomaticTuningDisabledReasonInheritedFromServer AutomaticTuningDisabledReason = "InheritedFromServer" + // AutomaticTuningDisabledReasonNotSupported ... + AutomaticTuningDisabledReasonNotSupported AutomaticTuningDisabledReason = "NotSupported" + // AutomaticTuningDisabledReasonQueryStoreOff ... + AutomaticTuningDisabledReasonQueryStoreOff AutomaticTuningDisabledReason = "QueryStoreOff" + // AutomaticTuningDisabledReasonQueryStoreReadOnly ... + AutomaticTuningDisabledReasonQueryStoreReadOnly AutomaticTuningDisabledReason = "QueryStoreReadOnly" +) + +// PossibleAutomaticTuningDisabledReasonValues returns an array of possible values for the AutomaticTuningDisabledReason const type. +func PossibleAutomaticTuningDisabledReasonValues() []AutomaticTuningDisabledReason { + return []AutomaticTuningDisabledReason{AutomaticTuningDisabledReasonAutoConfigured, AutomaticTuningDisabledReasonDefault, AutomaticTuningDisabledReasonDisabled, AutomaticTuningDisabledReasonInheritedFromServer, AutomaticTuningDisabledReasonNotSupported, AutomaticTuningDisabledReasonQueryStoreOff, AutomaticTuningDisabledReasonQueryStoreReadOnly} +} + +// AutomaticTuningMode enumerates the values for automatic tuning mode. +type AutomaticTuningMode string + +const ( + // AutomaticTuningModeAuto ... + AutomaticTuningModeAuto AutomaticTuningMode = "Auto" + // AutomaticTuningModeCustom ... + AutomaticTuningModeCustom AutomaticTuningMode = "Custom" + // AutomaticTuningModeInherit ... + AutomaticTuningModeInherit AutomaticTuningMode = "Inherit" + // AutomaticTuningModeUnspecified ... + AutomaticTuningModeUnspecified AutomaticTuningMode = "Unspecified" +) + +// PossibleAutomaticTuningModeValues returns an array of possible values for the AutomaticTuningMode const type. +func PossibleAutomaticTuningModeValues() []AutomaticTuningMode { + return []AutomaticTuningMode{AutomaticTuningModeAuto, AutomaticTuningModeCustom, AutomaticTuningModeInherit, AutomaticTuningModeUnspecified} +} + +// AutomaticTuningOptionModeActual enumerates the values for automatic tuning option mode actual. +type AutomaticTuningOptionModeActual string + +const ( + // AutomaticTuningOptionModeActualOff ... + AutomaticTuningOptionModeActualOff AutomaticTuningOptionModeActual = "Off" + // AutomaticTuningOptionModeActualOn ... + AutomaticTuningOptionModeActualOn AutomaticTuningOptionModeActual = "On" +) + +// PossibleAutomaticTuningOptionModeActualValues returns an array of possible values for the AutomaticTuningOptionModeActual const type. +func PossibleAutomaticTuningOptionModeActualValues() []AutomaticTuningOptionModeActual { + return []AutomaticTuningOptionModeActual{AutomaticTuningOptionModeActualOff, AutomaticTuningOptionModeActualOn} +} + +// 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} +} + +// BackupStorageRedundancy enumerates the values for backup storage redundancy. +type BackupStorageRedundancy string + +const ( + // BackupStorageRedundancyGeo ... + BackupStorageRedundancyGeo BackupStorageRedundancy = "Geo" + // BackupStorageRedundancyLocal ... + BackupStorageRedundancyLocal BackupStorageRedundancy = "Local" + // BackupStorageRedundancyZone ... + BackupStorageRedundancyZone BackupStorageRedundancy = "Zone" +) + +// PossibleBackupStorageRedundancyValues returns an array of possible values for the BackupStorageRedundancy const type. +func PossibleBackupStorageRedundancyValues() []BackupStorageRedundancy { + return []BackupStorageRedundancy{BackupStorageRedundancyGeo, BackupStorageRedundancyLocal, BackupStorageRedundancyZone} +} + +// BackupStorageRedundancy1 enumerates the values for backup storage redundancy 1. +type BackupStorageRedundancy1 string + +const ( + // BackupStorageRedundancy1Geo ... + BackupStorageRedundancy1Geo BackupStorageRedundancy1 = "Geo" + // BackupStorageRedundancy1Local ... + BackupStorageRedundancy1Local BackupStorageRedundancy1 = "Local" + // BackupStorageRedundancy1Zone ... + BackupStorageRedundancy1Zone BackupStorageRedundancy1 = "Zone" +) + +// PossibleBackupStorageRedundancy1Values returns an array of possible values for the BackupStorageRedundancy1 const type. +func PossibleBackupStorageRedundancy1Values() []BackupStorageRedundancy1 { + return []BackupStorageRedundancy1{BackupStorageRedundancy1Geo, BackupStorageRedundancy1Local, BackupStorageRedundancy1Zone} +} + +// BlobAuditingPolicyState enumerates the values for blob auditing policy state. +type BlobAuditingPolicyState string + +const ( + // BlobAuditingPolicyStateDisabled ... + BlobAuditingPolicyStateDisabled BlobAuditingPolicyState = "Disabled" + // BlobAuditingPolicyStateEnabled ... + BlobAuditingPolicyStateEnabled BlobAuditingPolicyState = "Enabled" +) + +// PossibleBlobAuditingPolicyStateValues returns an array of possible values for the BlobAuditingPolicyState const type. +func PossibleBlobAuditingPolicyStateValues() []BlobAuditingPolicyState { + return []BlobAuditingPolicyState{BlobAuditingPolicyStateDisabled, BlobAuditingPolicyStateEnabled} +} + +// CapabilityGroup enumerates the values for capability group. +type CapabilityGroup string + +const ( + // CapabilityGroupSupportedEditions ... + CapabilityGroupSupportedEditions CapabilityGroup = "supportedEditions" + // CapabilityGroupSupportedElasticPoolEditions ... + CapabilityGroupSupportedElasticPoolEditions CapabilityGroup = "supportedElasticPoolEditions" + // CapabilityGroupSupportedInstancePoolEditions ... + CapabilityGroupSupportedInstancePoolEditions CapabilityGroup = "supportedInstancePoolEditions" + // CapabilityGroupSupportedManagedInstanceEditions ... + CapabilityGroupSupportedManagedInstanceEditions CapabilityGroup = "supportedManagedInstanceEditions" + // CapabilityGroupSupportedManagedInstanceVersions ... + CapabilityGroupSupportedManagedInstanceVersions CapabilityGroup = "supportedManagedInstanceVersions" +) + +// PossibleCapabilityGroupValues returns an array of possible values for the CapabilityGroup const type. +func PossibleCapabilityGroupValues() []CapabilityGroup { + return []CapabilityGroup{CapabilityGroupSupportedEditions, CapabilityGroupSupportedElasticPoolEditions, CapabilityGroupSupportedInstancePoolEditions, CapabilityGroupSupportedManagedInstanceEditions, CapabilityGroupSupportedManagedInstanceVersions} +} + +// 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 ( + // CatalogCollationTypeDATABASEDEFAULT ... + CatalogCollationTypeDATABASEDEFAULT CatalogCollationType = "DATABASE_DEFAULT" + // CatalogCollationTypeSQLLatin1GeneralCP1CIAS ... + CatalogCollationTypeSQLLatin1GeneralCP1CIAS CatalogCollationType = "SQL_Latin1_General_CP1_CI_AS" +) + +// PossibleCatalogCollationTypeValues returns an array of possible values for the CatalogCollationType const type. +func PossibleCatalogCollationTypeValues() []CatalogCollationType { + return []CatalogCollationType{CatalogCollationTypeDATABASEDEFAULT, CatalogCollationTypeSQLLatin1GeneralCP1CIAS} +} + +// CheckNameAvailabilityReason enumerates the values for check name availability reason. +type CheckNameAvailabilityReason string + +const ( + // CheckNameAvailabilityReasonAlreadyExists ... + CheckNameAvailabilityReasonAlreadyExists CheckNameAvailabilityReason = "AlreadyExists" + // CheckNameAvailabilityReasonInvalid ... + CheckNameAvailabilityReasonInvalid CheckNameAvailabilityReason = "Invalid" +) + +// PossibleCheckNameAvailabilityReasonValues returns an array of possible values for the CheckNameAvailabilityReason const type. +func PossibleCheckNameAvailabilityReasonValues() []CheckNameAvailabilityReason { + return []CheckNameAvailabilityReason{CheckNameAvailabilityReasonAlreadyExists, CheckNameAvailabilityReasonInvalid} +} + +// ColumnDataType enumerates the values for column data type. +type ColumnDataType string + +const ( + // ColumnDataTypeBigint ... + ColumnDataTypeBigint ColumnDataType = "bigint" + // ColumnDataTypeBinary ... + ColumnDataTypeBinary ColumnDataType = "binary" + // ColumnDataTypeBit ... + ColumnDataTypeBit ColumnDataType = "bit" + // ColumnDataTypeChar ... + ColumnDataTypeChar ColumnDataType = "char" + // ColumnDataTypeDate ... + ColumnDataTypeDate ColumnDataType = "date" + // ColumnDataTypeDatetime ... + ColumnDataTypeDatetime ColumnDataType = "datetime" + // ColumnDataTypeDatetime2 ... + ColumnDataTypeDatetime2 ColumnDataType = "datetime2" + // ColumnDataTypeDatetimeoffset ... + ColumnDataTypeDatetimeoffset ColumnDataType = "datetimeoffset" + // ColumnDataTypeDecimal ... + ColumnDataTypeDecimal ColumnDataType = "decimal" + // ColumnDataTypeFloat ... + ColumnDataTypeFloat ColumnDataType = "float" + // ColumnDataTypeGeography ... + ColumnDataTypeGeography ColumnDataType = "geography" + // ColumnDataTypeGeometry ... + ColumnDataTypeGeometry ColumnDataType = "geometry" + // ColumnDataTypeHierarchyid ... + ColumnDataTypeHierarchyid ColumnDataType = "hierarchyid" + // ColumnDataTypeImage ... + ColumnDataTypeImage ColumnDataType = "image" + // ColumnDataTypeInt ... + ColumnDataTypeInt ColumnDataType = "int" + // ColumnDataTypeMoney ... + ColumnDataTypeMoney ColumnDataType = "money" + // ColumnDataTypeNchar ... + ColumnDataTypeNchar ColumnDataType = "nchar" + // ColumnDataTypeNtext ... + ColumnDataTypeNtext ColumnDataType = "ntext" + // ColumnDataTypeNumeric ... + ColumnDataTypeNumeric ColumnDataType = "numeric" + // ColumnDataTypeNvarchar ... + ColumnDataTypeNvarchar ColumnDataType = "nvarchar" + // ColumnDataTypeReal ... + ColumnDataTypeReal ColumnDataType = "real" + // ColumnDataTypeSmalldatetime ... + ColumnDataTypeSmalldatetime ColumnDataType = "smalldatetime" + // ColumnDataTypeSmallint ... + ColumnDataTypeSmallint ColumnDataType = "smallint" + // ColumnDataTypeSmallmoney ... + ColumnDataTypeSmallmoney ColumnDataType = "smallmoney" + // ColumnDataTypeSQLVariant ... + ColumnDataTypeSQLVariant ColumnDataType = "sql_variant" + // ColumnDataTypeSysname ... + ColumnDataTypeSysname ColumnDataType = "sysname" + // ColumnDataTypeText ... + ColumnDataTypeText ColumnDataType = "text" + // ColumnDataTypeTime ... + ColumnDataTypeTime ColumnDataType = "time" + // ColumnDataTypeTimestamp ... + ColumnDataTypeTimestamp ColumnDataType = "timestamp" + // ColumnDataTypeTinyint ... + ColumnDataTypeTinyint ColumnDataType = "tinyint" + // ColumnDataTypeUniqueidentifier ... + ColumnDataTypeUniqueidentifier ColumnDataType = "uniqueidentifier" + // ColumnDataTypeVarbinary ... + ColumnDataTypeVarbinary ColumnDataType = "varbinary" + // ColumnDataTypeVarchar ... + ColumnDataTypeVarchar ColumnDataType = "varchar" + // ColumnDataTypeXML ... + ColumnDataTypeXML ColumnDataType = "xml" +) + +// PossibleColumnDataTypeValues returns an array of possible values for the ColumnDataType const type. +func PossibleColumnDataTypeValues() []ColumnDataType { + return []ColumnDataType{ColumnDataTypeBigint, ColumnDataTypeBinary, ColumnDataTypeBit, ColumnDataTypeChar, ColumnDataTypeDate, ColumnDataTypeDatetime, ColumnDataTypeDatetime2, ColumnDataTypeDatetimeoffset, ColumnDataTypeDecimal, ColumnDataTypeFloat, ColumnDataTypeGeography, ColumnDataTypeGeometry, ColumnDataTypeHierarchyid, ColumnDataTypeImage, ColumnDataTypeInt, ColumnDataTypeMoney, ColumnDataTypeNchar, ColumnDataTypeNtext, ColumnDataTypeNumeric, ColumnDataTypeNvarchar, ColumnDataTypeReal, ColumnDataTypeSmalldatetime, ColumnDataTypeSmallint, ColumnDataTypeSmallmoney, ColumnDataTypeSQLVariant, ColumnDataTypeSysname, ColumnDataTypeText, ColumnDataTypeTime, ColumnDataTypeTimestamp, ColumnDataTypeTinyint, ColumnDataTypeUniqueidentifier, ColumnDataTypeVarbinary, ColumnDataTypeVarchar, ColumnDataTypeXML} +} + +// CreatedByType enumerates the values for created by type. +type CreatedByType string + +const ( + // CreatedByTypeApplication ... + CreatedByTypeApplication CreatedByType = "Application" + // CreatedByTypeKey ... + CreatedByTypeKey CreatedByType = "Key" + // CreatedByTypeManagedIdentity ... + CreatedByTypeManagedIdentity CreatedByType = "ManagedIdentity" + // CreatedByTypeUser ... + CreatedByTypeUser CreatedByType = "User" +) + +// PossibleCreatedByTypeValues returns an array of possible values for the CreatedByType const type. +func PossibleCreatedByTypeValues() []CreatedByType { + return []CreatedByType{CreatedByTypeApplication, CreatedByTypeKey, CreatedByTypeManagedIdentity, CreatedByTypeUser} +} + +// 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} +} + +// CurrentBackupStorageRedundancy enumerates the values for current backup storage redundancy. +type CurrentBackupStorageRedundancy string + +const ( + // CurrentBackupStorageRedundancyGeo ... + CurrentBackupStorageRedundancyGeo CurrentBackupStorageRedundancy = "Geo" + // CurrentBackupStorageRedundancyLocal ... + CurrentBackupStorageRedundancyLocal CurrentBackupStorageRedundancy = "Local" + // CurrentBackupStorageRedundancyZone ... + CurrentBackupStorageRedundancyZone CurrentBackupStorageRedundancy = "Zone" +) + +// PossibleCurrentBackupStorageRedundancyValues returns an array of possible values for the CurrentBackupStorageRedundancy const type. +func PossibleCurrentBackupStorageRedundancyValues() []CurrentBackupStorageRedundancy { + return []CurrentBackupStorageRedundancy{CurrentBackupStorageRedundancyGeo, CurrentBackupStorageRedundancyLocal, CurrentBackupStorageRedundancyZone} +} + +// DatabaseLicenseType enumerates the values for database license type. +type DatabaseLicenseType string + +const ( + // DatabaseLicenseTypeBasePrice ... + DatabaseLicenseTypeBasePrice DatabaseLicenseType = "BasePrice" + // DatabaseLicenseTypeLicenseIncluded ... + DatabaseLicenseTypeLicenseIncluded DatabaseLicenseType = "LicenseIncluded" +) + +// PossibleDatabaseLicenseTypeValues returns an array of possible values for the DatabaseLicenseType const type. +func PossibleDatabaseLicenseTypeValues() []DatabaseLicenseType { + return []DatabaseLicenseType{DatabaseLicenseTypeBasePrice, DatabaseLicenseTypeLicenseIncluded} +} + +// 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} +} + +// DatabaseState enumerates the values for database state. +type DatabaseState string + +const ( + // DatabaseStateAll ... + DatabaseStateAll DatabaseState = "All" + // DatabaseStateDeleted ... + DatabaseStateDeleted DatabaseState = "Deleted" + // DatabaseStateLive ... + DatabaseStateLive DatabaseState = "Live" +) + +// PossibleDatabaseStateValues returns an array of possible values for the DatabaseState const type. +func PossibleDatabaseStateValues() []DatabaseState { + return []DatabaseState{DatabaseStateAll, DatabaseStateDeleted, DatabaseStateLive} +} + +// DatabaseStatus enumerates the values for database status. +type DatabaseStatus string + +const ( + // DatabaseStatusAutoClosed ... + DatabaseStatusAutoClosed DatabaseStatus = "AutoClosed" + // DatabaseStatusCopying ... + DatabaseStatusCopying DatabaseStatus = "Copying" + // DatabaseStatusCreating ... + DatabaseStatusCreating DatabaseStatus = "Creating" + // DatabaseStatusDisabled ... + DatabaseStatusDisabled DatabaseStatus = "Disabled" + // DatabaseStatusEmergencyMode ... + DatabaseStatusEmergencyMode DatabaseStatus = "EmergencyMode" + // DatabaseStatusInaccessible ... + DatabaseStatusInaccessible DatabaseStatus = "Inaccessible" + // DatabaseStatusOffline ... + DatabaseStatusOffline DatabaseStatus = "Offline" + // DatabaseStatusOfflineChangingDwPerformanceTiers ... + DatabaseStatusOfflineChangingDwPerformanceTiers DatabaseStatus = "OfflineChangingDwPerformanceTiers" + // DatabaseStatusOfflineSecondary ... + DatabaseStatusOfflineSecondary DatabaseStatus = "OfflineSecondary" + // DatabaseStatusOnline ... + DatabaseStatusOnline DatabaseStatus = "Online" + // DatabaseStatusOnlineChangingDwPerformanceTiers ... + DatabaseStatusOnlineChangingDwPerformanceTiers DatabaseStatus = "OnlineChangingDwPerformanceTiers" + // DatabaseStatusPaused ... + DatabaseStatusPaused DatabaseStatus = "Paused" + // DatabaseStatusPausing ... + DatabaseStatusPausing DatabaseStatus = "Pausing" + // DatabaseStatusRecovering ... + DatabaseStatusRecovering DatabaseStatus = "Recovering" + // DatabaseStatusRecoveryPending ... + DatabaseStatusRecoveryPending DatabaseStatus = "RecoveryPending" + // DatabaseStatusRestoring ... + DatabaseStatusRestoring DatabaseStatus = "Restoring" + // DatabaseStatusResuming ... + DatabaseStatusResuming DatabaseStatus = "Resuming" + // DatabaseStatusScaling ... + DatabaseStatusScaling DatabaseStatus = "Scaling" + // DatabaseStatusShutdown ... + DatabaseStatusShutdown DatabaseStatus = "Shutdown" + // DatabaseStatusStandby ... + DatabaseStatusStandby DatabaseStatus = "Standby" + // DatabaseStatusSuspect ... + DatabaseStatusSuspect DatabaseStatus = "Suspect" +) + +// PossibleDatabaseStatusValues returns an array of possible values for the DatabaseStatus const type. +func PossibleDatabaseStatusValues() []DatabaseStatus { + return []DatabaseStatus{DatabaseStatusAutoClosed, DatabaseStatusCopying, DatabaseStatusCreating, DatabaseStatusDisabled, DatabaseStatusEmergencyMode, DatabaseStatusInaccessible, DatabaseStatusOffline, DatabaseStatusOfflineChangingDwPerformanceTiers, DatabaseStatusOfflineSecondary, DatabaseStatusOnline, DatabaseStatusOnlineChangingDwPerformanceTiers, DatabaseStatusPaused, DatabaseStatusPausing, DatabaseStatusRecovering, DatabaseStatusRecoveryPending, DatabaseStatusRestoring, DatabaseStatusResuming, DatabaseStatusScaling, DatabaseStatusShutdown, DatabaseStatusStandby, DatabaseStatusSuspect} +} + +// DataMaskingFunction enumerates the values for data masking function. +type DataMaskingFunction string + +const ( + // DataMaskingFunctionCCN ... + DataMaskingFunctionCCN DataMaskingFunction = "CCN" + // DataMaskingFunctionDefault ... + DataMaskingFunctionDefault DataMaskingFunction = "Default" + // DataMaskingFunctionEmail ... + DataMaskingFunctionEmail DataMaskingFunction = "Email" + // DataMaskingFunctionNumber ... + DataMaskingFunctionNumber DataMaskingFunction = "Number" + // DataMaskingFunctionSSN ... + DataMaskingFunctionSSN DataMaskingFunction = "SSN" + // DataMaskingFunctionText ... + DataMaskingFunctionText DataMaskingFunction = "Text" +) + +// PossibleDataMaskingFunctionValues returns an array of possible values for the DataMaskingFunction const type. +func PossibleDataMaskingFunctionValues() []DataMaskingFunction { + return []DataMaskingFunction{DataMaskingFunctionCCN, DataMaskingFunctionDefault, DataMaskingFunctionEmail, DataMaskingFunctionNumber, DataMaskingFunctionSSN, DataMaskingFunctionText} +} + +// DataMaskingRuleState enumerates the values for data masking rule state. +type DataMaskingRuleState string + +const ( + // DataMaskingRuleStateDisabled ... + DataMaskingRuleStateDisabled DataMaskingRuleState = "Disabled" + // DataMaskingRuleStateEnabled ... + DataMaskingRuleStateEnabled DataMaskingRuleState = "Enabled" +) + +// PossibleDataMaskingRuleStateValues returns an array of possible values for the DataMaskingRuleState const type. +func PossibleDataMaskingRuleStateValues() []DataMaskingRuleState { + return []DataMaskingRuleState{DataMaskingRuleStateDisabled, DataMaskingRuleStateEnabled} +} + +// DataMaskingState enumerates the values for data masking state. +type DataMaskingState string + +const ( + // DataMaskingStateDisabled ... + DataMaskingStateDisabled DataMaskingState = "Disabled" + // DataMaskingStateEnabled ... + DataMaskingStateEnabled DataMaskingState = "Enabled" +) + +// PossibleDataMaskingStateValues returns an array of possible values for the DataMaskingState const type. +func PossibleDataMaskingStateValues() []DataMaskingState { + return []DataMaskingState{DataMaskingStateDisabled, DataMaskingStateEnabled} +} + +// DayOfWeek enumerates the values for day of week. +type DayOfWeek string + +const ( + // DayOfWeekFriday ... + DayOfWeekFriday DayOfWeek = "Friday" + // DayOfWeekMonday ... + DayOfWeekMonday DayOfWeek = "Monday" + // DayOfWeekSaturday ... + DayOfWeekSaturday DayOfWeek = "Saturday" + // DayOfWeekSunday ... + DayOfWeekSunday DayOfWeek = "Sunday" + // DayOfWeekThursday ... + DayOfWeekThursday DayOfWeek = "Thursday" + // DayOfWeekTuesday ... + DayOfWeekTuesday DayOfWeek = "Tuesday" + // DayOfWeekWednesday ... + DayOfWeekWednesday DayOfWeek = "Wednesday" +) + +// PossibleDayOfWeekValues returns an array of possible values for the DayOfWeek const type. +func PossibleDayOfWeekValues() []DayOfWeek { + return []DayOfWeek{DayOfWeekFriday, DayOfWeekMonday, DayOfWeekSaturday, DayOfWeekSunday, DayOfWeekThursday, DayOfWeekTuesday, DayOfWeekWednesday} +} + +// ElasticPoolLicenseType enumerates the values for elastic pool license type. +type ElasticPoolLicenseType string + +const ( + // ElasticPoolLicenseTypeBasePrice ... + ElasticPoolLicenseTypeBasePrice ElasticPoolLicenseType = "BasePrice" + // ElasticPoolLicenseTypeLicenseIncluded ... + ElasticPoolLicenseTypeLicenseIncluded ElasticPoolLicenseType = "LicenseIncluded" +) + +// PossibleElasticPoolLicenseTypeValues returns an array of possible values for the ElasticPoolLicenseType const type. +func PossibleElasticPoolLicenseTypeValues() []ElasticPoolLicenseType { + return []ElasticPoolLicenseType{ElasticPoolLicenseTypeBasePrice, ElasticPoolLicenseTypeLicenseIncluded} +} + +// ElasticPoolState enumerates the values for elastic pool state. +type ElasticPoolState string + +const ( + // ElasticPoolStateCreating ... + ElasticPoolStateCreating ElasticPoolState = "Creating" + // ElasticPoolStateDisabled ... + ElasticPoolStateDisabled ElasticPoolState = "Disabled" + // ElasticPoolStateReady ... + ElasticPoolStateReady ElasticPoolState = "Ready" +) + +// PossibleElasticPoolStateValues returns an array of possible values for the ElasticPoolState const type. +func PossibleElasticPoolStateValues() []ElasticPoolState { + return []ElasticPoolState{ElasticPoolStateCreating, ElasticPoolStateDisabled, ElasticPoolStateReady} +} + +// FailoverGroupReplicationRole enumerates the values for failover group replication role. +type FailoverGroupReplicationRole string + +const ( + // FailoverGroupReplicationRolePrimary ... + FailoverGroupReplicationRolePrimary FailoverGroupReplicationRole = "Primary" + // FailoverGroupReplicationRoleSecondary ... + FailoverGroupReplicationRoleSecondary FailoverGroupReplicationRole = "Secondary" +) + +// PossibleFailoverGroupReplicationRoleValues returns an array of possible values for the FailoverGroupReplicationRole const type. +func PossibleFailoverGroupReplicationRoleValues() []FailoverGroupReplicationRole { + return []FailoverGroupReplicationRole{FailoverGroupReplicationRolePrimary, FailoverGroupReplicationRoleSecondary} +} + +// 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 ( + // IdentityTypeNone ... + IdentityTypeNone IdentityType = "None" + // IdentityTypeSystemAssigned ... + IdentityTypeSystemAssigned IdentityType = "SystemAssigned" + // IdentityTypeUserAssigned ... + IdentityTypeUserAssigned IdentityType = "UserAssigned" +) + +// PossibleIdentityTypeValues returns an array of possible values for the IdentityType const type. +func PossibleIdentityTypeValues() []IdentityType { + return []IdentityType{IdentityTypeNone, IdentityTypeSystemAssigned, IdentityTypeUserAssigned} +} + +// ImplementationMethod enumerates the values for implementation method. +type ImplementationMethod string + +const ( + // ImplementationMethodAzurePowerShell ... + ImplementationMethodAzurePowerShell ImplementationMethod = "AzurePowerShell" + // ImplementationMethodTSQL ... + ImplementationMethodTSQL ImplementationMethod = "TSql" +) + +// PossibleImplementationMethodValues returns an array of possible values for the ImplementationMethod const type. +func PossibleImplementationMethodValues() []ImplementationMethod { + return []ImplementationMethod{ImplementationMethodAzurePowerShell, ImplementationMethodTSQL} +} + +// InstanceFailoverGroupReplicationRole enumerates the values for instance failover group replication role. +type InstanceFailoverGroupReplicationRole string + +const ( + // InstanceFailoverGroupReplicationRolePrimary ... + InstanceFailoverGroupReplicationRolePrimary InstanceFailoverGroupReplicationRole = "Primary" + // InstanceFailoverGroupReplicationRoleSecondary ... + InstanceFailoverGroupReplicationRoleSecondary InstanceFailoverGroupReplicationRole = "Secondary" +) + +// PossibleInstanceFailoverGroupReplicationRoleValues returns an array of possible values for the InstanceFailoverGroupReplicationRole const type. +func PossibleInstanceFailoverGroupReplicationRoleValues() []InstanceFailoverGroupReplicationRole { + return []InstanceFailoverGroupReplicationRole{InstanceFailoverGroupReplicationRolePrimary, InstanceFailoverGroupReplicationRoleSecondary} +} + +// InstancePoolLicenseType enumerates the values for instance pool license type. +type InstancePoolLicenseType string + +const ( + // InstancePoolLicenseTypeBasePrice ... + InstancePoolLicenseTypeBasePrice InstancePoolLicenseType = "BasePrice" + // InstancePoolLicenseTypeLicenseIncluded ... + InstancePoolLicenseTypeLicenseIncluded InstancePoolLicenseType = "LicenseIncluded" +) + +// PossibleInstancePoolLicenseTypeValues returns an array of possible values for the InstancePoolLicenseType const type. +func PossibleInstancePoolLicenseTypeValues() []InstancePoolLicenseType { + return []InstancePoolLicenseType{InstancePoolLicenseTypeBasePrice, InstancePoolLicenseTypeLicenseIncluded} +} + +// IsRetryable enumerates the values for is retryable. +type IsRetryable string + +const ( + // IsRetryableNo ... + IsRetryableNo IsRetryable = "No" + // IsRetryableYes ... + IsRetryableYes IsRetryable = "Yes" +) + +// PossibleIsRetryableValues returns an array of possible values for the IsRetryable const type. +func PossibleIsRetryableValues() []IsRetryable { + return []IsRetryable{IsRetryableNo, IsRetryableYes} +} + +// JobAgentState enumerates the values for job agent state. +type JobAgentState string + +const ( + // JobAgentStateCreating ... + JobAgentStateCreating JobAgentState = "Creating" + // JobAgentStateDeleting ... + JobAgentStateDeleting JobAgentState = "Deleting" + // JobAgentStateDisabled ... + JobAgentStateDisabled JobAgentState = "Disabled" + // JobAgentStateReady ... + JobAgentStateReady JobAgentState = "Ready" + // JobAgentStateUpdating ... + JobAgentStateUpdating JobAgentState = "Updating" +) + +// PossibleJobAgentStateValues returns an array of possible values for the JobAgentState const type. +func PossibleJobAgentStateValues() []JobAgentState { + return []JobAgentState{JobAgentStateCreating, JobAgentStateDeleting, JobAgentStateDisabled, JobAgentStateReady, JobAgentStateUpdating} +} + +// JobExecutionLifecycle enumerates the values for job execution lifecycle. +type JobExecutionLifecycle string + +const ( + // JobExecutionLifecycleCanceled ... + JobExecutionLifecycleCanceled JobExecutionLifecycle = "Canceled" + // JobExecutionLifecycleCreated ... + JobExecutionLifecycleCreated JobExecutionLifecycle = "Created" + // JobExecutionLifecycleFailed ... + JobExecutionLifecycleFailed JobExecutionLifecycle = "Failed" + // JobExecutionLifecycleInProgress ... + JobExecutionLifecycleInProgress JobExecutionLifecycle = "InProgress" + // JobExecutionLifecycleSkipped ... + JobExecutionLifecycleSkipped JobExecutionLifecycle = "Skipped" + // JobExecutionLifecycleSucceeded ... + JobExecutionLifecycleSucceeded JobExecutionLifecycle = "Succeeded" + // JobExecutionLifecycleSucceededWithSkipped ... + JobExecutionLifecycleSucceededWithSkipped JobExecutionLifecycle = "SucceededWithSkipped" + // JobExecutionLifecycleTimedOut ... + JobExecutionLifecycleTimedOut JobExecutionLifecycle = "TimedOut" + // JobExecutionLifecycleWaitingForChildJobExecutions ... + JobExecutionLifecycleWaitingForChildJobExecutions JobExecutionLifecycle = "WaitingForChildJobExecutions" + // JobExecutionLifecycleWaitingForRetry ... + JobExecutionLifecycleWaitingForRetry JobExecutionLifecycle = "WaitingForRetry" +) + +// PossibleJobExecutionLifecycleValues returns an array of possible values for the JobExecutionLifecycle const type. +func PossibleJobExecutionLifecycleValues() []JobExecutionLifecycle { + return []JobExecutionLifecycle{JobExecutionLifecycleCanceled, JobExecutionLifecycleCreated, JobExecutionLifecycleFailed, JobExecutionLifecycleInProgress, JobExecutionLifecycleSkipped, JobExecutionLifecycleSucceeded, JobExecutionLifecycleSucceededWithSkipped, JobExecutionLifecycleTimedOut, JobExecutionLifecycleWaitingForChildJobExecutions, JobExecutionLifecycleWaitingForRetry} +} + +// JobScheduleType enumerates the values for job schedule type. +type JobScheduleType string + +const ( + // JobScheduleTypeOnce ... + JobScheduleTypeOnce JobScheduleType = "Once" + // JobScheduleTypeRecurring ... + JobScheduleTypeRecurring JobScheduleType = "Recurring" +) + +// PossibleJobScheduleTypeValues returns an array of possible values for the JobScheduleType const type. +func PossibleJobScheduleTypeValues() []JobScheduleType { + return []JobScheduleType{JobScheduleTypeOnce, JobScheduleTypeRecurring} +} + +// JobStepActionSource enumerates the values for job step action source. +type JobStepActionSource string + +const ( + // JobStepActionSourceInline ... + JobStepActionSourceInline JobStepActionSource = "Inline" +) + +// PossibleJobStepActionSourceValues returns an array of possible values for the JobStepActionSource const type. +func PossibleJobStepActionSourceValues() []JobStepActionSource { + return []JobStepActionSource{JobStepActionSourceInline} +} + +// JobStepActionType enumerates the values for job step action type. +type JobStepActionType string + +const ( + // JobStepActionTypeTSQL ... + JobStepActionTypeTSQL JobStepActionType = "TSql" +) + +// PossibleJobStepActionTypeValues returns an array of possible values for the JobStepActionType const type. +func PossibleJobStepActionTypeValues() []JobStepActionType { + return []JobStepActionType{JobStepActionTypeTSQL} +} + +// JobStepOutputType enumerates the values for job step output type. +type JobStepOutputType string + +const ( + // JobStepOutputTypeSQLDatabase ... + JobStepOutputTypeSQLDatabase JobStepOutputType = "SqlDatabase" +) + +// PossibleJobStepOutputTypeValues returns an array of possible values for the JobStepOutputType const type. +func PossibleJobStepOutputTypeValues() []JobStepOutputType { + return []JobStepOutputType{JobStepOutputTypeSQLDatabase} +} + +// JobTargetGroupMembershipType enumerates the values for job target group membership type. +type JobTargetGroupMembershipType string + +const ( + // JobTargetGroupMembershipTypeExclude ... + JobTargetGroupMembershipTypeExclude JobTargetGroupMembershipType = "Exclude" + // JobTargetGroupMembershipTypeInclude ... + JobTargetGroupMembershipTypeInclude JobTargetGroupMembershipType = "Include" +) + +// PossibleJobTargetGroupMembershipTypeValues returns an array of possible values for the JobTargetGroupMembershipType const type. +func PossibleJobTargetGroupMembershipTypeValues() []JobTargetGroupMembershipType { + return []JobTargetGroupMembershipType{JobTargetGroupMembershipTypeExclude, JobTargetGroupMembershipTypeInclude} +} + +// JobTargetType enumerates the values for job target type. +type JobTargetType string + +const ( + // JobTargetTypeSQLDatabase ... + JobTargetTypeSQLDatabase JobTargetType = "SqlDatabase" + // JobTargetTypeSQLElasticPool ... + JobTargetTypeSQLElasticPool JobTargetType = "SqlElasticPool" + // JobTargetTypeSQLServer ... + JobTargetTypeSQLServer JobTargetType = "SqlServer" + // JobTargetTypeSQLShardMap ... + JobTargetTypeSQLShardMap JobTargetType = "SqlShardMap" + // JobTargetTypeTargetGroup ... + JobTargetTypeTargetGroup JobTargetType = "TargetGroup" +) + +// PossibleJobTargetTypeValues returns an array of possible values for the JobTargetType const type. +func PossibleJobTargetTypeValues() []JobTargetType { + return []JobTargetType{JobTargetTypeSQLDatabase, JobTargetTypeSQLElasticPool, JobTargetTypeSQLServer, JobTargetTypeSQLShardMap, JobTargetTypeTargetGroup} +} + +// LedgerDigestUploadsState enumerates the values for ledger digest uploads state. +type LedgerDigestUploadsState string + +const ( + // LedgerDigestUploadsStateDisabled ... + LedgerDigestUploadsStateDisabled LedgerDigestUploadsState = "Disabled" + // LedgerDigestUploadsStateEnabled ... + LedgerDigestUploadsStateEnabled LedgerDigestUploadsState = "Enabled" +) + +// PossibleLedgerDigestUploadsStateValues returns an array of possible values for the LedgerDigestUploadsState const type. +func PossibleLedgerDigestUploadsStateValues() []LedgerDigestUploadsState { + return []LedgerDigestUploadsState{LedgerDigestUploadsStateDisabled, LedgerDigestUploadsStateEnabled} +} + +// LogSizeUnit enumerates the values for log size unit. +type LogSizeUnit string + +const ( + // LogSizeUnitGigabytes ... + LogSizeUnitGigabytes LogSizeUnit = "Gigabytes" + // LogSizeUnitMegabytes ... + LogSizeUnitMegabytes LogSizeUnit = "Megabytes" + // LogSizeUnitPercent ... + LogSizeUnitPercent LogSizeUnit = "Percent" + // LogSizeUnitPetabytes ... + LogSizeUnitPetabytes LogSizeUnit = "Petabytes" + // LogSizeUnitTerabytes ... + LogSizeUnitTerabytes LogSizeUnit = "Terabytes" +) + +// PossibleLogSizeUnitValues returns an array of possible values for the LogSizeUnit const type. +func PossibleLogSizeUnitValues() []LogSizeUnit { + return []LogSizeUnit{LogSizeUnitGigabytes, LogSizeUnitMegabytes, LogSizeUnitPercent, LogSizeUnitPetabytes, LogSizeUnitTerabytes} +} + +// ManagedDatabaseCreateMode enumerates the values for managed database create mode. +type ManagedDatabaseCreateMode string + +const ( + // ManagedDatabaseCreateModeDefault ... + ManagedDatabaseCreateModeDefault ManagedDatabaseCreateMode = "Default" + // ManagedDatabaseCreateModePointInTimeRestore ... + ManagedDatabaseCreateModePointInTimeRestore ManagedDatabaseCreateMode = "PointInTimeRestore" + // ManagedDatabaseCreateModeRecovery ... + ManagedDatabaseCreateModeRecovery ManagedDatabaseCreateMode = "Recovery" + // ManagedDatabaseCreateModeRestoreExternalBackup ... + ManagedDatabaseCreateModeRestoreExternalBackup ManagedDatabaseCreateMode = "RestoreExternalBackup" + // ManagedDatabaseCreateModeRestoreLongTermRetentionBackup ... + ManagedDatabaseCreateModeRestoreLongTermRetentionBackup ManagedDatabaseCreateMode = "RestoreLongTermRetentionBackup" +) + +// PossibleManagedDatabaseCreateModeValues returns an array of possible values for the ManagedDatabaseCreateMode const type. +func PossibleManagedDatabaseCreateModeValues() []ManagedDatabaseCreateMode { + return []ManagedDatabaseCreateMode{ManagedDatabaseCreateModeDefault, ManagedDatabaseCreateModePointInTimeRestore, ManagedDatabaseCreateModeRecovery, ManagedDatabaseCreateModeRestoreExternalBackup, ManagedDatabaseCreateModeRestoreLongTermRetentionBackup} +} + +// ManagedDatabaseStatus enumerates the values for managed database status. +type ManagedDatabaseStatus string + +const ( + // ManagedDatabaseStatusCreating ... + ManagedDatabaseStatusCreating ManagedDatabaseStatus = "Creating" + // ManagedDatabaseStatusInaccessible ... + ManagedDatabaseStatusInaccessible ManagedDatabaseStatus = "Inaccessible" + // ManagedDatabaseStatusOffline ... + ManagedDatabaseStatusOffline ManagedDatabaseStatus = "Offline" + // ManagedDatabaseStatusOnline ... + ManagedDatabaseStatusOnline ManagedDatabaseStatus = "Online" + // ManagedDatabaseStatusRestoring ... + ManagedDatabaseStatusRestoring ManagedDatabaseStatus = "Restoring" + // ManagedDatabaseStatusShutdown ... + ManagedDatabaseStatusShutdown ManagedDatabaseStatus = "Shutdown" + // ManagedDatabaseStatusUpdating ... + ManagedDatabaseStatusUpdating ManagedDatabaseStatus = "Updating" +) + +// PossibleManagedDatabaseStatusValues returns an array of possible values for the ManagedDatabaseStatus const type. +func PossibleManagedDatabaseStatusValues() []ManagedDatabaseStatus { + return []ManagedDatabaseStatus{ManagedDatabaseStatusCreating, ManagedDatabaseStatusInaccessible, ManagedDatabaseStatusOffline, ManagedDatabaseStatusOnline, ManagedDatabaseStatusRestoring, ManagedDatabaseStatusShutdown, ManagedDatabaseStatusUpdating} +} + +// ManagedInstanceLicenseType enumerates the values for managed instance license type. +type ManagedInstanceLicenseType string + +const ( + // ManagedInstanceLicenseTypeBasePrice ... + ManagedInstanceLicenseTypeBasePrice ManagedInstanceLicenseType = "BasePrice" + // ManagedInstanceLicenseTypeLicenseIncluded ... + ManagedInstanceLicenseTypeLicenseIncluded ManagedInstanceLicenseType = "LicenseIncluded" +) + +// PossibleManagedInstanceLicenseTypeValues returns an array of possible values for the ManagedInstanceLicenseType const type. +func PossibleManagedInstanceLicenseTypeValues() []ManagedInstanceLicenseType { + return []ManagedInstanceLicenseType{ManagedInstanceLicenseTypeBasePrice, ManagedInstanceLicenseTypeLicenseIncluded} +} + +// ManagedInstanceProxyOverride enumerates the values for managed instance proxy override. +type ManagedInstanceProxyOverride string + +const ( + // ManagedInstanceProxyOverrideDefault ... + ManagedInstanceProxyOverrideDefault ManagedInstanceProxyOverride = "Default" + // ManagedInstanceProxyOverrideProxy ... + ManagedInstanceProxyOverrideProxy ManagedInstanceProxyOverride = "Proxy" + // ManagedInstanceProxyOverrideRedirect ... + ManagedInstanceProxyOverrideRedirect ManagedInstanceProxyOverride = "Redirect" +) + +// PossibleManagedInstanceProxyOverrideValues returns an array of possible values for the ManagedInstanceProxyOverride const type. +func PossibleManagedInstanceProxyOverrideValues() []ManagedInstanceProxyOverride { + return []ManagedInstanceProxyOverride{ManagedInstanceProxyOverrideDefault, ManagedInstanceProxyOverrideProxy, ManagedInstanceProxyOverrideRedirect} +} + +// ManagedServerCreateMode enumerates the values for managed server create mode. +type ManagedServerCreateMode string + +const ( + // ManagedServerCreateModeDefault ... + ManagedServerCreateModeDefault ManagedServerCreateMode = "Default" + // ManagedServerCreateModePointInTimeRestore ... + ManagedServerCreateModePointInTimeRestore ManagedServerCreateMode = "PointInTimeRestore" +) + +// PossibleManagedServerCreateModeValues returns an array of possible values for the ManagedServerCreateMode const type. +func PossibleManagedServerCreateModeValues() []ManagedServerCreateMode { + return []ManagedServerCreateMode{ManagedServerCreateModeDefault, ManagedServerCreateModePointInTimeRestore} +} + +// ManagementOperationState enumerates the values for management operation state. +type ManagementOperationState string + +const ( + // ManagementOperationStateCancelInProgress ... + ManagementOperationStateCancelInProgress ManagementOperationState = "CancelInProgress" + // ManagementOperationStateCancelled ... + ManagementOperationStateCancelled ManagementOperationState = "Cancelled" + // ManagementOperationStateFailed ... + ManagementOperationStateFailed ManagementOperationState = "Failed" + // ManagementOperationStateInProgress ... + ManagementOperationStateInProgress ManagementOperationState = "InProgress" + // ManagementOperationStatePending ... + ManagementOperationStatePending ManagementOperationState = "Pending" + // ManagementOperationStateSucceeded ... + ManagementOperationStateSucceeded ManagementOperationState = "Succeeded" +) + +// PossibleManagementOperationStateValues returns an array of possible values for the ManagementOperationState const type. +func PossibleManagementOperationStateValues() []ManagementOperationState { + return []ManagementOperationState{ManagementOperationStateCancelInProgress, ManagementOperationStateCancelled, ManagementOperationStateFailed, ManagementOperationStateInProgress, ManagementOperationStatePending, ManagementOperationStateSucceeded} +} + +// MaxSizeUnit enumerates the values for max size unit. +type MaxSizeUnit string + +const ( + // MaxSizeUnitGigabytes ... + MaxSizeUnitGigabytes MaxSizeUnit = "Gigabytes" + // MaxSizeUnitMegabytes ... + MaxSizeUnitMegabytes MaxSizeUnit = "Megabytes" + // MaxSizeUnitPetabytes ... + MaxSizeUnitPetabytes MaxSizeUnit = "Petabytes" + // MaxSizeUnitTerabytes ... + MaxSizeUnitTerabytes MaxSizeUnit = "Terabytes" +) + +// PossibleMaxSizeUnitValues returns an array of possible values for the MaxSizeUnit const type. +func PossibleMaxSizeUnitValues() []MaxSizeUnit { + return []MaxSizeUnit{MaxSizeUnitGigabytes, MaxSizeUnitMegabytes, MaxSizeUnitPetabytes, MaxSizeUnitTerabytes} +} + +// MetricType enumerates the values for metric type. +type MetricType string + +const ( + // MetricTypeCPU ... + MetricTypeCPU MetricType = "cpu" + // MetricTypeDtu ... + MetricTypeDtu MetricType = "dtu" + // MetricTypeDuration ... + MetricTypeDuration MetricType = "duration" + // MetricTypeIo ... + MetricTypeIo MetricType = "io" + // MetricTypeLogIo ... + MetricTypeLogIo MetricType = "logIo" +) + +// PossibleMetricTypeValues returns an array of possible values for the MetricType const type. +func PossibleMetricTypeValues() []MetricType { + return []MetricType{MetricTypeCPU, MetricTypeDtu, MetricTypeDuration, MetricTypeIo, MetricTypeLogIo} +} + +// 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} +} + +// PauseDelayTimeUnit enumerates the values for pause delay time unit. +type PauseDelayTimeUnit string + +const ( + // PauseDelayTimeUnitMinutes ... + PauseDelayTimeUnitMinutes PauseDelayTimeUnit = "Minutes" +) + +// PossiblePauseDelayTimeUnitValues returns an array of possible values for the PauseDelayTimeUnit const type. +func PossiblePauseDelayTimeUnitValues() []PauseDelayTimeUnit { + return []PauseDelayTimeUnit{PauseDelayTimeUnitMinutes} +} + +// PerformanceLevelUnit enumerates the values for performance level unit. +type PerformanceLevelUnit string + +const ( + // PerformanceLevelUnitDTU ... + PerformanceLevelUnitDTU PerformanceLevelUnit = "DTU" + // PerformanceLevelUnitVCores ... + PerformanceLevelUnitVCores PerformanceLevelUnit = "VCores" +) + +// PossiblePerformanceLevelUnitValues returns an array of possible values for the PerformanceLevelUnit const type. +func PossiblePerformanceLevelUnitValues() []PerformanceLevelUnit { + return []PerformanceLevelUnit{PerformanceLevelUnitDTU, PerformanceLevelUnitVCores} +} + +// PrimaryAggregationType enumerates the values for primary aggregation type. +type PrimaryAggregationType string + +const ( + // PrimaryAggregationTypeAverage ... + PrimaryAggregationTypeAverage PrimaryAggregationType = "Average" + // PrimaryAggregationTypeCount ... + PrimaryAggregationTypeCount PrimaryAggregationType = "Count" + // PrimaryAggregationTypeMaximum ... + PrimaryAggregationTypeMaximum PrimaryAggregationType = "Maximum" + // PrimaryAggregationTypeMinimum ... + PrimaryAggregationTypeMinimum PrimaryAggregationType = "Minimum" + // PrimaryAggregationTypeNone ... + PrimaryAggregationTypeNone PrimaryAggregationType = "None" + // PrimaryAggregationTypeTotal ... + PrimaryAggregationTypeTotal PrimaryAggregationType = "Total" +) + +// PossiblePrimaryAggregationTypeValues returns an array of possible values for the PrimaryAggregationType const type. +func PossiblePrimaryAggregationTypeValues() []PrimaryAggregationType { + return []PrimaryAggregationType{PrimaryAggregationTypeAverage, PrimaryAggregationTypeCount, PrimaryAggregationTypeMaximum, PrimaryAggregationTypeMinimum, PrimaryAggregationTypeNone, PrimaryAggregationTypeTotal} +} + +// PrincipalType enumerates the values for principal type. +type PrincipalType string + +const ( + // PrincipalTypeApplication ... + PrincipalTypeApplication PrincipalType = "Application" + // PrincipalTypeGroup ... + PrincipalTypeGroup PrincipalType = "Group" + // PrincipalTypeUser ... + PrincipalTypeUser PrincipalType = "User" +) + +// PossiblePrincipalTypeValues returns an array of possible values for the PrincipalType const type. +func PossiblePrincipalTypeValues() []PrincipalType { + return []PrincipalType{PrincipalTypeApplication, PrincipalTypeGroup, PrincipalTypeUser} +} + +// PrivateEndpointProvisioningState enumerates the values for private endpoint provisioning state. +type PrivateEndpointProvisioningState string + +const ( + // PrivateEndpointProvisioningStateApproving ... + PrivateEndpointProvisioningStateApproving PrivateEndpointProvisioningState = "Approving" + // PrivateEndpointProvisioningStateDropping ... + PrivateEndpointProvisioningStateDropping PrivateEndpointProvisioningState = "Dropping" + // PrivateEndpointProvisioningStateFailed ... + PrivateEndpointProvisioningStateFailed PrivateEndpointProvisioningState = "Failed" + // PrivateEndpointProvisioningStateReady ... + PrivateEndpointProvisioningStateReady PrivateEndpointProvisioningState = "Ready" + // PrivateEndpointProvisioningStateRejecting ... + PrivateEndpointProvisioningStateRejecting PrivateEndpointProvisioningState = "Rejecting" +) + +// PossiblePrivateEndpointProvisioningStateValues returns an array of possible values for the PrivateEndpointProvisioningState const type. +func PossiblePrivateEndpointProvisioningStateValues() []PrivateEndpointProvisioningState { + return []PrivateEndpointProvisioningState{PrivateEndpointProvisioningStateApproving, PrivateEndpointProvisioningStateDropping, PrivateEndpointProvisioningStateFailed, PrivateEndpointProvisioningStateReady, PrivateEndpointProvisioningStateRejecting} +} + +// PrivateLinkServiceConnectionStateActionsRequire enumerates the values for private link service connection +// state actions require. +type PrivateLinkServiceConnectionStateActionsRequire string + +const ( + // PrivateLinkServiceConnectionStateActionsRequireNone ... + PrivateLinkServiceConnectionStateActionsRequireNone PrivateLinkServiceConnectionStateActionsRequire = "None" +) + +// PossiblePrivateLinkServiceConnectionStateActionsRequireValues returns an array of possible values for the PrivateLinkServiceConnectionStateActionsRequire const type. +func PossiblePrivateLinkServiceConnectionStateActionsRequireValues() []PrivateLinkServiceConnectionStateActionsRequire { + return []PrivateLinkServiceConnectionStateActionsRequire{PrivateLinkServiceConnectionStateActionsRequireNone} +} + +// PrivateLinkServiceConnectionStateStatus enumerates the values for private link service connection state +// status. +type PrivateLinkServiceConnectionStateStatus string + +const ( + // PrivateLinkServiceConnectionStateStatusApproved ... + PrivateLinkServiceConnectionStateStatusApproved PrivateLinkServiceConnectionStateStatus = "Approved" + // PrivateLinkServiceConnectionStateStatusDisconnected ... + PrivateLinkServiceConnectionStateStatusDisconnected PrivateLinkServiceConnectionStateStatus = "Disconnected" + // PrivateLinkServiceConnectionStateStatusPending ... + PrivateLinkServiceConnectionStateStatusPending PrivateLinkServiceConnectionStateStatus = "Pending" + // PrivateLinkServiceConnectionStateStatusRejected ... + PrivateLinkServiceConnectionStateStatusRejected PrivateLinkServiceConnectionStateStatus = "Rejected" +) + +// PossiblePrivateLinkServiceConnectionStateStatusValues returns an array of possible values for the PrivateLinkServiceConnectionStateStatus const type. +func PossiblePrivateLinkServiceConnectionStateStatusValues() []PrivateLinkServiceConnectionStateStatus { + return []PrivateLinkServiceConnectionStateStatus{PrivateLinkServiceConnectionStateStatusApproved, PrivateLinkServiceConnectionStateStatusDisconnected, PrivateLinkServiceConnectionStateStatusPending, PrivateLinkServiceConnectionStateStatusRejected} +} + +// ProvisioningState enumerates the values for provisioning state. +type ProvisioningState string + +const ( + // ProvisioningStateCanceled ... + ProvisioningStateCanceled ProvisioningState = "Canceled" + // ProvisioningStateCreated ... + ProvisioningStateCreated ProvisioningState = "Created" + // ProvisioningStateFailed ... + ProvisioningStateFailed ProvisioningState = "Failed" + // ProvisioningStateInProgress ... + ProvisioningStateInProgress ProvisioningState = "InProgress" + // ProvisioningStateSucceeded ... + ProvisioningStateSucceeded ProvisioningState = "Succeeded" +) + +// PossibleProvisioningStateValues returns an array of possible values for the ProvisioningState const type. +func PossibleProvisioningStateValues() []ProvisioningState { + return []ProvisioningState{ProvisioningStateCanceled, ProvisioningStateCreated, ProvisioningStateFailed, ProvisioningStateInProgress, ProvisioningStateSucceeded} +} + +// ProvisioningState1 enumerates the values for provisioning state 1. +type ProvisioningState1 string + +const ( + // ProvisioningState1Creating ... + ProvisioningState1Creating ProvisioningState1 = "Creating" + // ProvisioningState1Deleting ... + ProvisioningState1Deleting ProvisioningState1 = "Deleting" + // ProvisioningState1Failed ... + ProvisioningState1Failed ProvisioningState1 = "Failed" + // ProvisioningState1Succeeded ... + ProvisioningState1Succeeded ProvisioningState1 = "Succeeded" + // ProvisioningState1Unknown ... + ProvisioningState1Unknown ProvisioningState1 = "Unknown" + // ProvisioningState1Updating ... + ProvisioningState1Updating ProvisioningState1 = "Updating" +) + +// PossibleProvisioningState1Values returns an array of possible values for the ProvisioningState1 const type. +func PossibleProvisioningState1Values() []ProvisioningState1 { + return []ProvisioningState1{ProvisioningState1Creating, ProvisioningState1Deleting, ProvisioningState1Failed, ProvisioningState1Succeeded, ProvisioningState1Unknown, ProvisioningState1Updating} +} + +// QueryMetricUnitType enumerates the values for query metric unit type. +type QueryMetricUnitType string + +const ( + // QueryMetricUnitTypeCount ... + QueryMetricUnitTypeCount QueryMetricUnitType = "count" + // QueryMetricUnitTypeKB ... + QueryMetricUnitTypeKB QueryMetricUnitType = "KB" + // QueryMetricUnitTypeMicroseconds ... + QueryMetricUnitTypeMicroseconds QueryMetricUnitType = "microseconds" + // QueryMetricUnitTypePercentage ... + QueryMetricUnitTypePercentage QueryMetricUnitType = "percentage" +) + +// PossibleQueryMetricUnitTypeValues returns an array of possible values for the QueryMetricUnitType const type. +func PossibleQueryMetricUnitTypeValues() []QueryMetricUnitType { + return []QueryMetricUnitType{QueryMetricUnitTypeCount, QueryMetricUnitTypeKB, QueryMetricUnitTypeMicroseconds, QueryMetricUnitTypePercentage} +} + +// QueryTimeGrainType enumerates the values for query time grain type. +type QueryTimeGrainType string + +const ( + // QueryTimeGrainTypeP1D ... + QueryTimeGrainTypeP1D QueryTimeGrainType = "P1D" + // QueryTimeGrainTypePT1H ... + QueryTimeGrainTypePT1H QueryTimeGrainType = "PT1H" +) + +// PossibleQueryTimeGrainTypeValues returns an array of possible values for the QueryTimeGrainType const type. +func PossibleQueryTimeGrainTypeValues() []QueryTimeGrainType { + return []QueryTimeGrainType{QueryTimeGrainTypeP1D, QueryTimeGrainTypePT1H} +} + +// 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 ( + // ReadWriteEndpointFailoverPolicyAutomatic ... + ReadWriteEndpointFailoverPolicyAutomatic ReadWriteEndpointFailoverPolicy = "Automatic" + // ReadWriteEndpointFailoverPolicyManual ... + ReadWriteEndpointFailoverPolicyManual ReadWriteEndpointFailoverPolicy = "Manual" +) + +// PossibleReadWriteEndpointFailoverPolicyValues returns an array of possible values for the ReadWriteEndpointFailoverPolicy const type. +func PossibleReadWriteEndpointFailoverPolicyValues() []ReadWriteEndpointFailoverPolicy { + return []ReadWriteEndpointFailoverPolicy{ReadWriteEndpointFailoverPolicyAutomatic, ReadWriteEndpointFailoverPolicyManual} +} + +// RecommendedActionCurrentState enumerates the values for recommended action current state. +type RecommendedActionCurrentState string + +const ( + // RecommendedActionCurrentStateActive ... + RecommendedActionCurrentStateActive RecommendedActionCurrentState = "Active" + // RecommendedActionCurrentStateError ... + RecommendedActionCurrentStateError RecommendedActionCurrentState = "Error" + // RecommendedActionCurrentStateExecuting ... + RecommendedActionCurrentStateExecuting RecommendedActionCurrentState = "Executing" + // RecommendedActionCurrentStateExpired ... + RecommendedActionCurrentStateExpired RecommendedActionCurrentState = "Expired" + // RecommendedActionCurrentStateIgnored ... + RecommendedActionCurrentStateIgnored RecommendedActionCurrentState = "Ignored" + // RecommendedActionCurrentStateMonitoring ... + RecommendedActionCurrentStateMonitoring RecommendedActionCurrentState = "Monitoring" + // RecommendedActionCurrentStatePending ... + RecommendedActionCurrentStatePending RecommendedActionCurrentState = "Pending" + // RecommendedActionCurrentStatePendingRevert ... + RecommendedActionCurrentStatePendingRevert RecommendedActionCurrentState = "PendingRevert" + // RecommendedActionCurrentStateResolved ... + RecommendedActionCurrentStateResolved RecommendedActionCurrentState = "Resolved" + // RecommendedActionCurrentStateRevertCancelled ... + RecommendedActionCurrentStateRevertCancelled RecommendedActionCurrentState = "RevertCancelled" + // RecommendedActionCurrentStateReverted ... + RecommendedActionCurrentStateReverted RecommendedActionCurrentState = "Reverted" + // RecommendedActionCurrentStateReverting ... + RecommendedActionCurrentStateReverting RecommendedActionCurrentState = "Reverting" + // RecommendedActionCurrentStateSuccess ... + RecommendedActionCurrentStateSuccess RecommendedActionCurrentState = "Success" + // RecommendedActionCurrentStateVerifying ... + RecommendedActionCurrentStateVerifying RecommendedActionCurrentState = "Verifying" +) + +// PossibleRecommendedActionCurrentStateValues returns an array of possible values for the RecommendedActionCurrentState const type. +func PossibleRecommendedActionCurrentStateValues() []RecommendedActionCurrentState { + return []RecommendedActionCurrentState{RecommendedActionCurrentStateActive, RecommendedActionCurrentStateError, RecommendedActionCurrentStateExecuting, RecommendedActionCurrentStateExpired, RecommendedActionCurrentStateIgnored, RecommendedActionCurrentStateMonitoring, RecommendedActionCurrentStatePending, RecommendedActionCurrentStatePendingRevert, RecommendedActionCurrentStateResolved, RecommendedActionCurrentStateRevertCancelled, RecommendedActionCurrentStateReverted, RecommendedActionCurrentStateReverting, RecommendedActionCurrentStateSuccess, RecommendedActionCurrentStateVerifying} +} + +// RecommendedActionInitiatedBy enumerates the values for recommended action initiated by. +type RecommendedActionInitiatedBy string + +const ( + // RecommendedActionInitiatedBySystem ... + RecommendedActionInitiatedBySystem RecommendedActionInitiatedBy = "System" + // RecommendedActionInitiatedByUser ... + RecommendedActionInitiatedByUser RecommendedActionInitiatedBy = "User" +) + +// PossibleRecommendedActionInitiatedByValues returns an array of possible values for the RecommendedActionInitiatedBy const type. +func PossibleRecommendedActionInitiatedByValues() []RecommendedActionInitiatedBy { + return []RecommendedActionInitiatedBy{RecommendedActionInitiatedBySystem, RecommendedActionInitiatedByUser} +} + +// RecommendedSensitivityLabelUpdateKind enumerates the values for recommended sensitivity label update kind. +type RecommendedSensitivityLabelUpdateKind string + +const ( + // RecommendedSensitivityLabelUpdateKindDisable ... + RecommendedSensitivityLabelUpdateKindDisable RecommendedSensitivityLabelUpdateKind = "disable" + // RecommendedSensitivityLabelUpdateKindEnable ... + RecommendedSensitivityLabelUpdateKindEnable RecommendedSensitivityLabelUpdateKind = "enable" +) + +// PossibleRecommendedSensitivityLabelUpdateKindValues returns an array of possible values for the RecommendedSensitivityLabelUpdateKind const type. +func PossibleRecommendedSensitivityLabelUpdateKindValues() []RecommendedSensitivityLabelUpdateKind { + return []RecommendedSensitivityLabelUpdateKind{RecommendedSensitivityLabelUpdateKindDisable, RecommendedSensitivityLabelUpdateKindEnable} +} + +// ReplicationLinkType enumerates the values for replication link type. +type ReplicationLinkType string + +const ( + // ReplicationLinkTypeGEO ... + ReplicationLinkTypeGEO ReplicationLinkType = "GEO" + // ReplicationLinkTypeNAMED ... + ReplicationLinkTypeNAMED ReplicationLinkType = "NAMED" +) + +// PossibleReplicationLinkTypeValues returns an array of possible values for the ReplicationLinkType const type. +func PossibleReplicationLinkTypeValues() []ReplicationLinkType { + return []ReplicationLinkType{ReplicationLinkTypeGEO, ReplicationLinkTypeNAMED} +} + +// 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 ( + // ReplicationStateCATCHUP ... + ReplicationStateCATCHUP ReplicationState = "CATCH_UP" + // ReplicationStatePENDING ... + ReplicationStatePENDING ReplicationState = "PENDING" + // ReplicationStateSEEDING ... + ReplicationStateSEEDING ReplicationState = "SEEDING" + // ReplicationStateSUSPENDED ... + ReplicationStateSUSPENDED ReplicationState = "SUSPENDED" +) + +// PossibleReplicationStateValues returns an array of possible values for the ReplicationState const type. +func PossibleReplicationStateValues() []ReplicationState { + return []ReplicationState{ReplicationStateCATCHUP, ReplicationStatePENDING, ReplicationStateSEEDING, ReplicationStateSUSPENDED} +} + +// ReplicaType enumerates the values for replica type. +type ReplicaType string + +const ( + // ReplicaTypePrimary ... + ReplicaTypePrimary ReplicaType = "Primary" + // ReplicaTypeReadableSecondary ... + ReplicaTypeReadableSecondary ReplicaType = "ReadableSecondary" +) + +// PossibleReplicaTypeValues returns an array of possible values for the ReplicaType const type. +func PossibleReplicaTypeValues() []ReplicaType { + return []ReplicaType{ReplicaTypePrimary, ReplicaTypeReadableSecondary} +} + +// RequestedBackupStorageRedundancy enumerates the values for requested backup storage redundancy. +type RequestedBackupStorageRedundancy string + +const ( + // RequestedBackupStorageRedundancyGeo ... + RequestedBackupStorageRedundancyGeo RequestedBackupStorageRedundancy = "Geo" + // RequestedBackupStorageRedundancyLocal ... + RequestedBackupStorageRedundancyLocal RequestedBackupStorageRedundancy = "Local" + // RequestedBackupStorageRedundancyZone ... + RequestedBackupStorageRedundancyZone RequestedBackupStorageRedundancy = "Zone" +) + +// PossibleRequestedBackupStorageRedundancyValues returns an array of possible values for the RequestedBackupStorageRedundancy const type. +func PossibleRequestedBackupStorageRedundancyValues() []RequestedBackupStorageRedundancy { + return []RequestedBackupStorageRedundancy{RequestedBackupStorageRedundancyGeo, RequestedBackupStorageRedundancyLocal, RequestedBackupStorageRedundancyZone} +} + +// RestorePointType enumerates the values for restore point type. +type RestorePointType string + +const ( + // RestorePointTypeCONTINUOUS ... + RestorePointTypeCONTINUOUS RestorePointType = "CONTINUOUS" + // RestorePointTypeDISCRETE ... + RestorePointTypeDISCRETE RestorePointType = "DISCRETE" +) + +// PossibleRestorePointTypeValues returns an array of possible values for the RestorePointType const type. +func PossibleRestorePointTypeValues() []RestorePointType { + return []RestorePointType{RestorePointTypeCONTINUOUS, RestorePointTypeDISCRETE} +} + +// SampleName enumerates the values for sample name. +type SampleName string + +const ( + // SampleNameAdventureWorksLT ... + SampleNameAdventureWorksLT SampleName = "AdventureWorksLT" + // SampleNameWideWorldImportersFull ... + SampleNameWideWorldImportersFull SampleName = "WideWorldImportersFull" + // SampleNameWideWorldImportersStd ... + SampleNameWideWorldImportersStd SampleName = "WideWorldImportersStd" +) + +// PossibleSampleNameValues returns an array of possible values for the SampleName const type. +func PossibleSampleNameValues() []SampleName { + return []SampleName{SampleNameAdventureWorksLT, SampleNameWideWorldImportersFull, SampleNameWideWorldImportersStd} +} + +// SecondaryType enumerates the values for secondary type. +type SecondaryType string + +const ( + // SecondaryTypeGeo ... + SecondaryTypeGeo SecondaryType = "Geo" + // SecondaryTypeNamed ... + SecondaryTypeNamed SecondaryType = "Named" +) + +// PossibleSecondaryTypeValues returns an array of possible values for the SecondaryType const type. +func PossibleSecondaryTypeValues() []SecondaryType { + return []SecondaryType{SecondaryTypeGeo, SecondaryTypeNamed} +} + +// 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} +} + +// SecurityAlertsPolicyState enumerates the values for security alerts policy state. +type SecurityAlertsPolicyState string + +const ( + // SecurityAlertsPolicyStateDisabled ... + SecurityAlertsPolicyStateDisabled SecurityAlertsPolicyState = "Disabled" + // SecurityAlertsPolicyStateEnabled ... + SecurityAlertsPolicyStateEnabled SecurityAlertsPolicyState = "Enabled" +) + +// PossibleSecurityAlertsPolicyStateValues returns an array of possible values for the SecurityAlertsPolicyState const type. +func PossibleSecurityAlertsPolicyStateValues() []SecurityAlertsPolicyState { + return []SecurityAlertsPolicyState{SecurityAlertsPolicyStateDisabled, SecurityAlertsPolicyStateEnabled} +} + +// SecurityEventType enumerates the values for security event type. +type SecurityEventType string + +const ( + // SecurityEventTypeSQLInjectionExploit ... + SecurityEventTypeSQLInjectionExploit SecurityEventType = "SqlInjectionExploit" + // SecurityEventTypeSQLInjectionVulnerability ... + SecurityEventTypeSQLInjectionVulnerability SecurityEventType = "SqlInjectionVulnerability" + // SecurityEventTypeUndefined ... + SecurityEventTypeUndefined SecurityEventType = "Undefined" +) + +// PossibleSecurityEventTypeValues returns an array of possible values for the SecurityEventType const type. +func PossibleSecurityEventTypeValues() []SecurityEventType { + return []SecurityEventType{SecurityEventTypeSQLInjectionExploit, SecurityEventTypeSQLInjectionVulnerability, SecurityEventTypeUndefined} +} + +// SensitivityLabelRank enumerates the values for sensitivity label rank. +type SensitivityLabelRank string + +const ( + // SensitivityLabelRankCritical ... + SensitivityLabelRankCritical SensitivityLabelRank = "Critical" + // SensitivityLabelRankHigh ... + SensitivityLabelRankHigh SensitivityLabelRank = "High" + // SensitivityLabelRankLow ... + SensitivityLabelRankLow SensitivityLabelRank = "Low" + // SensitivityLabelRankMedium ... + SensitivityLabelRankMedium SensitivityLabelRank = "Medium" + // SensitivityLabelRankNone ... + SensitivityLabelRankNone SensitivityLabelRank = "None" +) + +// PossibleSensitivityLabelRankValues returns an array of possible values for the SensitivityLabelRank const type. +func PossibleSensitivityLabelRankValues() []SensitivityLabelRank { + return []SensitivityLabelRank{SensitivityLabelRankCritical, SensitivityLabelRankHigh, SensitivityLabelRankLow, SensitivityLabelRankMedium, SensitivityLabelRankNone} +} + +// SensitivityLabelSource enumerates the values for sensitivity label source. +type SensitivityLabelSource string + +const ( + // SensitivityLabelSourceCurrent ... + SensitivityLabelSourceCurrent SensitivityLabelSource = "current" + // SensitivityLabelSourceRecommended ... + SensitivityLabelSourceRecommended SensitivityLabelSource = "recommended" +) + +// PossibleSensitivityLabelSourceValues returns an array of possible values for the SensitivityLabelSource const type. +func PossibleSensitivityLabelSourceValues() []SensitivityLabelSource { + return []SensitivityLabelSource{SensitivityLabelSourceCurrent, SensitivityLabelSourceRecommended} +} + +// SensitivityLabelUpdateKind enumerates the values for sensitivity label update kind. +type SensitivityLabelUpdateKind string + +const ( + // SensitivityLabelUpdateKindRemove ... + SensitivityLabelUpdateKindRemove SensitivityLabelUpdateKind = "remove" + // SensitivityLabelUpdateKindSet ... + SensitivityLabelUpdateKindSet SensitivityLabelUpdateKind = "set" +) + +// PossibleSensitivityLabelUpdateKindValues returns an array of possible values for the SensitivityLabelUpdateKind const type. +func PossibleSensitivityLabelUpdateKindValues() []SensitivityLabelUpdateKind { + return []SensitivityLabelUpdateKind{SensitivityLabelUpdateKindRemove, SensitivityLabelUpdateKindSet} +} + +// 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 ( + // ServerKeyTypeAzureKeyVault ... + ServerKeyTypeAzureKeyVault ServerKeyType = "AzureKeyVault" + // ServerKeyTypeServiceManaged ... + ServerKeyTypeServiceManaged ServerKeyType = "ServiceManaged" +) + +// PossibleServerKeyTypeValues returns an array of possible values for the ServerKeyType const type. +func PossibleServerKeyTypeValues() []ServerKeyType { + return []ServerKeyType{ServerKeyTypeAzureKeyVault, ServerKeyTypeServiceManaged} +} + +// ServerNetworkAccessFlag enumerates the values for server network access flag. +type ServerNetworkAccessFlag string + +const ( + // ServerNetworkAccessFlagDisabled ... + ServerNetworkAccessFlagDisabled ServerNetworkAccessFlag = "Disabled" + // ServerNetworkAccessFlagEnabled ... + ServerNetworkAccessFlagEnabled ServerNetworkAccessFlag = "Enabled" +) + +// PossibleServerNetworkAccessFlagValues returns an array of possible values for the ServerNetworkAccessFlag const type. +func PossibleServerNetworkAccessFlagValues() []ServerNetworkAccessFlag { + return []ServerNetworkAccessFlag{ServerNetworkAccessFlagDisabled, ServerNetworkAccessFlagEnabled} +} + +// ServerWorkspaceFeature enumerates the values for server workspace feature. +type ServerWorkspaceFeature string + +const ( + // ServerWorkspaceFeatureConnected ... + ServerWorkspaceFeatureConnected ServerWorkspaceFeature = "Connected" + // ServerWorkspaceFeatureDisconnected ... + ServerWorkspaceFeatureDisconnected ServerWorkspaceFeature = "Disconnected" +) + +// PossibleServerWorkspaceFeatureValues returns an array of possible values for the ServerWorkspaceFeature const type. +func PossibleServerWorkspaceFeatureValues() []ServerWorkspaceFeature { + return []ServerWorkspaceFeature{ServerWorkspaceFeatureConnected, ServerWorkspaceFeatureDisconnected} +} + +// 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} +} + +// State enumerates the values for state. +type State string + +const ( + // StateDisabled ... + StateDisabled State = "Disabled" + // StateEnabled ... + StateEnabled State = "Enabled" +) + +// PossibleStateValues returns an array of possible values for the State const type. +func PossibleStateValues() []State { + return []State{StateDisabled, StateEnabled} +} + +// Status enumerates the values for status. +type Status string + +const ( + // StatusCanceled ... + StatusCanceled Status = "Canceled" + // StatusCompleted ... + StatusCompleted Status = "Completed" + // StatusFailed ... + StatusFailed Status = "Failed" + // StatusInProgress ... + StatusInProgress Status = "InProgress" + // StatusNotStarted ... + StatusNotStarted Status = "NotStarted" + // StatusSlowedDown ... + StatusSlowedDown Status = "SlowedDown" +) + +// PossibleStatusValues returns an array of possible values for the Status const type. +func PossibleStatusValues() []Status { + return []Status{StatusCanceled, StatusCompleted, StatusFailed, StatusInProgress, StatusNotStarted, StatusSlowedDown} +} + +// Status1 enumerates the values for status 1. +type Status1 string + +const ( + // Status1Failed ... + Status1Failed Status1 = "Failed" + // Status1Succeeded ... + Status1Succeeded Status1 = "Succeeded" +) + +// PossibleStatus1Values returns an array of possible values for the Status1 const type. +func PossibleStatus1Values() []Status1 { + return []Status1{Status1Failed, Status1Succeeded} +} + +// StorageAccountType enumerates the values for storage account type. +type StorageAccountType string + +const ( + // StorageAccountTypeGRS ... + StorageAccountTypeGRS StorageAccountType = "GRS" + // StorageAccountTypeLRS ... + StorageAccountTypeLRS StorageAccountType = "LRS" + // StorageAccountTypeZRS ... + StorageAccountTypeZRS StorageAccountType = "ZRS" +) + +// PossibleStorageAccountTypeValues returns an array of possible values for the StorageAccountType const type. +func PossibleStorageAccountTypeValues() []StorageAccountType { + return []StorageAccountType{StorageAccountTypeGRS, StorageAccountTypeLRS, StorageAccountTypeZRS} +} + +// StorageAccountType1 enumerates the values for storage account type 1. +type StorageAccountType1 string + +const ( + // StorageAccountType1GRS ... + StorageAccountType1GRS StorageAccountType1 = "GRS" + // StorageAccountType1LRS ... + StorageAccountType1LRS StorageAccountType1 = "LRS" + // StorageAccountType1ZRS ... + StorageAccountType1ZRS StorageAccountType1 = "ZRS" +) + +// PossibleStorageAccountType1Values returns an array of possible values for the StorageAccountType1 const type. +func PossibleStorageAccountType1Values() []StorageAccountType1 { + return []StorageAccountType1{StorageAccountType1GRS, StorageAccountType1LRS, StorageAccountType1ZRS} +} + +// StorageKeyType enumerates the values for storage key type. +type StorageKeyType string + +const ( + // StorageKeyTypeSharedAccessKey ... + StorageKeyTypeSharedAccessKey StorageKeyType = "SharedAccessKey" + // StorageKeyTypeStorageAccessKey ... + StorageKeyTypeStorageAccessKey StorageKeyType = "StorageAccessKey" +) + +// PossibleStorageKeyTypeValues returns an array of possible values for the StorageKeyType const type. +func PossibleStorageKeyTypeValues() []StorageKeyType { + return []StorageKeyType{StorageKeyTypeSharedAccessKey, StorageKeyTypeStorageAccessKey} +} + +// 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 ( + // SyncConflictResolutionPolicyHubWin ... + SyncConflictResolutionPolicyHubWin SyncConflictResolutionPolicy = "HubWin" + // SyncConflictResolutionPolicyMemberWin ... + SyncConflictResolutionPolicyMemberWin SyncConflictResolutionPolicy = "MemberWin" +) + +// PossibleSyncConflictResolutionPolicyValues returns an array of possible values for the SyncConflictResolutionPolicy const type. +func PossibleSyncConflictResolutionPolicyValues() []SyncConflictResolutionPolicy { + return []SyncConflictResolutionPolicy{SyncConflictResolutionPolicyHubWin, SyncConflictResolutionPolicyMemberWin} +} + +// SyncDirection enumerates the values for sync direction. +type SyncDirection string + +const ( + // SyncDirectionBidirectional ... + SyncDirectionBidirectional SyncDirection = "Bidirectional" + // SyncDirectionOneWayHubToMember ... + SyncDirectionOneWayHubToMember SyncDirection = "OneWayHubToMember" + // SyncDirectionOneWayMemberToHub ... + SyncDirectionOneWayMemberToHub SyncDirection = "OneWayMemberToHub" +) + +// PossibleSyncDirectionValues returns an array of possible values for the SyncDirection const type. +func PossibleSyncDirectionValues() []SyncDirection { + return []SyncDirection{SyncDirectionBidirectional, SyncDirectionOneWayHubToMember, SyncDirectionOneWayMemberToHub} +} + +// 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 ( + // 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 ( + // SyncMemberDbTypeAzureSQLDatabase ... + SyncMemberDbTypeAzureSQLDatabase SyncMemberDbType = "AzureSqlDatabase" + // SyncMemberDbTypeSQLServerDatabase ... + SyncMemberDbTypeSQLServerDatabase SyncMemberDbType = "SqlServerDatabase" +) + +// PossibleSyncMemberDbTypeValues returns an array of possible values for the SyncMemberDbType const type. +func PossibleSyncMemberDbTypeValues() []SyncMemberDbType { + return []SyncMemberDbType{SyncMemberDbTypeAzureSQLDatabase, SyncMemberDbTypeSQLServerDatabase} +} + +// SyncMemberState enumerates the values for sync member state. +type SyncMemberState string + +const ( + // SyncMemberStateDeProvisioned ... + SyncMemberStateDeProvisioned SyncMemberState = "DeProvisioned" + // SyncMemberStateDeProvisionFailed ... + SyncMemberStateDeProvisionFailed SyncMemberState = "DeProvisionFailed" + // SyncMemberStateDeProvisioning ... + SyncMemberStateDeProvisioning SyncMemberState = "DeProvisioning" + // SyncMemberStateDisabledBackupRestore ... + SyncMemberStateDisabledBackupRestore SyncMemberState = "DisabledBackupRestore" + // SyncMemberStateDisabledTombstoneCleanup ... + SyncMemberStateDisabledTombstoneCleanup SyncMemberState = "DisabledTombstoneCleanup" + // SyncMemberStateProvisioned ... + SyncMemberStateProvisioned SyncMemberState = "Provisioned" + // SyncMemberStateProvisionFailed ... + SyncMemberStateProvisionFailed SyncMemberState = "ProvisionFailed" + // SyncMemberStateProvisioning ... + SyncMemberStateProvisioning SyncMemberState = "Provisioning" + // SyncMemberStateReprovisionFailed ... + SyncMemberStateReprovisionFailed SyncMemberState = "ReprovisionFailed" + // SyncMemberStateReprovisioning ... + SyncMemberStateReprovisioning SyncMemberState = "Reprovisioning" + // SyncMemberStateSyncCancelled ... + SyncMemberStateSyncCancelled SyncMemberState = "SyncCancelled" + // SyncMemberStateSyncCancelling ... + SyncMemberStateSyncCancelling SyncMemberState = "SyncCancelling" + // SyncMemberStateSyncFailed ... + SyncMemberStateSyncFailed SyncMemberState = "SyncFailed" + // SyncMemberStateSyncInProgress ... + SyncMemberStateSyncInProgress SyncMemberState = "SyncInProgress" + // SyncMemberStateSyncSucceeded ... + SyncMemberStateSyncSucceeded SyncMemberState = "SyncSucceeded" + // SyncMemberStateSyncSucceededWithWarnings ... + SyncMemberStateSyncSucceededWithWarnings SyncMemberState = "SyncSucceededWithWarnings" + // SyncMemberStateUnProvisioned ... + SyncMemberStateUnProvisioned SyncMemberState = "UnProvisioned" + // SyncMemberStateUnReprovisioned ... + SyncMemberStateUnReprovisioned SyncMemberState = "UnReprovisioned" +) + +// PossibleSyncMemberStateValues returns an array of possible values for the SyncMemberState const type. +func PossibleSyncMemberStateValues() []SyncMemberState { + return []SyncMemberState{SyncMemberStateDeProvisioned, SyncMemberStateDeProvisionFailed, SyncMemberStateDeProvisioning, SyncMemberStateDisabledBackupRestore, SyncMemberStateDisabledTombstoneCleanup, SyncMemberStateProvisioned, SyncMemberStateProvisionFailed, SyncMemberStateProvisioning, SyncMemberStateReprovisionFailed, SyncMemberStateReprovisioning, SyncMemberStateSyncCancelled, SyncMemberStateSyncCancelling, SyncMemberStateSyncFailed, SyncMemberStateSyncInProgress, SyncMemberStateSyncSucceeded, SyncMemberStateSyncSucceededWithWarnings, SyncMemberStateUnProvisioned, SyncMemberStateUnReprovisioned} +} + +// TableTemporalType enumerates the values for table temporal type. +type TableTemporalType string + +const ( + // TableTemporalTypeHistoryTable ... + TableTemporalTypeHistoryTable TableTemporalType = "HistoryTable" + // TableTemporalTypeNonTemporalTable ... + TableTemporalTypeNonTemporalTable TableTemporalType = "NonTemporalTable" + // TableTemporalTypeSystemVersionedTemporalTable ... + TableTemporalTypeSystemVersionedTemporalTable TableTemporalType = "SystemVersionedTemporalTable" +) + +// PossibleTableTemporalTypeValues returns an array of possible values for the TableTemporalType const type. +func PossibleTableTemporalTypeValues() []TableTemporalType { + return []TableTemporalType{TableTemporalTypeHistoryTable, TableTemporalTypeNonTemporalTable, TableTemporalTypeSystemVersionedTemporalTable} +} + +// TargetBackupStorageRedundancy enumerates the values for target backup storage redundancy. +type TargetBackupStorageRedundancy string + +const ( + // TargetBackupStorageRedundancyGeo ... + TargetBackupStorageRedundancyGeo TargetBackupStorageRedundancy = "Geo" + // TargetBackupStorageRedundancyLocal ... + TargetBackupStorageRedundancyLocal TargetBackupStorageRedundancy = "Local" + // TargetBackupStorageRedundancyZone ... + TargetBackupStorageRedundancyZone TargetBackupStorageRedundancy = "Zone" +) + +// PossibleTargetBackupStorageRedundancyValues returns an array of possible values for the TargetBackupStorageRedundancy const type. +func PossibleTargetBackupStorageRedundancyValues() []TargetBackupStorageRedundancy { + return []TargetBackupStorageRedundancy{TargetBackupStorageRedundancyGeo, TargetBackupStorageRedundancyLocal, TargetBackupStorageRedundancyZone} +} + +// TransparentDataEncryptionActivityStatus enumerates the values for transparent data encryption activity +// status. +type TransparentDataEncryptionActivityStatus string + +const ( + // TransparentDataEncryptionActivityStatusDecrypting ... + TransparentDataEncryptionActivityStatusDecrypting TransparentDataEncryptionActivityStatus = "Decrypting" + // TransparentDataEncryptionActivityStatusEncrypting ... + TransparentDataEncryptionActivityStatusEncrypting TransparentDataEncryptionActivityStatus = "Encrypting" +) + +// PossibleTransparentDataEncryptionActivityStatusValues returns an array of possible values for the TransparentDataEncryptionActivityStatus const type. +func PossibleTransparentDataEncryptionActivityStatusValues() []TransparentDataEncryptionActivityStatus { + return []TransparentDataEncryptionActivityStatus{TransparentDataEncryptionActivityStatusDecrypting, TransparentDataEncryptionActivityStatusEncrypting} +} + +// TransparentDataEncryptionState enumerates the values for transparent data encryption state. +type TransparentDataEncryptionState string + +const ( + // TransparentDataEncryptionStateDisabled ... + TransparentDataEncryptionStateDisabled TransparentDataEncryptionState = "Disabled" + // TransparentDataEncryptionStateEnabled ... + TransparentDataEncryptionStateEnabled TransparentDataEncryptionState = "Enabled" +) + +// PossibleTransparentDataEncryptionStateValues returns an array of possible values for the TransparentDataEncryptionState const type. +func PossibleTransparentDataEncryptionStateValues() []TransparentDataEncryptionState { + return []TransparentDataEncryptionState{TransparentDataEncryptionStateDisabled, TransparentDataEncryptionStateEnabled} +} + +// TransparentDataEncryptionStatus enumerates the values for transparent data encryption status. +type TransparentDataEncryptionStatus string + +const ( + // TransparentDataEncryptionStatusDisabled ... + TransparentDataEncryptionStatusDisabled TransparentDataEncryptionStatus = "Disabled" + // TransparentDataEncryptionStatusEnabled ... + TransparentDataEncryptionStatusEnabled TransparentDataEncryptionStatus = "Enabled" +) + +// PossibleTransparentDataEncryptionStatusValues returns an array of possible values for the TransparentDataEncryptionStatus const type. +func PossibleTransparentDataEncryptionStatusValues() []TransparentDataEncryptionStatus { + return []TransparentDataEncryptionStatus{TransparentDataEncryptionStatusDisabled, TransparentDataEncryptionStatusEnabled} +} + +// UnitDefinitionType enumerates the values for unit definition type. +type UnitDefinitionType string + +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" + // VirtualNetworkRuleStateFailed ... + VirtualNetworkRuleStateFailed VirtualNetworkRuleState = "Failed" + // 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, VirtualNetworkRuleStateFailed, VirtualNetworkRuleStateInitializing, VirtualNetworkRuleStateInProgress, VirtualNetworkRuleStateReady, VirtualNetworkRuleStateUnknown} +} + +// VulnerabilityAssessmentPolicyBaselineName enumerates the values for vulnerability assessment policy baseline +// name. +type VulnerabilityAssessmentPolicyBaselineName string + +const ( + // VulnerabilityAssessmentPolicyBaselineNameDefault ... + VulnerabilityAssessmentPolicyBaselineNameDefault VulnerabilityAssessmentPolicyBaselineName = "default" + // VulnerabilityAssessmentPolicyBaselineNameMaster ... + VulnerabilityAssessmentPolicyBaselineNameMaster VulnerabilityAssessmentPolicyBaselineName = "master" +) + +// PossibleVulnerabilityAssessmentPolicyBaselineNameValues returns an array of possible values for the VulnerabilityAssessmentPolicyBaselineName const type. +func PossibleVulnerabilityAssessmentPolicyBaselineNameValues() []VulnerabilityAssessmentPolicyBaselineName { + return []VulnerabilityAssessmentPolicyBaselineName{VulnerabilityAssessmentPolicyBaselineNameDefault, VulnerabilityAssessmentPolicyBaselineNameMaster} +} + +// VulnerabilityAssessmentScanState enumerates the values for vulnerability assessment scan state. +type VulnerabilityAssessmentScanState string + +const ( + // VulnerabilityAssessmentScanStateFailed ... + VulnerabilityAssessmentScanStateFailed VulnerabilityAssessmentScanState = "Failed" + // VulnerabilityAssessmentScanStateFailedToRun ... + VulnerabilityAssessmentScanStateFailedToRun VulnerabilityAssessmentScanState = "FailedToRun" + // VulnerabilityAssessmentScanStateInProgress ... + VulnerabilityAssessmentScanStateInProgress VulnerabilityAssessmentScanState = "InProgress" + // VulnerabilityAssessmentScanStatePassed ... + VulnerabilityAssessmentScanStatePassed VulnerabilityAssessmentScanState = "Passed" +) + +// PossibleVulnerabilityAssessmentScanStateValues returns an array of possible values for the VulnerabilityAssessmentScanState const type. +func PossibleVulnerabilityAssessmentScanStateValues() []VulnerabilityAssessmentScanState { + return []VulnerabilityAssessmentScanState{VulnerabilityAssessmentScanStateFailed, VulnerabilityAssessmentScanStateFailedToRun, VulnerabilityAssessmentScanStateInProgress, VulnerabilityAssessmentScanStatePassed} +} + +// VulnerabilityAssessmentScanTriggerType enumerates the values for vulnerability assessment scan trigger type. +type VulnerabilityAssessmentScanTriggerType string + +const ( + // VulnerabilityAssessmentScanTriggerTypeOnDemand ... + VulnerabilityAssessmentScanTriggerTypeOnDemand VulnerabilityAssessmentScanTriggerType = "OnDemand" + // VulnerabilityAssessmentScanTriggerTypeRecurring ... + VulnerabilityAssessmentScanTriggerTypeRecurring VulnerabilityAssessmentScanTriggerType = "Recurring" +) + +// PossibleVulnerabilityAssessmentScanTriggerTypeValues returns an array of possible values for the VulnerabilityAssessmentScanTriggerType const type. +func PossibleVulnerabilityAssessmentScanTriggerTypeValues() []VulnerabilityAssessmentScanTriggerType { + return []VulnerabilityAssessmentScanTriggerType{VulnerabilityAssessmentScanTriggerTypeOnDemand, VulnerabilityAssessmentScanTriggerTypeRecurring} +} diff --git a/services/preview/sql/mgmt/v5.0/sql/extendeddatabaseblobauditingpolicies.go b/services/preview/sql/mgmt/v5.0/sql/extendeddatabaseblobauditingpolicies.go new file mode 100644 index 000000000000..31fbb81916b2 --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/extendeddatabaseblobauditingpolicies.go @@ -0,0 +1,319 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ExtendedDatabaseBlobAuditingPoliciesClient is the the Azure SQL Database management API provides a RESTful set of +// web services that interact with Azure SQL Database services to manage your databases. The API enables you to create, +// retrieve, update, and delete databases. +type ExtendedDatabaseBlobAuditingPoliciesClient struct { + BaseClient +} + +// NewExtendedDatabaseBlobAuditingPoliciesClient creates an instance of the ExtendedDatabaseBlobAuditingPoliciesClient +// client. +func NewExtendedDatabaseBlobAuditingPoliciesClient(subscriptionID string) ExtendedDatabaseBlobAuditingPoliciesClient { + return NewExtendedDatabaseBlobAuditingPoliciesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewExtendedDatabaseBlobAuditingPoliciesClientWithBaseURI creates an instance of the +// ExtendedDatabaseBlobAuditingPoliciesClient client using a custom endpoint. Use this when interacting with an Azure +// cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewExtendedDatabaseBlobAuditingPoliciesClientWithBaseURI(baseURI string, subscriptionID string) ExtendedDatabaseBlobAuditingPoliciesClient { + return ExtendedDatabaseBlobAuditingPoliciesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates an extended database's blob auditing policy. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database. +// parameters - the extended database blob auditing policy. +func (client ExtendedDatabaseBlobAuditingPoliciesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters ExtendedDatabaseBlobAuditingPolicy) (result ExtendedDatabaseBlobAuditingPolicy, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ExtendedDatabaseBlobAuditingPoliciesClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, databaseName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ExtendedDatabaseBlobAuditingPoliciesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ExtendedDatabaseBlobAuditingPoliciesClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ExtendedDatabaseBlobAuditingPoliciesClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ExtendedDatabaseBlobAuditingPoliciesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters ExtendedDatabaseBlobAuditingPolicy) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "blobAuditingPolicyName": autorest.Encode("path", "default"), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/extendedAuditingSettings/{blobAuditingPolicyName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client ExtendedDatabaseBlobAuditingPoliciesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ExtendedDatabaseBlobAuditingPoliciesClient) CreateOrUpdateResponder(resp *http.Response) (result ExtendedDatabaseBlobAuditingPolicy, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets an extended database's blob auditing policy. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database. +func (client ExtendedDatabaseBlobAuditingPoliciesClient) Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result ExtendedDatabaseBlobAuditingPolicy, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ExtendedDatabaseBlobAuditingPoliciesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ExtendedDatabaseBlobAuditingPoliciesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ExtendedDatabaseBlobAuditingPoliciesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ExtendedDatabaseBlobAuditingPoliciesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ExtendedDatabaseBlobAuditingPoliciesClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "blobAuditingPolicyName": autorest.Encode("path", "default"), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/extendedAuditingSettings/{blobAuditingPolicyName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ExtendedDatabaseBlobAuditingPoliciesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ExtendedDatabaseBlobAuditingPoliciesClient) GetResponder(resp *http.Response) (result ExtendedDatabaseBlobAuditingPolicy, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByDatabase lists extended auditing settings of a database. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database. +func (client ExtendedDatabaseBlobAuditingPoliciesClient) ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result ExtendedDatabaseBlobAuditingPolicyListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ExtendedDatabaseBlobAuditingPoliciesClient.ListByDatabase") + defer func() { + sc := -1 + if result.edbaplr.Response.Response != nil { + sc = result.edbaplr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByDatabaseNextResults + req, err := client.ListByDatabasePreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ExtendedDatabaseBlobAuditingPoliciesClient", "ListByDatabase", nil, "Failure preparing request") + return + } + + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.edbaplr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ExtendedDatabaseBlobAuditingPoliciesClient", "ListByDatabase", resp, "Failure sending request") + return + } + + result.edbaplr, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ExtendedDatabaseBlobAuditingPoliciesClient", "ListByDatabase", resp, "Failure responding to request") + return + } + if result.edbaplr.hasNextLink() && result.edbaplr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByDatabasePreparer prepares the ListByDatabase request. +func (client ExtendedDatabaseBlobAuditingPoliciesClient) ListByDatabasePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/extendedAuditingSettings", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByDatabaseSender sends the ListByDatabase request. The method will close the +// http.Response Body if it receives an error. +func (client ExtendedDatabaseBlobAuditingPoliciesClient) ListByDatabaseSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByDatabaseResponder handles the response to the ListByDatabase request. The method always +// closes the http.Response Body. +func (client ExtendedDatabaseBlobAuditingPoliciesClient) ListByDatabaseResponder(resp *http.Response) (result ExtendedDatabaseBlobAuditingPolicyListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByDatabaseNextResults retrieves the next set of results, if any. +func (client ExtendedDatabaseBlobAuditingPoliciesClient) listByDatabaseNextResults(ctx context.Context, lastResults ExtendedDatabaseBlobAuditingPolicyListResult) (result ExtendedDatabaseBlobAuditingPolicyListResult, err error) { + req, err := lastResults.extendedDatabaseBlobAuditingPolicyListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.ExtendedDatabaseBlobAuditingPoliciesClient", "listByDatabaseNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.ExtendedDatabaseBlobAuditingPoliciesClient", "listByDatabaseNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ExtendedDatabaseBlobAuditingPoliciesClient", "listByDatabaseNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByDatabaseComplete enumerates all values, automatically crossing page boundaries as required. +func (client ExtendedDatabaseBlobAuditingPoliciesClient) ListByDatabaseComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result ExtendedDatabaseBlobAuditingPolicyListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ExtendedDatabaseBlobAuditingPoliciesClient.ListByDatabase") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByDatabase(ctx, resourceGroupName, serverName, databaseName) + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/extendedserverblobauditingpolicies.go b/services/preview/sql/mgmt/v5.0/sql/extendedserverblobauditingpolicies.go new file mode 100644 index 000000000000..d4819d7e7082 --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/extendedserverblobauditingpolicies.go @@ -0,0 +1,315 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ExtendedServerBlobAuditingPoliciesClient is the the Azure SQL Database management API provides a RESTful set of web +// services that interact with Azure SQL Database services to manage your databases. The API enables you to create, +// retrieve, update, and delete databases. +type ExtendedServerBlobAuditingPoliciesClient struct { + BaseClient +} + +// NewExtendedServerBlobAuditingPoliciesClient creates an instance of the ExtendedServerBlobAuditingPoliciesClient +// client. +func NewExtendedServerBlobAuditingPoliciesClient(subscriptionID string) ExtendedServerBlobAuditingPoliciesClient { + return NewExtendedServerBlobAuditingPoliciesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewExtendedServerBlobAuditingPoliciesClientWithBaseURI creates an instance of the +// ExtendedServerBlobAuditingPoliciesClient client using a custom endpoint. Use this when interacting with an Azure +// cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewExtendedServerBlobAuditingPoliciesClientWithBaseURI(baseURI string, subscriptionID string) ExtendedServerBlobAuditingPoliciesClient { + return ExtendedServerBlobAuditingPoliciesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates an extended server's blob auditing policy. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// parameters - properties of extended blob auditing policy +func (client ExtendedServerBlobAuditingPoliciesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, parameters ExtendedServerBlobAuditingPolicy) (result ExtendedServerBlobAuditingPoliciesCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ExtendedServerBlobAuditingPoliciesClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ExtendedServerBlobAuditingPoliciesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ExtendedServerBlobAuditingPoliciesClient", "CreateOrUpdate", nil, "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ExtendedServerBlobAuditingPoliciesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, parameters ExtendedServerBlobAuditingPolicy) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "blobAuditingPolicyName": autorest.Encode("path", "default"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/extendedAuditingSettings/{blobAuditingPolicyName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client ExtendedServerBlobAuditingPoliciesClient) CreateOrUpdateSender(req *http.Request) (future ExtendedServerBlobAuditingPoliciesCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ExtendedServerBlobAuditingPoliciesClient) CreateOrUpdateResponder(resp *http.Response) (result ExtendedServerBlobAuditingPolicy, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets an extended server's blob auditing policy. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +func (client ExtendedServerBlobAuditingPoliciesClient) Get(ctx context.Context, resourceGroupName string, serverName string) (result ExtendedServerBlobAuditingPolicy, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ExtendedServerBlobAuditingPoliciesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ExtendedServerBlobAuditingPoliciesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ExtendedServerBlobAuditingPoliciesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ExtendedServerBlobAuditingPoliciesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ExtendedServerBlobAuditingPoliciesClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "blobAuditingPolicyName": autorest.Encode("path", "default"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/extendedAuditingSettings/{blobAuditingPolicyName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ExtendedServerBlobAuditingPoliciesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ExtendedServerBlobAuditingPoliciesClient) GetResponder(resp *http.Response) (result ExtendedServerBlobAuditingPolicy, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer lists extended auditing settings of a server. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +func (client ExtendedServerBlobAuditingPoliciesClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result ExtendedServerBlobAuditingPolicyListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ExtendedServerBlobAuditingPoliciesClient.ListByServer") + defer func() { + sc := -1 + if result.esbaplr.Response.Response != nil { + sc = result.esbaplr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByServerNextResults + req, err := client.ListByServerPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ExtendedServerBlobAuditingPoliciesClient", "ListByServer", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServerSender(req) + if err != nil { + result.esbaplr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ExtendedServerBlobAuditingPoliciesClient", "ListByServer", resp, "Failure sending request") + return + } + + result.esbaplr, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ExtendedServerBlobAuditingPoliciesClient", "ListByServer", resp, "Failure responding to request") + return + } + if result.esbaplr.hasNextLink() && result.esbaplr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServerPreparer prepares the ListByServer request. +func (client ExtendedServerBlobAuditingPoliciesClient) ListByServerPreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/extendedAuditingSettings", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByServerSender sends the ListByServer request. The method will close the +// http.Response Body if it receives an error. +func (client ExtendedServerBlobAuditingPoliciesClient) ListByServerSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client ExtendedServerBlobAuditingPoliciesClient) ListByServerResponder(resp *http.Response) (result ExtendedServerBlobAuditingPolicyListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByServerNextResults retrieves the next set of results, if any. +func (client ExtendedServerBlobAuditingPoliciesClient) listByServerNextResults(ctx context.Context, lastResults ExtendedServerBlobAuditingPolicyListResult) (result ExtendedServerBlobAuditingPolicyListResult, err error) { + req, err := lastResults.extendedServerBlobAuditingPolicyListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.ExtendedServerBlobAuditingPoliciesClient", "listByServerNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByServerSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.ExtendedServerBlobAuditingPoliciesClient", "listByServerNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ExtendedServerBlobAuditingPoliciesClient", "listByServerNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServerComplete enumerates all values, automatically crossing page boundaries as required. +func (client ExtendedServerBlobAuditingPoliciesClient) ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result ExtendedServerBlobAuditingPolicyListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ExtendedServerBlobAuditingPoliciesClient.ListByServer") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByServer(ctx, resourceGroupName, serverName) + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/failovergroups.go b/services/preview/sql/mgmt/v5.0/sql/failovergroups.go new file mode 100644 index 000000000000..66e326df4ec4 --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/failovergroups.go @@ -0,0 +1,653 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// FailoverGroupsClient is the the Azure SQL Database management API provides a RESTful set of web services that +// interact with Azure SQL Database services to manage your databases. The API enables you to create, retrieve, update, +// and delete databases. +type FailoverGroupsClient struct { + BaseClient +} + +// NewFailoverGroupsClient creates an instance of the FailoverGroupsClient client. +func NewFailoverGroupsClient(subscriptionID string) FailoverGroupsClient { + return NewFailoverGroupsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewFailoverGroupsClientWithBaseURI creates an instance of the FailoverGroupsClient client using a custom endpoint. +// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewFailoverGroupsClientWithBaseURI(baseURI string, subscriptionID string) FailoverGroupsClient { + return FailoverGroupsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a failover group. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server containing the failover group. +// failoverGroupName - the name of the failover group. +// parameters - the failover group parameters. +func (client FailoverGroupsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, failoverGroupName string, parameters FailoverGroup) (result FailoverGroupsCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/FailoverGroupsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.FailoverGroupProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.FailoverGroupProperties.ReadWriteEndpoint", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.FailoverGroupProperties.PartnerServers", Name: validation.Null, Rule: true, Chain: nil}, + }}}}}); err != nil { + return result, validation.NewError("sql.FailoverGroupsClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, failoverGroupName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsClient", "CreateOrUpdate", nil, "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 = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + parameters.Location = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/failoverGroups/{failoverGroupName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client FailoverGroupsClient) CreateOrUpdateSender(req *http.Request) (future FailoverGroupsCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client FailoverGroupsClient) CreateOrUpdateResponder(resp *http.Response) (result FailoverGroup, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a failover group. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server containing the failover group. +// failoverGroupName - the name of the failover group. +func (client FailoverGroupsClient) Delete(ctx context.Context, resourceGroupName string, serverName string, failoverGroupName string) (result FailoverGroupsDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/FailoverGroupsClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, serverName, failoverGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsClient", "Delete", nil, "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 = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/failoverGroups/{failoverGroupName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client FailoverGroupsClient) DeleteSender(req *http.Request) (future FailoverGroupsDeleteFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client FailoverGroupsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Failover fails over from the current primary server to this server. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server containing the failover group. +// failoverGroupName - the name of the failover group. +func (client FailoverGroupsClient) Failover(ctx context.Context, resourceGroupName string, serverName string, failoverGroupName string) (result FailoverGroupsFailoverFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/FailoverGroupsClient.Failover") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.FailoverPreparer(ctx, resourceGroupName, serverName, failoverGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsClient", "Failover", nil, "Failure preparing request") + return + } + + result, err = client.FailoverSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsClient", "Failover", nil, "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 = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/failoverGroups/{failoverGroupName}/failover", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// FailoverSender sends the Failover request. The method will close the +// http.Response Body if it receives an error. +func (client FailoverGroupsClient) FailoverSender(req *http.Request) (future FailoverGroupsFailoverFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// FailoverResponder handles the response to the Failover request. The method always +// closes the http.Response Body. +func (client FailoverGroupsClient) FailoverResponder(resp *http.Response) (result FailoverGroup, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ForceFailoverAllowDataLoss fails over from the current primary server to this server. This operation might result in +// data loss. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server containing the failover group. +// failoverGroupName - the name of the failover group. +func (client FailoverGroupsClient) ForceFailoverAllowDataLoss(ctx context.Context, resourceGroupName string, serverName string, failoverGroupName string) (result FailoverGroupsForceFailoverAllowDataLossFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/FailoverGroupsClient.ForceFailoverAllowDataLoss") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ForceFailoverAllowDataLossPreparer(ctx, resourceGroupName, serverName, failoverGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsClient", "ForceFailoverAllowDataLoss", nil, "Failure preparing request") + return + } + + result, err = client.ForceFailoverAllowDataLossSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsClient", "ForceFailoverAllowDataLoss", nil, "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 = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/failoverGroups/{failoverGroupName}/forceFailoverAllowDataLoss", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ForceFailoverAllowDataLossSender sends the ForceFailoverAllowDataLoss request. The method will close the +// http.Response Body if it receives an error. +func (client FailoverGroupsClient) ForceFailoverAllowDataLossSender(req *http.Request) (future FailoverGroupsForceFailoverAllowDataLossFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// ForceFailoverAllowDataLossResponder handles the response to the ForceFailoverAllowDataLoss request. The method always +// closes the http.Response Body. +func (client FailoverGroupsClient) ForceFailoverAllowDataLossResponder(resp *http.Response) (result FailoverGroup, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets a failover group. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server containing the failover group. +// failoverGroupName - the name of the failover group. +func (client FailoverGroupsClient) Get(ctx context.Context, resourceGroupName string, serverName string, failoverGroupName string) (result FailoverGroup, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/FailoverGroupsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, failoverGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client FailoverGroupsClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, failoverGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "failoverGroupName": autorest.Encode("path", failoverGroupName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/failoverGroups/{failoverGroupName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client FailoverGroupsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client FailoverGroupsClient) GetResponder(resp *http.Response) (result FailoverGroup, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer lists the failover groups in a server. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server containing the failover group. +func (client FailoverGroupsClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result FailoverGroupListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/FailoverGroupsClient.ListByServer") + defer func() { + sc := -1 + if result.fglr.Response.Response != nil { + sc = result.fglr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByServerNextResults + req, err := client.ListByServerPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsClient", "ListByServer", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServerSender(req) + if err != nil { + result.fglr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsClient", "ListByServer", resp, "Failure sending request") + return + } + + result.fglr, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsClient", "ListByServer", resp, "Failure responding to request") + return + } + if result.fglr.hasNextLink() && result.fglr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServerPreparer prepares the ListByServer request. +func (client FailoverGroupsClient) ListByServerPreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/failoverGroups", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByServerSender sends the ListByServer request. The method will close the +// http.Response Body if it receives an error. +func (client FailoverGroupsClient) ListByServerSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client FailoverGroupsClient) ListByServerResponder(resp *http.Response) (result FailoverGroupListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByServerNextResults retrieves the next set of results, if any. +func (client FailoverGroupsClient) listByServerNextResults(ctx context.Context, lastResults FailoverGroupListResult) (result FailoverGroupListResult, err error) { + req, err := lastResults.failoverGroupListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.FailoverGroupsClient", "listByServerNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByServerSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.FailoverGroupsClient", "listByServerNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsClient", "listByServerNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServerComplete enumerates all values, automatically crossing page boundaries as required. +func (client FailoverGroupsClient) ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result FailoverGroupListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/FailoverGroupsClient.ListByServer") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByServer(ctx, resourceGroupName, serverName) + return +} + +// Update updates a failover group. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server containing the failover group. +// failoverGroupName - the name of the failover group. +// parameters - the failover group parameters. +func (client FailoverGroupsClient) Update(ctx context.Context, resourceGroupName string, serverName string, failoverGroupName string, parameters FailoverGroupUpdate) (result FailoverGroupsUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/FailoverGroupsClient.Update") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.UpdatePreparer(ctx, resourceGroupName, serverName, failoverGroupName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsClient", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsClient", "Update", nil, "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 = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/failoverGroups/{failoverGroupName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client FailoverGroupsClient) UpdateSender(req *http.Request) (future FailoverGroupsUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client FailoverGroupsClient) UpdateResponder(resp *http.Response) (result FailoverGroup, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/firewallrules.go b/services/preview/sql/mgmt/v5.0/sql/firewallrules.go new file mode 100644 index 000000000000..d50038fb0e8d --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/firewallrules.go @@ -0,0 +1,470 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// FirewallRulesClient is the the Azure SQL Database management API provides a RESTful set of web services that +// interact with Azure SQL Database services to manage your databases. The API enables you to create, retrieve, update, +// and delete databases. +type FirewallRulesClient struct { + BaseClient +} + +// NewFirewallRulesClient creates an instance of the FirewallRulesClient client. +func NewFirewallRulesClient(subscriptionID string) FirewallRulesClient { + return NewFirewallRulesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewFirewallRulesClientWithBaseURI creates an instance of the FirewallRulesClient client using a custom endpoint. +// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewFirewallRulesClientWithBaseURI(baseURI string, subscriptionID string) FirewallRulesClient { + return FirewallRulesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a firewall rule. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// firewallRuleName - the name of the firewall rule. +// parameters - the required parameters for creating or updating a firewall rule. +func (client FirewallRulesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, firewallRuleName string, parameters FirewallRule) (result FirewallRule, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/FirewallRulesClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, firewallRuleName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FirewallRulesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.FirewallRulesClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FirewallRulesClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client FirewallRulesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, firewallRuleName string, parameters FirewallRule) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "firewallRuleName": autorest.Encode("path", firewallRuleName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/firewallRules/{firewallRuleName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client FirewallRulesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client FirewallRulesClient) CreateOrUpdateResponder(resp *http.Response) (result FirewallRule, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a firewall rule. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// firewallRuleName - the name of the firewall rule. +func (client FirewallRulesClient) Delete(ctx context.Context, resourceGroupName string, serverName string, firewallRuleName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/FirewallRulesClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, serverName, firewallRuleName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FirewallRulesClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "sql.FirewallRulesClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FirewallRulesClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client FirewallRulesClient) DeletePreparer(ctx context.Context, resourceGroupName string, serverName string, firewallRuleName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "firewallRuleName": autorest.Encode("path", firewallRuleName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/firewallRules/{firewallRuleName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client FirewallRulesClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client FirewallRulesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a firewall rule. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// firewallRuleName - the name of the firewall rule. +func (client FirewallRulesClient) Get(ctx context.Context, resourceGroupName string, serverName string, firewallRuleName string) (result FirewallRule, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/FirewallRulesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, firewallRuleName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FirewallRulesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.FirewallRulesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FirewallRulesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client FirewallRulesClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, firewallRuleName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "firewallRuleName": autorest.Encode("path", firewallRuleName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/firewallRules/{firewallRuleName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client FirewallRulesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client FirewallRulesClient) GetResponder(resp *http.Response) (result FirewallRule, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer gets a list of firewall rules. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +func (client FirewallRulesClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result FirewallRuleListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/FirewallRulesClient.ListByServer") + defer func() { + sc := -1 + if result.frlr.Response.Response != nil { + sc = result.frlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByServerNextResults + req, err := client.ListByServerPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FirewallRulesClient", "ListByServer", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServerSender(req) + if err != nil { + result.frlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.FirewallRulesClient", "ListByServer", resp, "Failure sending request") + return + } + + result.frlr, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FirewallRulesClient", "ListByServer", resp, "Failure responding to request") + return + } + if result.frlr.hasNextLink() && result.frlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServerPreparer prepares the ListByServer request. +func (client FirewallRulesClient) ListByServerPreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/firewallRules", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByServerSender sends the ListByServer request. The method will close the +// http.Response Body if it receives an error. +func (client FirewallRulesClient) ListByServerSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client FirewallRulesClient) ListByServerResponder(resp *http.Response) (result FirewallRuleListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByServerNextResults retrieves the next set of results, if any. +func (client FirewallRulesClient) listByServerNextResults(ctx context.Context, lastResults FirewallRuleListResult) (result FirewallRuleListResult, err error) { + req, err := lastResults.firewallRuleListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.FirewallRulesClient", "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.FirewallRulesClient", "listByServerNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FirewallRulesClient", "listByServerNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServerComplete enumerates all values, automatically crossing page boundaries as required. +func (client FirewallRulesClient) ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result FirewallRuleListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/FirewallRulesClient.ListByServer") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByServer(ctx, resourceGroupName, serverName) + return +} + +// Replace replaces all firewall rules on the server. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +func (client FirewallRulesClient) Replace(ctx context.Context, resourceGroupName string, serverName string, parameters FirewallRuleList) (result FirewallRule, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/FirewallRulesClient.Replace") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ReplacePreparer(ctx, resourceGroupName, serverName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FirewallRulesClient", "Replace", nil, "Failure preparing request") + return + } + + resp, err := client.ReplaceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.FirewallRulesClient", "Replace", resp, "Failure sending request") + return + } + + result, err = client.ReplaceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FirewallRulesClient", "Replace", resp, "Failure responding to request") + return + } + + return +} + +// ReplacePreparer prepares the Replace request. +func (client FirewallRulesClient) ReplacePreparer(ctx context.Context, resourceGroupName string, serverName string, parameters FirewallRuleList) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/firewallRules", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ReplaceSender sends the Replace request. The method will close the +// http.Response Body if it receives an error. +func (client FirewallRulesClient) ReplaceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ReplaceResponder handles the response to the Replace request. The method always +// closes the http.Response Body. +func (client FirewallRulesClient) ReplaceResponder(resp *http.Response) (result FirewallRule, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/geobackuppolicies.go b/services/preview/sql/mgmt/v5.0/sql/geobackuppolicies.go new file mode 100644 index 000000000000..605603cc5f04 --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/geobackuppolicies.go @@ -0,0 +1,285 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// GeoBackupPoliciesClient is the the Azure SQL Database management API provides a RESTful set of web services that +// interact with Azure SQL Database services to manage your databases. The API enables you to create, retrieve, update, +// and delete databases. +type GeoBackupPoliciesClient struct { + BaseClient +} + +// NewGeoBackupPoliciesClient creates an instance of the GeoBackupPoliciesClient client. +func NewGeoBackupPoliciesClient(subscriptionID string) GeoBackupPoliciesClient { + return NewGeoBackupPoliciesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewGeoBackupPoliciesClientWithBaseURI creates an instance of the GeoBackupPoliciesClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewGeoBackupPoliciesClientWithBaseURI(baseURI string, subscriptionID string) GeoBackupPoliciesClient { + return GeoBackupPoliciesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate updates a database geo backup policy. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database. +// parameters - the required parameters for creating or updating the geo backup policy. +func (client GeoBackupPoliciesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters GeoBackupPolicy) (result GeoBackupPolicy, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GeoBackupPoliciesClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.GeoBackupPolicyProperties", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewError("sql.GeoBackupPoliciesClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, databaseName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.GeoBackupPoliciesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.GeoBackupPoliciesClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.GeoBackupPoliciesClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client GeoBackupPoliciesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters GeoBackupPolicy) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "geoBackupPolicyName": autorest.Encode("path", "Default"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + parameters.Kind = nil + parameters.Location = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/geoBackupPolicies/{geoBackupPolicyName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client GeoBackupPoliciesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client GeoBackupPoliciesClient) CreateOrUpdateResponder(resp *http.Response) (result GeoBackupPolicy, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets a geo backup policy. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database. +func (client GeoBackupPoliciesClient) Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result GeoBackupPolicy, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GeoBackupPoliciesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.GeoBackupPoliciesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.GeoBackupPoliciesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.GeoBackupPoliciesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client GeoBackupPoliciesClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "geoBackupPolicyName": autorest.Encode("path", "Default"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/geoBackupPolicies/{geoBackupPolicyName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client GeoBackupPoliciesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client GeoBackupPoliciesClient) GetResponder(resp *http.Response) (result GeoBackupPolicy, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByDatabase returns a list of geo backup policies. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database. +func (client GeoBackupPoliciesClient) ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result GeoBackupPolicyListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GeoBackupPoliciesClient.ListByDatabase") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListByDatabasePreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.GeoBackupPoliciesClient", "ListByDatabase", nil, "Failure preparing request") + return + } + + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.GeoBackupPoliciesClient", "ListByDatabase", resp, "Failure sending request") + return + } + + result, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.GeoBackupPoliciesClient", "ListByDatabase", resp, "Failure responding to request") + return + } + + return +} + +// ListByDatabasePreparer prepares the ListByDatabase request. +func (client GeoBackupPoliciesClient) ListByDatabasePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/geoBackupPolicies", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByDatabaseSender sends the ListByDatabase request. The method will close the +// http.Response Body if it receives an error. +func (client GeoBackupPoliciesClient) ListByDatabaseSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByDatabaseResponder handles the response to the ListByDatabase request. The method always +// closes the http.Response Body. +func (client GeoBackupPoliciesClient) ListByDatabaseResponder(resp *http.Response) (result GeoBackupPolicyListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/instancefailovergroups.go b/services/preview/sql/mgmt/v5.0/sql/instancefailovergroups.go new file mode 100644 index 000000000000..b5aa1d578324 --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/instancefailovergroups.go @@ -0,0 +1,570 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// InstanceFailoverGroupsClient is the the Azure SQL Database management API provides a RESTful set of web services +// that interact with Azure SQL Database services to manage your databases. The API enables you to create, retrieve, +// update, and delete databases. +type InstanceFailoverGroupsClient struct { + BaseClient +} + +// NewInstanceFailoverGroupsClient creates an instance of the InstanceFailoverGroupsClient client. +func NewInstanceFailoverGroupsClient(subscriptionID string) InstanceFailoverGroupsClient { + return NewInstanceFailoverGroupsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewInstanceFailoverGroupsClientWithBaseURI creates an instance of the InstanceFailoverGroupsClient client using a +// custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, +// Azure stack). +func NewInstanceFailoverGroupsClientWithBaseURI(baseURI string, subscriptionID string) InstanceFailoverGroupsClient { + return InstanceFailoverGroupsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a failover group. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// locationName - the name of the region where the resource is located. +// failoverGroupName - the name of the failover group. +// parameters - the failover group parameters. +func (client InstanceFailoverGroupsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, locationName string, failoverGroupName string, parameters InstanceFailoverGroup) (result InstanceFailoverGroupsCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/InstanceFailoverGroupsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.InstanceFailoverGroupProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.InstanceFailoverGroupProperties.ReadWriteEndpoint", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.InstanceFailoverGroupProperties.PartnerRegions", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.InstanceFailoverGroupProperties.ManagedInstancePairs", Name: validation.Null, Rule: true, Chain: nil}, + }}}}}); err != nil { + return result, validation.NewError("sql.InstanceFailoverGroupsClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, locationName, failoverGroupName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsClient", "CreateOrUpdate", nil, "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 = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/instanceFailoverGroups/{failoverGroupName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client InstanceFailoverGroupsClient) CreateOrUpdateSender(req *http.Request) (future InstanceFailoverGroupsCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client InstanceFailoverGroupsClient) CreateOrUpdateResponder(resp *http.Response) (result InstanceFailoverGroup, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a failover group. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// locationName - the name of the region where the resource is located. +// failoverGroupName - the name of the failover group. +func (client InstanceFailoverGroupsClient) Delete(ctx context.Context, resourceGroupName string, locationName string, failoverGroupName string) (result InstanceFailoverGroupsDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/InstanceFailoverGroupsClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, locationName, failoverGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsClient", "Delete", nil, "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 = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/instanceFailoverGroups/{failoverGroupName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client InstanceFailoverGroupsClient) DeleteSender(req *http.Request) (future InstanceFailoverGroupsDeleteFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client InstanceFailoverGroupsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Failover fails over from the current primary managed instance to this managed instance. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// locationName - the name of the region where the resource is located. +// failoverGroupName - the name of the failover group. +func (client InstanceFailoverGroupsClient) Failover(ctx context.Context, resourceGroupName string, locationName string, failoverGroupName string) (result InstanceFailoverGroupsFailoverFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/InstanceFailoverGroupsClient.Failover") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.FailoverPreparer(ctx, resourceGroupName, locationName, failoverGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsClient", "Failover", nil, "Failure preparing request") + return + } + + result, err = client.FailoverSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsClient", "Failover", nil, "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 = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/instanceFailoverGroups/{failoverGroupName}/failover", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// FailoverSender sends the Failover request. The method will close the +// http.Response Body if it receives an error. +func (client InstanceFailoverGroupsClient) FailoverSender(req *http.Request) (future InstanceFailoverGroupsFailoverFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// FailoverResponder handles the response to the Failover request. The method always +// closes the http.Response Body. +func (client InstanceFailoverGroupsClient) FailoverResponder(resp *http.Response) (result InstanceFailoverGroup, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ForceFailoverAllowDataLoss fails over from the current primary managed instance to this managed instance. This +// operation might result in data loss. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// locationName - the name of the region where the resource is located. +// failoverGroupName - the name of the failover group. +func (client InstanceFailoverGroupsClient) ForceFailoverAllowDataLoss(ctx context.Context, resourceGroupName string, locationName string, failoverGroupName string) (result InstanceFailoverGroupsForceFailoverAllowDataLossFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/InstanceFailoverGroupsClient.ForceFailoverAllowDataLoss") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ForceFailoverAllowDataLossPreparer(ctx, resourceGroupName, locationName, failoverGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsClient", "ForceFailoverAllowDataLoss", nil, "Failure preparing request") + return + } + + result, err = client.ForceFailoverAllowDataLossSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsClient", "ForceFailoverAllowDataLoss", nil, "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 = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/instanceFailoverGroups/{failoverGroupName}/forceFailoverAllowDataLoss", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ForceFailoverAllowDataLossSender sends the ForceFailoverAllowDataLoss request. The method will close the +// http.Response Body if it receives an error. +func (client InstanceFailoverGroupsClient) ForceFailoverAllowDataLossSender(req *http.Request) (future InstanceFailoverGroupsForceFailoverAllowDataLossFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// ForceFailoverAllowDataLossResponder handles the response to the ForceFailoverAllowDataLoss request. The method always +// closes the http.Response Body. +func (client InstanceFailoverGroupsClient) ForceFailoverAllowDataLossResponder(resp *http.Response) (result InstanceFailoverGroup, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets a failover group. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// locationName - the name of the region where the resource is located. +// failoverGroupName - the name of the failover group. +func (client InstanceFailoverGroupsClient) Get(ctx context.Context, resourceGroupName string, locationName string, failoverGroupName string) (result InstanceFailoverGroup, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/InstanceFailoverGroupsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, locationName, failoverGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client InstanceFailoverGroupsClient) GetPreparer(ctx context.Context, resourceGroupName string, locationName string, failoverGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "failoverGroupName": autorest.Encode("path", failoverGroupName), + "locationName": autorest.Encode("path", locationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/instanceFailoverGroups/{failoverGroupName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client InstanceFailoverGroupsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client InstanceFailoverGroupsClient) GetResponder(resp *http.Response) (result InstanceFailoverGroup, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByLocation lists the failover groups in a location. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// locationName - the name of the region where the resource is located. +func (client InstanceFailoverGroupsClient) ListByLocation(ctx context.Context, resourceGroupName string, locationName string) (result InstanceFailoverGroupListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/InstanceFailoverGroupsClient.ListByLocation") + defer func() { + sc := -1 + if result.ifglr.Response.Response != nil { + sc = result.ifglr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByLocationNextResults + req, err := client.ListByLocationPreparer(ctx, resourceGroupName, locationName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsClient", "ListByLocation", nil, "Failure preparing request") + return + } + + resp, err := client.ListByLocationSender(req) + if err != nil { + result.ifglr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsClient", "ListByLocation", resp, "Failure sending request") + return + } + + result.ifglr, err = client.ListByLocationResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsClient", "ListByLocation", resp, "Failure responding to request") + return + } + if result.ifglr.hasNextLink() && result.ifglr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByLocationPreparer prepares the ListByLocation request. +func (client InstanceFailoverGroupsClient) ListByLocationPreparer(ctx context.Context, resourceGroupName string, locationName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "locationName": autorest.Encode("path", locationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/instanceFailoverGroups", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByLocationSender sends the ListByLocation request. The method will close the +// http.Response Body if it receives an error. +func (client InstanceFailoverGroupsClient) ListByLocationSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByLocationResponder handles the response to the ListByLocation request. The method always +// closes the http.Response Body. +func (client InstanceFailoverGroupsClient) ListByLocationResponder(resp *http.Response) (result InstanceFailoverGroupListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByLocationNextResults retrieves the next set of results, if any. +func (client InstanceFailoverGroupsClient) listByLocationNextResults(ctx context.Context, lastResults InstanceFailoverGroupListResult) (result InstanceFailoverGroupListResult, err error) { + req, err := lastResults.instanceFailoverGroupListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsClient", "listByLocationNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByLocationSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsClient", "listByLocationNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByLocationResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsClient", "listByLocationNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByLocationComplete enumerates all values, automatically crossing page boundaries as required. +func (client InstanceFailoverGroupsClient) ListByLocationComplete(ctx context.Context, resourceGroupName string, locationName string) (result InstanceFailoverGroupListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/InstanceFailoverGroupsClient.ListByLocation") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByLocation(ctx, resourceGroupName, locationName) + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/instancepools.go b/services/preview/sql/mgmt/v5.0/sql/instancepools.go new file mode 100644 index 000000000000..e390538d17ab --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/instancepools.go @@ -0,0 +1,594 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// InstancePoolsClient is the the Azure SQL Database management API provides a RESTful set of web services that +// interact with Azure SQL Database services to manage your databases. The API enables you to create, retrieve, update, +// and delete databases. +type InstancePoolsClient struct { + BaseClient +} + +// NewInstancePoolsClient creates an instance of the InstancePoolsClient client. +func NewInstancePoolsClient(subscriptionID string) InstancePoolsClient { + return NewInstancePoolsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewInstancePoolsClientWithBaseURI creates an instance of the InstancePoolsClient client using a custom endpoint. +// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewInstancePoolsClientWithBaseURI(baseURI string, subscriptionID string) InstancePoolsClient { + return InstancePoolsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates an instance pool. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// instancePoolName - the name of the instance pool to be created or updated. +// parameters - the requested instance pool resource state. +func (client InstancePoolsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, instancePoolName string, parameters InstancePool) (result InstancePoolsCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/InstancePoolsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.Sku", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.Sku.Name", Name: validation.Null, Rule: true, Chain: nil}}}, + {Target: "parameters.InstancePoolProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.InstancePoolProperties.SubnetID", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.InstancePoolProperties.VCores", Name: validation.Null, Rule: true, Chain: nil}, + }}}}}); err != nil { + return result, validation.NewError("sql.InstancePoolsClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, instancePoolName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstancePoolsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstancePoolsClient", "CreateOrUpdate", nil, "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client InstancePoolsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, instancePoolName string, parameters InstancePool) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "instancePoolName": autorest.Encode("path", instancePoolName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/instancePools/{instancePoolName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client InstancePoolsClient) CreateOrUpdateSender(req *http.Request) (future InstancePoolsCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client InstancePoolsClient) CreateOrUpdateResponder(resp *http.Response) (result InstancePool, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes an instance pool +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// instancePoolName - the name of the instance pool to be deleted +func (client InstancePoolsClient) Delete(ctx context.Context, resourceGroupName string, instancePoolName string) (result InstancePoolsDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/InstancePoolsClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, instancePoolName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstancePoolsClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstancePoolsClient", "Delete", nil, "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client InstancePoolsClient) DeletePreparer(ctx context.Context, resourceGroupName string, instancePoolName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "instancePoolName": autorest.Encode("path", instancePoolName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/instancePools/{instancePoolName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client InstancePoolsClient) DeleteSender(req *http.Request) (future InstancePoolsDeleteFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client InstancePoolsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets an instance pool. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// instancePoolName - the name of the instance pool to be retrieved. +func (client InstancePoolsClient) Get(ctx context.Context, resourceGroupName string, instancePoolName string) (result InstancePool, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/InstancePoolsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, instancePoolName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstancePoolsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.InstancePoolsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstancePoolsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client InstancePoolsClient) GetPreparer(ctx context.Context, resourceGroupName string, instancePoolName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "instancePoolName": autorest.Encode("path", instancePoolName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/instancePools/{instancePoolName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client InstancePoolsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client InstancePoolsClient) GetResponder(resp *http.Response) (result InstancePool, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List gets a list of all instance pools in the subscription. +func (client InstancePoolsClient) List(ctx context.Context) (result InstancePoolListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/InstancePoolsClient.List") + defer func() { + sc := -1 + if result.iplr.Response.Response != nil { + sc = result.iplr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstancePoolsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.iplr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.InstancePoolsClient", "List", resp, "Failure sending request") + return + } + + result.iplr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstancePoolsClient", "List", resp, "Failure responding to request") + return + } + if result.iplr.hasNextLink() && result.iplr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client InstancePoolsClient) ListPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Sql/instancePools", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client InstancePoolsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client InstancePoolsClient) ListResponder(resp *http.Response) (result InstancePoolListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client InstancePoolsClient) listNextResults(ctx context.Context, lastResults InstancePoolListResult) (result InstancePoolListResult, err error) { + req, err := lastResults.instancePoolListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.InstancePoolsClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.InstancePoolsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstancePoolsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client InstancePoolsClient) ListComplete(ctx context.Context) (result InstancePoolListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/InstancePoolsClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx) + return +} + +// ListByResourceGroup gets a list of instance pools in the resource group +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +func (client InstancePoolsClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result InstancePoolListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/InstancePoolsClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.iplr.Response.Response != nil { + sc = result.iplr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByResourceGroupNextResults + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstancePoolsClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.iplr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.InstancePoolsClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result.iplr, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstancePoolsClient", "ListByResourceGroup", resp, "Failure responding to request") + return + } + if result.iplr.hasNextLink() && result.iplr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client InstancePoolsClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/instancePools", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client InstancePoolsClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client InstancePoolsClient) ListByResourceGroupResponder(resp *http.Response) (result InstancePoolListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByResourceGroupNextResults retrieves the next set of results, if any. +func (client InstancePoolsClient) listByResourceGroupNextResults(ctx context.Context, lastResults InstancePoolListResult) (result InstancePoolListResult, err error) { + req, err := lastResults.instancePoolListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.InstancePoolsClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.InstancePoolsClient", "listByResourceGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstancePoolsClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. +func (client InstancePoolsClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result InstancePoolListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/InstancePoolsClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByResourceGroup(ctx, resourceGroupName) + return +} + +// Update updates an instance pool. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// instancePoolName - the name of the instance pool to be updated. +// parameters - the requested instance pool resource state. +func (client InstancePoolsClient) Update(ctx context.Context, resourceGroupName string, instancePoolName string, parameters InstancePoolUpdate) (result InstancePoolsUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/InstancePoolsClient.Update") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.UpdatePreparer(ctx, resourceGroupName, instancePoolName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstancePoolsClient", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstancePoolsClient", "Update", nil, "Failure sending request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client InstancePoolsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, instancePoolName string, parameters InstancePoolUpdate) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "instancePoolName": autorest.Encode("path", instancePoolName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/instancePools/{instancePoolName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client InstancePoolsClient) UpdateSender(req *http.Request) (future InstancePoolsUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client InstancePoolsClient) UpdateResponder(resp *http.Response) (result InstancePool, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/jobagents.go b/services/preview/sql/mgmt/v5.0/sql/jobagents.go new file mode 100644 index 000000000000..a9eeccd908aa --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/jobagents.go @@ -0,0 +1,489 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// JobAgentsClient is the the Azure SQL Database management API provides a RESTful set of web services that interact +// with Azure SQL Database services to manage your databases. The API enables you to create, retrieve, update, and +// delete databases. +type JobAgentsClient struct { + BaseClient +} + +// NewJobAgentsClient creates an instance of the JobAgentsClient client. +func NewJobAgentsClient(subscriptionID string) JobAgentsClient { + return NewJobAgentsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewJobAgentsClientWithBaseURI creates an instance of the JobAgentsClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewJobAgentsClientWithBaseURI(baseURI string, subscriptionID string) JobAgentsClient { + return JobAgentsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a job agent. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// jobAgentName - the name of the job agent to be created or updated. +// parameters - the requested job agent resource state. +func (client JobAgentsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, parameters JobAgent) (result JobAgentsCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobAgentsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.Sku", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.Sku.Name", Name: validation.Null, Rule: true, Chain: nil}}}, + {Target: "parameters.JobAgentProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.JobAgentProperties.DatabaseID", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("sql.JobAgentsClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, jobAgentName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobAgentsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobAgentsClient", "CreateOrUpdate", nil, "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client JobAgentsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, parameters JobAgent) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "jobAgentName": autorest.Encode("path", jobAgentName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client JobAgentsClient) CreateOrUpdateSender(req *http.Request) (future JobAgentsCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client JobAgentsClient) CreateOrUpdateResponder(resp *http.Response) (result JobAgent, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a job agent. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// jobAgentName - the name of the job agent to be deleted. +func (client JobAgentsClient) Delete(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string) (result JobAgentsDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobAgentsClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, serverName, jobAgentName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobAgentsClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobAgentsClient", "Delete", nil, "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client JobAgentsClient) DeletePreparer(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "jobAgentName": autorest.Encode("path", jobAgentName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client JobAgentsClient) DeleteSender(req *http.Request) (future JobAgentsDeleteFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client JobAgentsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a job agent. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// jobAgentName - the name of the job agent to be retrieved. +func (client JobAgentsClient) Get(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string) (result JobAgent, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobAgentsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, jobAgentName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobAgentsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.JobAgentsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobAgentsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client JobAgentsClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "jobAgentName": autorest.Encode("path", jobAgentName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client JobAgentsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client JobAgentsClient) GetResponder(resp *http.Response) (result JobAgent, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer gets a list of job agents in a server. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +func (client JobAgentsClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result JobAgentListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobAgentsClient.ListByServer") + defer func() { + sc := -1 + if result.jalr.Response.Response != nil { + sc = result.jalr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByServerNextResults + req, err := client.ListByServerPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobAgentsClient", "ListByServer", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServerSender(req) + if err != nil { + result.jalr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.JobAgentsClient", "ListByServer", resp, "Failure sending request") + return + } + + result.jalr, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobAgentsClient", "ListByServer", resp, "Failure responding to request") + return + } + if result.jalr.hasNextLink() && result.jalr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServerPreparer prepares the ListByServer request. +func (client JobAgentsClient) ListByServerPreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByServerSender sends the ListByServer request. The method will close the +// http.Response Body if it receives an error. +func (client JobAgentsClient) ListByServerSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client JobAgentsClient) ListByServerResponder(resp *http.Response) (result JobAgentListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByServerNextResults retrieves the next set of results, if any. +func (client JobAgentsClient) listByServerNextResults(ctx context.Context, lastResults JobAgentListResult) (result JobAgentListResult, err error) { + req, err := lastResults.jobAgentListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.JobAgentsClient", "listByServerNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByServerSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.JobAgentsClient", "listByServerNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobAgentsClient", "listByServerNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServerComplete enumerates all values, automatically crossing page boundaries as required. +func (client JobAgentsClient) ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result JobAgentListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobAgentsClient.ListByServer") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByServer(ctx, resourceGroupName, serverName) + return +} + +// Update updates a job agent. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// jobAgentName - the name of the job agent to be updated. +// parameters - the update to the job agent. +func (client JobAgentsClient) Update(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, parameters JobAgentUpdate) (result JobAgentsUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobAgentsClient.Update") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.UpdatePreparer(ctx, resourceGroupName, serverName, jobAgentName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobAgentsClient", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobAgentsClient", "Update", nil, "Failure sending request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client JobAgentsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, parameters JobAgentUpdate) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "jobAgentName": autorest.Encode("path", jobAgentName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client JobAgentsClient) UpdateSender(req *http.Request) (future JobAgentsUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client JobAgentsClient) UpdateResponder(resp *http.Response) (result JobAgent, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/jobcredentials.go b/services/preview/sql/mgmt/v5.0/sql/jobcredentials.go new file mode 100644 index 000000000000..e70ec19fbc60 --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/jobcredentials.go @@ -0,0 +1,409 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// JobCredentialsClient is the the Azure SQL Database management API provides a RESTful set of web services that +// interact with Azure SQL Database services to manage your databases. The API enables you to create, retrieve, update, +// and delete databases. +type JobCredentialsClient struct { + BaseClient +} + +// NewJobCredentialsClient creates an instance of the JobCredentialsClient client. +func NewJobCredentialsClient(subscriptionID string) JobCredentialsClient { + return NewJobCredentialsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewJobCredentialsClientWithBaseURI creates an instance of the JobCredentialsClient client using a custom endpoint. +// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewJobCredentialsClientWithBaseURI(baseURI string, subscriptionID string) JobCredentialsClient { + return JobCredentialsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a job credential. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// jobAgentName - the name of the job agent. +// credentialName - the name of the credential. +// parameters - the requested job credential state. +func (client JobCredentialsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, credentialName string, parameters JobCredential) (result JobCredential, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobCredentialsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.JobCredentialProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.JobCredentialProperties.Username", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.JobCredentialProperties.Password", Name: validation.Null, Rule: true, Chain: nil}, + }}}}}); err != nil { + return result, validation.NewError("sql.JobCredentialsClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, jobAgentName, credentialName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobCredentialsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.JobCredentialsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobCredentialsClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client JobCredentialsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, credentialName string, parameters JobCredential) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "credentialName": autorest.Encode("path", credentialName), + "jobAgentName": autorest.Encode("path", jobAgentName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/credentials/{credentialName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client JobCredentialsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client JobCredentialsClient) CreateOrUpdateResponder(resp *http.Response) (result JobCredential, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a job credential. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// jobAgentName - the name of the job agent. +// credentialName - the name of the credential. +func (client JobCredentialsClient) Delete(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, credentialName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobCredentialsClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, serverName, jobAgentName, credentialName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobCredentialsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "sql.JobCredentialsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobCredentialsClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client JobCredentialsClient) DeletePreparer(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, credentialName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "credentialName": autorest.Encode("path", credentialName), + "jobAgentName": autorest.Encode("path", jobAgentName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/credentials/{credentialName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client JobCredentialsClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client JobCredentialsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a jobs credential. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// jobAgentName - the name of the job agent. +// credentialName - the name of the credential. +func (client JobCredentialsClient) Get(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, credentialName string) (result JobCredential, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobCredentialsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, jobAgentName, credentialName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobCredentialsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.JobCredentialsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobCredentialsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client JobCredentialsClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, credentialName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "credentialName": autorest.Encode("path", credentialName), + "jobAgentName": autorest.Encode("path", jobAgentName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/credentials/{credentialName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client JobCredentialsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client JobCredentialsClient) GetResponder(resp *http.Response) (result JobCredential, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAgent gets a list of jobs credentials. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// jobAgentName - the name of the job agent. +func (client JobCredentialsClient) ListByAgent(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string) (result JobCredentialListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobCredentialsClient.ListByAgent") + defer func() { + sc := -1 + if result.jclr.Response.Response != nil { + sc = result.jclr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByAgentNextResults + req, err := client.ListByAgentPreparer(ctx, resourceGroupName, serverName, jobAgentName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobCredentialsClient", "ListByAgent", nil, "Failure preparing request") + return + } + + resp, err := client.ListByAgentSender(req) + if err != nil { + result.jclr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.JobCredentialsClient", "ListByAgent", resp, "Failure sending request") + return + } + + result.jclr, err = client.ListByAgentResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobCredentialsClient", "ListByAgent", resp, "Failure responding to request") + return + } + if result.jclr.hasNextLink() && result.jclr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByAgentPreparer prepares the ListByAgent request. +func (client JobCredentialsClient) ListByAgentPreparer(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "jobAgentName": autorest.Encode("path", jobAgentName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/credentials", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByAgentSender sends the ListByAgent request. The method will close the +// http.Response Body if it receives an error. +func (client JobCredentialsClient) ListByAgentSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByAgentResponder handles the response to the ListByAgent request. The method always +// closes the http.Response Body. +func (client JobCredentialsClient) ListByAgentResponder(resp *http.Response) (result JobCredentialListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByAgentNextResults retrieves the next set of results, if any. +func (client JobCredentialsClient) listByAgentNextResults(ctx context.Context, lastResults JobCredentialListResult) (result JobCredentialListResult, err error) { + req, err := lastResults.jobCredentialListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.JobCredentialsClient", "listByAgentNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByAgentSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.JobCredentialsClient", "listByAgentNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByAgentResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobCredentialsClient", "listByAgentNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByAgentComplete enumerates all values, automatically crossing page boundaries as required. +func (client JobCredentialsClient) ListByAgentComplete(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string) (result JobCredentialListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobCredentialsClient.ListByAgent") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByAgent(ctx, resourceGroupName, serverName, jobAgentName) + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/jobexecutions.go b/services/preview/sql/mgmt/v5.0/sql/jobexecutions.go new file mode 100644 index 000000000000..829f06c5ee4d --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/jobexecutions.go @@ -0,0 +1,668 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/date" + "github.com/Azure/go-autorest/tracing" + "github.com/gofrs/uuid" + "net/http" +) + +// JobExecutionsClient is the the Azure SQL Database management API provides a RESTful set of web services that +// interact with Azure SQL Database services to manage your databases. The API enables you to create, retrieve, update, +// and delete databases. +type JobExecutionsClient struct { + BaseClient +} + +// NewJobExecutionsClient creates an instance of the JobExecutionsClient client. +func NewJobExecutionsClient(subscriptionID string) JobExecutionsClient { + return NewJobExecutionsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewJobExecutionsClientWithBaseURI creates an instance of the JobExecutionsClient client using a custom endpoint. +// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewJobExecutionsClientWithBaseURI(baseURI string, subscriptionID string) JobExecutionsClient { + return JobExecutionsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Cancel requests cancellation of a job execution. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// jobAgentName - the name of the job agent. +// jobName - the name of the job. +// jobExecutionID - the id of the job execution to cancel. +func (client JobExecutionsClient) Cancel(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, jobExecutionID uuid.UUID) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobExecutionsClient.Cancel") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CancelPreparer(ctx, resourceGroupName, serverName, jobAgentName, jobName, jobExecutionID) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobExecutionsClient", "Cancel", nil, "Failure preparing request") + return + } + + resp, err := client.CancelSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "sql.JobExecutionsClient", "Cancel", resp, "Failure sending request") + return + } + + result, err = client.CancelResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobExecutionsClient", "Cancel", resp, "Failure responding to request") + return + } + + return +} + +// CancelPreparer prepares the Cancel request. +func (client JobExecutionsClient) CancelPreparer(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, jobExecutionID uuid.UUID) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "jobAgentName": autorest.Encode("path", jobAgentName), + "jobExecutionId": autorest.Encode("path", jobExecutionID), + "jobName": autorest.Encode("path", jobName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/executions/{jobExecutionId}/cancel", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CancelSender sends the Cancel request. The method will close the +// http.Response Body if it receives an error. +func (client JobExecutionsClient) CancelSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CancelResponder handles the response to the Cancel request. The method always +// closes the http.Response Body. +func (client JobExecutionsClient) CancelResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Create starts an elastic job execution. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// jobAgentName - the name of the job agent. +// jobName - the name of the job to get. +func (client JobExecutionsClient) Create(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string) (result JobExecutionsCreateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobExecutionsClient.Create") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreatePreparer(ctx, resourceGroupName, serverName, jobAgentName, jobName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobExecutionsClient", "Create", nil, "Failure preparing request") + return + } + + result, err = client.CreateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobExecutionsClient", "Create", nil, "Failure sending request") + return + } + + return +} + +// CreatePreparer prepares the Create request. +func (client JobExecutionsClient) CreatePreparer(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "jobAgentName": autorest.Encode("path", jobAgentName), + "jobName": autorest.Encode("path", jobName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/start", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateSender sends the Create request. The method will close the +// http.Response Body if it receives an error. +func (client JobExecutionsClient) CreateSender(req *http.Request) (future JobExecutionsCreateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client JobExecutionsClient) CreateResponder(resp *http.Response) (result JobExecution, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// CreateOrUpdate creates or updates a job execution. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// jobAgentName - the name of the job agent. +// jobName - the name of the job to get. +// jobExecutionID - the job execution id to create the job execution under. +func (client JobExecutionsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, jobExecutionID uuid.UUID) (result JobExecutionsCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobExecutionsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, jobAgentName, jobName, jobExecutionID) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobExecutionsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobExecutionsClient", "CreateOrUpdate", nil, "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client JobExecutionsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, jobExecutionID uuid.UUID) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "jobAgentName": autorest.Encode("path", jobAgentName), + "jobExecutionId": autorest.Encode("path", jobExecutionID), + "jobName": autorest.Encode("path", jobName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/executions/{jobExecutionId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client JobExecutionsClient) CreateOrUpdateSender(req *http.Request) (future JobExecutionsCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client JobExecutionsClient) CreateOrUpdateResponder(resp *http.Response) (result JobExecution, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets a job execution. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// jobAgentName - the name of the job agent. +// jobName - the name of the job. +// jobExecutionID - the id of the job execution +func (client JobExecutionsClient) Get(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, jobExecutionID uuid.UUID) (result JobExecution, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobExecutionsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, jobAgentName, jobName, jobExecutionID) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobExecutionsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.JobExecutionsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobExecutionsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client JobExecutionsClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, jobExecutionID uuid.UUID) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "jobAgentName": autorest.Encode("path", jobAgentName), + "jobExecutionId": autorest.Encode("path", jobExecutionID), + "jobName": autorest.Encode("path", jobName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/executions/{jobExecutionId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client JobExecutionsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client JobExecutionsClient) GetResponder(resp *http.Response) (result JobExecution, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAgent lists all executions in a job agent. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// jobAgentName - the name of the job agent. +// createTimeMin - if specified, only job executions created at or after the specified time are included. +// createTimeMax - if specified, only job executions created before the specified time are included. +// endTimeMin - if specified, only job executions completed at or after the specified time are included. +// endTimeMax - if specified, only job executions completed before the specified time are included. +// isActive - if specified, only active or only completed job executions are included. +// skip - the number of elements in the collection to skip. +// top - the number of elements to return from the collection. +func (client JobExecutionsClient) ListByAgent(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, createTimeMin *date.Time, createTimeMax *date.Time, endTimeMin *date.Time, endTimeMax *date.Time, isActive *bool, skip *int32, top *int32) (result JobExecutionListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobExecutionsClient.ListByAgent") + defer func() { + sc := -1 + if result.jelr.Response.Response != nil { + sc = result.jelr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByAgentNextResults + req, err := client.ListByAgentPreparer(ctx, resourceGroupName, serverName, jobAgentName, createTimeMin, createTimeMax, endTimeMin, endTimeMax, isActive, skip, top) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobExecutionsClient", "ListByAgent", nil, "Failure preparing request") + return + } + + resp, err := client.ListByAgentSender(req) + if err != nil { + result.jelr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.JobExecutionsClient", "ListByAgent", resp, "Failure sending request") + return + } + + result.jelr, err = client.ListByAgentResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobExecutionsClient", "ListByAgent", resp, "Failure responding to request") + return + } + if result.jelr.hasNextLink() && result.jelr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByAgentPreparer prepares the ListByAgent request. +func (client JobExecutionsClient) ListByAgentPreparer(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, createTimeMin *date.Time, createTimeMax *date.Time, endTimeMin *date.Time, endTimeMax *date.Time, isActive *bool, skip *int32, top *int32) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "jobAgentName": autorest.Encode("path", jobAgentName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if createTimeMin != nil { + queryParameters["createTimeMin"] = autorest.Encode("query", *createTimeMin) + } + if createTimeMax != nil { + queryParameters["createTimeMax"] = autorest.Encode("query", *createTimeMax) + } + if endTimeMin != nil { + queryParameters["endTimeMin"] = autorest.Encode("query", *endTimeMin) + } + if endTimeMax != nil { + queryParameters["endTimeMax"] = autorest.Encode("query", *endTimeMax) + } + if isActive != nil { + queryParameters["isActive"] = autorest.Encode("query", *isActive) + } + if skip != nil { + queryParameters["$skip"] = autorest.Encode("query", *skip) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/executions", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByAgentSender sends the ListByAgent request. The method will close the +// http.Response Body if it receives an error. +func (client JobExecutionsClient) ListByAgentSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByAgentResponder handles the response to the ListByAgent request. The method always +// closes the http.Response Body. +func (client JobExecutionsClient) ListByAgentResponder(resp *http.Response) (result JobExecutionListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByAgentNextResults retrieves the next set of results, if any. +func (client JobExecutionsClient) listByAgentNextResults(ctx context.Context, lastResults JobExecutionListResult) (result JobExecutionListResult, err error) { + req, err := lastResults.jobExecutionListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.JobExecutionsClient", "listByAgentNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByAgentSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.JobExecutionsClient", "listByAgentNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByAgentResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobExecutionsClient", "listByAgentNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByAgentComplete enumerates all values, automatically crossing page boundaries as required. +func (client JobExecutionsClient) ListByAgentComplete(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, createTimeMin *date.Time, createTimeMax *date.Time, endTimeMin *date.Time, endTimeMax *date.Time, isActive *bool, skip *int32, top *int32) (result JobExecutionListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobExecutionsClient.ListByAgent") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByAgent(ctx, resourceGroupName, serverName, jobAgentName, createTimeMin, createTimeMax, endTimeMin, endTimeMax, isActive, skip, top) + return +} + +// ListByJob lists a job's executions. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// jobAgentName - the name of the job agent. +// jobName - the name of the job to get. +// createTimeMin - if specified, only job executions created at or after the specified time are included. +// createTimeMax - if specified, only job executions created before the specified time are included. +// endTimeMin - if specified, only job executions completed at or after the specified time are included. +// endTimeMax - if specified, only job executions completed before the specified time are included. +// isActive - if specified, only active or only completed job executions are included. +// skip - the number of elements in the collection to skip. +// top - the number of elements to return from the collection. +func (client JobExecutionsClient) ListByJob(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, createTimeMin *date.Time, createTimeMax *date.Time, endTimeMin *date.Time, endTimeMax *date.Time, isActive *bool, skip *int32, top *int32) (result JobExecutionListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobExecutionsClient.ListByJob") + defer func() { + sc := -1 + if result.jelr.Response.Response != nil { + sc = result.jelr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByJobNextResults + req, err := client.ListByJobPreparer(ctx, resourceGroupName, serverName, jobAgentName, jobName, createTimeMin, createTimeMax, endTimeMin, endTimeMax, isActive, skip, top) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobExecutionsClient", "ListByJob", nil, "Failure preparing request") + return + } + + resp, err := client.ListByJobSender(req) + if err != nil { + result.jelr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.JobExecutionsClient", "ListByJob", resp, "Failure sending request") + return + } + + result.jelr, err = client.ListByJobResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobExecutionsClient", "ListByJob", resp, "Failure responding to request") + return + } + if result.jelr.hasNextLink() && result.jelr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByJobPreparer prepares the ListByJob request. +func (client JobExecutionsClient) ListByJobPreparer(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, createTimeMin *date.Time, createTimeMax *date.Time, endTimeMin *date.Time, endTimeMax *date.Time, isActive *bool, skip *int32, top *int32) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "jobAgentName": autorest.Encode("path", jobAgentName), + "jobName": autorest.Encode("path", jobName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if createTimeMin != nil { + queryParameters["createTimeMin"] = autorest.Encode("query", *createTimeMin) + } + if createTimeMax != nil { + queryParameters["createTimeMax"] = autorest.Encode("query", *createTimeMax) + } + if endTimeMin != nil { + queryParameters["endTimeMin"] = autorest.Encode("query", *endTimeMin) + } + if endTimeMax != nil { + queryParameters["endTimeMax"] = autorest.Encode("query", *endTimeMax) + } + if isActive != nil { + queryParameters["isActive"] = autorest.Encode("query", *isActive) + } + if skip != nil { + queryParameters["$skip"] = autorest.Encode("query", *skip) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/executions", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByJobSender sends the ListByJob request. The method will close the +// http.Response Body if it receives an error. +func (client JobExecutionsClient) ListByJobSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByJobResponder handles the response to the ListByJob request. The method always +// closes the http.Response Body. +func (client JobExecutionsClient) ListByJobResponder(resp *http.Response) (result JobExecutionListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByJobNextResults retrieves the next set of results, if any. +func (client JobExecutionsClient) listByJobNextResults(ctx context.Context, lastResults JobExecutionListResult) (result JobExecutionListResult, err error) { + req, err := lastResults.jobExecutionListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.JobExecutionsClient", "listByJobNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByJobSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.JobExecutionsClient", "listByJobNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByJobResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobExecutionsClient", "listByJobNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByJobComplete enumerates all values, automatically crossing page boundaries as required. +func (client JobExecutionsClient) ListByJobComplete(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, createTimeMin *date.Time, createTimeMax *date.Time, endTimeMin *date.Time, endTimeMax *date.Time, isActive *bool, skip *int32, top *int32) (result JobExecutionListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobExecutionsClient.ListByJob") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByJob(ctx, resourceGroupName, serverName, jobAgentName, jobName, createTimeMin, createTimeMax, endTimeMin, endTimeMax, isActive, skip, top) + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/jobs.go b/services/preview/sql/mgmt/v5.0/sql/jobs.go new file mode 100644 index 000000000000..6a409c44dee9 --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/jobs.go @@ -0,0 +1,399 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// JobsClient is the the Azure SQL Database management API provides a RESTful set of web services that interact with +// Azure SQL Database services to manage your databases. The API enables you to create, retrieve, update, and delete +// databases. +type JobsClient struct { + BaseClient +} + +// NewJobsClient creates an instance of the JobsClient client. +func NewJobsClient(subscriptionID string) JobsClient { + return NewJobsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewJobsClientWithBaseURI creates an instance of the JobsClient client using a custom endpoint. Use this when +// interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewJobsClientWithBaseURI(baseURI string, subscriptionID string) JobsClient { + return JobsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a job. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// jobAgentName - the name of the job agent. +// jobName - the name of the job to get. +// parameters - the requested job state. +func (client JobsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, parameters Job) (result Job, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, jobAgentName, jobName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.JobsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobsClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client JobsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, parameters Job) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "jobAgentName": autorest.Encode("path", jobAgentName), + "jobName": autorest.Encode("path", jobName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client JobsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client JobsClient) CreateOrUpdateResponder(resp *http.Response) (result Job, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a job. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// jobAgentName - the name of the job agent. +// jobName - the name of the job to delete. +func (client JobsClient) Delete(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobsClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, serverName, jobAgentName, jobName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "sql.JobsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobsClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client JobsClient) DeletePreparer(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "jobAgentName": autorest.Encode("path", jobAgentName), + "jobName": autorest.Encode("path", jobName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client JobsClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client JobsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a job. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// jobAgentName - the name of the job agent. +// jobName - the name of the job to get. +func (client JobsClient) Get(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string) (result Job, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, jobAgentName, jobName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.JobsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client JobsClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "jobAgentName": autorest.Encode("path", jobAgentName), + "jobName": autorest.Encode("path", jobName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client JobsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client JobsClient) GetResponder(resp *http.Response) (result Job, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAgent gets a list of jobs. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// jobAgentName - the name of the job agent. +func (client JobsClient) ListByAgent(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string) (result JobListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobsClient.ListByAgent") + defer func() { + sc := -1 + if result.jlr.Response.Response != nil { + sc = result.jlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByAgentNextResults + req, err := client.ListByAgentPreparer(ctx, resourceGroupName, serverName, jobAgentName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobsClient", "ListByAgent", nil, "Failure preparing request") + return + } + + resp, err := client.ListByAgentSender(req) + if err != nil { + result.jlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.JobsClient", "ListByAgent", resp, "Failure sending request") + return + } + + result.jlr, err = client.ListByAgentResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobsClient", "ListByAgent", resp, "Failure responding to request") + return + } + if result.jlr.hasNextLink() && result.jlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByAgentPreparer prepares the ListByAgent request. +func (client JobsClient) ListByAgentPreparer(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "jobAgentName": autorest.Encode("path", jobAgentName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByAgentSender sends the ListByAgent request. The method will close the +// http.Response Body if it receives an error. +func (client JobsClient) ListByAgentSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByAgentResponder handles the response to the ListByAgent request. The method always +// closes the http.Response Body. +func (client JobsClient) ListByAgentResponder(resp *http.Response) (result JobListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByAgentNextResults retrieves the next set of results, if any. +func (client JobsClient) listByAgentNextResults(ctx context.Context, lastResults JobListResult) (result JobListResult, err error) { + req, err := lastResults.jobListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.JobsClient", "listByAgentNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByAgentSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.JobsClient", "listByAgentNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByAgentResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobsClient", "listByAgentNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByAgentComplete enumerates all values, automatically crossing page boundaries as required. +func (client JobsClient) ListByAgentComplete(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string) (result JobListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobsClient.ListByAgent") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByAgent(ctx, resourceGroupName, serverName, jobAgentName) + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/jobstepexecutions.go b/services/preview/sql/mgmt/v5.0/sql/jobstepexecutions.go new file mode 100644 index 000000000000..c453242a2b5d --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/jobstepexecutions.go @@ -0,0 +1,274 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/date" + "github.com/Azure/go-autorest/tracing" + "github.com/gofrs/uuid" + "net/http" +) + +// JobStepExecutionsClient is the the Azure SQL Database management API provides a RESTful set of web services that +// interact with Azure SQL Database services to manage your databases. The API enables you to create, retrieve, update, +// and delete databases. +type JobStepExecutionsClient struct { + BaseClient +} + +// NewJobStepExecutionsClient creates an instance of the JobStepExecutionsClient client. +func NewJobStepExecutionsClient(subscriptionID string) JobStepExecutionsClient { + return NewJobStepExecutionsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewJobStepExecutionsClientWithBaseURI creates an instance of the JobStepExecutionsClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewJobStepExecutionsClientWithBaseURI(baseURI string, subscriptionID string) JobStepExecutionsClient { + return JobStepExecutionsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get gets a step execution of a job execution. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// jobAgentName - the name of the job agent. +// jobName - the name of the job to get. +// jobExecutionID - the unique id of the job execution +// stepName - the name of the step. +func (client JobStepExecutionsClient) Get(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, jobExecutionID uuid.UUID, stepName string) (result JobExecution, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobStepExecutionsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, jobAgentName, jobName, jobExecutionID, stepName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobStepExecutionsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.JobStepExecutionsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobStepExecutionsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client JobStepExecutionsClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, jobExecutionID uuid.UUID, stepName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "jobAgentName": autorest.Encode("path", jobAgentName), + "jobExecutionId": autorest.Encode("path", jobExecutionID), + "jobName": autorest.Encode("path", jobName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "stepName": autorest.Encode("path", stepName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/executions/{jobExecutionId}/steps/{stepName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client JobStepExecutionsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client JobStepExecutionsClient) GetResponder(resp *http.Response) (result JobExecution, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByJobExecution lists the step executions of a job execution. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// jobAgentName - the name of the job agent. +// jobName - the name of the job to get. +// jobExecutionID - the id of the job execution +// createTimeMin - if specified, only job executions created at or after the specified time are included. +// createTimeMax - if specified, only job executions created before the specified time are included. +// endTimeMin - if specified, only job executions completed at or after the specified time are included. +// endTimeMax - if specified, only job executions completed before the specified time are included. +// isActive - if specified, only active or only completed job executions are included. +// skip - the number of elements in the collection to skip. +// top - the number of elements to return from the collection. +func (client JobStepExecutionsClient) ListByJobExecution(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, jobExecutionID uuid.UUID, createTimeMin *date.Time, createTimeMax *date.Time, endTimeMin *date.Time, endTimeMax *date.Time, isActive *bool, skip *int32, top *int32) (result JobExecutionListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobStepExecutionsClient.ListByJobExecution") + defer func() { + sc := -1 + if result.jelr.Response.Response != nil { + sc = result.jelr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByJobExecutionNextResults + req, err := client.ListByJobExecutionPreparer(ctx, resourceGroupName, serverName, jobAgentName, jobName, jobExecutionID, createTimeMin, createTimeMax, endTimeMin, endTimeMax, isActive, skip, top) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobStepExecutionsClient", "ListByJobExecution", nil, "Failure preparing request") + return + } + + resp, err := client.ListByJobExecutionSender(req) + if err != nil { + result.jelr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.JobStepExecutionsClient", "ListByJobExecution", resp, "Failure sending request") + return + } + + result.jelr, err = client.ListByJobExecutionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobStepExecutionsClient", "ListByJobExecution", resp, "Failure responding to request") + return + } + if result.jelr.hasNextLink() && result.jelr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByJobExecutionPreparer prepares the ListByJobExecution request. +func (client JobStepExecutionsClient) ListByJobExecutionPreparer(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, jobExecutionID uuid.UUID, createTimeMin *date.Time, createTimeMax *date.Time, endTimeMin *date.Time, endTimeMax *date.Time, isActive *bool, skip *int32, top *int32) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "jobAgentName": autorest.Encode("path", jobAgentName), + "jobExecutionId": autorest.Encode("path", jobExecutionID), + "jobName": autorest.Encode("path", jobName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if createTimeMin != nil { + queryParameters["createTimeMin"] = autorest.Encode("query", *createTimeMin) + } + if createTimeMax != nil { + queryParameters["createTimeMax"] = autorest.Encode("query", *createTimeMax) + } + if endTimeMin != nil { + queryParameters["endTimeMin"] = autorest.Encode("query", *endTimeMin) + } + if endTimeMax != nil { + queryParameters["endTimeMax"] = autorest.Encode("query", *endTimeMax) + } + if isActive != nil { + queryParameters["isActive"] = autorest.Encode("query", *isActive) + } + if skip != nil { + queryParameters["$skip"] = autorest.Encode("query", *skip) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/executions/{jobExecutionId}/steps", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByJobExecutionSender sends the ListByJobExecution request. The method will close the +// http.Response Body if it receives an error. +func (client JobStepExecutionsClient) ListByJobExecutionSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByJobExecutionResponder handles the response to the ListByJobExecution request. The method always +// closes the http.Response Body. +func (client JobStepExecutionsClient) ListByJobExecutionResponder(resp *http.Response) (result JobExecutionListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByJobExecutionNextResults retrieves the next set of results, if any. +func (client JobStepExecutionsClient) listByJobExecutionNextResults(ctx context.Context, lastResults JobExecutionListResult) (result JobExecutionListResult, err error) { + req, err := lastResults.jobExecutionListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.JobStepExecutionsClient", "listByJobExecutionNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByJobExecutionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.JobStepExecutionsClient", "listByJobExecutionNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByJobExecutionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobStepExecutionsClient", "listByJobExecutionNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByJobExecutionComplete enumerates all values, automatically crossing page boundaries as required. +func (client JobStepExecutionsClient) ListByJobExecutionComplete(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, jobExecutionID uuid.UUID, createTimeMin *date.Time, createTimeMax *date.Time, endTimeMin *date.Time, endTimeMax *date.Time, isActive *bool, skip *int32, top *int32) (result JobExecutionListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobStepExecutionsClient.ListByJobExecution") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByJobExecution(ctx, resourceGroupName, serverName, jobAgentName, jobName, jobExecutionID, createTimeMin, createTimeMax, endTimeMin, endTimeMax, isActive, skip, top) + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/jobsteps.go b/services/preview/sql/mgmt/v5.0/sql/jobsteps.go new file mode 100644 index 000000000000..c50fbf05dd1f --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/jobsteps.go @@ -0,0 +1,635 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// JobStepsClient is the the Azure SQL Database management API provides a RESTful set of web services that interact +// with Azure SQL Database services to manage your databases. The API enables you to create, retrieve, update, and +// delete databases. +type JobStepsClient struct { + BaseClient +} + +// NewJobStepsClient creates an instance of the JobStepsClient client. +func NewJobStepsClient(subscriptionID string) JobStepsClient { + return NewJobStepsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewJobStepsClientWithBaseURI creates an instance of the JobStepsClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewJobStepsClientWithBaseURI(baseURI string, subscriptionID string) JobStepsClient { + return JobStepsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a job step. This will implicitly create a new job version. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// jobAgentName - the name of the job agent. +// jobName - the name of the job. +// stepName - the name of the job step. +// parameters - the requested state of the job step. +func (client JobStepsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, stepName string, parameters JobStep) (result JobStep, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobStepsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.JobStepProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.JobStepProperties.TargetGroup", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.JobStepProperties.Credential", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.JobStepProperties.Action", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.JobStepProperties.Action.Value", Name: validation.Null, Rule: true, Chain: nil}}}, + {Target: "parameters.JobStepProperties.Output", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.JobStepProperties.Output.ServerName", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.JobStepProperties.Output.DatabaseName", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.JobStepProperties.Output.TableName", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.JobStepProperties.Output.Credential", Name: validation.Null, Rule: true, Chain: nil}, + }}, + }}}}}); err != nil { + return result, validation.NewError("sql.JobStepsClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, jobAgentName, jobName, stepName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobStepsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.JobStepsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobStepsClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client JobStepsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, stepName string, parameters JobStep) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "jobAgentName": autorest.Encode("path", jobAgentName), + "jobName": autorest.Encode("path", jobName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "stepName": autorest.Encode("path", stepName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/steps/{stepName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client JobStepsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client JobStepsClient) CreateOrUpdateResponder(resp *http.Response) (result JobStep, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a job step. This will implicitly create a new job version. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// jobAgentName - the name of the job agent. +// jobName - the name of the job. +// stepName - the name of the job step to delete. +func (client JobStepsClient) Delete(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, stepName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobStepsClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, serverName, jobAgentName, jobName, stepName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobStepsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "sql.JobStepsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobStepsClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client JobStepsClient) DeletePreparer(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, stepName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "jobAgentName": autorest.Encode("path", jobAgentName), + "jobName": autorest.Encode("path", jobName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "stepName": autorest.Encode("path", stepName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/steps/{stepName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client JobStepsClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client JobStepsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a job step in a job's current version. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// jobAgentName - the name of the job agent. +// jobName - the name of the job. +// stepName - the name of the job step. +func (client JobStepsClient) Get(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, stepName string) (result JobStep, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobStepsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, jobAgentName, jobName, stepName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobStepsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.JobStepsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobStepsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client JobStepsClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, stepName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "jobAgentName": autorest.Encode("path", jobAgentName), + "jobName": autorest.Encode("path", jobName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "stepName": autorest.Encode("path", stepName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/steps/{stepName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client JobStepsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client JobStepsClient) GetResponder(resp *http.Response) (result JobStep, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetByVersion gets the specified version of a job step. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// jobAgentName - the name of the job agent. +// jobName - the name of the job. +// jobVersion - the version of the job to get. +// stepName - the name of the job step. +func (client JobStepsClient) GetByVersion(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, jobVersion int32, stepName string) (result JobStep, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobStepsClient.GetByVersion") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetByVersionPreparer(ctx, resourceGroupName, serverName, jobAgentName, jobName, jobVersion, stepName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobStepsClient", "GetByVersion", nil, "Failure preparing request") + return + } + + resp, err := client.GetByVersionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.JobStepsClient", "GetByVersion", resp, "Failure sending request") + return + } + + result, err = client.GetByVersionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobStepsClient", "GetByVersion", resp, "Failure responding to request") + return + } + + return +} + +// GetByVersionPreparer prepares the GetByVersion request. +func (client JobStepsClient) GetByVersionPreparer(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, jobVersion int32, stepName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "jobAgentName": autorest.Encode("path", jobAgentName), + "jobName": autorest.Encode("path", jobName), + "jobVersion": autorest.Encode("path", jobVersion), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "stepName": autorest.Encode("path", stepName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/versions/{jobVersion}/steps/{stepName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetByVersionSender sends the GetByVersion request. The method will close the +// http.Response Body if it receives an error. +func (client JobStepsClient) GetByVersionSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetByVersionResponder handles the response to the GetByVersion request. The method always +// closes the http.Response Body. +func (client JobStepsClient) GetByVersionResponder(resp *http.Response) (result JobStep, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByJob gets all job steps for a job's current version. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// jobAgentName - the name of the job agent. +// jobName - the name of the job to get. +func (client JobStepsClient) ListByJob(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string) (result JobStepListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobStepsClient.ListByJob") + defer func() { + sc := -1 + if result.jslr.Response.Response != nil { + sc = result.jslr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByJobNextResults + req, err := client.ListByJobPreparer(ctx, resourceGroupName, serverName, jobAgentName, jobName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobStepsClient", "ListByJob", nil, "Failure preparing request") + return + } + + resp, err := client.ListByJobSender(req) + if err != nil { + result.jslr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.JobStepsClient", "ListByJob", resp, "Failure sending request") + return + } + + result.jslr, err = client.ListByJobResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobStepsClient", "ListByJob", resp, "Failure responding to request") + return + } + if result.jslr.hasNextLink() && result.jslr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByJobPreparer prepares the ListByJob request. +func (client JobStepsClient) ListByJobPreparer(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "jobAgentName": autorest.Encode("path", jobAgentName), + "jobName": autorest.Encode("path", jobName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/steps", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByJobSender sends the ListByJob request. The method will close the +// http.Response Body if it receives an error. +func (client JobStepsClient) ListByJobSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByJobResponder handles the response to the ListByJob request. The method always +// closes the http.Response Body. +func (client JobStepsClient) ListByJobResponder(resp *http.Response) (result JobStepListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByJobNextResults retrieves the next set of results, if any. +func (client JobStepsClient) listByJobNextResults(ctx context.Context, lastResults JobStepListResult) (result JobStepListResult, err error) { + req, err := lastResults.jobStepListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.JobStepsClient", "listByJobNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByJobSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.JobStepsClient", "listByJobNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByJobResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobStepsClient", "listByJobNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByJobComplete enumerates all values, automatically crossing page boundaries as required. +func (client JobStepsClient) ListByJobComplete(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string) (result JobStepListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobStepsClient.ListByJob") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByJob(ctx, resourceGroupName, serverName, jobAgentName, jobName) + return +} + +// ListByVersion gets all job steps in the specified job version. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// jobAgentName - the name of the job agent. +// jobName - the name of the job to get. +// jobVersion - the version of the job to get. +func (client JobStepsClient) ListByVersion(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, jobVersion int32) (result JobStepListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobStepsClient.ListByVersion") + defer func() { + sc := -1 + if result.jslr.Response.Response != nil { + sc = result.jslr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByVersionNextResults + req, err := client.ListByVersionPreparer(ctx, resourceGroupName, serverName, jobAgentName, jobName, jobVersion) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobStepsClient", "ListByVersion", nil, "Failure preparing request") + return + } + + resp, err := client.ListByVersionSender(req) + if err != nil { + result.jslr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.JobStepsClient", "ListByVersion", resp, "Failure sending request") + return + } + + result.jslr, err = client.ListByVersionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobStepsClient", "ListByVersion", resp, "Failure responding to request") + return + } + if result.jslr.hasNextLink() && result.jslr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByVersionPreparer prepares the ListByVersion request. +func (client JobStepsClient) ListByVersionPreparer(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, jobVersion int32) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "jobAgentName": autorest.Encode("path", jobAgentName), + "jobName": autorest.Encode("path", jobName), + "jobVersion": autorest.Encode("path", jobVersion), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/versions/{jobVersion}/steps", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByVersionSender sends the ListByVersion request. The method will close the +// http.Response Body if it receives an error. +func (client JobStepsClient) ListByVersionSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByVersionResponder handles the response to the ListByVersion request. The method always +// closes the http.Response Body. +func (client JobStepsClient) ListByVersionResponder(resp *http.Response) (result JobStepListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByVersionNextResults retrieves the next set of results, if any. +func (client JobStepsClient) listByVersionNextResults(ctx context.Context, lastResults JobStepListResult) (result JobStepListResult, err error) { + req, err := lastResults.jobStepListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.JobStepsClient", "listByVersionNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByVersionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.JobStepsClient", "listByVersionNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByVersionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobStepsClient", "listByVersionNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByVersionComplete enumerates all values, automatically crossing page boundaries as required. +func (client JobStepsClient) ListByVersionComplete(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, jobVersion int32) (result JobStepListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobStepsClient.ListByVersion") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByVersion(ctx, resourceGroupName, serverName, jobAgentName, jobName, jobVersion) + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/jobtargetexecutions.go b/services/preview/sql/mgmt/v5.0/sql/jobtargetexecutions.go new file mode 100644 index 000000000000..bdb194f01efb --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/jobtargetexecutions.go @@ -0,0 +1,431 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/date" + "github.com/Azure/go-autorest/tracing" + "github.com/gofrs/uuid" + "net/http" +) + +// JobTargetExecutionsClient is the the Azure SQL Database management API provides a RESTful set of web services that +// interact with Azure SQL Database services to manage your databases. The API enables you to create, retrieve, update, +// and delete databases. +type JobTargetExecutionsClient struct { + BaseClient +} + +// NewJobTargetExecutionsClient creates an instance of the JobTargetExecutionsClient client. +func NewJobTargetExecutionsClient(subscriptionID string) JobTargetExecutionsClient { + return NewJobTargetExecutionsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewJobTargetExecutionsClientWithBaseURI creates an instance of the JobTargetExecutionsClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewJobTargetExecutionsClientWithBaseURI(baseURI string, subscriptionID string) JobTargetExecutionsClient { + return JobTargetExecutionsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get gets a target execution. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// jobAgentName - the name of the job agent. +// jobName - the name of the job to get. +// jobExecutionID - the unique id of the job execution +// stepName - the name of the step. +// targetID - the target id. +func (client JobTargetExecutionsClient) Get(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, jobExecutionID uuid.UUID, stepName string, targetID uuid.UUID) (result JobExecution, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobTargetExecutionsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, jobAgentName, jobName, jobExecutionID, stepName, targetID) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobTargetExecutionsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.JobTargetExecutionsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobTargetExecutionsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client JobTargetExecutionsClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, jobExecutionID uuid.UUID, stepName string, targetID uuid.UUID) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "jobAgentName": autorest.Encode("path", jobAgentName), + "jobExecutionId": autorest.Encode("path", jobExecutionID), + "jobName": autorest.Encode("path", jobName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "stepName": autorest.Encode("path", stepName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "targetId": autorest.Encode("path", targetID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/executions/{jobExecutionId}/steps/{stepName}/targets/{targetId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client JobTargetExecutionsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client JobTargetExecutionsClient) GetResponder(resp *http.Response) (result JobExecution, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByJobExecution lists target executions for all steps of a job execution. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// jobAgentName - the name of the job agent. +// jobName - the name of the job to get. +// jobExecutionID - the id of the job execution +// createTimeMin - if specified, only job executions created at or after the specified time are included. +// createTimeMax - if specified, only job executions created before the specified time are included. +// endTimeMin - if specified, only job executions completed at or after the specified time are included. +// endTimeMax - if specified, only job executions completed before the specified time are included. +// isActive - if specified, only active or only completed job executions are included. +// skip - the number of elements in the collection to skip. +// top - the number of elements to return from the collection. +func (client JobTargetExecutionsClient) ListByJobExecution(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, jobExecutionID uuid.UUID, createTimeMin *date.Time, createTimeMax *date.Time, endTimeMin *date.Time, endTimeMax *date.Time, isActive *bool, skip *int32, top *int32) (result JobExecutionListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobTargetExecutionsClient.ListByJobExecution") + defer func() { + sc := -1 + if result.jelr.Response.Response != nil { + sc = result.jelr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByJobExecutionNextResults + req, err := client.ListByJobExecutionPreparer(ctx, resourceGroupName, serverName, jobAgentName, jobName, jobExecutionID, createTimeMin, createTimeMax, endTimeMin, endTimeMax, isActive, skip, top) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobTargetExecutionsClient", "ListByJobExecution", nil, "Failure preparing request") + return + } + + resp, err := client.ListByJobExecutionSender(req) + if err != nil { + result.jelr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.JobTargetExecutionsClient", "ListByJobExecution", resp, "Failure sending request") + return + } + + result.jelr, err = client.ListByJobExecutionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobTargetExecutionsClient", "ListByJobExecution", resp, "Failure responding to request") + return + } + if result.jelr.hasNextLink() && result.jelr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByJobExecutionPreparer prepares the ListByJobExecution request. +func (client JobTargetExecutionsClient) ListByJobExecutionPreparer(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, jobExecutionID uuid.UUID, createTimeMin *date.Time, createTimeMax *date.Time, endTimeMin *date.Time, endTimeMax *date.Time, isActive *bool, skip *int32, top *int32) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "jobAgentName": autorest.Encode("path", jobAgentName), + "jobExecutionId": autorest.Encode("path", jobExecutionID), + "jobName": autorest.Encode("path", jobName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if createTimeMin != nil { + queryParameters["createTimeMin"] = autorest.Encode("query", *createTimeMin) + } + if createTimeMax != nil { + queryParameters["createTimeMax"] = autorest.Encode("query", *createTimeMax) + } + if endTimeMin != nil { + queryParameters["endTimeMin"] = autorest.Encode("query", *endTimeMin) + } + if endTimeMax != nil { + queryParameters["endTimeMax"] = autorest.Encode("query", *endTimeMax) + } + if isActive != nil { + queryParameters["isActive"] = autorest.Encode("query", *isActive) + } + if skip != nil { + queryParameters["$skip"] = autorest.Encode("query", *skip) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/executions/{jobExecutionId}/targets", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByJobExecutionSender sends the ListByJobExecution request. The method will close the +// http.Response Body if it receives an error. +func (client JobTargetExecutionsClient) ListByJobExecutionSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByJobExecutionResponder handles the response to the ListByJobExecution request. The method always +// closes the http.Response Body. +func (client JobTargetExecutionsClient) ListByJobExecutionResponder(resp *http.Response) (result JobExecutionListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByJobExecutionNextResults retrieves the next set of results, if any. +func (client JobTargetExecutionsClient) listByJobExecutionNextResults(ctx context.Context, lastResults JobExecutionListResult) (result JobExecutionListResult, err error) { + req, err := lastResults.jobExecutionListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.JobTargetExecutionsClient", "listByJobExecutionNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByJobExecutionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.JobTargetExecutionsClient", "listByJobExecutionNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByJobExecutionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobTargetExecutionsClient", "listByJobExecutionNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByJobExecutionComplete enumerates all values, automatically crossing page boundaries as required. +func (client JobTargetExecutionsClient) ListByJobExecutionComplete(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, jobExecutionID uuid.UUID, createTimeMin *date.Time, createTimeMax *date.Time, endTimeMin *date.Time, endTimeMax *date.Time, isActive *bool, skip *int32, top *int32) (result JobExecutionListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobTargetExecutionsClient.ListByJobExecution") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByJobExecution(ctx, resourceGroupName, serverName, jobAgentName, jobName, jobExecutionID, createTimeMin, createTimeMax, endTimeMin, endTimeMax, isActive, skip, top) + return +} + +// ListByStep lists the target executions of a job step execution. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// jobAgentName - the name of the job agent. +// jobName - the name of the job to get. +// jobExecutionID - the id of the job execution +// stepName - the name of the step. +// createTimeMin - if specified, only job executions created at or after the specified time are included. +// createTimeMax - if specified, only job executions created before the specified time are included. +// endTimeMin - if specified, only job executions completed at or after the specified time are included. +// endTimeMax - if specified, only job executions completed before the specified time are included. +// isActive - if specified, only active or only completed job executions are included. +// skip - the number of elements in the collection to skip. +// top - the number of elements to return from the collection. +func (client JobTargetExecutionsClient) ListByStep(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, jobExecutionID uuid.UUID, stepName string, createTimeMin *date.Time, createTimeMax *date.Time, endTimeMin *date.Time, endTimeMax *date.Time, isActive *bool, skip *int32, top *int32) (result JobExecutionListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobTargetExecutionsClient.ListByStep") + defer func() { + sc := -1 + if result.jelr.Response.Response != nil { + sc = result.jelr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByStepNextResults + req, err := client.ListByStepPreparer(ctx, resourceGroupName, serverName, jobAgentName, jobName, jobExecutionID, stepName, createTimeMin, createTimeMax, endTimeMin, endTimeMax, isActive, skip, top) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobTargetExecutionsClient", "ListByStep", nil, "Failure preparing request") + return + } + + resp, err := client.ListByStepSender(req) + if err != nil { + result.jelr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.JobTargetExecutionsClient", "ListByStep", resp, "Failure sending request") + return + } + + result.jelr, err = client.ListByStepResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobTargetExecutionsClient", "ListByStep", resp, "Failure responding to request") + return + } + if result.jelr.hasNextLink() && result.jelr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByStepPreparer prepares the ListByStep request. +func (client JobTargetExecutionsClient) ListByStepPreparer(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, jobExecutionID uuid.UUID, stepName string, createTimeMin *date.Time, createTimeMax *date.Time, endTimeMin *date.Time, endTimeMax *date.Time, isActive *bool, skip *int32, top *int32) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "jobAgentName": autorest.Encode("path", jobAgentName), + "jobExecutionId": autorest.Encode("path", jobExecutionID), + "jobName": autorest.Encode("path", jobName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "stepName": autorest.Encode("path", stepName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if createTimeMin != nil { + queryParameters["createTimeMin"] = autorest.Encode("query", *createTimeMin) + } + if createTimeMax != nil { + queryParameters["createTimeMax"] = autorest.Encode("query", *createTimeMax) + } + if endTimeMin != nil { + queryParameters["endTimeMin"] = autorest.Encode("query", *endTimeMin) + } + if endTimeMax != nil { + queryParameters["endTimeMax"] = autorest.Encode("query", *endTimeMax) + } + if isActive != nil { + queryParameters["isActive"] = autorest.Encode("query", *isActive) + } + if skip != nil { + queryParameters["$skip"] = autorest.Encode("query", *skip) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/executions/{jobExecutionId}/steps/{stepName}/targets", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByStepSender sends the ListByStep request. The method will close the +// http.Response Body if it receives an error. +func (client JobTargetExecutionsClient) ListByStepSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByStepResponder handles the response to the ListByStep request. The method always +// closes the http.Response Body. +func (client JobTargetExecutionsClient) ListByStepResponder(resp *http.Response) (result JobExecutionListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByStepNextResults retrieves the next set of results, if any. +func (client JobTargetExecutionsClient) listByStepNextResults(ctx context.Context, lastResults JobExecutionListResult) (result JobExecutionListResult, err error) { + req, err := lastResults.jobExecutionListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.JobTargetExecutionsClient", "listByStepNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByStepSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.JobTargetExecutionsClient", "listByStepNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByStepResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobTargetExecutionsClient", "listByStepNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByStepComplete enumerates all values, automatically crossing page boundaries as required. +func (client JobTargetExecutionsClient) ListByStepComplete(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, jobExecutionID uuid.UUID, stepName string, createTimeMin *date.Time, createTimeMax *date.Time, endTimeMin *date.Time, endTimeMax *date.Time, isActive *bool, skip *int32, top *int32) (result JobExecutionListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobTargetExecutionsClient.ListByStep") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByStep(ctx, resourceGroupName, serverName, jobAgentName, jobName, jobExecutionID, stepName, createTimeMin, createTimeMax, endTimeMin, endTimeMax, isActive, skip, top) + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/jobtargetgroups.go b/services/preview/sql/mgmt/v5.0/sql/jobtargetgroups.go new file mode 100644 index 000000000000..cd1c4e2937aa --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/jobtargetgroups.go @@ -0,0 +1,407 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// JobTargetGroupsClient is the the Azure SQL Database management API provides a RESTful set of web services that +// interact with Azure SQL Database services to manage your databases. The API enables you to create, retrieve, update, +// and delete databases. +type JobTargetGroupsClient struct { + BaseClient +} + +// NewJobTargetGroupsClient creates an instance of the JobTargetGroupsClient client. +func NewJobTargetGroupsClient(subscriptionID string) JobTargetGroupsClient { + return NewJobTargetGroupsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewJobTargetGroupsClientWithBaseURI creates an instance of the JobTargetGroupsClient client using a custom endpoint. +// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewJobTargetGroupsClientWithBaseURI(baseURI string, subscriptionID string) JobTargetGroupsClient { + return JobTargetGroupsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a target group. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// jobAgentName - the name of the job agent. +// targetGroupName - the name of the target group. +// parameters - the requested state of the target group. +func (client JobTargetGroupsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, targetGroupName string, parameters JobTargetGroup) (result JobTargetGroup, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobTargetGroupsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.JobTargetGroupProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.JobTargetGroupProperties.Members", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("sql.JobTargetGroupsClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, jobAgentName, targetGroupName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobTargetGroupsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.JobTargetGroupsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobTargetGroupsClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client JobTargetGroupsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, targetGroupName string, parameters JobTargetGroup) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "jobAgentName": autorest.Encode("path", jobAgentName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "targetGroupName": autorest.Encode("path", targetGroupName), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/targetGroups/{targetGroupName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client JobTargetGroupsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client JobTargetGroupsClient) CreateOrUpdateResponder(resp *http.Response) (result JobTargetGroup, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a target group. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// jobAgentName - the name of the job agent. +// targetGroupName - the name of the target group. +func (client JobTargetGroupsClient) Delete(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, targetGroupName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobTargetGroupsClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, serverName, jobAgentName, targetGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobTargetGroupsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "sql.JobTargetGroupsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobTargetGroupsClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client JobTargetGroupsClient) DeletePreparer(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, targetGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "jobAgentName": autorest.Encode("path", jobAgentName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "targetGroupName": autorest.Encode("path", targetGroupName), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/targetGroups/{targetGroupName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client JobTargetGroupsClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client JobTargetGroupsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a target group. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// jobAgentName - the name of the job agent. +// targetGroupName - the name of the target group. +func (client JobTargetGroupsClient) Get(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, targetGroupName string) (result JobTargetGroup, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobTargetGroupsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, jobAgentName, targetGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobTargetGroupsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.JobTargetGroupsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobTargetGroupsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client JobTargetGroupsClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, targetGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "jobAgentName": autorest.Encode("path", jobAgentName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "targetGroupName": autorest.Encode("path", targetGroupName), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/targetGroups/{targetGroupName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client JobTargetGroupsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client JobTargetGroupsClient) GetResponder(resp *http.Response) (result JobTargetGroup, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAgent gets all target groups in an agent. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// jobAgentName - the name of the job agent. +func (client JobTargetGroupsClient) ListByAgent(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string) (result JobTargetGroupListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobTargetGroupsClient.ListByAgent") + defer func() { + sc := -1 + if result.jtglr.Response.Response != nil { + sc = result.jtglr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByAgentNextResults + req, err := client.ListByAgentPreparer(ctx, resourceGroupName, serverName, jobAgentName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobTargetGroupsClient", "ListByAgent", nil, "Failure preparing request") + return + } + + resp, err := client.ListByAgentSender(req) + if err != nil { + result.jtglr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.JobTargetGroupsClient", "ListByAgent", resp, "Failure sending request") + return + } + + result.jtglr, err = client.ListByAgentResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobTargetGroupsClient", "ListByAgent", resp, "Failure responding to request") + return + } + if result.jtglr.hasNextLink() && result.jtglr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByAgentPreparer prepares the ListByAgent request. +func (client JobTargetGroupsClient) ListByAgentPreparer(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "jobAgentName": autorest.Encode("path", jobAgentName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/targetGroups", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByAgentSender sends the ListByAgent request. The method will close the +// http.Response Body if it receives an error. +func (client JobTargetGroupsClient) ListByAgentSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByAgentResponder handles the response to the ListByAgent request. The method always +// closes the http.Response Body. +func (client JobTargetGroupsClient) ListByAgentResponder(resp *http.Response) (result JobTargetGroupListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByAgentNextResults retrieves the next set of results, if any. +func (client JobTargetGroupsClient) listByAgentNextResults(ctx context.Context, lastResults JobTargetGroupListResult) (result JobTargetGroupListResult, err error) { + req, err := lastResults.jobTargetGroupListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.JobTargetGroupsClient", "listByAgentNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByAgentSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.JobTargetGroupsClient", "listByAgentNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByAgentResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobTargetGroupsClient", "listByAgentNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByAgentComplete enumerates all values, automatically crossing page boundaries as required. +func (client JobTargetGroupsClient) ListByAgentComplete(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string) (result JobTargetGroupListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobTargetGroupsClient.ListByAgent") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByAgent(ctx, resourceGroupName, serverName, jobAgentName) + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/jobversions.go b/services/preview/sql/mgmt/v5.0/sql/jobversions.go new file mode 100644 index 000000000000..da655fbfef2a --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/jobversions.go @@ -0,0 +1,239 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// JobVersionsClient is the the Azure SQL Database management API provides a RESTful set of web services that interact +// with Azure SQL Database services to manage your databases. The API enables you to create, retrieve, update, and +// delete databases. +type JobVersionsClient struct { + BaseClient +} + +// NewJobVersionsClient creates an instance of the JobVersionsClient client. +func NewJobVersionsClient(subscriptionID string) JobVersionsClient { + return NewJobVersionsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewJobVersionsClientWithBaseURI creates an instance of the JobVersionsClient client using a custom endpoint. Use +// this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewJobVersionsClientWithBaseURI(baseURI string, subscriptionID string) JobVersionsClient { + return JobVersionsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get gets a job version. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// jobAgentName - the name of the job agent. +// jobName - the name of the job. +// jobVersion - the version of the job to get. +func (client JobVersionsClient) Get(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, jobVersion int32) (result JobVersion, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobVersionsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, jobAgentName, jobName, jobVersion) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobVersionsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.JobVersionsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobVersionsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client JobVersionsClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, jobVersion int32) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "jobAgentName": autorest.Encode("path", jobAgentName), + "jobName": autorest.Encode("path", jobName), + "jobVersion": autorest.Encode("path", jobVersion), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/versions/{jobVersion}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client JobVersionsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client JobVersionsClient) GetResponder(resp *http.Response) (result JobVersion, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByJob gets all versions of a job. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// jobAgentName - the name of the job agent. +// jobName - the name of the job to get. +func (client JobVersionsClient) ListByJob(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string) (result JobVersionListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobVersionsClient.ListByJob") + defer func() { + sc := -1 + if result.jvlr.Response.Response != nil { + sc = result.jvlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByJobNextResults + req, err := client.ListByJobPreparer(ctx, resourceGroupName, serverName, jobAgentName, jobName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobVersionsClient", "ListByJob", nil, "Failure preparing request") + return + } + + resp, err := client.ListByJobSender(req) + if err != nil { + result.jvlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.JobVersionsClient", "ListByJob", resp, "Failure sending request") + return + } + + result.jvlr, err = client.ListByJobResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobVersionsClient", "ListByJob", resp, "Failure responding to request") + return + } + if result.jvlr.hasNextLink() && result.jvlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByJobPreparer prepares the ListByJob request. +func (client JobVersionsClient) ListByJobPreparer(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "jobAgentName": autorest.Encode("path", jobAgentName), + "jobName": autorest.Encode("path", jobName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/versions", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByJobSender sends the ListByJob request. The method will close the +// http.Response Body if it receives an error. +func (client JobVersionsClient) ListByJobSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByJobResponder handles the response to the ListByJob request. The method always +// closes the http.Response Body. +func (client JobVersionsClient) ListByJobResponder(resp *http.Response) (result JobVersionListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByJobNextResults retrieves the next set of results, if any. +func (client JobVersionsClient) listByJobNextResults(ctx context.Context, lastResults JobVersionListResult) (result JobVersionListResult, err error) { + req, err := lastResults.jobVersionListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.JobVersionsClient", "listByJobNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByJobSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.JobVersionsClient", "listByJobNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByJobResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobVersionsClient", "listByJobNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByJobComplete enumerates all values, automatically crossing page boundaries as required. +func (client JobVersionsClient) ListByJobComplete(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string) (result JobVersionListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobVersionsClient.ListByJob") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByJob(ctx, resourceGroupName, serverName, jobAgentName, jobName) + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/ledgerdigestuploads.go b/services/preview/sql/mgmt/v5.0/sql/ledgerdigestuploads.go new file mode 100644 index 000000000000..c5103a6ca454 --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/ledgerdigestuploads.go @@ -0,0 +1,397 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// LedgerDigestUploadsClient 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 LedgerDigestUploadsClient struct { + BaseClient +} + +// NewLedgerDigestUploadsClient creates an instance of the LedgerDigestUploadsClient client. +func NewLedgerDigestUploadsClient(subscriptionID string) LedgerDigestUploadsClient { + return NewLedgerDigestUploadsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewLedgerDigestUploadsClientWithBaseURI creates an instance of the LedgerDigestUploadsClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewLedgerDigestUploadsClientWithBaseURI(baseURI string, subscriptionID string) LedgerDigestUploadsClient { + return LedgerDigestUploadsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate enables upload ledger digests to an Azure Storage account or an Azure Confidential Ledger instance. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database. +func (client LedgerDigestUploadsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters LedgerDigestUploads) (result LedgerDigestUploads, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LedgerDigestUploadsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, databaseName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LedgerDigestUploadsClient", "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.LedgerDigestUploadsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LedgerDigestUploadsClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client LedgerDigestUploadsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters LedgerDigestUploads) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "ledgerDigestUploads": autorest.Encode("path", "current"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-02-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.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}/ledgerDigestUploads/{ledgerDigestUploads}", 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 LedgerDigestUploadsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client LedgerDigestUploadsClient) CreateOrUpdateResponder(resp *http.Response) (result LedgerDigestUploads, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Disable disables uploading ledger digests to an Azure Storage account or an Azure Confidential Ledger instance. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database. +func (client LedgerDigestUploadsClient) Disable(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result LedgerDigestUploads, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LedgerDigestUploadsClient.Disable") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DisablePreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LedgerDigestUploadsClient", "Disable", nil, "Failure preparing request") + return + } + + resp, err := client.DisableSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.LedgerDigestUploadsClient", "Disable", resp, "Failure sending request") + return + } + + result, err = client.DisableResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LedgerDigestUploadsClient", "Disable", resp, "Failure responding to request") + return + } + + return +} + +// DisablePreparer prepares the Disable request. +func (client LedgerDigestUploadsClient) DisablePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "ledgerDigestUploads": autorest.Encode("path", "current"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-02-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/ledgerDigestUploads/{ledgerDigestUploads}/disable", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DisableSender sends the Disable request. The method will close the +// http.Response Body if it receives an error. +func (client LedgerDigestUploadsClient) DisableSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DisableResponder handles the response to the Disable request. The method always +// closes the http.Response Body. +func (client LedgerDigestUploadsClient) DisableResponder(resp *http.Response) (result LedgerDigestUploads, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets the current ledger digest upload configuration for a database. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database. +func (client LedgerDigestUploadsClient) Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result LedgerDigestUploads, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LedgerDigestUploadsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LedgerDigestUploadsClient", "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.LedgerDigestUploadsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LedgerDigestUploadsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client LedgerDigestUploadsClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "ledgerDigestUploads": autorest.Encode("path", "current"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-02-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/ledgerDigestUploads/{ledgerDigestUploads}", 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 LedgerDigestUploadsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client LedgerDigestUploadsClient) GetResponder(resp *http.Response) (result LedgerDigestUploads, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByDatabase gets all ledger digest upload settings on a database. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database. +func (client LedgerDigestUploadsClient) ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result LedgerDigestUploadsListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LedgerDigestUploadsClient.ListByDatabase") + defer func() { + sc := -1 + if result.ldulr.Response.Response != nil { + sc = result.ldulr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByDatabaseNextResults + req, err := client.ListByDatabasePreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LedgerDigestUploadsClient", "ListByDatabase", nil, "Failure preparing request") + return + } + + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.ldulr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.LedgerDigestUploadsClient", "ListByDatabase", resp, "Failure sending request") + return + } + + result.ldulr, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LedgerDigestUploadsClient", "ListByDatabase", resp, "Failure responding to request") + return + } + if result.ldulr.hasNextLink() && result.ldulr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByDatabasePreparer prepares the ListByDatabase request. +func (client LedgerDigestUploadsClient) ListByDatabasePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-02-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/ledgerDigestUploads", 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 LedgerDigestUploadsClient) ListByDatabaseSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByDatabaseResponder handles the response to the ListByDatabase request. The method always +// closes the http.Response Body. +func (client LedgerDigestUploadsClient) ListByDatabaseResponder(resp *http.Response) (result LedgerDigestUploadsListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByDatabaseNextResults retrieves the next set of results, if any. +func (client LedgerDigestUploadsClient) listByDatabaseNextResults(ctx context.Context, lastResults LedgerDigestUploadsListResult) (result LedgerDigestUploadsListResult, err error) { + req, err := lastResults.ledgerDigestUploadsListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.LedgerDigestUploadsClient", "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.LedgerDigestUploadsClient", "listByDatabaseNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LedgerDigestUploadsClient", "listByDatabaseNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByDatabaseComplete enumerates all values, automatically crossing page boundaries as required. +func (client LedgerDigestUploadsClient) ListByDatabaseComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result LedgerDigestUploadsListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LedgerDigestUploadsClient.ListByDatabase") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByDatabase(ctx, resourceGroupName, serverName, databaseName) + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/longtermretentionbackups.go b/services/preview/sql/mgmt/v5.0/sql/longtermretentionbackups.go new file mode 100644 index 000000000000..9936c1b783ae --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/longtermretentionbackups.go @@ -0,0 +1,1473 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// LongTermRetentionBackupsClient is the the Azure SQL Database management API provides a RESTful set of web services +// that interact with Azure SQL Database services to manage your databases. The API enables you to create, retrieve, +// update, and delete databases. +type LongTermRetentionBackupsClient struct { + BaseClient +} + +// NewLongTermRetentionBackupsClient creates an instance of the LongTermRetentionBackupsClient client. +func NewLongTermRetentionBackupsClient(subscriptionID string) LongTermRetentionBackupsClient { + return NewLongTermRetentionBackupsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewLongTermRetentionBackupsClientWithBaseURI creates an instance of the LongTermRetentionBackupsClient client using +// a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign +// clouds, Azure stack). +func NewLongTermRetentionBackupsClientWithBaseURI(baseURI string, subscriptionID string) LongTermRetentionBackupsClient { + return LongTermRetentionBackupsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Copy copy an existing long term retention backup. +// Parameters: +// locationName - the location of the database. +// longTermRetentionServerName - the name of the server +// longTermRetentionDatabaseName - the name of the database +// backupName - the backup name. +// parameters - the parameters needed for long term retention copy request +func (client LongTermRetentionBackupsClient) Copy(ctx context.Context, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, backupName string, parameters CopyLongTermRetentionBackupParameters) (result LongTermRetentionBackupsCopyFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionBackupsClient.Copy") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CopyPreparer(ctx, locationName, longTermRetentionServerName, longTermRetentionDatabaseName, backupName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "Copy", nil, "Failure preparing request") + return + } + + result, err = client.CopySender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "Copy", nil, "Failure sending request") + return + } + + return +} + +// CopyPreparer prepares the Copy request. +func (client LongTermRetentionBackupsClient) CopyPreparer(ctx context.Context, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, backupName string, parameters CopyLongTermRetentionBackupParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "backupName": autorest.Encode("path", backupName), + "locationName": autorest.Encode("path", locationName), + "longTermRetentionDatabaseName": autorest.Encode("path", longTermRetentionDatabaseName), + "longTermRetentionServerName": autorest.Encode("path", longTermRetentionServerName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}/copy", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CopySender sends the Copy request. The method will close the +// http.Response Body if it receives an error. +func (client LongTermRetentionBackupsClient) CopySender(req *http.Request) (future LongTermRetentionBackupsCopyFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CopyResponder handles the response to the Copy request. The method always +// closes the http.Response Body. +func (client LongTermRetentionBackupsClient) CopyResponder(resp *http.Response) (result LongTermRetentionBackupOperationResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// CopyByResourceGroup copy an existing long term retention backup to a different server. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// locationName - the location of the database. +// longTermRetentionServerName - the name of the server +// longTermRetentionDatabaseName - the name of the database +// backupName - the backup name. +// parameters - the parameters needed for long term retention copy request +func (client LongTermRetentionBackupsClient) CopyByResourceGroup(ctx context.Context, resourceGroupName string, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, backupName string, parameters CopyLongTermRetentionBackupParameters) (result LongTermRetentionBackupsCopyByResourceGroupFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionBackupsClient.CopyByResourceGroup") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CopyByResourceGroupPreparer(ctx, resourceGroupName, locationName, longTermRetentionServerName, longTermRetentionDatabaseName, backupName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "CopyByResourceGroup", nil, "Failure preparing request") + return + } + + result, err = client.CopyByResourceGroupSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "CopyByResourceGroup", nil, "Failure sending request") + return + } + + return +} + +// CopyByResourceGroupPreparer prepares the CopyByResourceGroup request. +func (client LongTermRetentionBackupsClient) CopyByResourceGroupPreparer(ctx context.Context, resourceGroupName string, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, backupName string, parameters CopyLongTermRetentionBackupParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "backupName": autorest.Encode("path", backupName), + "locationName": autorest.Encode("path", locationName), + "longTermRetentionDatabaseName": autorest.Encode("path", longTermRetentionDatabaseName), + "longTermRetentionServerName": autorest.Encode("path", longTermRetentionServerName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}/copy", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CopyByResourceGroupSender sends the CopyByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client LongTermRetentionBackupsClient) CopyByResourceGroupSender(req *http.Request) (future LongTermRetentionBackupsCopyByResourceGroupFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CopyByResourceGroupResponder handles the response to the CopyByResourceGroup request. The method always +// closes the http.Response Body. +func (client LongTermRetentionBackupsClient) CopyByResourceGroupResponder(resp *http.Response) (result LongTermRetentionBackupOperationResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a long term retention backup. +// Parameters: +// locationName - the location of the database +// longTermRetentionServerName - the name of the server +// longTermRetentionDatabaseName - the name of the database +// backupName - the backup name. +func (client LongTermRetentionBackupsClient) Delete(ctx context.Context, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, backupName string) (result LongTermRetentionBackupsDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionBackupsClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, locationName, longTermRetentionServerName, longTermRetentionDatabaseName, backupName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "Delete", nil, "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client LongTermRetentionBackupsClient) DeletePreparer(ctx context.Context, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, backupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "backupName": autorest.Encode("path", backupName), + "locationName": autorest.Encode("path", locationName), + "longTermRetentionDatabaseName": autorest.Encode("path", longTermRetentionDatabaseName), + "longTermRetentionServerName": autorest.Encode("path", longTermRetentionServerName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client LongTermRetentionBackupsClient) DeleteSender(req *http.Request) (future LongTermRetentionBackupsDeleteFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client LongTermRetentionBackupsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + +// DeleteByResourceGroup deletes a long term retention backup. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// locationName - the location of the database +// longTermRetentionServerName - the name of the server +// longTermRetentionDatabaseName - the name of the database +// backupName - the backup name. +func (client LongTermRetentionBackupsClient) DeleteByResourceGroup(ctx context.Context, resourceGroupName string, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, backupName string) (result LongTermRetentionBackupsDeleteByResourceGroupFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionBackupsClient.DeleteByResourceGroup") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeleteByResourceGroupPreparer(ctx, resourceGroupName, locationName, longTermRetentionServerName, longTermRetentionDatabaseName, backupName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "DeleteByResourceGroup", nil, "Failure preparing request") + return + } + + result, err = client.DeleteByResourceGroupSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "DeleteByResourceGroup", nil, "Failure sending request") + return + } + + return +} + +// DeleteByResourceGroupPreparer prepares the DeleteByResourceGroup request. +func (client LongTermRetentionBackupsClient) DeleteByResourceGroupPreparer(ctx context.Context, resourceGroupName string, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, backupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "backupName": autorest.Encode("path", backupName), + "locationName": autorest.Encode("path", locationName), + "longTermRetentionDatabaseName": autorest.Encode("path", longTermRetentionDatabaseName), + "longTermRetentionServerName": autorest.Encode("path", longTermRetentionServerName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteByResourceGroupSender sends the DeleteByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client LongTermRetentionBackupsClient) DeleteByResourceGroupSender(req *http.Request) (future LongTermRetentionBackupsDeleteByResourceGroupFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteByResourceGroupResponder handles the response to the DeleteByResourceGroup request. The method always +// closes the http.Response Body. +func (client LongTermRetentionBackupsClient) DeleteByResourceGroupResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a long term retention backup. +// Parameters: +// locationName - the location of the database. +// longTermRetentionServerName - the name of the server +// longTermRetentionDatabaseName - the name of the database +// backupName - the backup name. +func (client LongTermRetentionBackupsClient) Get(ctx context.Context, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, backupName string) (result LongTermRetentionBackup, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionBackupsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, locationName, longTermRetentionServerName, longTermRetentionDatabaseName, backupName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client LongTermRetentionBackupsClient) GetPreparer(ctx context.Context, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, backupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "backupName": autorest.Encode("path", backupName), + "locationName": autorest.Encode("path", locationName), + "longTermRetentionDatabaseName": autorest.Encode("path", longTermRetentionDatabaseName), + "longTermRetentionServerName": autorest.Encode("path", longTermRetentionServerName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client LongTermRetentionBackupsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client LongTermRetentionBackupsClient) GetResponder(resp *http.Response) (result LongTermRetentionBackup, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetByResourceGroup gets a long term retention backup. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// locationName - the location of the database. +// longTermRetentionServerName - the name of the server +// longTermRetentionDatabaseName - the name of the database +// backupName - the backup name. +func (client LongTermRetentionBackupsClient) GetByResourceGroup(ctx context.Context, resourceGroupName string, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, backupName string) (result LongTermRetentionBackup, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionBackupsClient.GetByResourceGroup") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetByResourceGroupPreparer(ctx, resourceGroupName, locationName, longTermRetentionServerName, longTermRetentionDatabaseName, backupName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "GetByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.GetByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "GetByResourceGroup", resp, "Failure sending request") + return + } + + result, err = client.GetByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "GetByResourceGroup", resp, "Failure responding to request") + return + } + + return +} + +// GetByResourceGroupPreparer prepares the GetByResourceGroup request. +func (client LongTermRetentionBackupsClient) GetByResourceGroupPreparer(ctx context.Context, resourceGroupName string, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, backupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "backupName": autorest.Encode("path", backupName), + "locationName": autorest.Encode("path", locationName), + "longTermRetentionDatabaseName": autorest.Encode("path", longTermRetentionDatabaseName), + "longTermRetentionServerName": autorest.Encode("path", longTermRetentionServerName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetByResourceGroupSender sends the GetByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client LongTermRetentionBackupsClient) GetByResourceGroupSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetByResourceGroupResponder handles the response to the GetByResourceGroup request. The method always +// closes the http.Response Body. +func (client LongTermRetentionBackupsClient) GetByResourceGroupResponder(resp *http.Response) (result LongTermRetentionBackup, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByDatabase lists all long term retention backups for a database. +// Parameters: +// locationName - the location of the database +// longTermRetentionServerName - the name of the server +// longTermRetentionDatabaseName - the name of the database +// onlyLatestPerDatabase - whether or not to only get the latest backup for each database. +// databaseState - whether to query against just live databases, just deleted databases, or all databases. +func (client LongTermRetentionBackupsClient) ListByDatabase(ctx context.Context, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, onlyLatestPerDatabase *bool, databaseState DatabaseState) (result LongTermRetentionBackupListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionBackupsClient.ListByDatabase") + defer func() { + sc := -1 + if result.ltrblr.Response.Response != nil { + sc = result.ltrblr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByDatabaseNextResults + req, err := client.ListByDatabasePreparer(ctx, locationName, longTermRetentionServerName, longTermRetentionDatabaseName, onlyLatestPerDatabase, databaseState) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "ListByDatabase", nil, "Failure preparing request") + return + } + + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.ltrblr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "ListByDatabase", resp, "Failure sending request") + return + } + + result.ltrblr, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "ListByDatabase", resp, "Failure responding to request") + return + } + if result.ltrblr.hasNextLink() && result.ltrblr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByDatabasePreparer prepares the ListByDatabase request. +func (client LongTermRetentionBackupsClient) ListByDatabasePreparer(ctx context.Context, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, onlyLatestPerDatabase *bool, databaseState DatabaseState) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "locationName": autorest.Encode("path", locationName), + "longTermRetentionDatabaseName": autorest.Encode("path", longTermRetentionDatabaseName), + "longTermRetentionServerName": autorest.Encode("path", longTermRetentionServerName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if onlyLatestPerDatabase != nil { + queryParameters["onlyLatestPerDatabase"] = autorest.Encode("query", *onlyLatestPerDatabase) + } + if len(string(databaseState)) > 0 { + queryParameters["databaseState"] = autorest.Encode("query", databaseState) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByDatabaseSender sends the ListByDatabase request. The method will close the +// http.Response Body if it receives an error. +func (client LongTermRetentionBackupsClient) ListByDatabaseSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByDatabaseResponder handles the response to the ListByDatabase request. The method always +// closes the http.Response Body. +func (client LongTermRetentionBackupsClient) ListByDatabaseResponder(resp *http.Response) (result LongTermRetentionBackupListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByDatabaseNextResults retrieves the next set of results, if any. +func (client LongTermRetentionBackupsClient) listByDatabaseNextResults(ctx context.Context, lastResults LongTermRetentionBackupListResult) (result LongTermRetentionBackupListResult, err error) { + req, err := lastResults.longTermRetentionBackupListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "listByDatabaseNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "listByDatabaseNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "listByDatabaseNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByDatabaseComplete enumerates all values, automatically crossing page boundaries as required. +func (client LongTermRetentionBackupsClient) ListByDatabaseComplete(ctx context.Context, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, onlyLatestPerDatabase *bool, databaseState DatabaseState) (result LongTermRetentionBackupListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionBackupsClient.ListByDatabase") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByDatabase(ctx, locationName, longTermRetentionServerName, longTermRetentionDatabaseName, onlyLatestPerDatabase, databaseState) + return +} + +// ListByLocation lists the long term retention backups for a given location. +// Parameters: +// locationName - the location of the database +// onlyLatestPerDatabase - whether or not to only get the latest backup for each database. +// databaseState - whether to query against just live databases, just deleted databases, or all databases. +func (client LongTermRetentionBackupsClient) ListByLocation(ctx context.Context, locationName string, onlyLatestPerDatabase *bool, databaseState DatabaseState) (result LongTermRetentionBackupListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionBackupsClient.ListByLocation") + defer func() { + sc := -1 + if result.ltrblr.Response.Response != nil { + sc = result.ltrblr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByLocationNextResults + req, err := client.ListByLocationPreparer(ctx, locationName, onlyLatestPerDatabase, databaseState) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "ListByLocation", nil, "Failure preparing request") + return + } + + resp, err := client.ListByLocationSender(req) + if err != nil { + result.ltrblr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "ListByLocation", resp, "Failure sending request") + return + } + + result.ltrblr, err = client.ListByLocationResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "ListByLocation", resp, "Failure responding to request") + return + } + if result.ltrblr.hasNextLink() && result.ltrblr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByLocationPreparer prepares the ListByLocation request. +func (client LongTermRetentionBackupsClient) ListByLocationPreparer(ctx context.Context, locationName string, onlyLatestPerDatabase *bool, databaseState DatabaseState) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "locationName": autorest.Encode("path", locationName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if onlyLatestPerDatabase != nil { + queryParameters["onlyLatestPerDatabase"] = autorest.Encode("query", *onlyLatestPerDatabase) + } + if len(string(databaseState)) > 0 { + queryParameters["databaseState"] = autorest.Encode("query", databaseState) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionBackups", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByLocationSender sends the ListByLocation request. The method will close the +// http.Response Body if it receives an error. +func (client LongTermRetentionBackupsClient) ListByLocationSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByLocationResponder handles the response to the ListByLocation request. The method always +// closes the http.Response Body. +func (client LongTermRetentionBackupsClient) ListByLocationResponder(resp *http.Response) (result LongTermRetentionBackupListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByLocationNextResults retrieves the next set of results, if any. +func (client LongTermRetentionBackupsClient) listByLocationNextResults(ctx context.Context, lastResults LongTermRetentionBackupListResult) (result LongTermRetentionBackupListResult, err error) { + req, err := lastResults.longTermRetentionBackupListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "listByLocationNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByLocationSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "listByLocationNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByLocationResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "listByLocationNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByLocationComplete enumerates all values, automatically crossing page boundaries as required. +func (client LongTermRetentionBackupsClient) ListByLocationComplete(ctx context.Context, locationName string, onlyLatestPerDatabase *bool, databaseState DatabaseState) (result LongTermRetentionBackupListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionBackupsClient.ListByLocation") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByLocation(ctx, locationName, onlyLatestPerDatabase, databaseState) + return +} + +// ListByResourceGroupDatabase lists all long term retention backups for a database. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// locationName - the location of the database +// longTermRetentionServerName - the name of the server +// longTermRetentionDatabaseName - the name of the database +// onlyLatestPerDatabase - whether or not to only get the latest backup for each database. +// databaseState - whether to query against just live databases, just deleted databases, or all databases. +func (client LongTermRetentionBackupsClient) ListByResourceGroupDatabase(ctx context.Context, resourceGroupName string, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, onlyLatestPerDatabase *bool, databaseState DatabaseState) (result LongTermRetentionBackupListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionBackupsClient.ListByResourceGroupDatabase") + defer func() { + sc := -1 + if result.ltrblr.Response.Response != nil { + sc = result.ltrblr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByResourceGroupDatabaseNextResults + req, err := client.ListByResourceGroupDatabasePreparer(ctx, resourceGroupName, locationName, longTermRetentionServerName, longTermRetentionDatabaseName, onlyLatestPerDatabase, databaseState) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "ListByResourceGroupDatabase", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupDatabaseSender(req) + if err != nil { + result.ltrblr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "ListByResourceGroupDatabase", resp, "Failure sending request") + return + } + + result.ltrblr, err = client.ListByResourceGroupDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "ListByResourceGroupDatabase", resp, "Failure responding to request") + return + } + if result.ltrblr.hasNextLink() && result.ltrblr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByResourceGroupDatabasePreparer prepares the ListByResourceGroupDatabase request. +func (client LongTermRetentionBackupsClient) ListByResourceGroupDatabasePreparer(ctx context.Context, resourceGroupName string, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, onlyLatestPerDatabase *bool, databaseState DatabaseState) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "locationName": autorest.Encode("path", locationName), + "longTermRetentionDatabaseName": autorest.Encode("path", longTermRetentionDatabaseName), + "longTermRetentionServerName": autorest.Encode("path", longTermRetentionServerName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if onlyLatestPerDatabase != nil { + queryParameters["onlyLatestPerDatabase"] = autorest.Encode("query", *onlyLatestPerDatabase) + } + if len(string(databaseState)) > 0 { + queryParameters["databaseState"] = autorest.Encode("query", databaseState) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByResourceGroupDatabaseSender sends the ListByResourceGroupDatabase request. The method will close the +// http.Response Body if it receives an error. +func (client LongTermRetentionBackupsClient) ListByResourceGroupDatabaseSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupDatabaseResponder handles the response to the ListByResourceGroupDatabase request. The method always +// closes the http.Response Body. +func (client LongTermRetentionBackupsClient) ListByResourceGroupDatabaseResponder(resp *http.Response) (result LongTermRetentionBackupListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByResourceGroupDatabaseNextResults retrieves the next set of results, if any. +func (client LongTermRetentionBackupsClient) listByResourceGroupDatabaseNextResults(ctx context.Context, lastResults LongTermRetentionBackupListResult) (result LongTermRetentionBackupListResult, err error) { + req, err := lastResults.longTermRetentionBackupListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "listByResourceGroupDatabaseNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByResourceGroupDatabaseSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "listByResourceGroupDatabaseNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByResourceGroupDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "listByResourceGroupDatabaseNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByResourceGroupDatabaseComplete enumerates all values, automatically crossing page boundaries as required. +func (client LongTermRetentionBackupsClient) ListByResourceGroupDatabaseComplete(ctx context.Context, resourceGroupName string, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, onlyLatestPerDatabase *bool, databaseState DatabaseState) (result LongTermRetentionBackupListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionBackupsClient.ListByResourceGroupDatabase") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByResourceGroupDatabase(ctx, resourceGroupName, locationName, longTermRetentionServerName, longTermRetentionDatabaseName, onlyLatestPerDatabase, databaseState) + return +} + +// ListByResourceGroupLocation lists the long term retention backups for a given location. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// locationName - the location of the database +// onlyLatestPerDatabase - whether or not to only get the latest backup for each database. +// databaseState - whether to query against just live databases, just deleted databases, or all databases. +func (client LongTermRetentionBackupsClient) ListByResourceGroupLocation(ctx context.Context, resourceGroupName string, locationName string, onlyLatestPerDatabase *bool, databaseState DatabaseState) (result LongTermRetentionBackupListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionBackupsClient.ListByResourceGroupLocation") + defer func() { + sc := -1 + if result.ltrblr.Response.Response != nil { + sc = result.ltrblr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByResourceGroupLocationNextResults + req, err := client.ListByResourceGroupLocationPreparer(ctx, resourceGroupName, locationName, onlyLatestPerDatabase, databaseState) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "ListByResourceGroupLocation", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupLocationSender(req) + if err != nil { + result.ltrblr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "ListByResourceGroupLocation", resp, "Failure sending request") + return + } + + result.ltrblr, err = client.ListByResourceGroupLocationResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "ListByResourceGroupLocation", resp, "Failure responding to request") + return + } + if result.ltrblr.hasNextLink() && result.ltrblr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByResourceGroupLocationPreparer prepares the ListByResourceGroupLocation request. +func (client LongTermRetentionBackupsClient) ListByResourceGroupLocationPreparer(ctx context.Context, resourceGroupName string, locationName string, onlyLatestPerDatabase *bool, databaseState DatabaseState) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "locationName": autorest.Encode("path", locationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if onlyLatestPerDatabase != nil { + queryParameters["onlyLatestPerDatabase"] = autorest.Encode("query", *onlyLatestPerDatabase) + } + if len(string(databaseState)) > 0 { + queryParameters["databaseState"] = autorest.Encode("query", databaseState) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionBackups", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByResourceGroupLocationSender sends the ListByResourceGroupLocation request. The method will close the +// http.Response Body if it receives an error. +func (client LongTermRetentionBackupsClient) ListByResourceGroupLocationSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupLocationResponder handles the response to the ListByResourceGroupLocation request. The method always +// closes the http.Response Body. +func (client LongTermRetentionBackupsClient) ListByResourceGroupLocationResponder(resp *http.Response) (result LongTermRetentionBackupListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByResourceGroupLocationNextResults retrieves the next set of results, if any. +func (client LongTermRetentionBackupsClient) listByResourceGroupLocationNextResults(ctx context.Context, lastResults LongTermRetentionBackupListResult) (result LongTermRetentionBackupListResult, err error) { + req, err := lastResults.longTermRetentionBackupListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "listByResourceGroupLocationNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByResourceGroupLocationSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "listByResourceGroupLocationNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByResourceGroupLocationResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "listByResourceGroupLocationNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByResourceGroupLocationComplete enumerates all values, automatically crossing page boundaries as required. +func (client LongTermRetentionBackupsClient) ListByResourceGroupLocationComplete(ctx context.Context, resourceGroupName string, locationName string, onlyLatestPerDatabase *bool, databaseState DatabaseState) (result LongTermRetentionBackupListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionBackupsClient.ListByResourceGroupLocation") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByResourceGroupLocation(ctx, resourceGroupName, locationName, onlyLatestPerDatabase, databaseState) + return +} + +// ListByResourceGroupServer lists the long term retention backups for a given server. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// locationName - the location of the database +// longTermRetentionServerName - the name of the server +// onlyLatestPerDatabase - whether or not to only get the latest backup for each database. +// databaseState - whether to query against just live databases, just deleted databases, or all databases. +func (client LongTermRetentionBackupsClient) ListByResourceGroupServer(ctx context.Context, resourceGroupName string, locationName string, longTermRetentionServerName string, onlyLatestPerDatabase *bool, databaseState DatabaseState) (result LongTermRetentionBackupListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionBackupsClient.ListByResourceGroupServer") + defer func() { + sc := -1 + if result.ltrblr.Response.Response != nil { + sc = result.ltrblr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByResourceGroupServerNextResults + req, err := client.ListByResourceGroupServerPreparer(ctx, resourceGroupName, locationName, longTermRetentionServerName, onlyLatestPerDatabase, databaseState) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "ListByResourceGroupServer", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupServerSender(req) + if err != nil { + result.ltrblr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "ListByResourceGroupServer", resp, "Failure sending request") + return + } + + result.ltrblr, err = client.ListByResourceGroupServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "ListByResourceGroupServer", resp, "Failure responding to request") + return + } + if result.ltrblr.hasNextLink() && result.ltrblr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByResourceGroupServerPreparer prepares the ListByResourceGroupServer request. +func (client LongTermRetentionBackupsClient) ListByResourceGroupServerPreparer(ctx context.Context, resourceGroupName string, locationName string, longTermRetentionServerName string, onlyLatestPerDatabase *bool, databaseState DatabaseState) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "locationName": autorest.Encode("path", locationName), + "longTermRetentionServerName": autorest.Encode("path", longTermRetentionServerName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if onlyLatestPerDatabase != nil { + queryParameters["onlyLatestPerDatabase"] = autorest.Encode("query", *onlyLatestPerDatabase) + } + if len(string(databaseState)) > 0 { + queryParameters["databaseState"] = autorest.Encode("query", databaseState) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionBackups", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByResourceGroupServerSender sends the ListByResourceGroupServer request. The method will close the +// http.Response Body if it receives an error. +func (client LongTermRetentionBackupsClient) ListByResourceGroupServerSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupServerResponder handles the response to the ListByResourceGroupServer request. The method always +// closes the http.Response Body. +func (client LongTermRetentionBackupsClient) ListByResourceGroupServerResponder(resp *http.Response) (result LongTermRetentionBackupListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByResourceGroupServerNextResults retrieves the next set of results, if any. +func (client LongTermRetentionBackupsClient) listByResourceGroupServerNextResults(ctx context.Context, lastResults LongTermRetentionBackupListResult) (result LongTermRetentionBackupListResult, err error) { + req, err := lastResults.longTermRetentionBackupListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "listByResourceGroupServerNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByResourceGroupServerSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "listByResourceGroupServerNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByResourceGroupServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "listByResourceGroupServerNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByResourceGroupServerComplete enumerates all values, automatically crossing page boundaries as required. +func (client LongTermRetentionBackupsClient) ListByResourceGroupServerComplete(ctx context.Context, resourceGroupName string, locationName string, longTermRetentionServerName string, onlyLatestPerDatabase *bool, databaseState DatabaseState) (result LongTermRetentionBackupListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionBackupsClient.ListByResourceGroupServer") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByResourceGroupServer(ctx, resourceGroupName, locationName, longTermRetentionServerName, onlyLatestPerDatabase, databaseState) + return +} + +// ListByServer lists the long term retention backups for a given server. +// Parameters: +// locationName - the location of the database +// longTermRetentionServerName - the name of the server +// onlyLatestPerDatabase - whether or not to only get the latest backup for each database. +// databaseState - whether to query against just live databases, just deleted databases, or all databases. +func (client LongTermRetentionBackupsClient) ListByServer(ctx context.Context, locationName string, longTermRetentionServerName string, onlyLatestPerDatabase *bool, databaseState DatabaseState) (result LongTermRetentionBackupListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionBackupsClient.ListByServer") + defer func() { + sc := -1 + if result.ltrblr.Response.Response != nil { + sc = result.ltrblr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByServerNextResults + req, err := client.ListByServerPreparer(ctx, locationName, longTermRetentionServerName, onlyLatestPerDatabase, databaseState) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "ListByServer", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServerSender(req) + if err != nil { + result.ltrblr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "ListByServer", resp, "Failure sending request") + return + } + + result.ltrblr, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "ListByServer", resp, "Failure responding to request") + return + } + if result.ltrblr.hasNextLink() && result.ltrblr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServerPreparer prepares the ListByServer request. +func (client LongTermRetentionBackupsClient) ListByServerPreparer(ctx context.Context, locationName string, longTermRetentionServerName string, onlyLatestPerDatabase *bool, databaseState DatabaseState) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "locationName": autorest.Encode("path", locationName), + "longTermRetentionServerName": autorest.Encode("path", longTermRetentionServerName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if onlyLatestPerDatabase != nil { + queryParameters["onlyLatestPerDatabase"] = autorest.Encode("query", *onlyLatestPerDatabase) + } + if len(string(databaseState)) > 0 { + queryParameters["databaseState"] = autorest.Encode("query", databaseState) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionBackups", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByServerSender sends the ListByServer request. The method will close the +// http.Response Body if it receives an error. +func (client LongTermRetentionBackupsClient) ListByServerSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client LongTermRetentionBackupsClient) ListByServerResponder(resp *http.Response) (result LongTermRetentionBackupListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByServerNextResults retrieves the next set of results, if any. +func (client LongTermRetentionBackupsClient) listByServerNextResults(ctx context.Context, lastResults LongTermRetentionBackupListResult) (result LongTermRetentionBackupListResult, err error) { + req, err := lastResults.longTermRetentionBackupListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "listByServerNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByServerSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "listByServerNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "listByServerNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServerComplete enumerates all values, automatically crossing page boundaries as required. +func (client LongTermRetentionBackupsClient) ListByServerComplete(ctx context.Context, locationName string, longTermRetentionServerName string, onlyLatestPerDatabase *bool, databaseState DatabaseState) (result LongTermRetentionBackupListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionBackupsClient.ListByServer") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByServer(ctx, locationName, longTermRetentionServerName, onlyLatestPerDatabase, databaseState) + return +} + +// Update updates an existing long term retention backup. +// Parameters: +// locationName - the location of the database. +// longTermRetentionServerName - the name of the server +// longTermRetentionDatabaseName - the name of the database +// backupName - the backup name. +// parameters - the requested backup resource state +func (client LongTermRetentionBackupsClient) Update(ctx context.Context, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, backupName string, parameters UpdateLongTermRetentionBackupParameters) (result LongTermRetentionBackupsUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionBackupsClient.Update") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.UpdatePreparer(ctx, locationName, longTermRetentionServerName, longTermRetentionDatabaseName, backupName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "Update", nil, "Failure sending request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client LongTermRetentionBackupsClient) UpdatePreparer(ctx context.Context, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, backupName string, parameters UpdateLongTermRetentionBackupParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "backupName": autorest.Encode("path", backupName), + "locationName": autorest.Encode("path", locationName), + "longTermRetentionDatabaseName": autorest.Encode("path", longTermRetentionDatabaseName), + "longTermRetentionServerName": autorest.Encode("path", longTermRetentionServerName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}/update", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client LongTermRetentionBackupsClient) UpdateSender(req *http.Request) (future LongTermRetentionBackupsUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client LongTermRetentionBackupsClient) UpdateResponder(resp *http.Response) (result LongTermRetentionBackupOperationResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// UpdateByResourceGroup updates an existing long term retention backup. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// locationName - the location of the database. +// longTermRetentionServerName - the name of the server +// longTermRetentionDatabaseName - the name of the database +// backupName - the backup name. +// parameters - the requested backup resource state +func (client LongTermRetentionBackupsClient) UpdateByResourceGroup(ctx context.Context, resourceGroupName string, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, backupName string, parameters UpdateLongTermRetentionBackupParameters) (result LongTermRetentionBackupsUpdateByResourceGroupFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionBackupsClient.UpdateByResourceGroup") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.UpdateByResourceGroupPreparer(ctx, resourceGroupName, locationName, longTermRetentionServerName, longTermRetentionDatabaseName, backupName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "UpdateByResourceGroup", nil, "Failure preparing request") + return + } + + result, err = client.UpdateByResourceGroupSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsClient", "UpdateByResourceGroup", nil, "Failure sending request") + return + } + + return +} + +// UpdateByResourceGroupPreparer prepares the UpdateByResourceGroup request. +func (client LongTermRetentionBackupsClient) UpdateByResourceGroupPreparer(ctx context.Context, resourceGroupName string, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, backupName string, parameters UpdateLongTermRetentionBackupParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "backupName": autorest.Encode("path", backupName), + "locationName": autorest.Encode("path", locationName), + "longTermRetentionDatabaseName": autorest.Encode("path", longTermRetentionDatabaseName), + "longTermRetentionServerName": autorest.Encode("path", longTermRetentionServerName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}/update", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateByResourceGroupSender sends the UpdateByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client LongTermRetentionBackupsClient) UpdateByResourceGroupSender(req *http.Request) (future LongTermRetentionBackupsUpdateByResourceGroupFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// UpdateByResourceGroupResponder handles the response to the UpdateByResourceGroup request. The method always +// closes the http.Response Body. +func (client LongTermRetentionBackupsClient) UpdateByResourceGroupResponder(resp *http.Response) (result LongTermRetentionBackupOperationResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/longtermretentionmanagedinstancebackups.go b/services/preview/sql/mgmt/v5.0/sql/longtermretentionmanagedinstancebackups.go new file mode 100644 index 000000000000..7fa2f44e8bb1 --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/longtermretentionmanagedinstancebackups.go @@ -0,0 +1,1128 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// LongTermRetentionManagedInstanceBackupsClient is the the Azure SQL Database management API provides a RESTful set of +// web services that interact with Azure SQL Database services to manage your databases. The API enables you to create, +// retrieve, update, and delete databases. +type LongTermRetentionManagedInstanceBackupsClient struct { + BaseClient +} + +// NewLongTermRetentionManagedInstanceBackupsClient creates an instance of the +// LongTermRetentionManagedInstanceBackupsClient client. +func NewLongTermRetentionManagedInstanceBackupsClient(subscriptionID string) LongTermRetentionManagedInstanceBackupsClient { + return NewLongTermRetentionManagedInstanceBackupsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewLongTermRetentionManagedInstanceBackupsClientWithBaseURI creates an instance of the +// LongTermRetentionManagedInstanceBackupsClient client using a custom endpoint. Use this when interacting with an +// Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewLongTermRetentionManagedInstanceBackupsClientWithBaseURI(baseURI string, subscriptionID string) LongTermRetentionManagedInstanceBackupsClient { + return LongTermRetentionManagedInstanceBackupsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Delete deletes a long term retention backup. +// Parameters: +// locationName - the location of the database. +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the managed database. +// backupName - the backup name. +func (client LongTermRetentionManagedInstanceBackupsClient) Delete(ctx context.Context, locationName string, managedInstanceName string, databaseName string, backupName string) (result LongTermRetentionManagedInstanceBackupsDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionManagedInstanceBackupsClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, locationName, managedInstanceName, databaseName, backupName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionManagedInstanceBackupsClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionManagedInstanceBackupsClient", "Delete", nil, "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client LongTermRetentionManagedInstanceBackupsClient) DeletePreparer(ctx context.Context, locationName string, managedInstanceName string, databaseName string, backupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "backupName": autorest.Encode("path", backupName), + "databaseName": autorest.Encode("path", databaseName), + "locationName": autorest.Encode("path", locationName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstances/{managedInstanceName}/longTermRetentionDatabases/{databaseName}/longTermRetentionManagedInstanceBackups/{backupName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client LongTermRetentionManagedInstanceBackupsClient) DeleteSender(req *http.Request) (future LongTermRetentionManagedInstanceBackupsDeleteFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client LongTermRetentionManagedInstanceBackupsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + +// DeleteByResourceGroup deletes a long term retention backup. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// locationName - the location of the database +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the managed database. +// backupName - the backup name. +func (client LongTermRetentionManagedInstanceBackupsClient) DeleteByResourceGroup(ctx context.Context, resourceGroupName string, locationName string, managedInstanceName string, databaseName string, backupName string) (result LongTermRetentionManagedInstanceBackupsDeleteByResourceGroupFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionManagedInstanceBackupsClient.DeleteByResourceGroup") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeleteByResourceGroupPreparer(ctx, resourceGroupName, locationName, managedInstanceName, databaseName, backupName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionManagedInstanceBackupsClient", "DeleteByResourceGroup", nil, "Failure preparing request") + return + } + + result, err = client.DeleteByResourceGroupSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionManagedInstanceBackupsClient", "DeleteByResourceGroup", nil, "Failure sending request") + return + } + + return +} + +// DeleteByResourceGroupPreparer prepares the DeleteByResourceGroup request. +func (client LongTermRetentionManagedInstanceBackupsClient) DeleteByResourceGroupPreparer(ctx context.Context, resourceGroupName string, locationName string, managedInstanceName string, databaseName string, backupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "backupName": autorest.Encode("path", backupName), + "databaseName": autorest.Encode("path", databaseName), + "locationName": autorest.Encode("path", locationName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstances/{managedInstanceName}/longTermRetentionDatabases/{databaseName}/longTermRetentionManagedInstanceBackups/{backupName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteByResourceGroupSender sends the DeleteByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client LongTermRetentionManagedInstanceBackupsClient) DeleteByResourceGroupSender(req *http.Request) (future LongTermRetentionManagedInstanceBackupsDeleteByResourceGroupFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteByResourceGroupResponder handles the response to the DeleteByResourceGroup request. The method always +// closes the http.Response Body. +func (client LongTermRetentionManagedInstanceBackupsClient) DeleteByResourceGroupResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a long term retention backup for a managed database. +// Parameters: +// locationName - the location of the database. +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the managed database. +// backupName - the backup name. +func (client LongTermRetentionManagedInstanceBackupsClient) Get(ctx context.Context, locationName string, managedInstanceName string, databaseName string, backupName string) (result ManagedInstanceLongTermRetentionBackup, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionManagedInstanceBackupsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, locationName, managedInstanceName, databaseName, backupName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionManagedInstanceBackupsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionManagedInstanceBackupsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionManagedInstanceBackupsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client LongTermRetentionManagedInstanceBackupsClient) GetPreparer(ctx context.Context, locationName string, managedInstanceName string, databaseName string, backupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "backupName": autorest.Encode("path", backupName), + "databaseName": autorest.Encode("path", databaseName), + "locationName": autorest.Encode("path", locationName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstances/{managedInstanceName}/longTermRetentionDatabases/{databaseName}/longTermRetentionManagedInstanceBackups/{backupName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client LongTermRetentionManagedInstanceBackupsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client LongTermRetentionManagedInstanceBackupsClient) GetResponder(resp *http.Response) (result ManagedInstanceLongTermRetentionBackup, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetByResourceGroup gets a long term retention backup for a managed database. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// locationName - the location of the database. +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the managed database. +// backupName - the backup name. +func (client LongTermRetentionManagedInstanceBackupsClient) GetByResourceGroup(ctx context.Context, resourceGroupName string, locationName string, managedInstanceName string, databaseName string, backupName string) (result ManagedInstanceLongTermRetentionBackup, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionManagedInstanceBackupsClient.GetByResourceGroup") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetByResourceGroupPreparer(ctx, resourceGroupName, locationName, managedInstanceName, databaseName, backupName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionManagedInstanceBackupsClient", "GetByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.GetByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionManagedInstanceBackupsClient", "GetByResourceGroup", resp, "Failure sending request") + return + } + + result, err = client.GetByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionManagedInstanceBackupsClient", "GetByResourceGroup", resp, "Failure responding to request") + return + } + + return +} + +// GetByResourceGroupPreparer prepares the GetByResourceGroup request. +func (client LongTermRetentionManagedInstanceBackupsClient) GetByResourceGroupPreparer(ctx context.Context, resourceGroupName string, locationName string, managedInstanceName string, databaseName string, backupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "backupName": autorest.Encode("path", backupName), + "databaseName": autorest.Encode("path", databaseName), + "locationName": autorest.Encode("path", locationName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstances/{managedInstanceName}/longTermRetentionDatabases/{databaseName}/longTermRetentionManagedInstanceBackups/{backupName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetByResourceGroupSender sends the GetByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client LongTermRetentionManagedInstanceBackupsClient) GetByResourceGroupSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetByResourceGroupResponder handles the response to the GetByResourceGroup request. The method always +// closes the http.Response Body. +func (client LongTermRetentionManagedInstanceBackupsClient) GetByResourceGroupResponder(resp *http.Response) (result ManagedInstanceLongTermRetentionBackup, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByDatabase lists all long term retention backups for a managed database. +// Parameters: +// locationName - the location of the database. +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the managed database. +// onlyLatestPerDatabase - whether or not to only get the latest backup for each database. +// databaseState - whether to query against just live databases, just deleted databases, or all databases. +func (client LongTermRetentionManagedInstanceBackupsClient) ListByDatabase(ctx context.Context, locationName string, managedInstanceName string, databaseName string, onlyLatestPerDatabase *bool, databaseState DatabaseState) (result ManagedInstanceLongTermRetentionBackupListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionManagedInstanceBackupsClient.ListByDatabase") + defer func() { + sc := -1 + if result.miltrblr.Response.Response != nil { + sc = result.miltrblr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByDatabaseNextResults + req, err := client.ListByDatabasePreparer(ctx, locationName, managedInstanceName, databaseName, onlyLatestPerDatabase, databaseState) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionManagedInstanceBackupsClient", "ListByDatabase", nil, "Failure preparing request") + return + } + + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.miltrblr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionManagedInstanceBackupsClient", "ListByDatabase", resp, "Failure sending request") + return + } + + result.miltrblr, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionManagedInstanceBackupsClient", "ListByDatabase", resp, "Failure responding to request") + return + } + if result.miltrblr.hasNextLink() && result.miltrblr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByDatabasePreparer prepares the ListByDatabase request. +func (client LongTermRetentionManagedInstanceBackupsClient) ListByDatabasePreparer(ctx context.Context, locationName string, managedInstanceName string, databaseName string, onlyLatestPerDatabase *bool, databaseState DatabaseState) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "locationName": autorest.Encode("path", locationName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if onlyLatestPerDatabase != nil { + queryParameters["onlyLatestPerDatabase"] = autorest.Encode("query", *onlyLatestPerDatabase) + } + if len(string(databaseState)) > 0 { + queryParameters["databaseState"] = autorest.Encode("query", databaseState) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstances/{managedInstanceName}/longTermRetentionDatabases/{databaseName}/longTermRetentionManagedInstanceBackups", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByDatabaseSender sends the ListByDatabase request. The method will close the +// http.Response Body if it receives an error. +func (client LongTermRetentionManagedInstanceBackupsClient) ListByDatabaseSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByDatabaseResponder handles the response to the ListByDatabase request. The method always +// closes the http.Response Body. +func (client LongTermRetentionManagedInstanceBackupsClient) ListByDatabaseResponder(resp *http.Response) (result ManagedInstanceLongTermRetentionBackupListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByDatabaseNextResults retrieves the next set of results, if any. +func (client LongTermRetentionManagedInstanceBackupsClient) listByDatabaseNextResults(ctx context.Context, lastResults ManagedInstanceLongTermRetentionBackupListResult) (result ManagedInstanceLongTermRetentionBackupListResult, err error) { + req, err := lastResults.managedInstanceLongTermRetentionBackupListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.LongTermRetentionManagedInstanceBackupsClient", "listByDatabaseNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.LongTermRetentionManagedInstanceBackupsClient", "listByDatabaseNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionManagedInstanceBackupsClient", "listByDatabaseNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByDatabaseComplete enumerates all values, automatically crossing page boundaries as required. +func (client LongTermRetentionManagedInstanceBackupsClient) ListByDatabaseComplete(ctx context.Context, locationName string, managedInstanceName string, databaseName string, onlyLatestPerDatabase *bool, databaseState DatabaseState) (result ManagedInstanceLongTermRetentionBackupListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionManagedInstanceBackupsClient.ListByDatabase") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByDatabase(ctx, locationName, managedInstanceName, databaseName, onlyLatestPerDatabase, databaseState) + return +} + +// ListByInstance lists the long term retention backups for a given managed instance. +// Parameters: +// locationName - the location of the database +// managedInstanceName - the name of the managed instance. +// onlyLatestPerDatabase - whether or not to only get the latest backup for each database. +// databaseState - whether to query against just live databases, just deleted databases, or all databases. +func (client LongTermRetentionManagedInstanceBackupsClient) ListByInstance(ctx context.Context, locationName string, managedInstanceName string, onlyLatestPerDatabase *bool, databaseState DatabaseState) (result ManagedInstanceLongTermRetentionBackupListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionManagedInstanceBackupsClient.ListByInstance") + defer func() { + sc := -1 + if result.miltrblr.Response.Response != nil { + sc = result.miltrblr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByInstanceNextResults + req, err := client.ListByInstancePreparer(ctx, locationName, managedInstanceName, onlyLatestPerDatabase, databaseState) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionManagedInstanceBackupsClient", "ListByInstance", nil, "Failure preparing request") + return + } + + resp, err := client.ListByInstanceSender(req) + if err != nil { + result.miltrblr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionManagedInstanceBackupsClient", "ListByInstance", resp, "Failure sending request") + return + } + + result.miltrblr, err = client.ListByInstanceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionManagedInstanceBackupsClient", "ListByInstance", resp, "Failure responding to request") + return + } + if result.miltrblr.hasNextLink() && result.miltrblr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByInstancePreparer prepares the ListByInstance request. +func (client LongTermRetentionManagedInstanceBackupsClient) ListByInstancePreparer(ctx context.Context, locationName string, managedInstanceName string, onlyLatestPerDatabase *bool, databaseState DatabaseState) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "locationName": autorest.Encode("path", locationName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if onlyLatestPerDatabase != nil { + queryParameters["onlyLatestPerDatabase"] = autorest.Encode("query", *onlyLatestPerDatabase) + } + if len(string(databaseState)) > 0 { + queryParameters["databaseState"] = autorest.Encode("query", databaseState) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstances/{managedInstanceName}/longTermRetentionManagedInstanceBackups", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByInstanceSender sends the ListByInstance request. The method will close the +// http.Response Body if it receives an error. +func (client LongTermRetentionManagedInstanceBackupsClient) ListByInstanceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByInstanceResponder handles the response to the ListByInstance request. The method always +// closes the http.Response Body. +func (client LongTermRetentionManagedInstanceBackupsClient) ListByInstanceResponder(resp *http.Response) (result ManagedInstanceLongTermRetentionBackupListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByInstanceNextResults retrieves the next set of results, if any. +func (client LongTermRetentionManagedInstanceBackupsClient) listByInstanceNextResults(ctx context.Context, lastResults ManagedInstanceLongTermRetentionBackupListResult) (result ManagedInstanceLongTermRetentionBackupListResult, err error) { + req, err := lastResults.managedInstanceLongTermRetentionBackupListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.LongTermRetentionManagedInstanceBackupsClient", "listByInstanceNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByInstanceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.LongTermRetentionManagedInstanceBackupsClient", "listByInstanceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByInstanceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionManagedInstanceBackupsClient", "listByInstanceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByInstanceComplete enumerates all values, automatically crossing page boundaries as required. +func (client LongTermRetentionManagedInstanceBackupsClient) ListByInstanceComplete(ctx context.Context, locationName string, managedInstanceName string, onlyLatestPerDatabase *bool, databaseState DatabaseState) (result ManagedInstanceLongTermRetentionBackupListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionManagedInstanceBackupsClient.ListByInstance") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByInstance(ctx, locationName, managedInstanceName, onlyLatestPerDatabase, databaseState) + return +} + +// ListByLocation lists the long term retention backups for managed databases in a given location. +// Parameters: +// locationName - the location of the database. +// onlyLatestPerDatabase - whether or not to only get the latest backup for each database. +// databaseState - whether to query against just live databases, just deleted databases, or all databases. +func (client LongTermRetentionManagedInstanceBackupsClient) ListByLocation(ctx context.Context, locationName string, onlyLatestPerDatabase *bool, databaseState DatabaseState) (result ManagedInstanceLongTermRetentionBackupListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionManagedInstanceBackupsClient.ListByLocation") + defer func() { + sc := -1 + if result.miltrblr.Response.Response != nil { + sc = result.miltrblr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByLocationNextResults + req, err := client.ListByLocationPreparer(ctx, locationName, onlyLatestPerDatabase, databaseState) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionManagedInstanceBackupsClient", "ListByLocation", nil, "Failure preparing request") + return + } + + resp, err := client.ListByLocationSender(req) + if err != nil { + result.miltrblr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionManagedInstanceBackupsClient", "ListByLocation", resp, "Failure sending request") + return + } + + result.miltrblr, err = client.ListByLocationResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionManagedInstanceBackupsClient", "ListByLocation", resp, "Failure responding to request") + return + } + if result.miltrblr.hasNextLink() && result.miltrblr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByLocationPreparer prepares the ListByLocation request. +func (client LongTermRetentionManagedInstanceBackupsClient) ListByLocationPreparer(ctx context.Context, locationName string, onlyLatestPerDatabase *bool, databaseState DatabaseState) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "locationName": autorest.Encode("path", locationName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if onlyLatestPerDatabase != nil { + queryParameters["onlyLatestPerDatabase"] = autorest.Encode("query", *onlyLatestPerDatabase) + } + if len(string(databaseState)) > 0 { + queryParameters["databaseState"] = autorest.Encode("query", databaseState) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstanceBackups", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByLocationSender sends the ListByLocation request. The method will close the +// http.Response Body if it receives an error. +func (client LongTermRetentionManagedInstanceBackupsClient) ListByLocationSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByLocationResponder handles the response to the ListByLocation request. The method always +// closes the http.Response Body. +func (client LongTermRetentionManagedInstanceBackupsClient) ListByLocationResponder(resp *http.Response) (result ManagedInstanceLongTermRetentionBackupListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByLocationNextResults retrieves the next set of results, if any. +func (client LongTermRetentionManagedInstanceBackupsClient) listByLocationNextResults(ctx context.Context, lastResults ManagedInstanceLongTermRetentionBackupListResult) (result ManagedInstanceLongTermRetentionBackupListResult, err error) { + req, err := lastResults.managedInstanceLongTermRetentionBackupListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.LongTermRetentionManagedInstanceBackupsClient", "listByLocationNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByLocationSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.LongTermRetentionManagedInstanceBackupsClient", "listByLocationNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByLocationResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionManagedInstanceBackupsClient", "listByLocationNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByLocationComplete enumerates all values, automatically crossing page boundaries as required. +func (client LongTermRetentionManagedInstanceBackupsClient) ListByLocationComplete(ctx context.Context, locationName string, onlyLatestPerDatabase *bool, databaseState DatabaseState) (result ManagedInstanceLongTermRetentionBackupListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionManagedInstanceBackupsClient.ListByLocation") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByLocation(ctx, locationName, onlyLatestPerDatabase, databaseState) + return +} + +// ListByResourceGroupDatabase lists all long term retention backups for a managed database. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// locationName - the location of the database +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the managed database. +// onlyLatestPerDatabase - whether or not to only get the latest backup for each database. +// databaseState - whether to query against just live databases, just deleted databases, or all databases. +func (client LongTermRetentionManagedInstanceBackupsClient) ListByResourceGroupDatabase(ctx context.Context, resourceGroupName string, locationName string, managedInstanceName string, databaseName string, onlyLatestPerDatabase *bool, databaseState DatabaseState) (result ManagedInstanceLongTermRetentionBackupListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionManagedInstanceBackupsClient.ListByResourceGroupDatabase") + defer func() { + sc := -1 + if result.miltrblr.Response.Response != nil { + sc = result.miltrblr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByResourceGroupDatabaseNextResults + req, err := client.ListByResourceGroupDatabasePreparer(ctx, resourceGroupName, locationName, managedInstanceName, databaseName, onlyLatestPerDatabase, databaseState) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionManagedInstanceBackupsClient", "ListByResourceGroupDatabase", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupDatabaseSender(req) + if err != nil { + result.miltrblr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionManagedInstanceBackupsClient", "ListByResourceGroupDatabase", resp, "Failure sending request") + return + } + + result.miltrblr, err = client.ListByResourceGroupDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionManagedInstanceBackupsClient", "ListByResourceGroupDatabase", resp, "Failure responding to request") + return + } + if result.miltrblr.hasNextLink() && result.miltrblr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByResourceGroupDatabasePreparer prepares the ListByResourceGroupDatabase request. +func (client LongTermRetentionManagedInstanceBackupsClient) ListByResourceGroupDatabasePreparer(ctx context.Context, resourceGroupName string, locationName string, managedInstanceName string, databaseName string, onlyLatestPerDatabase *bool, databaseState DatabaseState) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "locationName": autorest.Encode("path", locationName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if onlyLatestPerDatabase != nil { + queryParameters["onlyLatestPerDatabase"] = autorest.Encode("query", *onlyLatestPerDatabase) + } + if len(string(databaseState)) > 0 { + queryParameters["databaseState"] = autorest.Encode("query", databaseState) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstances/{managedInstanceName}/longTermRetentionDatabases/{databaseName}/longTermRetentionManagedInstanceBackups", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByResourceGroupDatabaseSender sends the ListByResourceGroupDatabase request. The method will close the +// http.Response Body if it receives an error. +func (client LongTermRetentionManagedInstanceBackupsClient) ListByResourceGroupDatabaseSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupDatabaseResponder handles the response to the ListByResourceGroupDatabase request. The method always +// closes the http.Response Body. +func (client LongTermRetentionManagedInstanceBackupsClient) ListByResourceGroupDatabaseResponder(resp *http.Response) (result ManagedInstanceLongTermRetentionBackupListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByResourceGroupDatabaseNextResults retrieves the next set of results, if any. +func (client LongTermRetentionManagedInstanceBackupsClient) listByResourceGroupDatabaseNextResults(ctx context.Context, lastResults ManagedInstanceLongTermRetentionBackupListResult) (result ManagedInstanceLongTermRetentionBackupListResult, err error) { + req, err := lastResults.managedInstanceLongTermRetentionBackupListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.LongTermRetentionManagedInstanceBackupsClient", "listByResourceGroupDatabaseNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByResourceGroupDatabaseSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.LongTermRetentionManagedInstanceBackupsClient", "listByResourceGroupDatabaseNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByResourceGroupDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionManagedInstanceBackupsClient", "listByResourceGroupDatabaseNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByResourceGroupDatabaseComplete enumerates all values, automatically crossing page boundaries as required. +func (client LongTermRetentionManagedInstanceBackupsClient) ListByResourceGroupDatabaseComplete(ctx context.Context, resourceGroupName string, locationName string, managedInstanceName string, databaseName string, onlyLatestPerDatabase *bool, databaseState DatabaseState) (result ManagedInstanceLongTermRetentionBackupListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionManagedInstanceBackupsClient.ListByResourceGroupDatabase") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByResourceGroupDatabase(ctx, resourceGroupName, locationName, managedInstanceName, databaseName, onlyLatestPerDatabase, databaseState) + return +} + +// ListByResourceGroupInstance lists the long term retention backups for a given managed instance. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// locationName - the location of the database. +// managedInstanceName - the name of the managed instance. +// onlyLatestPerDatabase - whether or not to only get the latest backup for each database. +// databaseState - whether to query against just live databases, just deleted databases, or all databases. +func (client LongTermRetentionManagedInstanceBackupsClient) ListByResourceGroupInstance(ctx context.Context, resourceGroupName string, locationName string, managedInstanceName string, onlyLatestPerDatabase *bool, databaseState DatabaseState) (result ManagedInstanceLongTermRetentionBackupListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionManagedInstanceBackupsClient.ListByResourceGroupInstance") + defer func() { + sc := -1 + if result.miltrblr.Response.Response != nil { + sc = result.miltrblr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByResourceGroupInstanceNextResults + req, err := client.ListByResourceGroupInstancePreparer(ctx, resourceGroupName, locationName, managedInstanceName, onlyLatestPerDatabase, databaseState) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionManagedInstanceBackupsClient", "ListByResourceGroupInstance", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupInstanceSender(req) + if err != nil { + result.miltrblr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionManagedInstanceBackupsClient", "ListByResourceGroupInstance", resp, "Failure sending request") + return + } + + result.miltrblr, err = client.ListByResourceGroupInstanceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionManagedInstanceBackupsClient", "ListByResourceGroupInstance", resp, "Failure responding to request") + return + } + if result.miltrblr.hasNextLink() && result.miltrblr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByResourceGroupInstancePreparer prepares the ListByResourceGroupInstance request. +func (client LongTermRetentionManagedInstanceBackupsClient) ListByResourceGroupInstancePreparer(ctx context.Context, resourceGroupName string, locationName string, managedInstanceName string, onlyLatestPerDatabase *bool, databaseState DatabaseState) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "locationName": autorest.Encode("path", locationName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if onlyLatestPerDatabase != nil { + queryParameters["onlyLatestPerDatabase"] = autorest.Encode("query", *onlyLatestPerDatabase) + } + if len(string(databaseState)) > 0 { + queryParameters["databaseState"] = autorest.Encode("query", databaseState) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstances/{managedInstanceName}/longTermRetentionManagedInstanceBackups", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByResourceGroupInstanceSender sends the ListByResourceGroupInstance request. The method will close the +// http.Response Body if it receives an error. +func (client LongTermRetentionManagedInstanceBackupsClient) ListByResourceGroupInstanceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupInstanceResponder handles the response to the ListByResourceGroupInstance request. The method always +// closes the http.Response Body. +func (client LongTermRetentionManagedInstanceBackupsClient) ListByResourceGroupInstanceResponder(resp *http.Response) (result ManagedInstanceLongTermRetentionBackupListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByResourceGroupInstanceNextResults retrieves the next set of results, if any. +func (client LongTermRetentionManagedInstanceBackupsClient) listByResourceGroupInstanceNextResults(ctx context.Context, lastResults ManagedInstanceLongTermRetentionBackupListResult) (result ManagedInstanceLongTermRetentionBackupListResult, err error) { + req, err := lastResults.managedInstanceLongTermRetentionBackupListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.LongTermRetentionManagedInstanceBackupsClient", "listByResourceGroupInstanceNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByResourceGroupInstanceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.LongTermRetentionManagedInstanceBackupsClient", "listByResourceGroupInstanceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByResourceGroupInstanceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionManagedInstanceBackupsClient", "listByResourceGroupInstanceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByResourceGroupInstanceComplete enumerates all values, automatically crossing page boundaries as required. +func (client LongTermRetentionManagedInstanceBackupsClient) ListByResourceGroupInstanceComplete(ctx context.Context, resourceGroupName string, locationName string, managedInstanceName string, onlyLatestPerDatabase *bool, databaseState DatabaseState) (result ManagedInstanceLongTermRetentionBackupListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionManagedInstanceBackupsClient.ListByResourceGroupInstance") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByResourceGroupInstance(ctx, resourceGroupName, locationName, managedInstanceName, onlyLatestPerDatabase, databaseState) + return +} + +// ListByResourceGroupLocation lists the long term retention backups for managed databases in a given location. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// locationName - the location of the database. +// onlyLatestPerDatabase - whether or not to only get the latest backup for each database. +// databaseState - whether to query against just live databases, just deleted databases, or all databases. +func (client LongTermRetentionManagedInstanceBackupsClient) ListByResourceGroupLocation(ctx context.Context, resourceGroupName string, locationName string, onlyLatestPerDatabase *bool, databaseState DatabaseState) (result ManagedInstanceLongTermRetentionBackupListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionManagedInstanceBackupsClient.ListByResourceGroupLocation") + defer func() { + sc := -1 + if result.miltrblr.Response.Response != nil { + sc = result.miltrblr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByResourceGroupLocationNextResults + req, err := client.ListByResourceGroupLocationPreparer(ctx, resourceGroupName, locationName, onlyLatestPerDatabase, databaseState) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionManagedInstanceBackupsClient", "ListByResourceGroupLocation", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupLocationSender(req) + if err != nil { + result.miltrblr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionManagedInstanceBackupsClient", "ListByResourceGroupLocation", resp, "Failure sending request") + return + } + + result.miltrblr, err = client.ListByResourceGroupLocationResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionManagedInstanceBackupsClient", "ListByResourceGroupLocation", resp, "Failure responding to request") + return + } + if result.miltrblr.hasNextLink() && result.miltrblr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByResourceGroupLocationPreparer prepares the ListByResourceGroupLocation request. +func (client LongTermRetentionManagedInstanceBackupsClient) ListByResourceGroupLocationPreparer(ctx context.Context, resourceGroupName string, locationName string, onlyLatestPerDatabase *bool, databaseState DatabaseState) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "locationName": autorest.Encode("path", locationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if onlyLatestPerDatabase != nil { + queryParameters["onlyLatestPerDatabase"] = autorest.Encode("query", *onlyLatestPerDatabase) + } + if len(string(databaseState)) > 0 { + queryParameters["databaseState"] = autorest.Encode("query", databaseState) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstanceBackups", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByResourceGroupLocationSender sends the ListByResourceGroupLocation request. The method will close the +// http.Response Body if it receives an error. +func (client LongTermRetentionManagedInstanceBackupsClient) ListByResourceGroupLocationSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupLocationResponder handles the response to the ListByResourceGroupLocation request. The method always +// closes the http.Response Body. +func (client LongTermRetentionManagedInstanceBackupsClient) ListByResourceGroupLocationResponder(resp *http.Response) (result ManagedInstanceLongTermRetentionBackupListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByResourceGroupLocationNextResults retrieves the next set of results, if any. +func (client LongTermRetentionManagedInstanceBackupsClient) listByResourceGroupLocationNextResults(ctx context.Context, lastResults ManagedInstanceLongTermRetentionBackupListResult) (result ManagedInstanceLongTermRetentionBackupListResult, err error) { + req, err := lastResults.managedInstanceLongTermRetentionBackupListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.LongTermRetentionManagedInstanceBackupsClient", "listByResourceGroupLocationNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByResourceGroupLocationSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.LongTermRetentionManagedInstanceBackupsClient", "listByResourceGroupLocationNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByResourceGroupLocationResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionManagedInstanceBackupsClient", "listByResourceGroupLocationNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByResourceGroupLocationComplete enumerates all values, automatically crossing page boundaries as required. +func (client LongTermRetentionManagedInstanceBackupsClient) ListByResourceGroupLocationComplete(ctx context.Context, resourceGroupName string, locationName string, onlyLatestPerDatabase *bool, databaseState DatabaseState) (result ManagedInstanceLongTermRetentionBackupListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionManagedInstanceBackupsClient.ListByResourceGroupLocation") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByResourceGroupLocation(ctx, resourceGroupName, locationName, onlyLatestPerDatabase, databaseState) + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/longtermretentionpolicies.go b/services/preview/sql/mgmt/v5.0/sql/longtermretentionpolicies.go new file mode 100644 index 000000000000..fc31c8f81ff8 --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/longtermretentionpolicies.go @@ -0,0 +1,320 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// LongTermRetentionPoliciesClient is the the Azure SQL Database management API provides a RESTful set of web services +// that interact with Azure SQL Database services to manage your databases. The API enables you to create, retrieve, +// update, and delete databases. +type LongTermRetentionPoliciesClient struct { + BaseClient +} + +// NewLongTermRetentionPoliciesClient creates an instance of the LongTermRetentionPoliciesClient client. +func NewLongTermRetentionPoliciesClient(subscriptionID string) LongTermRetentionPoliciesClient { + return NewLongTermRetentionPoliciesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewLongTermRetentionPoliciesClientWithBaseURI creates an instance of the LongTermRetentionPoliciesClient client +// using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign +// clouds, Azure stack). +func NewLongTermRetentionPoliciesClientWithBaseURI(baseURI string, subscriptionID string) LongTermRetentionPoliciesClient { + return LongTermRetentionPoliciesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate sets a database's long term retention policy. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database. +// parameters - the long term retention policy info. +func (client LongTermRetentionPoliciesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters LongTermRetentionPolicy) (result LongTermRetentionPoliciesCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionPoliciesClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, databaseName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionPoliciesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionPoliciesClient", "CreateOrUpdate", nil, "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client LongTermRetentionPoliciesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters LongTermRetentionPolicy) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "policyName": autorest.Encode("path", "default"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/backupLongTermRetentionPolicies/{policyName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client LongTermRetentionPoliciesClient) CreateOrUpdateSender(req *http.Request) (future LongTermRetentionPoliciesCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client LongTermRetentionPoliciesClient) CreateOrUpdateResponder(resp *http.Response) (result LongTermRetentionPolicy, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets a database's long term retention policy. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database. +func (client LongTermRetentionPoliciesClient) Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result LongTermRetentionPolicy, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionPoliciesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionPoliciesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionPoliciesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionPoliciesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client LongTermRetentionPoliciesClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "policyName": autorest.Encode("path", "default"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/backupLongTermRetentionPolicies/{policyName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client LongTermRetentionPoliciesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client LongTermRetentionPoliciesClient) GetResponder(resp *http.Response) (result LongTermRetentionPolicy, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByDatabase gets a database's long term retention policy. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database. +func (client LongTermRetentionPoliciesClient) ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result LongTermRetentionPolicyListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionPoliciesClient.ListByDatabase") + defer func() { + sc := -1 + if result.ltrplr.Response.Response != nil { + sc = result.ltrplr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByDatabaseNextResults + req, err := client.ListByDatabasePreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionPoliciesClient", "ListByDatabase", nil, "Failure preparing request") + return + } + + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.ltrplr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionPoliciesClient", "ListByDatabase", resp, "Failure sending request") + return + } + + result.ltrplr, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionPoliciesClient", "ListByDatabase", resp, "Failure responding to request") + return + } + if result.ltrplr.hasNextLink() && result.ltrplr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByDatabasePreparer prepares the ListByDatabase request. +func (client LongTermRetentionPoliciesClient) ListByDatabasePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/backupLongTermRetentionPolicies", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByDatabaseSender sends the ListByDatabase request. The method will close the +// http.Response Body if it receives an error. +func (client LongTermRetentionPoliciesClient) ListByDatabaseSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByDatabaseResponder handles the response to the ListByDatabase request. The method always +// closes the http.Response Body. +func (client LongTermRetentionPoliciesClient) ListByDatabaseResponder(resp *http.Response) (result LongTermRetentionPolicyListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByDatabaseNextResults retrieves the next set of results, if any. +func (client LongTermRetentionPoliciesClient) listByDatabaseNextResults(ctx context.Context, lastResults LongTermRetentionPolicyListResult) (result LongTermRetentionPolicyListResult, err error) { + req, err := lastResults.longTermRetentionPolicyListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.LongTermRetentionPoliciesClient", "listByDatabaseNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.LongTermRetentionPoliciesClient", "listByDatabaseNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionPoliciesClient", "listByDatabaseNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByDatabaseComplete enumerates all values, automatically crossing page boundaries as required. +func (client LongTermRetentionPoliciesClient) ListByDatabaseComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result LongTermRetentionPolicyListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionPoliciesClient.ListByDatabase") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByDatabase(ctx, resourceGroupName, serverName, databaseName) + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/maintenancewindowoptions.go b/services/preview/sql/mgmt/v5.0/sql/maintenancewindowoptions.go new file mode 100644 index 000000000000..92c265483a51 --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/maintenancewindowoptions.go @@ -0,0 +1,115 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// MaintenanceWindowOptionsClient 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 MaintenanceWindowOptionsClient struct { + BaseClient +} + +// NewMaintenanceWindowOptionsClient creates an instance of the MaintenanceWindowOptionsClient client. +func NewMaintenanceWindowOptionsClient(subscriptionID string) MaintenanceWindowOptionsClient { + return NewMaintenanceWindowOptionsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewMaintenanceWindowOptionsClientWithBaseURI creates an instance of the MaintenanceWindowOptionsClient client using +// a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign +// clouds, Azure stack). +func NewMaintenanceWindowOptionsClientWithBaseURI(baseURI string, subscriptionID string) MaintenanceWindowOptionsClient { + return MaintenanceWindowOptionsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get gets a list of available maintenance windows. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database to get maintenance windows options for. +// maintenanceWindowOptionsName - maintenance window options name. +func (client MaintenanceWindowOptionsClient) Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string, maintenanceWindowOptionsName string) (result MaintenanceWindowOptions, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MaintenanceWindowOptionsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, databaseName, maintenanceWindowOptionsName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.MaintenanceWindowOptionsClient", "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.MaintenanceWindowOptionsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.MaintenanceWindowOptionsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client MaintenanceWindowOptionsClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, maintenanceWindowOptionsName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + "maintenanceWindowOptionsName": autorest.Encode("query", maintenanceWindowOptionsName), + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/maintenanceWindowOptions/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 MaintenanceWindowOptionsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client MaintenanceWindowOptionsClient) GetResponder(resp *http.Response) (result MaintenanceWindowOptions, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/maintenancewindows.go b/services/preview/sql/mgmt/v5.0/sql/maintenancewindows.go new file mode 100644 index 000000000000..cd9922e3253d --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/maintenancewindows.go @@ -0,0 +1,197 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// MaintenanceWindowsClient 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 MaintenanceWindowsClient struct { + BaseClient +} + +// NewMaintenanceWindowsClient creates an instance of the MaintenanceWindowsClient client. +func NewMaintenanceWindowsClient(subscriptionID string) MaintenanceWindowsClient { + return NewMaintenanceWindowsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewMaintenanceWindowsClientWithBaseURI creates an instance of the MaintenanceWindowsClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewMaintenanceWindowsClientWithBaseURI(baseURI string, subscriptionID string) MaintenanceWindowsClient { + return MaintenanceWindowsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate sets maintenance windows settings for a database. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database to set maintenance windows for. +// maintenanceWindowName - maintenance window name. +func (client MaintenanceWindowsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, maintenanceWindowName string, parameters MaintenanceWindows) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MaintenanceWindowsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, databaseName, maintenanceWindowName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.MaintenanceWindowsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "sql.MaintenanceWindowsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.MaintenanceWindowsClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client MaintenanceWindowsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, maintenanceWindowName string, parameters MaintenanceWindows) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + "maintenanceWindowName": autorest.Encode("query", maintenanceWindowName), + } + + 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}/maintenanceWindows/current", 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 MaintenanceWindowsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client MaintenanceWindowsClient) CreateOrUpdateResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets maintenance windows settings for a database. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database to get maintenance windows for. +// maintenanceWindowName - maintenance window name. +func (client MaintenanceWindowsClient) Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string, maintenanceWindowName string) (result MaintenanceWindows, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MaintenanceWindowsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, databaseName, maintenanceWindowName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.MaintenanceWindowsClient", "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.MaintenanceWindowsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.MaintenanceWindowsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client MaintenanceWindowsClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, maintenanceWindowName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + "maintenanceWindowName": autorest.Encode("query", maintenanceWindowName), + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/maintenanceWindows/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 MaintenanceWindowsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client MaintenanceWindowsClient) GetResponder(resp *http.Response) (result MaintenanceWindows, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/managedbackupshorttermretentionpolicies.go b/services/preview/sql/mgmt/v5.0/sql/managedbackupshorttermretentionpolicies.go new file mode 100644 index 000000000000..c2c3a30e0b5d --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/managedbackupshorttermretentionpolicies.go @@ -0,0 +1,406 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ManagedBackupShortTermRetentionPoliciesClient is the the Azure SQL Database management API provides a RESTful set of +// web services that interact with Azure SQL Database services to manage your databases. The API enables you to create, +// retrieve, update, and delete databases. +type ManagedBackupShortTermRetentionPoliciesClient struct { + BaseClient +} + +// NewManagedBackupShortTermRetentionPoliciesClient creates an instance of the +// ManagedBackupShortTermRetentionPoliciesClient client. +func NewManagedBackupShortTermRetentionPoliciesClient(subscriptionID string) ManagedBackupShortTermRetentionPoliciesClient { + return NewManagedBackupShortTermRetentionPoliciesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewManagedBackupShortTermRetentionPoliciesClientWithBaseURI creates an instance of the +// ManagedBackupShortTermRetentionPoliciesClient client using a custom endpoint. Use this when interacting with an +// Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewManagedBackupShortTermRetentionPoliciesClientWithBaseURI(baseURI string, subscriptionID string) ManagedBackupShortTermRetentionPoliciesClient { + return ManagedBackupShortTermRetentionPoliciesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate updates a managed database's short term retention policy. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the database. +// parameters - the short term retention policy info. +func (client ManagedBackupShortTermRetentionPoliciesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, parameters ManagedBackupShortTermRetentionPolicy) (result ManagedBackupShortTermRetentionPoliciesCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedBackupShortTermRetentionPoliciesClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, managedInstanceName, databaseName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedBackupShortTermRetentionPoliciesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedBackupShortTermRetentionPoliciesClient", "CreateOrUpdate", nil, "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ManagedBackupShortTermRetentionPoliciesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, parameters ManagedBackupShortTermRetentionPolicy) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "policyName": autorest.Encode("path", "default"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/backupShortTermRetentionPolicies/{policyName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedBackupShortTermRetentionPoliciesClient) CreateOrUpdateSender(req *http.Request) (future ManagedBackupShortTermRetentionPoliciesCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ManagedBackupShortTermRetentionPoliciesClient) CreateOrUpdateResponder(resp *http.Response) (result ManagedBackupShortTermRetentionPolicy, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets a managed database's short term retention policy. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the database. +func (client ManagedBackupShortTermRetentionPoliciesClient) Get(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (result ManagedBackupShortTermRetentionPolicy, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedBackupShortTermRetentionPoliciesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, managedInstanceName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedBackupShortTermRetentionPoliciesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ManagedBackupShortTermRetentionPoliciesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedBackupShortTermRetentionPoliciesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ManagedBackupShortTermRetentionPoliciesClient) GetPreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "policyName": autorest.Encode("path", "default"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/backupShortTermRetentionPolicies/{policyName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedBackupShortTermRetentionPoliciesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ManagedBackupShortTermRetentionPoliciesClient) GetResponder(resp *http.Response) (result ManagedBackupShortTermRetentionPolicy, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByDatabase gets a managed database's short term retention policy list. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the database. +func (client ManagedBackupShortTermRetentionPoliciesClient) ListByDatabase(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (result ManagedBackupShortTermRetentionPolicyListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedBackupShortTermRetentionPoliciesClient.ListByDatabase") + defer func() { + sc := -1 + if result.mbstrplr.Response.Response != nil { + sc = result.mbstrplr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByDatabaseNextResults + req, err := client.ListByDatabasePreparer(ctx, resourceGroupName, managedInstanceName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedBackupShortTermRetentionPoliciesClient", "ListByDatabase", nil, "Failure preparing request") + return + } + + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.mbstrplr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ManagedBackupShortTermRetentionPoliciesClient", "ListByDatabase", resp, "Failure sending request") + return + } + + result.mbstrplr, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedBackupShortTermRetentionPoliciesClient", "ListByDatabase", resp, "Failure responding to request") + return + } + if result.mbstrplr.hasNextLink() && result.mbstrplr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByDatabasePreparer prepares the ListByDatabase request. +func (client ManagedBackupShortTermRetentionPoliciesClient) ListByDatabasePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/backupShortTermRetentionPolicies", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByDatabaseSender sends the ListByDatabase request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedBackupShortTermRetentionPoliciesClient) ListByDatabaseSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByDatabaseResponder handles the response to the ListByDatabase request. The method always +// closes the http.Response Body. +func (client ManagedBackupShortTermRetentionPoliciesClient) ListByDatabaseResponder(resp *http.Response) (result ManagedBackupShortTermRetentionPolicyListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByDatabaseNextResults retrieves the next set of results, if any. +func (client ManagedBackupShortTermRetentionPoliciesClient) listByDatabaseNextResults(ctx context.Context, lastResults ManagedBackupShortTermRetentionPolicyListResult) (result ManagedBackupShortTermRetentionPolicyListResult, err error) { + req, err := lastResults.managedBackupShortTermRetentionPolicyListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.ManagedBackupShortTermRetentionPoliciesClient", "listByDatabaseNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.ManagedBackupShortTermRetentionPoliciesClient", "listByDatabaseNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedBackupShortTermRetentionPoliciesClient", "listByDatabaseNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByDatabaseComplete enumerates all values, automatically crossing page boundaries as required. +func (client ManagedBackupShortTermRetentionPoliciesClient) ListByDatabaseComplete(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (result ManagedBackupShortTermRetentionPolicyListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedBackupShortTermRetentionPoliciesClient.ListByDatabase") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByDatabase(ctx, resourceGroupName, managedInstanceName, databaseName) + return +} + +// Update updates a managed database's short term retention policy. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the database. +// parameters - the short term retention policy info. +func (client ManagedBackupShortTermRetentionPoliciesClient) Update(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, parameters ManagedBackupShortTermRetentionPolicy) (result ManagedBackupShortTermRetentionPoliciesUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedBackupShortTermRetentionPoliciesClient.Update") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.UpdatePreparer(ctx, resourceGroupName, managedInstanceName, databaseName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedBackupShortTermRetentionPoliciesClient", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedBackupShortTermRetentionPoliciesClient", "Update", nil, "Failure sending request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client ManagedBackupShortTermRetentionPoliciesClient) UpdatePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, parameters ManagedBackupShortTermRetentionPolicy) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "policyName": autorest.Encode("path", "default"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/backupShortTermRetentionPolicies/{policyName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedBackupShortTermRetentionPoliciesClient) UpdateSender(req *http.Request) (future ManagedBackupShortTermRetentionPoliciesUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client ManagedBackupShortTermRetentionPoliciesClient) UpdateResponder(resp *http.Response) (result ManagedBackupShortTermRetentionPolicy, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/manageddatabasecolumns.go b/services/preview/sql/mgmt/v5.0/sql/manageddatabasecolumns.go new file mode 100644 index 000000000000..1b642047bfe9 --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/manageddatabasecolumns.go @@ -0,0 +1,385 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ManagedDatabaseColumnsClient 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 ManagedDatabaseColumnsClient struct { + BaseClient +} + +// NewManagedDatabaseColumnsClient creates an instance of the ManagedDatabaseColumnsClient client. +func NewManagedDatabaseColumnsClient(subscriptionID string) ManagedDatabaseColumnsClient { + return NewManagedDatabaseColumnsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewManagedDatabaseColumnsClientWithBaseURI creates an instance of the ManagedDatabaseColumnsClient client using a +// custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, +// Azure stack). +func NewManagedDatabaseColumnsClientWithBaseURI(baseURI string, subscriptionID string) ManagedDatabaseColumnsClient { + return ManagedDatabaseColumnsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get get managed database column +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the database. +// schemaName - the name of the schema. +// tableName - the name of the table. +// columnName - the name of the column. +func (client ManagedDatabaseColumnsClient) Get(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, schemaName string, tableName string, columnName string) (result DatabaseColumn, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabaseColumnsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, managedInstanceName, databaseName, schemaName, tableName, columnName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseColumnsClient", "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.ManagedDatabaseColumnsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseColumnsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ManagedDatabaseColumnsClient) GetPreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, schemaName string, tableName string, columnName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "columnName": autorest.Encode("path", columnName), + "databaseName": autorest.Encode("path", databaseName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "schemaName": autorest.Encode("path", schemaName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "tableName": autorest.Encode("path", tableName), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}", 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 ManagedDatabaseColumnsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ManagedDatabaseColumnsClient) GetResponder(resp *http.Response) (result DatabaseColumn, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByDatabase list managed database columns +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the database. +// skiptoken - an opaque token that identifies a starting point in the collection. +func (client ManagedDatabaseColumnsClient) ListByDatabase(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, schema []string, table []string, column []string, orderBy []string, skiptoken string) (result DatabaseColumnListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabaseColumnsClient.ListByDatabase") + defer func() { + sc := -1 + if result.dclr.Response.Response != nil { + sc = result.dclr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByDatabaseNextResults + req, err := client.ListByDatabasePreparer(ctx, resourceGroupName, managedInstanceName, databaseName, schema, table, column, orderBy, skiptoken) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseColumnsClient", "ListByDatabase", nil, "Failure preparing request") + return + } + + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.dclr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseColumnsClient", "ListByDatabase", resp, "Failure sending request") + return + } + + result.dclr, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseColumnsClient", "ListByDatabase", resp, "Failure responding to request") + return + } + if result.dclr.hasNextLink() && result.dclr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByDatabasePreparer prepares the ListByDatabase request. +func (client ManagedDatabaseColumnsClient) ListByDatabasePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, schema []string, table []string, column []string, orderBy []string, skiptoken string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if schema != nil && len(schema) > 0 { + queryParameters["schema"] = schema + } + if table != nil && len(table) > 0 { + queryParameters["table"] = table + } + if column != nil && len(column) > 0 { + queryParameters["column"] = column + } + if orderBy != nil && len(orderBy) > 0 { + queryParameters["orderBy"] = orderBy + } + if len(skiptoken) > 0 { + queryParameters["$skiptoken"] = autorest.Encode("query", skiptoken) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/columns", 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 ManagedDatabaseColumnsClient) ListByDatabaseSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByDatabaseResponder handles the response to the ListByDatabase request. The method always +// closes the http.Response Body. +func (client ManagedDatabaseColumnsClient) ListByDatabaseResponder(resp *http.Response) (result DatabaseColumnListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByDatabaseNextResults retrieves the next set of results, if any. +func (client ManagedDatabaseColumnsClient) listByDatabaseNextResults(ctx context.Context, lastResults DatabaseColumnListResult) (result DatabaseColumnListResult, err error) { + req, err := lastResults.databaseColumnListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.ManagedDatabaseColumnsClient", "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.ManagedDatabaseColumnsClient", "listByDatabaseNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseColumnsClient", "listByDatabaseNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByDatabaseComplete enumerates all values, automatically crossing page boundaries as required. +func (client ManagedDatabaseColumnsClient) ListByDatabaseComplete(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, schema []string, table []string, column []string, orderBy []string, skiptoken string) (result DatabaseColumnListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabaseColumnsClient.ListByDatabase") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByDatabase(ctx, resourceGroupName, managedInstanceName, databaseName, schema, table, column, orderBy, skiptoken) + return +} + +// ListByTable list managed database columns +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the database. +// schemaName - the name of the schema. +// tableName - the name of the table. +// filter - an OData filter expression that filters elements in the collection. +func (client ManagedDatabaseColumnsClient) ListByTable(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, schemaName string, tableName string, filter string) (result DatabaseColumnListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabaseColumnsClient.ListByTable") + defer func() { + sc := -1 + if result.dclr.Response.Response != nil { + sc = result.dclr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByTableNextResults + req, err := client.ListByTablePreparer(ctx, resourceGroupName, managedInstanceName, databaseName, schemaName, tableName, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseColumnsClient", "ListByTable", nil, "Failure preparing request") + return + } + + resp, err := client.ListByTableSender(req) + if err != nil { + result.dclr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseColumnsClient", "ListByTable", resp, "Failure sending request") + return + } + + result.dclr, err = client.ListByTableResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseColumnsClient", "ListByTable", resp, "Failure responding to request") + return + } + if result.dclr.hasNextLink() && result.dclr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByTablePreparer prepares the ListByTable request. +func (client ManagedDatabaseColumnsClient) ListByTablePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, schemaName string, tableName string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "schemaName": autorest.Encode("path", schemaName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "tableName": autorest.Encode("path", tableName), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByTableSender sends the ListByTable request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedDatabaseColumnsClient) ListByTableSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByTableResponder handles the response to the ListByTable request. The method always +// closes the http.Response Body. +func (client ManagedDatabaseColumnsClient) ListByTableResponder(resp *http.Response) (result DatabaseColumnListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByTableNextResults retrieves the next set of results, if any. +func (client ManagedDatabaseColumnsClient) listByTableNextResults(ctx context.Context, lastResults DatabaseColumnListResult) (result DatabaseColumnListResult, err error) { + req, err := lastResults.databaseColumnListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.ManagedDatabaseColumnsClient", "listByTableNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByTableSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.ManagedDatabaseColumnsClient", "listByTableNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByTableResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseColumnsClient", "listByTableNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByTableComplete enumerates all values, automatically crossing page boundaries as required. +func (client ManagedDatabaseColumnsClient) ListByTableComplete(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, schemaName string, tableName string, filter string) (result DatabaseColumnListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabaseColumnsClient.ListByTable") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByTable(ctx, resourceGroupName, managedInstanceName, databaseName, schemaName, tableName, filter) + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/manageddatabasequeries.go b/services/preview/sql/mgmt/v5.0/sql/manageddatabasequeries.go new file mode 100644 index 000000000000..f40cedd192ab --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/manageddatabasequeries.go @@ -0,0 +1,248 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ManagedDatabaseQueriesClient 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 ManagedDatabaseQueriesClient struct { + BaseClient +} + +// NewManagedDatabaseQueriesClient creates an instance of the ManagedDatabaseQueriesClient client. +func NewManagedDatabaseQueriesClient(subscriptionID string) ManagedDatabaseQueriesClient { + return NewManagedDatabaseQueriesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewManagedDatabaseQueriesClientWithBaseURI creates an instance of the ManagedDatabaseQueriesClient client using a +// custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, +// Azure stack). +func NewManagedDatabaseQueriesClientWithBaseURI(baseURI string, subscriptionID string) ManagedDatabaseQueriesClient { + return ManagedDatabaseQueriesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get get query by query id. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the database. +func (client ManagedDatabaseQueriesClient) Get(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, queryID string) (result ManagedInstanceQuery, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabaseQueriesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, managedInstanceName, databaseName, queryID) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseQueriesClient", "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.ManagedDatabaseQueriesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseQueriesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ManagedDatabaseQueriesClient) GetPreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, queryID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "queryId": autorest.Encode("path", queryID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/queries/{queryId}", 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 ManagedDatabaseQueriesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ManagedDatabaseQueriesClient) GetResponder(resp *http.Response) (result ManagedInstanceQuery, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByQuery get query execution statistics by query id. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the database. +// startTime - start time for observed period. +// endTime - end time for observed period. +// interval - the time step to be used to summarize the metric values. +func (client ManagedDatabaseQueriesClient) ListByQuery(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, queryID string, startTime string, endTime string, interval QueryTimeGrainType) (result ManagedInstanceQueryStatisticsPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabaseQueriesClient.ListByQuery") + defer func() { + sc := -1 + if result.miqs.Response.Response != nil { + sc = result.miqs.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByQueryNextResults + req, err := client.ListByQueryPreparer(ctx, resourceGroupName, managedInstanceName, databaseName, queryID, startTime, endTime, interval) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseQueriesClient", "ListByQuery", nil, "Failure preparing request") + return + } + + resp, err := client.ListByQuerySender(req) + if err != nil { + result.miqs.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseQueriesClient", "ListByQuery", resp, "Failure sending request") + return + } + + result.miqs, err = client.ListByQueryResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseQueriesClient", "ListByQuery", resp, "Failure responding to request") + return + } + if result.miqs.hasNextLink() && result.miqs.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByQueryPreparer prepares the ListByQuery request. +func (client ManagedDatabaseQueriesClient) ListByQueryPreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, queryID string, startTime string, endTime string, interval QueryTimeGrainType) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "queryId": autorest.Encode("path", queryID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(startTime) > 0 { + queryParameters["startTime"] = autorest.Encode("query", startTime) + } + if len(endTime) > 0 { + queryParameters["endTime"] = autorest.Encode("query", endTime) + } + if len(string(interval)) > 0 { + queryParameters["interval"] = autorest.Encode("query", interval) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/queries/{queryId}/statistics", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByQuerySender sends the ListByQuery request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedDatabaseQueriesClient) ListByQuerySender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByQueryResponder handles the response to the ListByQuery request. The method always +// closes the http.Response Body. +func (client ManagedDatabaseQueriesClient) ListByQueryResponder(resp *http.Response) (result ManagedInstanceQueryStatistics, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByQueryNextResults retrieves the next set of results, if any. +func (client ManagedDatabaseQueriesClient) listByQueryNextResults(ctx context.Context, lastResults ManagedInstanceQueryStatistics) (result ManagedInstanceQueryStatistics, err error) { + req, err := lastResults.managedInstanceQueryStatisticsPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.ManagedDatabaseQueriesClient", "listByQueryNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByQuerySender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.ManagedDatabaseQueriesClient", "listByQueryNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByQueryResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseQueriesClient", "listByQueryNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByQueryComplete enumerates all values, automatically crossing page boundaries as required. +func (client ManagedDatabaseQueriesClient) ListByQueryComplete(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, queryID string, startTime string, endTime string, interval QueryTimeGrainType) (result ManagedInstanceQueryStatisticsIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabaseQueriesClient.ListByQuery") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByQuery(ctx, resourceGroupName, managedInstanceName, databaseName, queryID, startTime, endTime, interval) + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/manageddatabaserecommendedsensitivitylabels.go b/services/preview/sql/mgmt/v5.0/sql/manageddatabaserecommendedsensitivitylabels.go new file mode 100644 index 000000000000..a235d74b0697 --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/manageddatabaserecommendedsensitivitylabels.go @@ -0,0 +1,115 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ManagedDatabaseRecommendedSensitivityLabelsClient 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 ManagedDatabaseRecommendedSensitivityLabelsClient struct { + BaseClient +} + +// NewManagedDatabaseRecommendedSensitivityLabelsClient creates an instance of the +// ManagedDatabaseRecommendedSensitivityLabelsClient client. +func NewManagedDatabaseRecommendedSensitivityLabelsClient(subscriptionID string) ManagedDatabaseRecommendedSensitivityLabelsClient { + return NewManagedDatabaseRecommendedSensitivityLabelsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewManagedDatabaseRecommendedSensitivityLabelsClientWithBaseURI creates an instance of the +// ManagedDatabaseRecommendedSensitivityLabelsClient client using a custom endpoint. Use this when interacting with an +// Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewManagedDatabaseRecommendedSensitivityLabelsClientWithBaseURI(baseURI string, subscriptionID string) ManagedDatabaseRecommendedSensitivityLabelsClient { + return ManagedDatabaseRecommendedSensitivityLabelsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Update update recommended sensitivity labels states of a given database using an operations batch. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the database. +func (client ManagedDatabaseRecommendedSensitivityLabelsClient) Update(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, parameters RecommendedSensitivityLabelUpdateList) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabaseRecommendedSensitivityLabelsClient.Update") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.UpdatePreparer(ctx, resourceGroupName, managedInstanceName, databaseName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseRecommendedSensitivityLabelsClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseRecommendedSensitivityLabelsClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseRecommendedSensitivityLabelsClient", "Update", resp, "Failure responding to request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client ManagedDatabaseRecommendedSensitivityLabelsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, parameters RecommendedSensitivityLabelUpdateList) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/recommendedSensitivityLabels", 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 ManagedDatabaseRecommendedSensitivityLabelsClient) UpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client ManagedDatabaseRecommendedSensitivityLabelsClient) UpdateResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/manageddatabaserestoredetails.go b/services/preview/sql/mgmt/v5.0/sql/manageddatabaserestoredetails.go new file mode 100644 index 000000000000..d944de7e93ae --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/manageddatabaserestoredetails.go @@ -0,0 +1,114 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ManagedDatabaseRestoreDetailsClient 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 ManagedDatabaseRestoreDetailsClient struct { + BaseClient +} + +// NewManagedDatabaseRestoreDetailsClient creates an instance of the ManagedDatabaseRestoreDetailsClient client. +func NewManagedDatabaseRestoreDetailsClient(subscriptionID string) ManagedDatabaseRestoreDetailsClient { + return NewManagedDatabaseRestoreDetailsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewManagedDatabaseRestoreDetailsClientWithBaseURI creates an instance of the ManagedDatabaseRestoreDetailsClient +// client using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI +// (sovereign clouds, Azure stack). +func NewManagedDatabaseRestoreDetailsClientWithBaseURI(baseURI string, subscriptionID string) ManagedDatabaseRestoreDetailsClient { + return ManagedDatabaseRestoreDetailsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get gets managed database restore details. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the database. +func (client ManagedDatabaseRestoreDetailsClient) Get(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (result ManagedDatabaseRestoreDetailsResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabaseRestoreDetailsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, managedInstanceName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseRestoreDetailsClient", "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.ManagedDatabaseRestoreDetailsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseRestoreDetailsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ManagedDatabaseRestoreDetailsClient) 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), + "restoreDetailsName": autorest.Encode("path", "Default"), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/restoreDetails/{restoreDetailsName}", 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 ManagedDatabaseRestoreDetailsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ManagedDatabaseRestoreDetailsClient) GetResponder(resp *http.Response) (result ManagedDatabaseRestoreDetailsResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/manageddatabases.go b/services/preview/sql/mgmt/v5.0/sql/manageddatabases.go new file mode 100644 index 000000000000..3a7acfa75ea1 --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/manageddatabases.go @@ -0,0 +1,689 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ManagedDatabasesClient is the the Azure SQL Database management API provides a RESTful set of web services that +// interact with Azure SQL Database services to manage your databases. The API enables you to create, retrieve, update, +// and delete databases. +type ManagedDatabasesClient struct { + BaseClient +} + +// NewManagedDatabasesClient creates an instance of the ManagedDatabasesClient client. +func NewManagedDatabasesClient(subscriptionID string) ManagedDatabasesClient { + return NewManagedDatabasesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewManagedDatabasesClientWithBaseURI creates an instance of the ManagedDatabasesClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewManagedDatabasesClientWithBaseURI(baseURI string, subscriptionID string) ManagedDatabasesClient { + return ManagedDatabasesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CompleteRestore completes the restore operation on a managed database. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the database. +// parameters - the definition for completing the restore of this managed database. +func (client ManagedDatabasesClient) CompleteRestore(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, parameters CompleteDatabaseRestoreDefinition) (result ManagedDatabasesCompleteRestoreFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabasesClient.CompleteRestore") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.LastBackupName", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewError("sql.ManagedDatabasesClient", "CompleteRestore", err.Error()) + } + + req, err := client.CompleteRestorePreparer(ctx, resourceGroupName, managedInstanceName, databaseName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabasesClient", "CompleteRestore", nil, "Failure preparing request") + return + } + + result, err = client.CompleteRestoreSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabasesClient", "CompleteRestore", nil, "Failure sending request") + return + } + + return +} + +// CompleteRestorePreparer prepares the CompleteRestore request. +func (client ManagedDatabasesClient) CompleteRestorePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, parameters CompleteDatabaseRestoreDefinition) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/completeRestore", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CompleteRestoreSender sends the CompleteRestore request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedDatabasesClient) CompleteRestoreSender(req *http.Request) (future ManagedDatabasesCompleteRestoreFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CompleteRestoreResponder handles the response to the CompleteRestore request. The method always +// closes the http.Response Body. +func (client ManagedDatabasesClient) CompleteRestoreResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + +// CreateOrUpdate creates a new database or updates an existing database. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the database. +// parameters - the requested database resource state. +func (client ManagedDatabasesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, parameters ManagedDatabase) (result ManagedDatabasesCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabasesClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, managedInstanceName, databaseName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabasesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabasesClient", "CreateOrUpdate", nil, "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ManagedDatabasesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, parameters ManagedDatabase) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedDatabasesClient) CreateOrUpdateSender(req *http.Request) (future ManagedDatabasesCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ManagedDatabasesClient) CreateOrUpdateResponder(resp *http.Response) (result ManagedDatabase, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a managed database. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the database. +func (client ManagedDatabasesClient) Delete(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (result ManagedDatabasesDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabasesClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, managedInstanceName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabasesClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabasesClient", "Delete", nil, "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ManagedDatabasesClient) DeletePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedDatabasesClient) DeleteSender(req *http.Request) (future ManagedDatabasesDeleteFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ManagedDatabasesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a managed database. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the database. +func (client ManagedDatabasesClient) Get(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (result ManagedDatabase, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabasesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, managedInstanceName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabasesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ManagedDatabasesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabasesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ManagedDatabasesClient) GetPreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedDatabasesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ManagedDatabasesClient) GetResponder(resp *http.Response) (result ManagedDatabase, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByInstance gets a list of managed databases. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +func (client ManagedDatabasesClient) ListByInstance(ctx context.Context, resourceGroupName string, managedInstanceName string) (result ManagedDatabaseListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabasesClient.ListByInstance") + defer func() { + sc := -1 + if result.mdlr.Response.Response != nil { + sc = result.mdlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByInstanceNextResults + req, err := client.ListByInstancePreparer(ctx, resourceGroupName, managedInstanceName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabasesClient", "ListByInstance", nil, "Failure preparing request") + return + } + + resp, err := client.ListByInstanceSender(req) + if err != nil { + result.mdlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ManagedDatabasesClient", "ListByInstance", resp, "Failure sending request") + return + } + + result.mdlr, err = client.ListByInstanceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabasesClient", "ListByInstance", resp, "Failure responding to request") + return + } + if result.mdlr.hasNextLink() && result.mdlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByInstancePreparer prepares the ListByInstance request. +func (client ManagedDatabasesClient) ListByInstancePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByInstanceSender sends the ListByInstance request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedDatabasesClient) ListByInstanceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByInstanceResponder handles the response to the ListByInstance request. The method always +// closes the http.Response Body. +func (client ManagedDatabasesClient) ListByInstanceResponder(resp *http.Response) (result ManagedDatabaseListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByInstanceNextResults retrieves the next set of results, if any. +func (client ManagedDatabasesClient) listByInstanceNextResults(ctx context.Context, lastResults ManagedDatabaseListResult) (result ManagedDatabaseListResult, err error) { + req, err := lastResults.managedDatabaseListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.ManagedDatabasesClient", "listByInstanceNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByInstanceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.ManagedDatabasesClient", "listByInstanceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByInstanceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabasesClient", "listByInstanceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByInstanceComplete enumerates all values, automatically crossing page boundaries as required. +func (client ManagedDatabasesClient) ListByInstanceComplete(ctx context.Context, resourceGroupName string, managedInstanceName string) (result ManagedDatabaseListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabasesClient.ListByInstance") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByInstance(ctx, resourceGroupName, managedInstanceName) + return +} + +// ListInaccessibleByInstance gets a list of inaccessible managed databases in a managed instance +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +func (client ManagedDatabasesClient) ListInaccessibleByInstance(ctx context.Context, resourceGroupName string, managedInstanceName string) (result ManagedDatabaseListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabasesClient.ListInaccessibleByInstance") + defer func() { + sc := -1 + if result.mdlr.Response.Response != nil { + sc = result.mdlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listInaccessibleByInstanceNextResults + req, err := client.ListInaccessibleByInstancePreparer(ctx, resourceGroupName, managedInstanceName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabasesClient", "ListInaccessibleByInstance", nil, "Failure preparing request") + return + } + + resp, err := client.ListInaccessibleByInstanceSender(req) + if err != nil { + result.mdlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ManagedDatabasesClient", "ListInaccessibleByInstance", resp, "Failure sending request") + return + } + + result.mdlr, err = client.ListInaccessibleByInstanceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabasesClient", "ListInaccessibleByInstance", resp, "Failure responding to request") + return + } + if result.mdlr.hasNextLink() && result.mdlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListInaccessibleByInstancePreparer prepares the ListInaccessibleByInstance request. +func (client ManagedDatabasesClient) ListInaccessibleByInstancePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/inaccessibleManagedDatabases", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListInaccessibleByInstanceSender sends the ListInaccessibleByInstance request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedDatabasesClient) ListInaccessibleByInstanceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListInaccessibleByInstanceResponder handles the response to the ListInaccessibleByInstance request. The method always +// closes the http.Response Body. +func (client ManagedDatabasesClient) ListInaccessibleByInstanceResponder(resp *http.Response) (result ManagedDatabaseListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listInaccessibleByInstanceNextResults retrieves the next set of results, if any. +func (client ManagedDatabasesClient) listInaccessibleByInstanceNextResults(ctx context.Context, lastResults ManagedDatabaseListResult) (result ManagedDatabaseListResult, err error) { + req, err := lastResults.managedDatabaseListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.ManagedDatabasesClient", "listInaccessibleByInstanceNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListInaccessibleByInstanceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.ManagedDatabasesClient", "listInaccessibleByInstanceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListInaccessibleByInstanceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabasesClient", "listInaccessibleByInstanceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListInaccessibleByInstanceComplete enumerates all values, automatically crossing page boundaries as required. +func (client ManagedDatabasesClient) ListInaccessibleByInstanceComplete(ctx context.Context, resourceGroupName string, managedInstanceName string) (result ManagedDatabaseListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabasesClient.ListInaccessibleByInstance") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListInaccessibleByInstance(ctx, resourceGroupName, managedInstanceName) + return +} + +// Update updates an existing database. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the database. +// parameters - the requested database resource state. +func (client ManagedDatabasesClient) Update(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, parameters ManagedDatabaseUpdate) (result ManagedDatabasesUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabasesClient.Update") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.UpdatePreparer(ctx, resourceGroupName, managedInstanceName, databaseName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabasesClient", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabasesClient", "Update", nil, "Failure sending request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client ManagedDatabasesClient) UpdatePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, parameters ManagedDatabaseUpdate) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedDatabasesClient) UpdateSender(req *http.Request) (future ManagedDatabasesUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client ManagedDatabasesClient) UpdateResponder(resp *http.Response) (result ManagedDatabase, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/manageddatabaseschemas.go b/services/preview/sql/mgmt/v5.0/sql/manageddatabaseschemas.go new file mode 100644 index 000000000000..085bedb662d7 --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/manageddatabaseschemas.go @@ -0,0 +1,240 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ManagedDatabaseSchemasClient 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 ManagedDatabaseSchemasClient struct { + BaseClient +} + +// NewManagedDatabaseSchemasClient creates an instance of the ManagedDatabaseSchemasClient client. +func NewManagedDatabaseSchemasClient(subscriptionID string) ManagedDatabaseSchemasClient { + return NewManagedDatabaseSchemasClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewManagedDatabaseSchemasClientWithBaseURI creates an instance of the ManagedDatabaseSchemasClient client using a +// custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, +// Azure stack). +func NewManagedDatabaseSchemasClientWithBaseURI(baseURI string, subscriptionID string) ManagedDatabaseSchemasClient { + return ManagedDatabaseSchemasClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get get managed database schema +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the database. +// schemaName - the name of the schema. +func (client ManagedDatabaseSchemasClient) Get(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, schemaName string) (result DatabaseSchema, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabaseSchemasClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, managedInstanceName, databaseName, schemaName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseSchemasClient", "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.ManagedDatabaseSchemasClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseSchemasClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ManagedDatabaseSchemasClient) GetPreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, schemaName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "schemaName": autorest.Encode("path", schemaName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/schemas/{schemaName}", 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 ManagedDatabaseSchemasClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ManagedDatabaseSchemasClient) GetResponder(resp *http.Response) (result DatabaseSchema, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByDatabase list managed database schemas +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the database. +// filter - an OData filter expression that filters elements in the collection. +func (client ManagedDatabaseSchemasClient) ListByDatabase(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, filter string) (result DatabaseSchemaListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabaseSchemasClient.ListByDatabase") + defer func() { + sc := -1 + if result.dslr.Response.Response != nil { + sc = result.dslr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByDatabaseNextResults + req, err := client.ListByDatabasePreparer(ctx, resourceGroupName, managedInstanceName, databaseName, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseSchemasClient", "ListByDatabase", nil, "Failure preparing request") + return + } + + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.dslr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseSchemasClient", "ListByDatabase", resp, "Failure sending request") + return + } + + result.dslr, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseSchemasClient", "ListByDatabase", resp, "Failure responding to request") + return + } + if result.dslr.hasNextLink() && result.dslr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByDatabasePreparer prepares the ListByDatabase request. +func (client ManagedDatabaseSchemasClient) ListByDatabasePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/schemas", 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 ManagedDatabaseSchemasClient) ListByDatabaseSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByDatabaseResponder handles the response to the ListByDatabase request. The method always +// closes the http.Response Body. +func (client ManagedDatabaseSchemasClient) ListByDatabaseResponder(resp *http.Response) (result DatabaseSchemaListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByDatabaseNextResults retrieves the next set of results, if any. +func (client ManagedDatabaseSchemasClient) listByDatabaseNextResults(ctx context.Context, lastResults DatabaseSchemaListResult) (result DatabaseSchemaListResult, err error) { + req, err := lastResults.databaseSchemaListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.ManagedDatabaseSchemasClient", "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.ManagedDatabaseSchemasClient", "listByDatabaseNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseSchemasClient", "listByDatabaseNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByDatabaseComplete enumerates all values, automatically crossing page boundaries as required. +func (client ManagedDatabaseSchemasClient) ListByDatabaseComplete(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, filter string) (result DatabaseSchemaListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabaseSchemasClient.ListByDatabase") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByDatabase(ctx, resourceGroupName, managedInstanceName, databaseName, filter) + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/manageddatabasesecurityalertpolicies.go b/services/preview/sql/mgmt/v5.0/sql/manageddatabasesecurityalertpolicies.go new file mode 100644 index 000000000000..dfd1380ebc88 --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/manageddatabasesecurityalertpolicies.go @@ -0,0 +1,319 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ManagedDatabaseSecurityAlertPoliciesClient is the the Azure SQL Database management API provides a RESTful set of +// web services that interact with Azure SQL Database services to manage your databases. The API enables you to create, +// retrieve, update, and delete databases. +type ManagedDatabaseSecurityAlertPoliciesClient struct { + BaseClient +} + +// NewManagedDatabaseSecurityAlertPoliciesClient creates an instance of the ManagedDatabaseSecurityAlertPoliciesClient +// client. +func NewManagedDatabaseSecurityAlertPoliciesClient(subscriptionID string) ManagedDatabaseSecurityAlertPoliciesClient { + return NewManagedDatabaseSecurityAlertPoliciesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewManagedDatabaseSecurityAlertPoliciesClientWithBaseURI creates an instance of the +// ManagedDatabaseSecurityAlertPoliciesClient client using a custom endpoint. Use this when interacting with an Azure +// cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewManagedDatabaseSecurityAlertPoliciesClientWithBaseURI(baseURI string, subscriptionID string) ManagedDatabaseSecurityAlertPoliciesClient { + return ManagedDatabaseSecurityAlertPoliciesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a database's security alert policy. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the managed database for which the security alert policy is defined. +// parameters - the database security alert policy. +func (client ManagedDatabaseSecurityAlertPoliciesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, parameters ManagedDatabaseSecurityAlertPolicy) (result ManagedDatabaseSecurityAlertPolicy, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabaseSecurityAlertPoliciesClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, managedInstanceName, databaseName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseSecurityAlertPoliciesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseSecurityAlertPoliciesClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseSecurityAlertPoliciesClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ManagedDatabaseSecurityAlertPoliciesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, parameters ManagedDatabaseSecurityAlertPolicy) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "securityAlertPolicyName": autorest.Encode("path", "default"), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/securityAlertPolicies/{securityAlertPolicyName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedDatabaseSecurityAlertPoliciesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ManagedDatabaseSecurityAlertPoliciesClient) CreateOrUpdateResponder(resp *http.Response) (result ManagedDatabaseSecurityAlertPolicy, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets a managed database's security alert policy. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the managed database for which the security alert policy is defined. +func (client ManagedDatabaseSecurityAlertPoliciesClient) Get(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (result ManagedDatabaseSecurityAlertPolicy, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabaseSecurityAlertPoliciesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, managedInstanceName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseSecurityAlertPoliciesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseSecurityAlertPoliciesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseSecurityAlertPoliciesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ManagedDatabaseSecurityAlertPoliciesClient) GetPreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "securityAlertPolicyName": autorest.Encode("path", "default"), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/securityAlertPolicies/{securityAlertPolicyName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedDatabaseSecurityAlertPoliciesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ManagedDatabaseSecurityAlertPoliciesClient) GetResponder(resp *http.Response) (result ManagedDatabaseSecurityAlertPolicy, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByDatabase gets a list of managed database's security alert policies. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the managed database for which the security alert policies are defined. +func (client ManagedDatabaseSecurityAlertPoliciesClient) ListByDatabase(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (result ManagedDatabaseSecurityAlertPolicyListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabaseSecurityAlertPoliciesClient.ListByDatabase") + defer func() { + sc := -1 + if result.mdsaplr.Response.Response != nil { + sc = result.mdsaplr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByDatabaseNextResults + req, err := client.ListByDatabasePreparer(ctx, resourceGroupName, managedInstanceName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseSecurityAlertPoliciesClient", "ListByDatabase", nil, "Failure preparing request") + return + } + + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.mdsaplr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseSecurityAlertPoliciesClient", "ListByDatabase", resp, "Failure sending request") + return + } + + result.mdsaplr, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseSecurityAlertPoliciesClient", "ListByDatabase", resp, "Failure responding to request") + return + } + if result.mdsaplr.hasNextLink() && result.mdsaplr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByDatabasePreparer prepares the ListByDatabase request. +func (client ManagedDatabaseSecurityAlertPoliciesClient) ListByDatabasePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/securityAlertPolicies", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByDatabaseSender sends the ListByDatabase request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedDatabaseSecurityAlertPoliciesClient) ListByDatabaseSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByDatabaseResponder handles the response to the ListByDatabase request. The method always +// closes the http.Response Body. +func (client ManagedDatabaseSecurityAlertPoliciesClient) ListByDatabaseResponder(resp *http.Response) (result ManagedDatabaseSecurityAlertPolicyListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByDatabaseNextResults retrieves the next set of results, if any. +func (client ManagedDatabaseSecurityAlertPoliciesClient) listByDatabaseNextResults(ctx context.Context, lastResults ManagedDatabaseSecurityAlertPolicyListResult) (result ManagedDatabaseSecurityAlertPolicyListResult, err error) { + req, err := lastResults.managedDatabaseSecurityAlertPolicyListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.ManagedDatabaseSecurityAlertPoliciesClient", "listByDatabaseNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.ManagedDatabaseSecurityAlertPoliciesClient", "listByDatabaseNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseSecurityAlertPoliciesClient", "listByDatabaseNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByDatabaseComplete enumerates all values, automatically crossing page boundaries as required. +func (client ManagedDatabaseSecurityAlertPoliciesClient) ListByDatabaseComplete(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (result ManagedDatabaseSecurityAlertPolicyListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabaseSecurityAlertPoliciesClient.ListByDatabase") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByDatabase(ctx, resourceGroupName, managedInstanceName, databaseName) + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/manageddatabasesecurityevents.go b/services/preview/sql/mgmt/v5.0/sql/manageddatabasesecurityevents.go new file mode 100644 index 000000000000..d7cbdfffef6d --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/manageddatabasesecurityevents.go @@ -0,0 +1,171 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ManagedDatabaseSecurityEventsClient 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 ManagedDatabaseSecurityEventsClient struct { + BaseClient +} + +// NewManagedDatabaseSecurityEventsClient creates an instance of the ManagedDatabaseSecurityEventsClient client. +func NewManagedDatabaseSecurityEventsClient(subscriptionID string) ManagedDatabaseSecurityEventsClient { + return NewManagedDatabaseSecurityEventsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewManagedDatabaseSecurityEventsClientWithBaseURI creates an instance of the ManagedDatabaseSecurityEventsClient +// client using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI +// (sovereign clouds, Azure stack). +func NewManagedDatabaseSecurityEventsClientWithBaseURI(baseURI string, subscriptionID string) ManagedDatabaseSecurityEventsClient { + return ManagedDatabaseSecurityEventsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListByDatabase gets a list of security events. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the managed database for which the security events are retrieved. +// filter - an OData filter expression that filters elements in the collection. +// skip - the number of elements in the collection to skip. +// top - the number of elements to return from the collection. +// skiptoken - an opaque token that identifies a starting point in the collection. +func (client ManagedDatabaseSecurityEventsClient) ListByDatabase(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, filter string, skip *int32, top *int32, skiptoken string) (result SecurityEventCollectionPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabaseSecurityEventsClient.ListByDatabase") + defer func() { + sc := -1 + if result.sec.Response.Response != nil { + sc = result.sec.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByDatabaseNextResults + req, err := client.ListByDatabasePreparer(ctx, resourceGroupName, managedInstanceName, databaseName, filter, skip, top, skiptoken) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseSecurityEventsClient", "ListByDatabase", nil, "Failure preparing request") + return + } + + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.sec.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseSecurityEventsClient", "ListByDatabase", resp, "Failure sending request") + return + } + + result.sec, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseSecurityEventsClient", "ListByDatabase", resp, "Failure responding to request") + return + } + if result.sec.hasNextLink() && result.sec.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByDatabasePreparer prepares the ListByDatabase request. +func (client ManagedDatabaseSecurityEventsClient) ListByDatabasePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, filter string, skip *int32, top *int32, skiptoken string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if skip != nil { + queryParameters["$skip"] = autorest.Encode("query", *skip) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + if len(skiptoken) > 0 { + queryParameters["$skiptoken"] = autorest.Encode("query", skiptoken) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/securityEvents", 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 ManagedDatabaseSecurityEventsClient) ListByDatabaseSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByDatabaseResponder handles the response to the ListByDatabase request. The method always +// closes the http.Response Body. +func (client ManagedDatabaseSecurityEventsClient) ListByDatabaseResponder(resp *http.Response) (result SecurityEventCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByDatabaseNextResults retrieves the next set of results, if any. +func (client ManagedDatabaseSecurityEventsClient) listByDatabaseNextResults(ctx context.Context, lastResults SecurityEventCollection) (result SecurityEventCollection, err error) { + req, err := lastResults.securityEventCollectionPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.ManagedDatabaseSecurityEventsClient", "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.ManagedDatabaseSecurityEventsClient", "listByDatabaseNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseSecurityEventsClient", "listByDatabaseNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByDatabaseComplete enumerates all values, automatically crossing page boundaries as required. +func (client ManagedDatabaseSecurityEventsClient) ListByDatabaseComplete(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, filter string, skip *int32, top *int32, skiptoken string) (result SecurityEventCollectionIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabaseSecurityEventsClient.ListByDatabase") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByDatabase(ctx, resourceGroupName, managedInstanceName, databaseName, filter, skip, top, skiptoken) + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/manageddatabasesensitivitylabels.go b/services/preview/sql/mgmt/v5.0/sql/manageddatabasesensitivitylabels.go new file mode 100644 index 000000000000..f74ae569ae7f --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/manageddatabasesensitivitylabels.go @@ -0,0 +1,810 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ManagedDatabaseSensitivityLabelsClient is the the Azure SQL Database management API provides a RESTful set of web +// services that interact with Azure SQL Database services to manage your databases. The API enables you to create, +// retrieve, update, and delete databases. +type ManagedDatabaseSensitivityLabelsClient struct { + BaseClient +} + +// NewManagedDatabaseSensitivityLabelsClient creates an instance of the ManagedDatabaseSensitivityLabelsClient client. +func NewManagedDatabaseSensitivityLabelsClient(subscriptionID string) ManagedDatabaseSensitivityLabelsClient { + return NewManagedDatabaseSensitivityLabelsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewManagedDatabaseSensitivityLabelsClientWithBaseURI creates an instance of the +// ManagedDatabaseSensitivityLabelsClient client using a custom endpoint. Use this when interacting with an Azure +// cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewManagedDatabaseSensitivityLabelsClientWithBaseURI(baseURI string, subscriptionID string) ManagedDatabaseSensitivityLabelsClient { + return ManagedDatabaseSensitivityLabelsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates the sensitivity label of a given column +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the database. +// schemaName - the name of the schema. +// tableName - the name of the table. +// columnName - the name of the column. +// parameters - the column sensitivity label resource. +func (client ManagedDatabaseSensitivityLabelsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, schemaName string, tableName string, columnName string, parameters SensitivityLabel) (result SensitivityLabel, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabaseSensitivityLabelsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, managedInstanceName, databaseName, schemaName, tableName, columnName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseSensitivityLabelsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseSensitivityLabelsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseSensitivityLabelsClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ManagedDatabaseSensitivityLabelsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, schemaName string, tableName string, columnName string, parameters SensitivityLabel) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "columnName": autorest.Encode("path", columnName), + "databaseName": autorest.Encode("path", databaseName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "schemaName": autorest.Encode("path", schemaName), + "sensitivityLabelSource": autorest.Encode("path", "current"), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "tableName": autorest.Encode("path", tableName), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + parameters.ManagedBy = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedDatabaseSensitivityLabelsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ManagedDatabaseSensitivityLabelsClient) CreateOrUpdateResponder(resp *http.Response) (result SensitivityLabel, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes the sensitivity label of a given column +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the database. +// schemaName - the name of the schema. +// tableName - the name of the table. +// columnName - the name of the column. +func (client ManagedDatabaseSensitivityLabelsClient) Delete(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, schemaName string, tableName string, columnName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabaseSensitivityLabelsClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, managedInstanceName, databaseName, schemaName, tableName, columnName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseSensitivityLabelsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseSensitivityLabelsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseSensitivityLabelsClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ManagedDatabaseSensitivityLabelsClient) DeletePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, schemaName string, tableName string, columnName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "columnName": autorest.Encode("path", columnName), + "databaseName": autorest.Encode("path", databaseName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "schemaName": autorest.Encode("path", schemaName), + "sensitivityLabelSource": autorest.Encode("path", "current"), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "tableName": autorest.Encode("path", tableName), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedDatabaseSensitivityLabelsClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ManagedDatabaseSensitivityLabelsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// DisableRecommendation disables sensitivity recommendations on a given column +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the database. +// schemaName - the name of the schema. +// tableName - the name of the table. +// columnName - the name of the column. +func (client ManagedDatabaseSensitivityLabelsClient) DisableRecommendation(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, schemaName string, tableName string, columnName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabaseSensitivityLabelsClient.DisableRecommendation") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DisableRecommendationPreparer(ctx, resourceGroupName, managedInstanceName, databaseName, schemaName, tableName, columnName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseSensitivityLabelsClient", "DisableRecommendation", nil, "Failure preparing request") + return + } + + resp, err := client.DisableRecommendationSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseSensitivityLabelsClient", "DisableRecommendation", resp, "Failure sending request") + return + } + + result, err = client.DisableRecommendationResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseSensitivityLabelsClient", "DisableRecommendation", resp, "Failure responding to request") + return + } + + return +} + +// DisableRecommendationPreparer prepares the DisableRecommendation request. +func (client ManagedDatabaseSensitivityLabelsClient) DisableRecommendationPreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, schemaName string, tableName string, columnName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "columnName": autorest.Encode("path", columnName), + "databaseName": autorest.Encode("path", databaseName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "schemaName": autorest.Encode("path", schemaName), + "sensitivityLabelSource": autorest.Encode("path", "recommended"), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "tableName": autorest.Encode("path", tableName), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}/disable", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DisableRecommendationSender sends the DisableRecommendation request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedDatabaseSensitivityLabelsClient) DisableRecommendationSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DisableRecommendationResponder handles the response to the DisableRecommendation request. The method always +// closes the http.Response Body. +func (client ManagedDatabaseSensitivityLabelsClient) DisableRecommendationResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// EnableRecommendation enables sensitivity recommendations on a given column (recommendations are enabled by default +// on all columns) +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the database. +// schemaName - the name of the schema. +// tableName - the name of the table. +// columnName - the name of the column. +func (client ManagedDatabaseSensitivityLabelsClient) EnableRecommendation(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, schemaName string, tableName string, columnName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabaseSensitivityLabelsClient.EnableRecommendation") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.EnableRecommendationPreparer(ctx, resourceGroupName, managedInstanceName, databaseName, schemaName, tableName, columnName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseSensitivityLabelsClient", "EnableRecommendation", nil, "Failure preparing request") + return + } + + resp, err := client.EnableRecommendationSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseSensitivityLabelsClient", "EnableRecommendation", resp, "Failure sending request") + return + } + + result, err = client.EnableRecommendationResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseSensitivityLabelsClient", "EnableRecommendation", resp, "Failure responding to request") + return + } + + return +} + +// EnableRecommendationPreparer prepares the EnableRecommendation request. +func (client ManagedDatabaseSensitivityLabelsClient) EnableRecommendationPreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, schemaName string, tableName string, columnName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "columnName": autorest.Encode("path", columnName), + "databaseName": autorest.Encode("path", databaseName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "schemaName": autorest.Encode("path", schemaName), + "sensitivityLabelSource": autorest.Encode("path", "recommended"), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "tableName": autorest.Encode("path", tableName), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}/enable", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// EnableRecommendationSender sends the EnableRecommendation request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedDatabaseSensitivityLabelsClient) EnableRecommendationSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// EnableRecommendationResponder handles the response to the EnableRecommendation request. The method always +// closes the http.Response Body. +func (client ManagedDatabaseSensitivityLabelsClient) EnableRecommendationResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets the sensitivity label of a given column +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the database. +// schemaName - the name of the schema. +// tableName - the name of the table. +// columnName - the name of the column. +// sensitivityLabelSource - the source of the sensitivity label. +func (client ManagedDatabaseSensitivityLabelsClient) Get(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, schemaName string, tableName string, columnName string, sensitivityLabelSource SensitivityLabelSource) (result SensitivityLabel, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabaseSensitivityLabelsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, managedInstanceName, databaseName, schemaName, tableName, columnName, sensitivityLabelSource) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseSensitivityLabelsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseSensitivityLabelsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseSensitivityLabelsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ManagedDatabaseSensitivityLabelsClient) GetPreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, schemaName string, tableName string, columnName string, sensitivityLabelSource SensitivityLabelSource) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "columnName": autorest.Encode("path", columnName), + "databaseName": autorest.Encode("path", databaseName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "schemaName": autorest.Encode("path", schemaName), + "sensitivityLabelSource": autorest.Encode("path", sensitivityLabelSource), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "tableName": autorest.Encode("path", tableName), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedDatabaseSensitivityLabelsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ManagedDatabaseSensitivityLabelsClient) GetResponder(resp *http.Response) (result SensitivityLabel, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListCurrentByDatabase gets the sensitivity labels of a given database +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the database. +// filter - an OData filter expression that filters elements in the collection. +func (client ManagedDatabaseSensitivityLabelsClient) ListCurrentByDatabase(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, skipToken string, count *bool, filter string) (result SensitivityLabelListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabaseSensitivityLabelsClient.ListCurrentByDatabase") + defer func() { + sc := -1 + if result.sllr.Response.Response != nil { + sc = result.sllr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listCurrentByDatabaseNextResults + req, err := client.ListCurrentByDatabasePreparer(ctx, resourceGroupName, managedInstanceName, databaseName, skipToken, count, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseSensitivityLabelsClient", "ListCurrentByDatabase", nil, "Failure preparing request") + return + } + + resp, err := client.ListCurrentByDatabaseSender(req) + if err != nil { + result.sllr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseSensitivityLabelsClient", "ListCurrentByDatabase", resp, "Failure sending request") + return + } + + result.sllr, err = client.ListCurrentByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseSensitivityLabelsClient", "ListCurrentByDatabase", resp, "Failure responding to request") + return + } + if result.sllr.hasNextLink() && result.sllr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListCurrentByDatabasePreparer prepares the ListCurrentByDatabase request. +func (client ManagedDatabaseSensitivityLabelsClient) ListCurrentByDatabasePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, skipToken string, count *bool, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(skipToken) > 0 { + queryParameters["$skipToken"] = autorest.Encode("query", skipToken) + } + if count != nil { + queryParameters["$count"] = autorest.Encode("query", *count) + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/currentSensitivityLabels", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListCurrentByDatabaseSender sends the ListCurrentByDatabase request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedDatabaseSensitivityLabelsClient) ListCurrentByDatabaseSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListCurrentByDatabaseResponder handles the response to the ListCurrentByDatabase request. The method always +// closes the http.Response Body. +func (client ManagedDatabaseSensitivityLabelsClient) ListCurrentByDatabaseResponder(resp *http.Response) (result SensitivityLabelListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listCurrentByDatabaseNextResults retrieves the next set of results, if any. +func (client ManagedDatabaseSensitivityLabelsClient) listCurrentByDatabaseNextResults(ctx context.Context, lastResults SensitivityLabelListResult) (result SensitivityLabelListResult, err error) { + req, err := lastResults.sensitivityLabelListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.ManagedDatabaseSensitivityLabelsClient", "listCurrentByDatabaseNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListCurrentByDatabaseSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.ManagedDatabaseSensitivityLabelsClient", "listCurrentByDatabaseNextResults", resp, "Failure sending next results request") + } + result, err = client.ListCurrentByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseSensitivityLabelsClient", "listCurrentByDatabaseNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListCurrentByDatabaseComplete enumerates all values, automatically crossing page boundaries as required. +func (client ManagedDatabaseSensitivityLabelsClient) ListCurrentByDatabaseComplete(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, skipToken string, count *bool, filter string) (result SensitivityLabelListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabaseSensitivityLabelsClient.ListCurrentByDatabase") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListCurrentByDatabase(ctx, resourceGroupName, managedInstanceName, databaseName, skipToken, count, filter) + return +} + +// ListRecommendedByDatabase gets the sensitivity labels of a given database +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the database. +// includeDisabledRecommendations - specifies whether to include disabled recommendations or not. +// filter - an OData filter expression that filters elements in the collection. +func (client ManagedDatabaseSensitivityLabelsClient) ListRecommendedByDatabase(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, skipToken string, includeDisabledRecommendations *bool, filter string) (result SensitivityLabelListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabaseSensitivityLabelsClient.ListRecommendedByDatabase") + defer func() { + sc := -1 + if result.sllr.Response.Response != nil { + sc = result.sllr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listRecommendedByDatabaseNextResults + req, err := client.ListRecommendedByDatabasePreparer(ctx, resourceGroupName, managedInstanceName, databaseName, skipToken, includeDisabledRecommendations, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseSensitivityLabelsClient", "ListRecommendedByDatabase", nil, "Failure preparing request") + return + } + + resp, err := client.ListRecommendedByDatabaseSender(req) + if err != nil { + result.sllr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseSensitivityLabelsClient", "ListRecommendedByDatabase", resp, "Failure sending request") + return + } + + result.sllr, err = client.ListRecommendedByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseSensitivityLabelsClient", "ListRecommendedByDatabase", resp, "Failure responding to request") + return + } + if result.sllr.hasNextLink() && result.sllr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListRecommendedByDatabasePreparer prepares the ListRecommendedByDatabase request. +func (client ManagedDatabaseSensitivityLabelsClient) ListRecommendedByDatabasePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, skipToken string, includeDisabledRecommendations *bool, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(skipToken) > 0 { + queryParameters["$skipToken"] = autorest.Encode("query", skipToken) + } + if includeDisabledRecommendations != nil { + queryParameters["includeDisabledRecommendations"] = autorest.Encode("query", *includeDisabledRecommendations) + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/recommendedSensitivityLabels", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListRecommendedByDatabaseSender sends the ListRecommendedByDatabase request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedDatabaseSensitivityLabelsClient) ListRecommendedByDatabaseSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListRecommendedByDatabaseResponder handles the response to the ListRecommendedByDatabase request. The method always +// closes the http.Response Body. +func (client ManagedDatabaseSensitivityLabelsClient) ListRecommendedByDatabaseResponder(resp *http.Response) (result SensitivityLabelListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listRecommendedByDatabaseNextResults retrieves the next set of results, if any. +func (client ManagedDatabaseSensitivityLabelsClient) listRecommendedByDatabaseNextResults(ctx context.Context, lastResults SensitivityLabelListResult) (result SensitivityLabelListResult, err error) { + req, err := lastResults.sensitivityLabelListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.ManagedDatabaseSensitivityLabelsClient", "listRecommendedByDatabaseNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListRecommendedByDatabaseSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.ManagedDatabaseSensitivityLabelsClient", "listRecommendedByDatabaseNextResults", resp, "Failure sending next results request") + } + result, err = client.ListRecommendedByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseSensitivityLabelsClient", "listRecommendedByDatabaseNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListRecommendedByDatabaseComplete enumerates all values, automatically crossing page boundaries as required. +func (client ManagedDatabaseSensitivityLabelsClient) ListRecommendedByDatabaseComplete(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, skipToken string, includeDisabledRecommendations *bool, filter string) (result SensitivityLabelListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabaseSensitivityLabelsClient.ListRecommendedByDatabase") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListRecommendedByDatabase(ctx, resourceGroupName, managedInstanceName, databaseName, skipToken, includeDisabledRecommendations, filter) + return +} + +// Update update sensitivity labels of a given database using an operations batch. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the database. +func (client ManagedDatabaseSensitivityLabelsClient) Update(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, parameters SensitivityLabelUpdateList) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabaseSensitivityLabelsClient.Update") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.UpdatePreparer(ctx, resourceGroupName, managedInstanceName, databaseName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseSensitivityLabelsClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseSensitivityLabelsClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseSensitivityLabelsClient", "Update", resp, "Failure responding to request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client ManagedDatabaseSensitivityLabelsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, parameters SensitivityLabelUpdateList) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/currentSensitivityLabels", 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 ManagedDatabaseSensitivityLabelsClient) UpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client ManagedDatabaseSensitivityLabelsClient) UpdateResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/manageddatabasetables.go b/services/preview/sql/mgmt/v5.0/sql/manageddatabasetables.go new file mode 100644 index 000000000000..9784c823472c --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/manageddatabasetables.go @@ -0,0 +1,244 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ManagedDatabaseTablesClient 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 ManagedDatabaseTablesClient struct { + BaseClient +} + +// NewManagedDatabaseTablesClient creates an instance of the ManagedDatabaseTablesClient client. +func NewManagedDatabaseTablesClient(subscriptionID string) ManagedDatabaseTablesClient { + return NewManagedDatabaseTablesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewManagedDatabaseTablesClientWithBaseURI creates an instance of the ManagedDatabaseTablesClient client using a +// custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, +// Azure stack). +func NewManagedDatabaseTablesClientWithBaseURI(baseURI string, subscriptionID string) ManagedDatabaseTablesClient { + return ManagedDatabaseTablesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get get managed database table +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the database. +// schemaName - the name of the schema. +// tableName - the name of the table. +func (client ManagedDatabaseTablesClient) Get(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, schemaName string, tableName string) (result DatabaseTable, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabaseTablesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, managedInstanceName, databaseName, schemaName, tableName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseTablesClient", "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.ManagedDatabaseTablesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseTablesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ManagedDatabaseTablesClient) GetPreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, schemaName string, tableName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "schemaName": autorest.Encode("path", schemaName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "tableName": autorest.Encode("path", tableName), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}", 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 ManagedDatabaseTablesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ManagedDatabaseTablesClient) GetResponder(resp *http.Response) (result DatabaseTable, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListBySchema list managed database tables +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the database. +// schemaName - the name of the schema. +// filter - an OData filter expression that filters elements in the collection. +func (client ManagedDatabaseTablesClient) ListBySchema(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, schemaName string, filter string) (result DatabaseTableListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabaseTablesClient.ListBySchema") + defer func() { + sc := -1 + if result.dtlr.Response.Response != nil { + sc = result.dtlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listBySchemaNextResults + req, err := client.ListBySchemaPreparer(ctx, resourceGroupName, managedInstanceName, databaseName, schemaName, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseTablesClient", "ListBySchema", nil, "Failure preparing request") + return + } + + resp, err := client.ListBySchemaSender(req) + if err != nil { + result.dtlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseTablesClient", "ListBySchema", resp, "Failure sending request") + return + } + + result.dtlr, err = client.ListBySchemaResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseTablesClient", "ListBySchema", resp, "Failure responding to request") + return + } + if result.dtlr.hasNextLink() && result.dtlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListBySchemaPreparer prepares the ListBySchema request. +func (client ManagedDatabaseTablesClient) ListBySchemaPreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, schemaName string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "schemaName": autorest.Encode("path", schemaName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/schemas/{schemaName}/tables", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListBySchemaSender sends the ListBySchema request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedDatabaseTablesClient) ListBySchemaSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListBySchemaResponder handles the response to the ListBySchema request. The method always +// closes the http.Response Body. +func (client ManagedDatabaseTablesClient) ListBySchemaResponder(resp *http.Response) (result DatabaseTableListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listBySchemaNextResults retrieves the next set of results, if any. +func (client ManagedDatabaseTablesClient) listBySchemaNextResults(ctx context.Context, lastResults DatabaseTableListResult) (result DatabaseTableListResult, err error) { + req, err := lastResults.databaseTableListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.ManagedDatabaseTablesClient", "listBySchemaNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListBySchemaSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.ManagedDatabaseTablesClient", "listBySchemaNextResults", resp, "Failure sending next results request") + } + result, err = client.ListBySchemaResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseTablesClient", "listBySchemaNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListBySchemaComplete enumerates all values, automatically crossing page boundaries as required. +func (client ManagedDatabaseTablesClient) ListBySchemaComplete(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, schemaName string, filter string) (result DatabaseTableListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabaseTablesClient.ListBySchema") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListBySchema(ctx, resourceGroupName, managedInstanceName, databaseName, schemaName, filter) + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/manageddatabasetransparentdataencryption.go b/services/preview/sql/mgmt/v5.0/sql/manageddatabasetransparentdataencryption.go new file mode 100644 index 000000000000..02f75940f3b4 --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/manageddatabasetransparentdataencryption.go @@ -0,0 +1,319 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ManagedDatabaseTransparentDataEncryptionClient 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 ManagedDatabaseTransparentDataEncryptionClient struct { + BaseClient +} + +// NewManagedDatabaseTransparentDataEncryptionClient creates an instance of the +// ManagedDatabaseTransparentDataEncryptionClient client. +func NewManagedDatabaseTransparentDataEncryptionClient(subscriptionID string) ManagedDatabaseTransparentDataEncryptionClient { + return NewManagedDatabaseTransparentDataEncryptionClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewManagedDatabaseTransparentDataEncryptionClientWithBaseURI creates an instance of the +// ManagedDatabaseTransparentDataEncryptionClient client using a custom endpoint. Use this when interacting with an +// Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewManagedDatabaseTransparentDataEncryptionClientWithBaseURI(baseURI string, subscriptionID string) ManagedDatabaseTransparentDataEncryptionClient { + return ManagedDatabaseTransparentDataEncryptionClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate updates a database's transparent data encryption configuration. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the managed database for which the security alert policy is defined. +// parameters - the database transparent data encryption. +func (client ManagedDatabaseTransparentDataEncryptionClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, parameters ManagedTransparentDataEncryption) (result ManagedTransparentDataEncryption, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabaseTransparentDataEncryptionClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, managedInstanceName, databaseName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseTransparentDataEncryptionClient", "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.ManagedDatabaseTransparentDataEncryptionClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseTransparentDataEncryptionClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ManagedDatabaseTransparentDataEncryptionClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, parameters ManagedTransparentDataEncryption) (*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), + "tdeName": autorest.Encode("path", "current"), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/transparentDataEncryption/{tdeName}", 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 ManagedDatabaseTransparentDataEncryptionClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ManagedDatabaseTransparentDataEncryptionClient) CreateOrUpdateResponder(resp *http.Response) (result ManagedTransparentDataEncryption, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets a managed database's transparent data encryption. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the managed database for which the transparent data encryption is defined. +func (client ManagedDatabaseTransparentDataEncryptionClient) Get(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (result ManagedTransparentDataEncryption, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabaseTransparentDataEncryptionClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, managedInstanceName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseTransparentDataEncryptionClient", "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.ManagedDatabaseTransparentDataEncryptionClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseTransparentDataEncryptionClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ManagedDatabaseTransparentDataEncryptionClient) 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), + "tdeName": autorest.Encode("path", "current"), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/transparentDataEncryption/{tdeName}", 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 ManagedDatabaseTransparentDataEncryptionClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ManagedDatabaseTransparentDataEncryptionClient) GetResponder(resp *http.Response) (result ManagedTransparentDataEncryption, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByDatabase gets a list of managed database's transparent data encryptions. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the managed database for which the transparent data encryption is defined. +func (client ManagedDatabaseTransparentDataEncryptionClient) ListByDatabase(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (result ManagedTransparentDataEncryptionListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabaseTransparentDataEncryptionClient.ListByDatabase") + defer func() { + sc := -1 + if result.mtdelr.Response.Response != nil { + sc = result.mtdelr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByDatabaseNextResults + req, err := client.ListByDatabasePreparer(ctx, resourceGroupName, managedInstanceName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseTransparentDataEncryptionClient", "ListByDatabase", nil, "Failure preparing request") + return + } + + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.mtdelr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseTransparentDataEncryptionClient", "ListByDatabase", resp, "Failure sending request") + return + } + + result.mtdelr, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseTransparentDataEncryptionClient", "ListByDatabase", resp, "Failure responding to request") + return + } + if result.mtdelr.hasNextLink() && result.mtdelr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByDatabasePreparer prepares the ListByDatabase request. +func (client ManagedDatabaseTransparentDataEncryptionClient) ListByDatabasePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/transparentDataEncryption", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByDatabaseSender sends the ListByDatabase request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedDatabaseTransparentDataEncryptionClient) ListByDatabaseSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByDatabaseResponder handles the response to the ListByDatabase request. The method always +// closes the http.Response Body. +func (client ManagedDatabaseTransparentDataEncryptionClient) ListByDatabaseResponder(resp *http.Response) (result ManagedTransparentDataEncryptionListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByDatabaseNextResults retrieves the next set of results, if any. +func (client ManagedDatabaseTransparentDataEncryptionClient) listByDatabaseNextResults(ctx context.Context, lastResults ManagedTransparentDataEncryptionListResult) (result ManagedTransparentDataEncryptionListResult, err error) { + req, err := lastResults.managedTransparentDataEncryptionListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.ManagedDatabaseTransparentDataEncryptionClient", "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.ManagedDatabaseTransparentDataEncryptionClient", "listByDatabaseNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseTransparentDataEncryptionClient", "listByDatabaseNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByDatabaseComplete enumerates all values, automatically crossing page boundaries as required. +func (client ManagedDatabaseTransparentDataEncryptionClient) ListByDatabaseComplete(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (result ManagedTransparentDataEncryptionListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabaseTransparentDataEncryptionClient.ListByDatabase") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByDatabase(ctx, resourceGroupName, managedInstanceName, databaseName) + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/manageddatabasevulnerabilityassessmentrulebaselines.go b/services/preview/sql/mgmt/v5.0/sql/manageddatabasevulnerabilityassessmentrulebaselines.go new file mode 100644 index 000000000000..c42a3edc2bc2 --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/manageddatabasevulnerabilityassessmentrulebaselines.go @@ -0,0 +1,300 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient is the the Azure SQL Database management API provides a +// RESTful set of web services that interact with Azure SQL Database services to manage your databases. The API enables +// you to create, retrieve, update, and delete databases. +type ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient struct { + BaseClient +} + +// NewManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient creates an instance of the +// ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient client. +func NewManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient(subscriptionID string) ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient { + return NewManagedDatabaseVulnerabilityAssessmentRuleBaselinesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewManagedDatabaseVulnerabilityAssessmentRuleBaselinesClientWithBaseURI creates an instance of the +// ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient client using a custom endpoint. Use this when interacting +// with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewManagedDatabaseVulnerabilityAssessmentRuleBaselinesClientWithBaseURI(baseURI string, subscriptionID string) ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient { + return ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a database's vulnerability assessment rule baseline. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the database for which the vulnerability assessment rule baseline is defined. +// ruleID - the vulnerability assessment rule ID. +// baselineName - the name of the vulnerability assessment rule baseline (default implies a baseline on a +// database level rule and master for server level rule). +// parameters - the requested rule baseline resource. +func (client ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, ruleID string, baselineName VulnerabilityAssessmentPolicyBaselineName, parameters DatabaseVulnerabilityAssessmentRuleBaseline) (result DatabaseVulnerabilityAssessmentRuleBaseline, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.DatabaseVulnerabilityAssessmentRuleBaselineProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.DatabaseVulnerabilityAssessmentRuleBaselineProperties.BaselineResults", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("sql.ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, managedInstanceName, databaseName, ruleID, baselineName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, ruleID string, baselineName VulnerabilityAssessmentPolicyBaselineName, parameters DatabaseVulnerabilityAssessmentRuleBaseline) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "baselineName": autorest.Encode("path", baselineName), + "databaseName": autorest.Encode("path", databaseName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "ruleId": autorest.Encode("path", ruleID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vulnerabilityAssessmentName": autorest.Encode("path", "default"), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/rules/{ruleId}/baselines/{baselineName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient) CreateOrUpdateResponder(resp *http.Response) (result DatabaseVulnerabilityAssessmentRuleBaseline, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete removes the database's vulnerability assessment rule baseline. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the database for which the vulnerability assessment rule baseline is defined. +// ruleID - the vulnerability assessment rule ID. +// baselineName - the name of the vulnerability assessment rule baseline (default implies a baseline on a +// database level rule and master for server level rule). +func (client ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient) Delete(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, ruleID string, baselineName VulnerabilityAssessmentPolicyBaselineName) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, managedInstanceName, databaseName, ruleID, baselineName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient) DeletePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, ruleID string, baselineName VulnerabilityAssessmentPolicyBaselineName) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "baselineName": autorest.Encode("path", baselineName), + "databaseName": autorest.Encode("path", databaseName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "ruleId": autorest.Encode("path", ruleID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vulnerabilityAssessmentName": autorest.Encode("path", "default"), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/rules/{ruleId}/baselines/{baselineName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a database's vulnerability assessment rule baseline. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the database for which the vulnerability assessment rule baseline is defined. +// ruleID - the vulnerability assessment rule ID. +// baselineName - the name of the vulnerability assessment rule baseline (default implies a baseline on a +// database level rule and master for server level rule). +func (client ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient) Get(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, ruleID string, baselineName VulnerabilityAssessmentPolicyBaselineName) (result DatabaseVulnerabilityAssessmentRuleBaseline, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, managedInstanceName, databaseName, ruleID, baselineName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient) GetPreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, ruleID string, baselineName VulnerabilityAssessmentPolicyBaselineName) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "baselineName": autorest.Encode("path", baselineName), + "databaseName": autorest.Encode("path", databaseName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "ruleId": autorest.Encode("path", ruleID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vulnerabilityAssessmentName": autorest.Encode("path", "default"), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/rules/{ruleId}/baselines/{baselineName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient) GetResponder(resp *http.Response) (result DatabaseVulnerabilityAssessmentRuleBaseline, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/manageddatabasevulnerabilityassessments.go b/services/preview/sql/mgmt/v5.0/sql/manageddatabasevulnerabilityassessments.go new file mode 100644 index 000000000000..13478ea53783 --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/manageddatabasevulnerabilityassessments.go @@ -0,0 +1,398 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ManagedDatabaseVulnerabilityAssessmentsClient is the the Azure SQL Database management API provides a RESTful set of +// web services that interact with Azure SQL Database services to manage your databases. The API enables you to create, +// retrieve, update, and delete databases. +type ManagedDatabaseVulnerabilityAssessmentsClient struct { + BaseClient +} + +// NewManagedDatabaseVulnerabilityAssessmentsClient creates an instance of the +// ManagedDatabaseVulnerabilityAssessmentsClient client. +func NewManagedDatabaseVulnerabilityAssessmentsClient(subscriptionID string) ManagedDatabaseVulnerabilityAssessmentsClient { + return NewManagedDatabaseVulnerabilityAssessmentsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewManagedDatabaseVulnerabilityAssessmentsClientWithBaseURI creates an instance of the +// ManagedDatabaseVulnerabilityAssessmentsClient client using a custom endpoint. Use this when interacting with an +// Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewManagedDatabaseVulnerabilityAssessmentsClientWithBaseURI(baseURI string, subscriptionID string) ManagedDatabaseVulnerabilityAssessmentsClient { + return ManagedDatabaseVulnerabilityAssessmentsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates the database's vulnerability assessment. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the database for which the vulnerability assessment is defined. +// parameters - the requested resource. +func (client ManagedDatabaseVulnerabilityAssessmentsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, parameters DatabaseVulnerabilityAssessment) (result DatabaseVulnerabilityAssessment, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabaseVulnerabilityAssessmentsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, managedInstanceName, databaseName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentsClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ManagedDatabaseVulnerabilityAssessmentsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, parameters DatabaseVulnerabilityAssessment) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vulnerabilityAssessmentName": autorest.Encode("path", "default"), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedDatabaseVulnerabilityAssessmentsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ManagedDatabaseVulnerabilityAssessmentsClient) CreateOrUpdateResponder(resp *http.Response) (result DatabaseVulnerabilityAssessment, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete removes the database's vulnerability assessment. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the database for which the vulnerability assessment is defined. +func (client ManagedDatabaseVulnerabilityAssessmentsClient) Delete(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabaseVulnerabilityAssessmentsClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, managedInstanceName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentsClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ManagedDatabaseVulnerabilityAssessmentsClient) DeletePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vulnerabilityAssessmentName": autorest.Encode("path", "default"), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedDatabaseVulnerabilityAssessmentsClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ManagedDatabaseVulnerabilityAssessmentsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets the database's vulnerability assessment. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the database for which the vulnerability assessment is defined. +func (client ManagedDatabaseVulnerabilityAssessmentsClient) Get(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (result DatabaseVulnerabilityAssessment, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabaseVulnerabilityAssessmentsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, managedInstanceName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ManagedDatabaseVulnerabilityAssessmentsClient) GetPreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vulnerabilityAssessmentName": autorest.Encode("path", "default"), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedDatabaseVulnerabilityAssessmentsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ManagedDatabaseVulnerabilityAssessmentsClient) GetResponder(resp *http.Response) (result DatabaseVulnerabilityAssessment, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByDatabase lists the vulnerability assessments of a managed database. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the database for which the vulnerability assessment is defined. +func (client ManagedDatabaseVulnerabilityAssessmentsClient) ListByDatabase(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (result DatabaseVulnerabilityAssessmentListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabaseVulnerabilityAssessmentsClient.ListByDatabase") + defer func() { + sc := -1 + if result.dvalr.Response.Response != nil { + sc = result.dvalr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByDatabaseNextResults + req, err := client.ListByDatabasePreparer(ctx, resourceGroupName, managedInstanceName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentsClient", "ListByDatabase", nil, "Failure preparing request") + return + } + + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.dvalr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentsClient", "ListByDatabase", resp, "Failure sending request") + return + } + + result.dvalr, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentsClient", "ListByDatabase", resp, "Failure responding to request") + return + } + if result.dvalr.hasNextLink() && result.dvalr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByDatabasePreparer prepares the ListByDatabase request. +func (client ManagedDatabaseVulnerabilityAssessmentsClient) ListByDatabasePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByDatabaseSender sends the ListByDatabase request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedDatabaseVulnerabilityAssessmentsClient) ListByDatabaseSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByDatabaseResponder handles the response to the ListByDatabase request. The method always +// closes the http.Response Body. +func (client ManagedDatabaseVulnerabilityAssessmentsClient) ListByDatabaseResponder(resp *http.Response) (result DatabaseVulnerabilityAssessmentListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByDatabaseNextResults retrieves the next set of results, if any. +func (client ManagedDatabaseVulnerabilityAssessmentsClient) listByDatabaseNextResults(ctx context.Context, lastResults DatabaseVulnerabilityAssessmentListResult) (result DatabaseVulnerabilityAssessmentListResult, err error) { + req, err := lastResults.databaseVulnerabilityAssessmentListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentsClient", "listByDatabaseNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentsClient", "listByDatabaseNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentsClient", "listByDatabaseNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByDatabaseComplete enumerates all values, automatically crossing page boundaries as required. +func (client ManagedDatabaseVulnerabilityAssessmentsClient) ListByDatabaseComplete(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (result DatabaseVulnerabilityAssessmentListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabaseVulnerabilityAssessmentsClient.ListByDatabase") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByDatabase(ctx, resourceGroupName, managedInstanceName, databaseName) + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/manageddatabasevulnerabilityassessmentscans.go b/services/preview/sql/mgmt/v5.0/sql/manageddatabasevulnerabilityassessmentscans.go new file mode 100644 index 000000000000..2e470b47ce2d --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/manageddatabasevulnerabilityassessmentscans.go @@ -0,0 +1,404 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ManagedDatabaseVulnerabilityAssessmentScansClient is the the Azure SQL Database management API provides a RESTful +// set of web services that interact with Azure SQL Database services to manage your databases. The API enables you to +// create, retrieve, update, and delete databases. +type ManagedDatabaseVulnerabilityAssessmentScansClient struct { + BaseClient +} + +// NewManagedDatabaseVulnerabilityAssessmentScansClient creates an instance of the +// ManagedDatabaseVulnerabilityAssessmentScansClient client. +func NewManagedDatabaseVulnerabilityAssessmentScansClient(subscriptionID string) ManagedDatabaseVulnerabilityAssessmentScansClient { + return NewManagedDatabaseVulnerabilityAssessmentScansClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewManagedDatabaseVulnerabilityAssessmentScansClientWithBaseURI creates an instance of the +// ManagedDatabaseVulnerabilityAssessmentScansClient client using a custom endpoint. Use this when interacting with an +// Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewManagedDatabaseVulnerabilityAssessmentScansClientWithBaseURI(baseURI string, subscriptionID string) ManagedDatabaseVulnerabilityAssessmentScansClient { + return ManagedDatabaseVulnerabilityAssessmentScansClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Export convert an existing scan result to a human readable format. If already exists nothing happens +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the scanned database. +// scanID - the vulnerability assessment scan Id. +func (client ManagedDatabaseVulnerabilityAssessmentScansClient) Export(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, scanID string) (result DatabaseVulnerabilityAssessmentScansExport, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabaseVulnerabilityAssessmentScansClient.Export") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ExportPreparer(ctx, resourceGroupName, managedInstanceName, databaseName, scanID) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentScansClient", "Export", nil, "Failure preparing request") + return + } + + resp, err := client.ExportSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentScansClient", "Export", resp, "Failure sending request") + return + } + + result, err = client.ExportResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentScansClient", "Export", resp, "Failure responding to request") + return + } + + return +} + +// ExportPreparer prepares the Export request. +func (client ManagedDatabaseVulnerabilityAssessmentScansClient) ExportPreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, scanID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "scanId": autorest.Encode("path", scanID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vulnerabilityAssessmentName": autorest.Encode("path", "default"), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}/export", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ExportSender sends the Export request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedDatabaseVulnerabilityAssessmentScansClient) ExportSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ExportResponder handles the response to the Export request. The method always +// closes the http.Response Body. +func (client ManagedDatabaseVulnerabilityAssessmentScansClient) ExportResponder(resp *http.Response) (result DatabaseVulnerabilityAssessmentScansExport, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets a vulnerability assessment scan record of a database. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the database. +// scanID - the vulnerability assessment scan Id of the scan to retrieve. +func (client ManagedDatabaseVulnerabilityAssessmentScansClient) Get(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, scanID string) (result VulnerabilityAssessmentScanRecord, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabaseVulnerabilityAssessmentScansClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, managedInstanceName, databaseName, scanID) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentScansClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentScansClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentScansClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ManagedDatabaseVulnerabilityAssessmentScansClient) GetPreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, scanID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "scanId": autorest.Encode("path", scanID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vulnerabilityAssessmentName": autorest.Encode("path", "default"), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedDatabaseVulnerabilityAssessmentScansClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ManagedDatabaseVulnerabilityAssessmentScansClient) GetResponder(resp *http.Response) (result VulnerabilityAssessmentScanRecord, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// InitiateScan executes a Vulnerability Assessment database scan. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the database. +// scanID - the vulnerability assessment scan Id of the scan to retrieve. +func (client ManagedDatabaseVulnerabilityAssessmentScansClient) InitiateScan(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, scanID string) (result ManagedDatabaseVulnerabilityAssessmentScansInitiateScanFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabaseVulnerabilityAssessmentScansClient.InitiateScan") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.InitiateScanPreparer(ctx, resourceGroupName, managedInstanceName, databaseName, scanID) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentScansClient", "InitiateScan", nil, "Failure preparing request") + return + } + + result, err = client.InitiateScanSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentScansClient", "InitiateScan", nil, "Failure sending request") + return + } + + return +} + +// InitiateScanPreparer prepares the InitiateScan request. +func (client ManagedDatabaseVulnerabilityAssessmentScansClient) InitiateScanPreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, scanID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "scanId": autorest.Encode("path", scanID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vulnerabilityAssessmentName": autorest.Encode("path", "default"), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}/initiateScan", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// InitiateScanSender sends the InitiateScan request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedDatabaseVulnerabilityAssessmentScansClient) InitiateScanSender(req *http.Request) (future ManagedDatabaseVulnerabilityAssessmentScansInitiateScanFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// InitiateScanResponder handles the response to the InitiateScan request. The method always +// closes the http.Response Body. +func (client ManagedDatabaseVulnerabilityAssessmentScansClient) InitiateScanResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + +// ListByDatabase lists the vulnerability assessment scans of a database. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the database. +func (client ManagedDatabaseVulnerabilityAssessmentScansClient) ListByDatabase(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (result VulnerabilityAssessmentScanRecordListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabaseVulnerabilityAssessmentScansClient.ListByDatabase") + defer func() { + sc := -1 + if result.vasrlr.Response.Response != nil { + sc = result.vasrlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByDatabaseNextResults + req, err := client.ListByDatabasePreparer(ctx, resourceGroupName, managedInstanceName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentScansClient", "ListByDatabase", nil, "Failure preparing request") + return + } + + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.vasrlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentScansClient", "ListByDatabase", resp, "Failure sending request") + return + } + + result.vasrlr, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentScansClient", "ListByDatabase", resp, "Failure responding to request") + return + } + if result.vasrlr.hasNextLink() && result.vasrlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByDatabasePreparer prepares the ListByDatabase request. +func (client ManagedDatabaseVulnerabilityAssessmentScansClient) ListByDatabasePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vulnerabilityAssessmentName": autorest.Encode("path", "default"), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByDatabaseSender sends the ListByDatabase request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedDatabaseVulnerabilityAssessmentScansClient) ListByDatabaseSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByDatabaseResponder handles the response to the ListByDatabase request. The method always +// closes the http.Response Body. +func (client ManagedDatabaseVulnerabilityAssessmentScansClient) ListByDatabaseResponder(resp *http.Response) (result VulnerabilityAssessmentScanRecordListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByDatabaseNextResults retrieves the next set of results, if any. +func (client ManagedDatabaseVulnerabilityAssessmentScansClient) listByDatabaseNextResults(ctx context.Context, lastResults VulnerabilityAssessmentScanRecordListResult) (result VulnerabilityAssessmentScanRecordListResult, err error) { + req, err := lastResults.vulnerabilityAssessmentScanRecordListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentScansClient", "listByDatabaseNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentScansClient", "listByDatabaseNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentScansClient", "listByDatabaseNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByDatabaseComplete enumerates all values, automatically crossing page boundaries as required. +func (client ManagedDatabaseVulnerabilityAssessmentScansClient) ListByDatabaseComplete(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (result VulnerabilityAssessmentScanRecordListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabaseVulnerabilityAssessmentScansClient.ListByDatabase") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByDatabase(ctx, resourceGroupName, managedInstanceName, databaseName) + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/managedinstanceadministrators.go b/services/preview/sql/mgmt/v5.0/sql/managedinstanceadministrators.go new file mode 100644 index 000000000000..73cdbc1de6e3 --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/managedinstanceadministrators.go @@ -0,0 +1,404 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ManagedInstanceAdministratorsClient is the the Azure SQL Database management API provides a RESTful set of web +// services that interact with Azure SQL Database services to manage your databases. The API enables you to create, +// retrieve, update, and delete databases. +type ManagedInstanceAdministratorsClient struct { + BaseClient +} + +// NewManagedInstanceAdministratorsClient creates an instance of the ManagedInstanceAdministratorsClient client. +func NewManagedInstanceAdministratorsClient(subscriptionID string) ManagedInstanceAdministratorsClient { + return NewManagedInstanceAdministratorsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewManagedInstanceAdministratorsClientWithBaseURI creates an instance of the ManagedInstanceAdministratorsClient +// client using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI +// (sovereign clouds, Azure stack). +func NewManagedInstanceAdministratorsClientWithBaseURI(baseURI string, subscriptionID string) ManagedInstanceAdministratorsClient { + return ManagedInstanceAdministratorsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a managed instance administrator. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// parameters - the requested administrator parameters. +func (client ManagedInstanceAdministratorsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, managedInstanceName string, parameters ManagedInstanceAdministrator) (result ManagedInstanceAdministratorsCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceAdministratorsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.ManagedInstanceAdministratorProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ManagedInstanceAdministratorProperties.AdministratorType", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.ManagedInstanceAdministratorProperties.Login", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.ManagedInstanceAdministratorProperties.Sid", Name: validation.Null, Rule: true, Chain: nil}, + }}}}}); err != nil { + return result, validation.NewError("sql.ManagedInstanceAdministratorsClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, managedInstanceName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceAdministratorsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceAdministratorsClient", "CreateOrUpdate", nil, "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ManagedInstanceAdministratorsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, parameters ManagedInstanceAdministrator) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "administratorName": autorest.Encode("path", "ActiveDirectory"), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/administrators/{administratorName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedInstanceAdministratorsClient) CreateOrUpdateSender(req *http.Request) (future ManagedInstanceAdministratorsCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ManagedInstanceAdministratorsClient) CreateOrUpdateResponder(resp *http.Response) (result ManagedInstanceAdministrator, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a managed instance administrator. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +func (client ManagedInstanceAdministratorsClient) Delete(ctx context.Context, resourceGroupName string, managedInstanceName string) (result ManagedInstanceAdministratorsDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceAdministratorsClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, managedInstanceName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceAdministratorsClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceAdministratorsClient", "Delete", nil, "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ManagedInstanceAdministratorsClient) DeletePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "administratorName": autorest.Encode("path", "ActiveDirectory"), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/administrators/{administratorName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedInstanceAdministratorsClient) DeleteSender(req *http.Request) (future ManagedInstanceAdministratorsDeleteFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ManagedInstanceAdministratorsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a managed instance administrator. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +func (client ManagedInstanceAdministratorsClient) Get(ctx context.Context, resourceGroupName string, managedInstanceName string) (result ManagedInstanceAdministrator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceAdministratorsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, managedInstanceName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceAdministratorsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceAdministratorsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceAdministratorsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ManagedInstanceAdministratorsClient) GetPreparer(ctx context.Context, resourceGroupName string, managedInstanceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "administratorName": autorest.Encode("path", "ActiveDirectory"), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/administrators/{administratorName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedInstanceAdministratorsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ManagedInstanceAdministratorsClient) GetResponder(resp *http.Response) (result ManagedInstanceAdministrator, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByInstance gets a list of managed instance administrators. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +func (client ManagedInstanceAdministratorsClient) ListByInstance(ctx context.Context, resourceGroupName string, managedInstanceName string) (result ManagedInstanceAdministratorListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceAdministratorsClient.ListByInstance") + defer func() { + sc := -1 + if result.mialr.Response.Response != nil { + sc = result.mialr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByInstanceNextResults + req, err := client.ListByInstancePreparer(ctx, resourceGroupName, managedInstanceName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceAdministratorsClient", "ListByInstance", nil, "Failure preparing request") + return + } + + resp, err := client.ListByInstanceSender(req) + if err != nil { + result.mialr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceAdministratorsClient", "ListByInstance", resp, "Failure sending request") + return + } + + result.mialr, err = client.ListByInstanceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceAdministratorsClient", "ListByInstance", resp, "Failure responding to request") + return + } + if result.mialr.hasNextLink() && result.mialr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByInstancePreparer prepares the ListByInstance request. +func (client ManagedInstanceAdministratorsClient) ListByInstancePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/administrators", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByInstanceSender sends the ListByInstance request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedInstanceAdministratorsClient) ListByInstanceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByInstanceResponder handles the response to the ListByInstance request. The method always +// closes the http.Response Body. +func (client ManagedInstanceAdministratorsClient) ListByInstanceResponder(resp *http.Response) (result ManagedInstanceAdministratorListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByInstanceNextResults retrieves the next set of results, if any. +func (client ManagedInstanceAdministratorsClient) listByInstanceNextResults(ctx context.Context, lastResults ManagedInstanceAdministratorListResult) (result ManagedInstanceAdministratorListResult, err error) { + req, err := lastResults.managedInstanceAdministratorListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.ManagedInstanceAdministratorsClient", "listByInstanceNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByInstanceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.ManagedInstanceAdministratorsClient", "listByInstanceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByInstanceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceAdministratorsClient", "listByInstanceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByInstanceComplete enumerates all values, automatically crossing page boundaries as required. +func (client ManagedInstanceAdministratorsClient) ListByInstanceComplete(ctx context.Context, resourceGroupName string, managedInstanceName string) (result ManagedInstanceAdministratorListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceAdministratorsClient.ListByInstance") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByInstance(ctx, resourceGroupName, managedInstanceName) + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/managedinstanceazureadonlyauthentications.go b/services/preview/sql/mgmt/v5.0/sql/managedinstanceazureadonlyauthentications.go new file mode 100644 index 000000000000..abd79c228797 --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/managedinstanceazureadonlyauthentications.go @@ -0,0 +1,404 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ManagedInstanceAzureADOnlyAuthenticationsClient is the the Azure SQL Database management API provides a RESTful set +// of web services that interact with Azure SQL Database services to manage your databases. The API enables you to +// create, retrieve, update, and delete databases. +type ManagedInstanceAzureADOnlyAuthenticationsClient struct { + BaseClient +} + +// NewManagedInstanceAzureADOnlyAuthenticationsClient creates an instance of the +// ManagedInstanceAzureADOnlyAuthenticationsClient client. +func NewManagedInstanceAzureADOnlyAuthenticationsClient(subscriptionID string) ManagedInstanceAzureADOnlyAuthenticationsClient { + return NewManagedInstanceAzureADOnlyAuthenticationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewManagedInstanceAzureADOnlyAuthenticationsClientWithBaseURI creates an instance of the +// ManagedInstanceAzureADOnlyAuthenticationsClient client using a custom endpoint. Use this when interacting with an +// Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewManagedInstanceAzureADOnlyAuthenticationsClientWithBaseURI(baseURI string, subscriptionID string) ManagedInstanceAzureADOnlyAuthenticationsClient { + return ManagedInstanceAzureADOnlyAuthenticationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate sets Server Active Directory only authentication property or updates an existing server Active +// Directory only authentication property. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// parameters - the required parameters for creating or updating an Active Directory only authentication +// property. +func (client ManagedInstanceAzureADOnlyAuthenticationsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, managedInstanceName string, parameters ManagedInstanceAzureADOnlyAuthentication) (result ManagedInstanceAzureADOnlyAuthenticationsCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceAzureADOnlyAuthenticationsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.ManagedInstanceAzureADOnlyAuthProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ManagedInstanceAzureADOnlyAuthProperties.AzureADOnlyAuthentication", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("sql.ManagedInstanceAzureADOnlyAuthenticationsClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, managedInstanceName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceAzureADOnlyAuthenticationsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceAzureADOnlyAuthenticationsClient", "CreateOrUpdate", nil, "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ManagedInstanceAzureADOnlyAuthenticationsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, parameters ManagedInstanceAzureADOnlyAuthentication) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "authenticationName": autorest.Encode("path", "Default"), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/azureADOnlyAuthentications/{authenticationName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedInstanceAzureADOnlyAuthenticationsClient) CreateOrUpdateSender(req *http.Request) (future ManagedInstanceAzureADOnlyAuthenticationsCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ManagedInstanceAzureADOnlyAuthenticationsClient) CreateOrUpdateResponder(resp *http.Response) (result ManagedInstanceAzureADOnlyAuthentication, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes an existing server Active Directory only authentication property. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +func (client ManagedInstanceAzureADOnlyAuthenticationsClient) Delete(ctx context.Context, resourceGroupName string, managedInstanceName string) (result ManagedInstanceAzureADOnlyAuthenticationsDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceAzureADOnlyAuthenticationsClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, managedInstanceName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceAzureADOnlyAuthenticationsClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceAzureADOnlyAuthenticationsClient", "Delete", nil, "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ManagedInstanceAzureADOnlyAuthenticationsClient) DeletePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "authenticationName": autorest.Encode("path", "Default"), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/azureADOnlyAuthentications/{authenticationName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedInstanceAzureADOnlyAuthenticationsClient) DeleteSender(req *http.Request) (future ManagedInstanceAzureADOnlyAuthenticationsDeleteFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ManagedInstanceAzureADOnlyAuthenticationsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a specific Azure Active Directory only authentication property. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +func (client ManagedInstanceAzureADOnlyAuthenticationsClient) Get(ctx context.Context, resourceGroupName string, managedInstanceName string) (result ManagedInstanceAzureADOnlyAuthentication, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceAzureADOnlyAuthenticationsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, managedInstanceName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceAzureADOnlyAuthenticationsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceAzureADOnlyAuthenticationsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceAzureADOnlyAuthenticationsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ManagedInstanceAzureADOnlyAuthenticationsClient) GetPreparer(ctx context.Context, resourceGroupName string, managedInstanceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "authenticationName": autorest.Encode("path", "Default"), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/azureADOnlyAuthentications/{authenticationName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedInstanceAzureADOnlyAuthenticationsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ManagedInstanceAzureADOnlyAuthenticationsClient) GetResponder(resp *http.Response) (result ManagedInstanceAzureADOnlyAuthentication, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByInstance gets a list of server Azure Active Directory only authentications. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +func (client ManagedInstanceAzureADOnlyAuthenticationsClient) ListByInstance(ctx context.Context, resourceGroupName string, managedInstanceName string) (result ManagedInstanceAzureADOnlyAuthListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceAzureADOnlyAuthenticationsClient.ListByInstance") + defer func() { + sc := -1 + if result.miaaoalr.Response.Response != nil { + sc = result.miaaoalr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByInstanceNextResults + req, err := client.ListByInstancePreparer(ctx, resourceGroupName, managedInstanceName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceAzureADOnlyAuthenticationsClient", "ListByInstance", nil, "Failure preparing request") + return + } + + resp, err := client.ListByInstanceSender(req) + if err != nil { + result.miaaoalr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceAzureADOnlyAuthenticationsClient", "ListByInstance", resp, "Failure sending request") + return + } + + result.miaaoalr, err = client.ListByInstanceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceAzureADOnlyAuthenticationsClient", "ListByInstance", resp, "Failure responding to request") + return + } + if result.miaaoalr.hasNextLink() && result.miaaoalr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByInstancePreparer prepares the ListByInstance request. +func (client ManagedInstanceAzureADOnlyAuthenticationsClient) ListByInstancePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/azureADOnlyAuthentications", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByInstanceSender sends the ListByInstance request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedInstanceAzureADOnlyAuthenticationsClient) ListByInstanceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByInstanceResponder handles the response to the ListByInstance request. The method always +// closes the http.Response Body. +func (client ManagedInstanceAzureADOnlyAuthenticationsClient) ListByInstanceResponder(resp *http.Response) (result ManagedInstanceAzureADOnlyAuthListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByInstanceNextResults retrieves the next set of results, if any. +func (client ManagedInstanceAzureADOnlyAuthenticationsClient) listByInstanceNextResults(ctx context.Context, lastResults ManagedInstanceAzureADOnlyAuthListResult) (result ManagedInstanceAzureADOnlyAuthListResult, err error) { + req, err := lastResults.managedInstanceAzureADOnlyAuthListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.ManagedInstanceAzureADOnlyAuthenticationsClient", "listByInstanceNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByInstanceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.ManagedInstanceAzureADOnlyAuthenticationsClient", "listByInstanceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByInstanceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceAzureADOnlyAuthenticationsClient", "listByInstanceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByInstanceComplete enumerates all values, automatically crossing page boundaries as required. +func (client ManagedInstanceAzureADOnlyAuthenticationsClient) ListByInstanceComplete(ctx context.Context, resourceGroupName string, managedInstanceName string) (result ManagedInstanceAzureADOnlyAuthListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceAzureADOnlyAuthenticationsClient.ListByInstance") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByInstance(ctx, resourceGroupName, managedInstanceName) + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/managedinstanceencryptionprotectors.go b/services/preview/sql/mgmt/v5.0/sql/managedinstanceencryptionprotectors.go new file mode 100644 index 000000000000..659d67f00d9c --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/managedinstanceencryptionprotectors.go @@ -0,0 +1,395 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ManagedInstanceEncryptionProtectorsClient is the the Azure SQL Database management API provides a RESTful set of web +// services that interact with Azure SQL Database services to manage your databases. The API enables you to create, +// retrieve, update, and delete databases. +type ManagedInstanceEncryptionProtectorsClient struct { + BaseClient +} + +// NewManagedInstanceEncryptionProtectorsClient creates an instance of the ManagedInstanceEncryptionProtectorsClient +// client. +func NewManagedInstanceEncryptionProtectorsClient(subscriptionID string) ManagedInstanceEncryptionProtectorsClient { + return NewManagedInstanceEncryptionProtectorsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewManagedInstanceEncryptionProtectorsClientWithBaseURI creates an instance of the +// ManagedInstanceEncryptionProtectorsClient client using a custom endpoint. Use this when interacting with an Azure +// cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewManagedInstanceEncryptionProtectorsClientWithBaseURI(baseURI string, subscriptionID string) ManagedInstanceEncryptionProtectorsClient { + return ManagedInstanceEncryptionProtectorsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate updates an existing encryption protector. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// parameters - the requested encryption protector resource state. +func (client ManagedInstanceEncryptionProtectorsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, managedInstanceName string, parameters ManagedInstanceEncryptionProtector) (result ManagedInstanceEncryptionProtectorsCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceEncryptionProtectorsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, managedInstanceName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceEncryptionProtectorsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceEncryptionProtectorsClient", "CreateOrUpdate", nil, "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ManagedInstanceEncryptionProtectorsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, parameters ManagedInstanceEncryptionProtector) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "encryptionProtectorName": autorest.Encode("path", "current"), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + parameters.Kind = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/encryptionProtector/{encryptionProtectorName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedInstanceEncryptionProtectorsClient) CreateOrUpdateSender(req *http.Request) (future ManagedInstanceEncryptionProtectorsCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ManagedInstanceEncryptionProtectorsClient) CreateOrUpdateResponder(resp *http.Response) (result ManagedInstanceEncryptionProtector, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets a managed instance encryption protector. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +func (client ManagedInstanceEncryptionProtectorsClient) Get(ctx context.Context, resourceGroupName string, managedInstanceName string) (result ManagedInstanceEncryptionProtector, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceEncryptionProtectorsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, managedInstanceName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceEncryptionProtectorsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceEncryptionProtectorsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceEncryptionProtectorsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ManagedInstanceEncryptionProtectorsClient) GetPreparer(ctx context.Context, resourceGroupName string, managedInstanceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "encryptionProtectorName": autorest.Encode("path", "current"), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/encryptionProtector/{encryptionProtectorName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedInstanceEncryptionProtectorsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ManagedInstanceEncryptionProtectorsClient) GetResponder(resp *http.Response) (result ManagedInstanceEncryptionProtector, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByInstance gets a list of managed instance encryption protectors +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +func (client ManagedInstanceEncryptionProtectorsClient) ListByInstance(ctx context.Context, resourceGroupName string, managedInstanceName string) (result ManagedInstanceEncryptionProtectorListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceEncryptionProtectorsClient.ListByInstance") + defer func() { + sc := -1 + if result.mieplr.Response.Response != nil { + sc = result.mieplr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByInstanceNextResults + req, err := client.ListByInstancePreparer(ctx, resourceGroupName, managedInstanceName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceEncryptionProtectorsClient", "ListByInstance", nil, "Failure preparing request") + return + } + + resp, err := client.ListByInstanceSender(req) + if err != nil { + result.mieplr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceEncryptionProtectorsClient", "ListByInstance", resp, "Failure sending request") + return + } + + result.mieplr, err = client.ListByInstanceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceEncryptionProtectorsClient", "ListByInstance", resp, "Failure responding to request") + return + } + if result.mieplr.hasNextLink() && result.mieplr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByInstancePreparer prepares the ListByInstance request. +func (client ManagedInstanceEncryptionProtectorsClient) ListByInstancePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/encryptionProtector", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByInstanceSender sends the ListByInstance request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedInstanceEncryptionProtectorsClient) ListByInstanceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByInstanceResponder handles the response to the ListByInstance request. The method always +// closes the http.Response Body. +func (client ManagedInstanceEncryptionProtectorsClient) ListByInstanceResponder(resp *http.Response) (result ManagedInstanceEncryptionProtectorListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByInstanceNextResults retrieves the next set of results, if any. +func (client ManagedInstanceEncryptionProtectorsClient) listByInstanceNextResults(ctx context.Context, lastResults ManagedInstanceEncryptionProtectorListResult) (result ManagedInstanceEncryptionProtectorListResult, err error) { + req, err := lastResults.managedInstanceEncryptionProtectorListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.ManagedInstanceEncryptionProtectorsClient", "listByInstanceNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByInstanceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.ManagedInstanceEncryptionProtectorsClient", "listByInstanceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByInstanceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceEncryptionProtectorsClient", "listByInstanceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByInstanceComplete enumerates all values, automatically crossing page boundaries as required. +func (client ManagedInstanceEncryptionProtectorsClient) ListByInstanceComplete(ctx context.Context, resourceGroupName string, managedInstanceName string) (result ManagedInstanceEncryptionProtectorListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceEncryptionProtectorsClient.ListByInstance") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByInstance(ctx, resourceGroupName, managedInstanceName) + return +} + +// Revalidate revalidates an existing encryption protector. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +func (client ManagedInstanceEncryptionProtectorsClient) Revalidate(ctx context.Context, resourceGroupName string, managedInstanceName string) (result ManagedInstanceEncryptionProtectorsRevalidateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceEncryptionProtectorsClient.Revalidate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.RevalidatePreparer(ctx, resourceGroupName, managedInstanceName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceEncryptionProtectorsClient", "Revalidate", nil, "Failure preparing request") + return + } + + result, err = client.RevalidateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceEncryptionProtectorsClient", "Revalidate", nil, "Failure sending request") + return + } + + return +} + +// RevalidatePreparer prepares the Revalidate request. +func (client ManagedInstanceEncryptionProtectorsClient) RevalidatePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "encryptionProtectorName": autorest.Encode("path", "current"), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/encryptionProtector/{encryptionProtectorName}/revalidate", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// RevalidateSender sends the Revalidate request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedInstanceEncryptionProtectorsClient) RevalidateSender(req *http.Request) (future ManagedInstanceEncryptionProtectorsRevalidateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// RevalidateResponder handles the response to the Revalidate request. The method always +// closes the http.Response Body. +func (client ManagedInstanceEncryptionProtectorsClient) RevalidateResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/managedinstancekeys.go b/services/preview/sql/mgmt/v5.0/sql/managedinstancekeys.go new file mode 100644 index 000000000000..3da5afe89b6b --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/managedinstancekeys.go @@ -0,0 +1,401 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ManagedInstanceKeysClient is the the Azure SQL Database management API provides a RESTful set of web services that +// interact with Azure SQL Database services to manage your databases. The API enables you to create, retrieve, update, +// and delete databases. +type ManagedInstanceKeysClient struct { + BaseClient +} + +// NewManagedInstanceKeysClient creates an instance of the ManagedInstanceKeysClient client. +func NewManagedInstanceKeysClient(subscriptionID string) ManagedInstanceKeysClient { + return NewManagedInstanceKeysClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewManagedInstanceKeysClientWithBaseURI creates an instance of the ManagedInstanceKeysClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewManagedInstanceKeysClientWithBaseURI(baseURI string, subscriptionID string) ManagedInstanceKeysClient { + return ManagedInstanceKeysClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a managed instance key. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// keyName - the name of the managed instance key to be operated on (updated or created). +// parameters - the requested managed instance key resource state. +func (client ManagedInstanceKeysClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, managedInstanceName string, keyName string, parameters ManagedInstanceKey) (result ManagedInstanceKeysCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceKeysClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, managedInstanceName, keyName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceKeysClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceKeysClient", "CreateOrUpdate", nil, "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ManagedInstanceKeysClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, keyName string, parameters ManagedInstanceKey) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "keyName": autorest.Encode("path", keyName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + parameters.Kind = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/keys/{keyName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedInstanceKeysClient) CreateOrUpdateSender(req *http.Request) (future ManagedInstanceKeysCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ManagedInstanceKeysClient) CreateOrUpdateResponder(resp *http.Response) (result ManagedInstanceKey, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes the managed instance key with the given name. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// keyName - the name of the managed instance key to be deleted. +func (client ManagedInstanceKeysClient) Delete(ctx context.Context, resourceGroupName string, managedInstanceName string, keyName string) (result ManagedInstanceKeysDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceKeysClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, managedInstanceName, keyName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceKeysClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceKeysClient", "Delete", nil, "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ManagedInstanceKeysClient) DeletePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, keyName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "keyName": autorest.Encode("path", keyName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/keys/{keyName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedInstanceKeysClient) DeleteSender(req *http.Request) (future ManagedInstanceKeysDeleteFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ManagedInstanceKeysClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a managed instance key. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// keyName - the name of the managed instance key to be retrieved. +func (client ManagedInstanceKeysClient) Get(ctx context.Context, resourceGroupName string, managedInstanceName string, keyName string) (result ManagedInstanceKey, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceKeysClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, managedInstanceName, keyName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceKeysClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceKeysClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceKeysClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ManagedInstanceKeysClient) GetPreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, keyName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "keyName": autorest.Encode("path", keyName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/keys/{keyName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedInstanceKeysClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ManagedInstanceKeysClient) GetResponder(resp *http.Response) (result ManagedInstanceKey, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByInstance gets a list of managed instance keys. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// filter - an OData filter expression that filters elements in the collection. +func (client ManagedInstanceKeysClient) ListByInstance(ctx context.Context, resourceGroupName string, managedInstanceName string, filter string) (result ManagedInstanceKeyListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceKeysClient.ListByInstance") + defer func() { + sc := -1 + if result.miklr.Response.Response != nil { + sc = result.miklr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByInstanceNextResults + req, err := client.ListByInstancePreparer(ctx, resourceGroupName, managedInstanceName, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceKeysClient", "ListByInstance", nil, "Failure preparing request") + return + } + + resp, err := client.ListByInstanceSender(req) + if err != nil { + result.miklr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceKeysClient", "ListByInstance", resp, "Failure sending request") + return + } + + result.miklr, err = client.ListByInstanceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceKeysClient", "ListByInstance", resp, "Failure responding to request") + return + } + if result.miklr.hasNextLink() && result.miklr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByInstancePreparer prepares the ListByInstance request. +func (client ManagedInstanceKeysClient) ListByInstancePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/keys", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByInstanceSender sends the ListByInstance request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedInstanceKeysClient) ListByInstanceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByInstanceResponder handles the response to the ListByInstance request. The method always +// closes the http.Response Body. +func (client ManagedInstanceKeysClient) ListByInstanceResponder(resp *http.Response) (result ManagedInstanceKeyListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByInstanceNextResults retrieves the next set of results, if any. +func (client ManagedInstanceKeysClient) listByInstanceNextResults(ctx context.Context, lastResults ManagedInstanceKeyListResult) (result ManagedInstanceKeyListResult, err error) { + req, err := lastResults.managedInstanceKeyListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.ManagedInstanceKeysClient", "listByInstanceNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByInstanceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.ManagedInstanceKeysClient", "listByInstanceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByInstanceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceKeysClient", "listByInstanceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByInstanceComplete enumerates all values, automatically crossing page boundaries as required. +func (client ManagedInstanceKeysClient) ListByInstanceComplete(ctx context.Context, resourceGroupName string, managedInstanceName string, filter string) (result ManagedInstanceKeyListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceKeysClient.ListByInstance") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByInstance(ctx, resourceGroupName, managedInstanceName, filter) + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/managedinstancelongtermretentionpolicies.go b/services/preview/sql/mgmt/v5.0/sql/managedinstancelongtermretentionpolicies.go new file mode 100644 index 000000000000..bfd78e54a7bc --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/managedinstancelongtermretentionpolicies.go @@ -0,0 +1,321 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ManagedInstanceLongTermRetentionPoliciesClient is the the Azure SQL Database management API provides a RESTful set +// of web services that interact with Azure SQL Database services to manage your databases. The API enables you to +// create, retrieve, update, and delete databases. +type ManagedInstanceLongTermRetentionPoliciesClient struct { + BaseClient +} + +// NewManagedInstanceLongTermRetentionPoliciesClient creates an instance of the +// ManagedInstanceLongTermRetentionPoliciesClient client. +func NewManagedInstanceLongTermRetentionPoliciesClient(subscriptionID string) ManagedInstanceLongTermRetentionPoliciesClient { + return NewManagedInstanceLongTermRetentionPoliciesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewManagedInstanceLongTermRetentionPoliciesClientWithBaseURI creates an instance of the +// ManagedInstanceLongTermRetentionPoliciesClient client using a custom endpoint. Use this when interacting with an +// Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewManagedInstanceLongTermRetentionPoliciesClientWithBaseURI(baseURI string, subscriptionID string) ManagedInstanceLongTermRetentionPoliciesClient { + return ManagedInstanceLongTermRetentionPoliciesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate sets a managed database's long term retention policy. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the database. +// parameters - the long term retention policy info. +func (client ManagedInstanceLongTermRetentionPoliciesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, parameters ManagedInstanceLongTermRetentionPolicy) (result ManagedInstanceLongTermRetentionPoliciesCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceLongTermRetentionPoliciesClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, managedInstanceName, databaseName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceLongTermRetentionPoliciesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceLongTermRetentionPoliciesClient", "CreateOrUpdate", nil, "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ManagedInstanceLongTermRetentionPoliciesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, parameters ManagedInstanceLongTermRetentionPolicy) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "policyName": autorest.Encode("path", "default"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/backupLongTermRetentionPolicies/{policyName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedInstanceLongTermRetentionPoliciesClient) CreateOrUpdateSender(req *http.Request) (future ManagedInstanceLongTermRetentionPoliciesCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ManagedInstanceLongTermRetentionPoliciesClient) CreateOrUpdateResponder(resp *http.Response) (result ManagedInstanceLongTermRetentionPolicy, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets a managed database's long term retention policy. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the database. +func (client ManagedInstanceLongTermRetentionPoliciesClient) Get(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (result ManagedInstanceLongTermRetentionPolicy, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceLongTermRetentionPoliciesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, managedInstanceName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceLongTermRetentionPoliciesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceLongTermRetentionPoliciesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceLongTermRetentionPoliciesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ManagedInstanceLongTermRetentionPoliciesClient) GetPreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "policyName": autorest.Encode("path", "default"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/backupLongTermRetentionPolicies/{policyName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedInstanceLongTermRetentionPoliciesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ManagedInstanceLongTermRetentionPoliciesClient) GetResponder(resp *http.Response) (result ManagedInstanceLongTermRetentionPolicy, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByDatabase gets a database's long term retention policy. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// databaseName - the name of the database. +func (client ManagedInstanceLongTermRetentionPoliciesClient) ListByDatabase(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (result ManagedInstanceLongTermRetentionPolicyListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceLongTermRetentionPoliciesClient.ListByDatabase") + defer func() { + sc := -1 + if result.miltrplr.Response.Response != nil { + sc = result.miltrplr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByDatabaseNextResults + req, err := client.ListByDatabasePreparer(ctx, resourceGroupName, managedInstanceName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceLongTermRetentionPoliciesClient", "ListByDatabase", nil, "Failure preparing request") + return + } + + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.miltrplr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceLongTermRetentionPoliciesClient", "ListByDatabase", resp, "Failure sending request") + return + } + + result.miltrplr, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceLongTermRetentionPoliciesClient", "ListByDatabase", resp, "Failure responding to request") + return + } + if result.miltrplr.hasNextLink() && result.miltrplr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByDatabasePreparer prepares the ListByDatabase request. +func (client ManagedInstanceLongTermRetentionPoliciesClient) ListByDatabasePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/backupLongTermRetentionPolicies", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByDatabaseSender sends the ListByDatabase request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedInstanceLongTermRetentionPoliciesClient) ListByDatabaseSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByDatabaseResponder handles the response to the ListByDatabase request. The method always +// closes the http.Response Body. +func (client ManagedInstanceLongTermRetentionPoliciesClient) ListByDatabaseResponder(resp *http.Response) (result ManagedInstanceLongTermRetentionPolicyListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByDatabaseNextResults retrieves the next set of results, if any. +func (client ManagedInstanceLongTermRetentionPoliciesClient) listByDatabaseNextResults(ctx context.Context, lastResults ManagedInstanceLongTermRetentionPolicyListResult) (result ManagedInstanceLongTermRetentionPolicyListResult, err error) { + req, err := lastResults.managedInstanceLongTermRetentionPolicyListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.ManagedInstanceLongTermRetentionPoliciesClient", "listByDatabaseNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.ManagedInstanceLongTermRetentionPoliciesClient", "listByDatabaseNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceLongTermRetentionPoliciesClient", "listByDatabaseNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByDatabaseComplete enumerates all values, automatically crossing page boundaries as required. +func (client ManagedInstanceLongTermRetentionPoliciesClient) ListByDatabaseComplete(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (result ManagedInstanceLongTermRetentionPolicyListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceLongTermRetentionPoliciesClient.ListByDatabase") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByDatabase(ctx, resourceGroupName, managedInstanceName, databaseName) + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/managedinstanceoperations.go b/services/preview/sql/mgmt/v5.0/sql/managedinstanceoperations.go new file mode 100644 index 000000000000..8759be9d6935 --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/managedinstanceoperations.go @@ -0,0 +1,309 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "github.com/gofrs/uuid" + "net/http" +) + +// ManagedInstanceOperationsClient is the the Azure SQL Database management API provides a RESTful set of web services +// that interact with Azure SQL Database services to manage your databases. The API enables you to create, retrieve, +// update, and delete databases. +type ManagedInstanceOperationsClient struct { + BaseClient +} + +// NewManagedInstanceOperationsClient creates an instance of the ManagedInstanceOperationsClient client. +func NewManagedInstanceOperationsClient(subscriptionID string) ManagedInstanceOperationsClient { + return NewManagedInstanceOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewManagedInstanceOperationsClientWithBaseURI creates an instance of the ManagedInstanceOperationsClient client +// using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign +// clouds, Azure stack). +func NewManagedInstanceOperationsClientWithBaseURI(baseURI string, subscriptionID string) ManagedInstanceOperationsClient { + return ManagedInstanceOperationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Cancel cancels the asynchronous operation on the managed instance. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +func (client ManagedInstanceOperationsClient) Cancel(ctx context.Context, resourceGroupName string, managedInstanceName string, operationID uuid.UUID) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceOperationsClient.Cancel") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CancelPreparer(ctx, resourceGroupName, managedInstanceName, operationID) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceOperationsClient", "Cancel", nil, "Failure preparing request") + return + } + + resp, err := client.CancelSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceOperationsClient", "Cancel", resp, "Failure sending request") + return + } + + result, err = client.CancelResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceOperationsClient", "Cancel", resp, "Failure responding to request") + return + } + + return +} + +// CancelPreparer prepares the Cancel request. +func (client ManagedInstanceOperationsClient) CancelPreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, operationID uuid.UUID) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "operationId": autorest.Encode("path", operationID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/operations/{operationId}/cancel", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CancelSender sends the Cancel request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedInstanceOperationsClient) CancelSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CancelResponder handles the response to the Cancel request. The method always +// closes the http.Response Body. +func (client ManagedInstanceOperationsClient) CancelResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a management operation on a managed instance. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +func (client ManagedInstanceOperationsClient) Get(ctx context.Context, resourceGroupName string, managedInstanceName string, operationID uuid.UUID) (result ManagedInstanceOperation, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceOperationsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, managedInstanceName, operationID) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceOperationsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceOperationsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceOperationsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ManagedInstanceOperationsClient) GetPreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, operationID uuid.UUID) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "operationId": autorest.Encode("path", operationID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/operations/{operationId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedInstanceOperationsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ManagedInstanceOperationsClient) GetResponder(resp *http.Response) (result ManagedInstanceOperation, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByManagedInstance gets a list of operations performed on the managed instance. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +func (client ManagedInstanceOperationsClient) ListByManagedInstance(ctx context.Context, resourceGroupName string, managedInstanceName string) (result ManagedInstanceOperationListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceOperationsClient.ListByManagedInstance") + defer func() { + sc := -1 + if result.miolr.Response.Response != nil { + sc = result.miolr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByManagedInstanceNextResults + req, err := client.ListByManagedInstancePreparer(ctx, resourceGroupName, managedInstanceName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceOperationsClient", "ListByManagedInstance", nil, "Failure preparing request") + return + } + + resp, err := client.ListByManagedInstanceSender(req) + if err != nil { + result.miolr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceOperationsClient", "ListByManagedInstance", resp, "Failure sending request") + return + } + + result.miolr, err = client.ListByManagedInstanceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceOperationsClient", "ListByManagedInstance", resp, "Failure responding to request") + return + } + if result.miolr.hasNextLink() && result.miolr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByManagedInstancePreparer prepares the ListByManagedInstance request. +func (client ManagedInstanceOperationsClient) ListByManagedInstancePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/operations", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByManagedInstanceSender sends the ListByManagedInstance request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedInstanceOperationsClient) ListByManagedInstanceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByManagedInstanceResponder handles the response to the ListByManagedInstance request. The method always +// closes the http.Response Body. +func (client ManagedInstanceOperationsClient) ListByManagedInstanceResponder(resp *http.Response) (result ManagedInstanceOperationListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByManagedInstanceNextResults retrieves the next set of results, if any. +func (client ManagedInstanceOperationsClient) listByManagedInstanceNextResults(ctx context.Context, lastResults ManagedInstanceOperationListResult) (result ManagedInstanceOperationListResult, err error) { + req, err := lastResults.managedInstanceOperationListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.ManagedInstanceOperationsClient", "listByManagedInstanceNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByManagedInstanceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.ManagedInstanceOperationsClient", "listByManagedInstanceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByManagedInstanceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceOperationsClient", "listByManagedInstanceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByManagedInstanceComplete enumerates all values, automatically crossing page boundaries as required. +func (client ManagedInstanceOperationsClient) ListByManagedInstanceComplete(ctx context.Context, resourceGroupName string, managedInstanceName string) (result ManagedInstanceOperationListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceOperationsClient.ListByManagedInstance") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByManagedInstance(ctx, resourceGroupName, managedInstanceName) + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/managedinstanceprivateendpointconnections.go b/services/preview/sql/mgmt/v5.0/sql/managedinstanceprivateendpointconnections.go new file mode 100644 index 000000000000..fb7e243e8ca3 --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/managedinstanceprivateendpointconnections.go @@ -0,0 +1,406 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ManagedInstancePrivateEndpointConnectionsClient 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 ManagedInstancePrivateEndpointConnectionsClient struct { + BaseClient +} + +// NewManagedInstancePrivateEndpointConnectionsClient creates an instance of the +// ManagedInstancePrivateEndpointConnectionsClient client. +func NewManagedInstancePrivateEndpointConnectionsClient(subscriptionID string) ManagedInstancePrivateEndpointConnectionsClient { + return NewManagedInstancePrivateEndpointConnectionsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewManagedInstancePrivateEndpointConnectionsClientWithBaseURI creates an instance of the +// ManagedInstancePrivateEndpointConnectionsClient client using a custom endpoint. Use this when interacting with an +// Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewManagedInstancePrivateEndpointConnectionsClientWithBaseURI(baseURI string, subscriptionID string) ManagedInstancePrivateEndpointConnectionsClient { + return ManagedInstancePrivateEndpointConnectionsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate approve or reject a private endpoint connection with a given name. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +func (client ManagedInstancePrivateEndpointConnectionsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, managedInstanceName string, privateEndpointConnectionName string, parameters ManagedInstancePrivateEndpointConnection) (result ManagedInstancePrivateEndpointConnectionsCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstancePrivateEndpointConnectionsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.ManagedInstancePrivateEndpointConnectionProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ManagedInstancePrivateEndpointConnectionProperties.PrivateLinkServiceConnectionState", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ManagedInstancePrivateEndpointConnectionProperties.PrivateLinkServiceConnectionState.Status", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.ManagedInstancePrivateEndpointConnectionProperties.PrivateLinkServiceConnectionState.Description", Name: validation.Null, Rule: true, Chain: nil}, + }}, + }}}}}); err != nil { + return result, validation.NewError("sql.ManagedInstancePrivateEndpointConnectionsClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, managedInstanceName, privateEndpointConnectionName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancePrivateEndpointConnectionsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancePrivateEndpointConnectionsClient", "CreateOrUpdate", nil, "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ManagedInstancePrivateEndpointConnectionsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, privateEndpointConnectionName string, parameters ManagedInstancePrivateEndpointConnection) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "privateEndpointConnectionName": autorest.Encode("path", privateEndpointConnectionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/privateEndpointConnections/{privateEndpointConnectionName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedInstancePrivateEndpointConnectionsClient) CreateOrUpdateSender(req *http.Request) (future ManagedInstancePrivateEndpointConnectionsCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ManagedInstancePrivateEndpointConnectionsClient) CreateOrUpdateResponder(resp *http.Response) (result ManagedInstancePrivateEndpointConnection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a private endpoint connection with a given name. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +func (client ManagedInstancePrivateEndpointConnectionsClient) Delete(ctx context.Context, resourceGroupName string, managedInstanceName string, privateEndpointConnectionName string) (result ManagedInstancePrivateEndpointConnectionsDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstancePrivateEndpointConnectionsClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, managedInstanceName, privateEndpointConnectionName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancePrivateEndpointConnectionsClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancePrivateEndpointConnectionsClient", "Delete", nil, "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ManagedInstancePrivateEndpointConnectionsClient) DeletePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, privateEndpointConnectionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "privateEndpointConnectionName": autorest.Encode("path", privateEndpointConnectionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/privateEndpointConnections/{privateEndpointConnectionName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedInstancePrivateEndpointConnectionsClient) DeleteSender(req *http.Request) (future ManagedInstancePrivateEndpointConnectionsDeleteFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ManagedInstancePrivateEndpointConnectionsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a private endpoint connection. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// privateEndpointConnectionName - the name of the private endpoint connection. +func (client ManagedInstancePrivateEndpointConnectionsClient) Get(ctx context.Context, resourceGroupName string, managedInstanceName string, privateEndpointConnectionName string) (result ManagedInstancePrivateEndpointConnection, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstancePrivateEndpointConnectionsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, managedInstanceName, privateEndpointConnectionName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancePrivateEndpointConnectionsClient", "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.ManagedInstancePrivateEndpointConnectionsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancePrivateEndpointConnectionsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ManagedInstancePrivateEndpointConnectionsClient) GetPreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, privateEndpointConnectionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "privateEndpointConnectionName": autorest.Encode("path", privateEndpointConnectionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/privateEndpointConnections/{privateEndpointConnectionName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedInstancePrivateEndpointConnectionsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ManagedInstancePrivateEndpointConnectionsClient) GetResponder(resp *http.Response) (result ManagedInstancePrivateEndpointConnection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByManagedInstance gets all private endpoint connections on a server. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +func (client ManagedInstancePrivateEndpointConnectionsClient) ListByManagedInstance(ctx context.Context, resourceGroupName string, managedInstanceName string) (result ManagedInstancePrivateEndpointConnectionListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstancePrivateEndpointConnectionsClient.ListByManagedInstance") + defer func() { + sc := -1 + if result.mipeclr.Response.Response != nil { + sc = result.mipeclr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByManagedInstanceNextResults + req, err := client.ListByManagedInstancePreparer(ctx, resourceGroupName, managedInstanceName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancePrivateEndpointConnectionsClient", "ListByManagedInstance", nil, "Failure preparing request") + return + } + + resp, err := client.ListByManagedInstanceSender(req) + if err != nil { + result.mipeclr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ManagedInstancePrivateEndpointConnectionsClient", "ListByManagedInstance", resp, "Failure sending request") + return + } + + result.mipeclr, err = client.ListByManagedInstanceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancePrivateEndpointConnectionsClient", "ListByManagedInstance", resp, "Failure responding to request") + return + } + if result.mipeclr.hasNextLink() && result.mipeclr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByManagedInstancePreparer prepares the ListByManagedInstance request. +func (client ManagedInstancePrivateEndpointConnectionsClient) ListByManagedInstancePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/privateEndpointConnections", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByManagedInstanceSender sends the ListByManagedInstance request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedInstancePrivateEndpointConnectionsClient) ListByManagedInstanceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByManagedInstanceResponder handles the response to the ListByManagedInstance request. The method always +// closes the http.Response Body. +func (client ManagedInstancePrivateEndpointConnectionsClient) ListByManagedInstanceResponder(resp *http.Response) (result ManagedInstancePrivateEndpointConnectionListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByManagedInstanceNextResults retrieves the next set of results, if any. +func (client ManagedInstancePrivateEndpointConnectionsClient) listByManagedInstanceNextResults(ctx context.Context, lastResults ManagedInstancePrivateEndpointConnectionListResult) (result ManagedInstancePrivateEndpointConnectionListResult, err error) { + req, err := lastResults.managedInstancePrivateEndpointConnectionListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.ManagedInstancePrivateEndpointConnectionsClient", "listByManagedInstanceNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByManagedInstanceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.ManagedInstancePrivateEndpointConnectionsClient", "listByManagedInstanceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByManagedInstanceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancePrivateEndpointConnectionsClient", "listByManagedInstanceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByManagedInstanceComplete enumerates all values, automatically crossing page boundaries as required. +func (client ManagedInstancePrivateEndpointConnectionsClient) ListByManagedInstanceComplete(ctx context.Context, resourceGroupName string, managedInstanceName string) (result ManagedInstancePrivateEndpointConnectionListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstancePrivateEndpointConnectionsClient.ListByManagedInstance") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByManagedInstance(ctx, resourceGroupName, managedInstanceName) + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/managedinstanceprivatelinkresources.go b/services/preview/sql/mgmt/v5.0/sql/managedinstanceprivatelinkresources.go new file mode 100644 index 000000000000..bc34e355be7d --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/managedinstanceprivatelinkresources.go @@ -0,0 +1,233 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ManagedInstancePrivateLinkResourcesClient 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 ManagedInstancePrivateLinkResourcesClient struct { + BaseClient +} + +// NewManagedInstancePrivateLinkResourcesClient creates an instance of the ManagedInstancePrivateLinkResourcesClient +// client. +func NewManagedInstancePrivateLinkResourcesClient(subscriptionID string) ManagedInstancePrivateLinkResourcesClient { + return NewManagedInstancePrivateLinkResourcesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewManagedInstancePrivateLinkResourcesClientWithBaseURI creates an instance of the +// ManagedInstancePrivateLinkResourcesClient client using a custom endpoint. Use this when interacting with an Azure +// cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewManagedInstancePrivateLinkResourcesClientWithBaseURI(baseURI string, subscriptionID string) ManagedInstancePrivateLinkResourcesClient { + return ManagedInstancePrivateLinkResourcesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get gets a private link resource for SQL server. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// groupName - the name of the private link resource. +func (client ManagedInstancePrivateLinkResourcesClient) Get(ctx context.Context, resourceGroupName string, managedInstanceName string, groupName string) (result ManagedInstancePrivateLink, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstancePrivateLinkResourcesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, managedInstanceName, groupName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancePrivateLinkResourcesClient", "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.ManagedInstancePrivateLinkResourcesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancePrivateLinkResourcesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ManagedInstancePrivateLinkResourcesClient) GetPreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, groupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "groupName": autorest.Encode("path", groupName), + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/privateLinkResources/{groupName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedInstancePrivateLinkResourcesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ManagedInstancePrivateLinkResourcesClient) GetResponder(resp *http.Response) (result ManagedInstancePrivateLink, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByManagedInstance gets the private link resources for SQL server. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +func (client ManagedInstancePrivateLinkResourcesClient) ListByManagedInstance(ctx context.Context, resourceGroupName string, managedInstanceName string) (result ManagedInstancePrivateLinkListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstancePrivateLinkResourcesClient.ListByManagedInstance") + defer func() { + sc := -1 + if result.mipllr.Response.Response != nil { + sc = result.mipllr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByManagedInstanceNextResults + req, err := client.ListByManagedInstancePreparer(ctx, resourceGroupName, managedInstanceName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancePrivateLinkResourcesClient", "ListByManagedInstance", nil, "Failure preparing request") + return + } + + resp, err := client.ListByManagedInstanceSender(req) + if err != nil { + result.mipllr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ManagedInstancePrivateLinkResourcesClient", "ListByManagedInstance", resp, "Failure sending request") + return + } + + result.mipllr, err = client.ListByManagedInstanceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancePrivateLinkResourcesClient", "ListByManagedInstance", resp, "Failure responding to request") + return + } + if result.mipllr.hasNextLink() && result.mipllr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByManagedInstancePreparer prepares the ListByManagedInstance request. +func (client ManagedInstancePrivateLinkResourcesClient) ListByManagedInstancePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/privateLinkResources", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByManagedInstanceSender sends the ListByManagedInstance request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedInstancePrivateLinkResourcesClient) ListByManagedInstanceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByManagedInstanceResponder handles the response to the ListByManagedInstance request. The method always +// closes the http.Response Body. +func (client ManagedInstancePrivateLinkResourcesClient) ListByManagedInstanceResponder(resp *http.Response) (result ManagedInstancePrivateLinkListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByManagedInstanceNextResults retrieves the next set of results, if any. +func (client ManagedInstancePrivateLinkResourcesClient) listByManagedInstanceNextResults(ctx context.Context, lastResults ManagedInstancePrivateLinkListResult) (result ManagedInstancePrivateLinkListResult, err error) { + req, err := lastResults.managedInstancePrivateLinkListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.ManagedInstancePrivateLinkResourcesClient", "listByManagedInstanceNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByManagedInstanceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.ManagedInstancePrivateLinkResourcesClient", "listByManagedInstanceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByManagedInstanceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancePrivateLinkResourcesClient", "listByManagedInstanceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByManagedInstanceComplete enumerates all values, automatically crossing page boundaries as required. +func (client ManagedInstancePrivateLinkResourcesClient) ListByManagedInstanceComplete(ctx context.Context, resourceGroupName string, managedInstanceName string) (result ManagedInstancePrivateLinkListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstancePrivateLinkResourcesClient.ListByManagedInstance") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByManagedInstance(ctx, resourceGroupName, managedInstanceName) + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/managedinstances.go b/services/preview/sql/mgmt/v5.0/sql/managedinstances.go new file mode 100644 index 000000000000..52e990521d9d --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/managedinstances.go @@ -0,0 +1,957 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ManagedInstancesClient is the the Azure SQL Database management API provides a RESTful set of web services that +// interact with Azure SQL Database services to manage your databases. The API enables you to create, retrieve, update, +// and delete databases. +type ManagedInstancesClient struct { + BaseClient +} + +// NewManagedInstancesClient creates an instance of the ManagedInstancesClient client. +func NewManagedInstancesClient(subscriptionID string) ManagedInstancesClient { + return NewManagedInstancesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewManagedInstancesClientWithBaseURI creates an instance of the ManagedInstancesClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewManagedInstancesClientWithBaseURI(baseURI string, subscriptionID string) ManagedInstancesClient { + return ManagedInstancesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a managed instance. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// parameters - the requested managed instance resource state. +func (client ManagedInstancesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, managedInstanceName string, parameters ManagedInstance) (result ManagedInstancesCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstancesClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.Sku", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.Sku.Name", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("sql.ManagedInstancesClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, managedInstanceName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesClient", "CreateOrUpdate", nil, "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ManagedInstancesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, parameters ManagedInstance) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedInstancesClient) CreateOrUpdateSender(req *http.Request) (future ManagedInstancesCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ManagedInstancesClient) CreateOrUpdateResponder(resp *http.Response) (result ManagedInstance, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a managed instance. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +func (client ManagedInstancesClient) Delete(ctx context.Context, resourceGroupName string, managedInstanceName string) (result ManagedInstancesDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstancesClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, managedInstanceName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesClient", "Delete", nil, "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ManagedInstancesClient) DeletePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedInstancesClient) DeleteSender(req *http.Request) (future ManagedInstancesDeleteFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ManagedInstancesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Failover failovers a managed instance. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance to failover. +// replicaType - the type of replica to be failed over. +func (client ManagedInstancesClient) Failover(ctx context.Context, resourceGroupName string, managedInstanceName string, replicaType ReplicaType) (result ManagedInstancesFailoverFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstancesClient.Failover") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.FailoverPreparer(ctx, resourceGroupName, managedInstanceName, replicaType) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesClient", "Failover", nil, "Failure preparing request") + return + } + + result, err = client.FailoverSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesClient", "Failover", nil, "Failure sending request") + return + } + + return +} + +// FailoverPreparer prepares the Failover request. +func (client ManagedInstancesClient) FailoverPreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, replicaType ReplicaType) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(string(replicaType)) > 0 { + queryParameters["replicaType"] = autorest.Encode("query", replicaType) + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/failover", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// FailoverSender sends the Failover request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedInstancesClient) FailoverSender(req *http.Request) (future ManagedInstancesFailoverFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// FailoverResponder handles the response to the Failover request. The method always +// closes the http.Response Body. +func (client ManagedInstancesClient) FailoverResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a managed instance. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// expand - the child resources to include in the response. +func (client ManagedInstancesClient) Get(ctx context.Context, resourceGroupName string, managedInstanceName string, expand string) (result ManagedInstance, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstancesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, managedInstanceName, expand) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ManagedInstancesClient) GetPreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, expand string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + 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/managedInstances/{managedInstanceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedInstancesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ManagedInstancesClient) GetResponder(resp *http.Response) (result ManagedInstance, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List gets a list of all managed instances in the subscription. +// Parameters: +// expand - the child resources to include in the response. +func (client ManagedInstancesClient) List(ctx context.Context, expand string) (result ManagedInstanceListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstancesClient.List") + defer func() { + sc := -1 + if result.milr.Response.Response != nil { + sc = result.milr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, expand) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.milr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesClient", "List", resp, "Failure sending request") + return + } + + result.milr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesClient", "List", resp, "Failure responding to request") + return + } + if result.milr.hasNextLink() && result.milr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client ManagedInstancesClient) ListPreparer(ctx context.Context, expand string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + 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}/providers/Microsoft.Sql/managedInstances", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedInstancesClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client ManagedInstancesClient) ListResponder(resp *http.Response) (result ManagedInstanceListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client ManagedInstancesClient) listNextResults(ctx context.Context, lastResults ManagedInstanceListResult) (result ManagedInstanceListResult, err error) { + req, err := lastResults.managedInstanceListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.ManagedInstancesClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.ManagedInstancesClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client ManagedInstancesClient) ListComplete(ctx context.Context, expand string) (result ManagedInstanceListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstancesClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx, expand) + return +} + +// ListByInstancePool gets a list of all managed instances in an instance pool. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// instancePoolName - the instance pool name. +// expand - the child resources to include in the response. +func (client ManagedInstancesClient) ListByInstancePool(ctx context.Context, resourceGroupName string, instancePoolName string, expand string) (result ManagedInstanceListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstancesClient.ListByInstancePool") + defer func() { + sc := -1 + if result.milr.Response.Response != nil { + sc = result.milr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByInstancePoolNextResults + req, err := client.ListByInstancePoolPreparer(ctx, resourceGroupName, instancePoolName, expand) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesClient", "ListByInstancePool", nil, "Failure preparing request") + return + } + + resp, err := client.ListByInstancePoolSender(req) + if err != nil { + result.milr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesClient", "ListByInstancePool", resp, "Failure sending request") + return + } + + result.milr, err = client.ListByInstancePoolResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesClient", "ListByInstancePool", resp, "Failure responding to request") + return + } + if result.milr.hasNextLink() && result.milr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByInstancePoolPreparer prepares the ListByInstancePool request. +func (client ManagedInstancesClient) ListByInstancePoolPreparer(ctx context.Context, resourceGroupName string, instancePoolName string, expand string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "instancePoolName": autorest.Encode("path", instancePoolName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + 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/instancePools/{instancePoolName}/managedInstances", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByInstancePoolSender sends the ListByInstancePool request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedInstancesClient) ListByInstancePoolSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByInstancePoolResponder handles the response to the ListByInstancePool request. The method always +// closes the http.Response Body. +func (client ManagedInstancesClient) ListByInstancePoolResponder(resp *http.Response) (result ManagedInstanceListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByInstancePoolNextResults retrieves the next set of results, if any. +func (client ManagedInstancesClient) listByInstancePoolNextResults(ctx context.Context, lastResults ManagedInstanceListResult) (result ManagedInstanceListResult, err error) { + req, err := lastResults.managedInstanceListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.ManagedInstancesClient", "listByInstancePoolNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByInstancePoolSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.ManagedInstancesClient", "listByInstancePoolNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByInstancePoolResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesClient", "listByInstancePoolNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByInstancePoolComplete enumerates all values, automatically crossing page boundaries as required. +func (client ManagedInstancesClient) ListByInstancePoolComplete(ctx context.Context, resourceGroupName string, instancePoolName string, expand string) (result ManagedInstanceListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstancesClient.ListByInstancePool") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByInstancePool(ctx, resourceGroupName, instancePoolName, expand) + return +} + +// ListByManagedInstance get top resource consuming queries of a managed instance. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// numberOfQueries - how many 'top queries' to return. Default is 5. +// databases - comma separated list of databases to be included into search. All DB's are included if this +// parameter is not specified. +// startTime - start time for observed period. +// endTime - end time for observed period. +// interval - the time step to be used to summarize the metric values. Default value is PT1H +// aggregationFunction - aggregation function to be used, default value is 'sum' +// observationMetric - metric to be used for ranking top queries. Default is 'cpu' +func (client ManagedInstancesClient) ListByManagedInstance(ctx context.Context, resourceGroupName string, managedInstanceName string, numberOfQueries *int32, databases string, startTime string, endTime string, interval QueryTimeGrainType, aggregationFunction AggregationFunctionType, observationMetric MetricType) (result TopQueriesListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstancesClient.ListByManagedInstance") + defer func() { + sc := -1 + if result.tqlr.Response.Response != nil { + sc = result.tqlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByManagedInstanceNextResults + req, err := client.ListByManagedInstancePreparer(ctx, resourceGroupName, managedInstanceName, numberOfQueries, databases, startTime, endTime, interval, aggregationFunction, observationMetric) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesClient", "ListByManagedInstance", nil, "Failure preparing request") + return + } + + resp, err := client.ListByManagedInstanceSender(req) + if err != nil { + result.tqlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesClient", "ListByManagedInstance", resp, "Failure sending request") + return + } + + result.tqlr, err = client.ListByManagedInstanceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesClient", "ListByManagedInstance", resp, "Failure responding to request") + return + } + if result.tqlr.hasNextLink() && result.tqlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByManagedInstancePreparer prepares the ListByManagedInstance request. +func (client ManagedInstancesClient) ListByManagedInstancePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, numberOfQueries *int32, databases string, startTime string, endTime string, interval QueryTimeGrainType, aggregationFunction AggregationFunctionType, observationMetric MetricType) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if numberOfQueries != nil { + queryParameters["numberOfQueries"] = autorest.Encode("query", *numberOfQueries) + } + if len(databases) > 0 { + queryParameters["databases"] = autorest.Encode("query", databases) + } + if len(startTime) > 0 { + queryParameters["startTime"] = autorest.Encode("query", startTime) + } + if len(endTime) > 0 { + queryParameters["endTime"] = autorest.Encode("query", endTime) + } + if len(string(interval)) > 0 { + queryParameters["interval"] = autorest.Encode("query", interval) + } + if len(string(aggregationFunction)) > 0 { + queryParameters["aggregationFunction"] = autorest.Encode("query", aggregationFunction) + } + if len(string(observationMetric)) > 0 { + queryParameters["observationMetric"] = autorest.Encode("query", observationMetric) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/topqueries", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByManagedInstanceSender sends the ListByManagedInstance request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedInstancesClient) ListByManagedInstanceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByManagedInstanceResponder handles the response to the ListByManagedInstance request. The method always +// closes the http.Response Body. +func (client ManagedInstancesClient) ListByManagedInstanceResponder(resp *http.Response) (result TopQueriesListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByManagedInstanceNextResults retrieves the next set of results, if any. +func (client ManagedInstancesClient) listByManagedInstanceNextResults(ctx context.Context, lastResults TopQueriesListResult) (result TopQueriesListResult, err error) { + req, err := lastResults.topQueriesListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.ManagedInstancesClient", "listByManagedInstanceNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByManagedInstanceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.ManagedInstancesClient", "listByManagedInstanceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByManagedInstanceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesClient", "listByManagedInstanceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByManagedInstanceComplete enumerates all values, automatically crossing page boundaries as required. +func (client ManagedInstancesClient) ListByManagedInstanceComplete(ctx context.Context, resourceGroupName string, managedInstanceName string, numberOfQueries *int32, databases string, startTime string, endTime string, interval QueryTimeGrainType, aggregationFunction AggregationFunctionType, observationMetric MetricType) (result TopQueriesListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstancesClient.ListByManagedInstance") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByManagedInstance(ctx, resourceGroupName, managedInstanceName, numberOfQueries, databases, startTime, endTime, interval, aggregationFunction, observationMetric) + return +} + +// ListByResourceGroup gets a list of managed instances in a resource group. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// expand - the child resources to include in the response. +func (client ManagedInstancesClient) ListByResourceGroup(ctx context.Context, resourceGroupName string, expand string) (result ManagedInstanceListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstancesClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.milr.Response.Response != nil { + sc = result.milr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByResourceGroupNextResults + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName, expand) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.milr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result.milr, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesClient", "ListByResourceGroup", resp, "Failure responding to request") + return + } + if result.milr.hasNextLink() && result.milr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client ManagedInstancesClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string, expand string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + 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/managedInstances", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedInstancesClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client ManagedInstancesClient) ListByResourceGroupResponder(resp *http.Response) (result ManagedInstanceListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByResourceGroupNextResults retrieves the next set of results, if any. +func (client ManagedInstancesClient) listByResourceGroupNextResults(ctx context.Context, lastResults ManagedInstanceListResult) (result ManagedInstanceListResult, err error) { + req, err := lastResults.managedInstanceListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.ManagedInstancesClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.ManagedInstancesClient", "listByResourceGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. +func (client ManagedInstancesClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string, expand string) (result ManagedInstanceListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstancesClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByResourceGroup(ctx, resourceGroupName, expand) + return +} + +// Update updates a managed instance. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// parameters - the requested managed instance resource state. +func (client ManagedInstancesClient) Update(ctx context.Context, resourceGroupName string, managedInstanceName string, parameters ManagedInstanceUpdate) (result ManagedInstancesUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstancesClient.Update") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.UpdatePreparer(ctx, resourceGroupName, managedInstanceName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesClient", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesClient", "Update", nil, "Failure sending request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client ManagedInstancesClient) UpdatePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, parameters ManagedInstanceUpdate) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedInstancesClient) UpdateSender(req *http.Request) (future ManagedInstancesUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client ManagedInstancesClient) UpdateResponder(resp *http.Response) (result ManagedInstance, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/managedinstancetdecertificates.go b/services/preview/sql/mgmt/v5.0/sql/managedinstancetdecertificates.go new file mode 100644 index 000000000000..b8a2d6b2876e --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/managedinstancetdecertificates.go @@ -0,0 +1,123 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ManagedInstanceTdeCertificatesClient is the the Azure SQL Database management API provides a RESTful set of web +// services that interact with Azure SQL Database services to manage your databases. The API enables you to create, +// retrieve, update, and delete databases. +type ManagedInstanceTdeCertificatesClient struct { + BaseClient +} + +// NewManagedInstanceTdeCertificatesClient creates an instance of the ManagedInstanceTdeCertificatesClient client. +func NewManagedInstanceTdeCertificatesClient(subscriptionID string) ManagedInstanceTdeCertificatesClient { + return NewManagedInstanceTdeCertificatesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewManagedInstanceTdeCertificatesClientWithBaseURI creates an instance of the ManagedInstanceTdeCertificatesClient +// client using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI +// (sovereign clouds, Azure stack). +func NewManagedInstanceTdeCertificatesClientWithBaseURI(baseURI string, subscriptionID string) ManagedInstanceTdeCertificatesClient { + return ManagedInstanceTdeCertificatesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Create creates a TDE certificate for a given server. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// parameters - the requested TDE certificate to be created or updated. +func (client ManagedInstanceTdeCertificatesClient) Create(ctx context.Context, resourceGroupName string, managedInstanceName string, parameters TdeCertificate) (result ManagedInstanceTdeCertificatesCreateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceTdeCertificatesClient.Create") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.TdeCertificateProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.TdeCertificateProperties.PrivateBlob", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("sql.ManagedInstanceTdeCertificatesClient", "Create", err.Error()) + } + + req, err := client.CreatePreparer(ctx, resourceGroupName, managedInstanceName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceTdeCertificatesClient", "Create", nil, "Failure preparing request") + return + } + + result, err = client.CreateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceTdeCertificatesClient", "Create", nil, "Failure sending request") + return + } + + return +} + +// CreatePreparer prepares the Create request. +func (client ManagedInstanceTdeCertificatesClient) CreatePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, parameters TdeCertificate) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/tdeCertificates", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateSender sends the Create request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedInstanceTdeCertificatesClient) CreateSender(req *http.Request) (future ManagedInstanceTdeCertificatesCreateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client ManagedInstanceTdeCertificatesClient) CreateResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/managedinstancevulnerabilityassessments.go b/services/preview/sql/mgmt/v5.0/sql/managedinstancevulnerabilityassessments.go new file mode 100644 index 000000000000..70c1dbfda76c --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/managedinstancevulnerabilityassessments.go @@ -0,0 +1,400 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ManagedInstanceVulnerabilityAssessmentsClient is the the Azure SQL Database management API provides a RESTful set of +// web services that interact with Azure SQL Database services to manage your databases. The API enables you to create, +// retrieve, update, and delete databases. +type ManagedInstanceVulnerabilityAssessmentsClient struct { + BaseClient +} + +// NewManagedInstanceVulnerabilityAssessmentsClient creates an instance of the +// ManagedInstanceVulnerabilityAssessmentsClient client. +func NewManagedInstanceVulnerabilityAssessmentsClient(subscriptionID string) ManagedInstanceVulnerabilityAssessmentsClient { + return NewManagedInstanceVulnerabilityAssessmentsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewManagedInstanceVulnerabilityAssessmentsClientWithBaseURI creates an instance of the +// ManagedInstanceVulnerabilityAssessmentsClient client using a custom endpoint. Use this when interacting with an +// Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewManagedInstanceVulnerabilityAssessmentsClientWithBaseURI(baseURI string, subscriptionID string) ManagedInstanceVulnerabilityAssessmentsClient { + return ManagedInstanceVulnerabilityAssessmentsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates the managed instance's vulnerability assessment. Learn more about setting SQL +// vulnerability assessment with managed identity - +// https://docs.microsoft.com/azure/azure-sql/database/sql-database-vulnerability-assessment-storage +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance for which the vulnerability assessment is defined. +// parameters - the requested resource. +func (client ManagedInstanceVulnerabilityAssessmentsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, managedInstanceName string, parameters ManagedInstanceVulnerabilityAssessment) (result ManagedInstanceVulnerabilityAssessment, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceVulnerabilityAssessmentsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.ManagedInstanceVulnerabilityAssessmentProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ManagedInstanceVulnerabilityAssessmentProperties.StorageContainerPath", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("sql.ManagedInstanceVulnerabilityAssessmentsClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, managedInstanceName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceVulnerabilityAssessmentsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceVulnerabilityAssessmentsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceVulnerabilityAssessmentsClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ManagedInstanceVulnerabilityAssessmentsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, parameters ManagedInstanceVulnerabilityAssessment) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vulnerabilityAssessmentName": autorest.Encode("path", "default"), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedInstanceVulnerabilityAssessmentsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ManagedInstanceVulnerabilityAssessmentsClient) CreateOrUpdateResponder(resp *http.Response) (result ManagedInstanceVulnerabilityAssessment, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete removes the managed instance's vulnerability assessment. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance for which the vulnerability assessment is defined. +func (client ManagedInstanceVulnerabilityAssessmentsClient) Delete(ctx context.Context, resourceGroupName string, managedInstanceName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceVulnerabilityAssessmentsClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, managedInstanceName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceVulnerabilityAssessmentsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceVulnerabilityAssessmentsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceVulnerabilityAssessmentsClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ManagedInstanceVulnerabilityAssessmentsClient) DeletePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vulnerabilityAssessmentName": autorest.Encode("path", "default"), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedInstanceVulnerabilityAssessmentsClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ManagedInstanceVulnerabilityAssessmentsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets the managed instance's vulnerability assessment. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance for which the vulnerability assessment is defined. +func (client ManagedInstanceVulnerabilityAssessmentsClient) Get(ctx context.Context, resourceGroupName string, managedInstanceName string) (result ManagedInstanceVulnerabilityAssessment, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceVulnerabilityAssessmentsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, managedInstanceName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceVulnerabilityAssessmentsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceVulnerabilityAssessmentsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceVulnerabilityAssessmentsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ManagedInstanceVulnerabilityAssessmentsClient) GetPreparer(ctx context.Context, resourceGroupName string, managedInstanceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vulnerabilityAssessmentName": autorest.Encode("path", "default"), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedInstanceVulnerabilityAssessmentsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ManagedInstanceVulnerabilityAssessmentsClient) GetResponder(resp *http.Response) (result ManagedInstanceVulnerabilityAssessment, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByInstance gets the managed instance's vulnerability assessment policies. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance for which the vulnerability assessments is defined. +func (client ManagedInstanceVulnerabilityAssessmentsClient) ListByInstance(ctx context.Context, resourceGroupName string, managedInstanceName string) (result ManagedInstanceVulnerabilityAssessmentListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceVulnerabilityAssessmentsClient.ListByInstance") + defer func() { + sc := -1 + if result.mivalr.Response.Response != nil { + sc = result.mivalr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByInstanceNextResults + req, err := client.ListByInstancePreparer(ctx, resourceGroupName, managedInstanceName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceVulnerabilityAssessmentsClient", "ListByInstance", nil, "Failure preparing request") + return + } + + resp, err := client.ListByInstanceSender(req) + if err != nil { + result.mivalr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceVulnerabilityAssessmentsClient", "ListByInstance", resp, "Failure sending request") + return + } + + result.mivalr, err = client.ListByInstanceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceVulnerabilityAssessmentsClient", "ListByInstance", resp, "Failure responding to request") + return + } + if result.mivalr.hasNextLink() && result.mivalr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByInstancePreparer prepares the ListByInstance request. +func (client ManagedInstanceVulnerabilityAssessmentsClient) ListByInstancePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/vulnerabilityAssessments", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByInstanceSender sends the ListByInstance request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedInstanceVulnerabilityAssessmentsClient) ListByInstanceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByInstanceResponder handles the response to the ListByInstance request. The method always +// closes the http.Response Body. +func (client ManagedInstanceVulnerabilityAssessmentsClient) ListByInstanceResponder(resp *http.Response) (result ManagedInstanceVulnerabilityAssessmentListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByInstanceNextResults retrieves the next set of results, if any. +func (client ManagedInstanceVulnerabilityAssessmentsClient) listByInstanceNextResults(ctx context.Context, lastResults ManagedInstanceVulnerabilityAssessmentListResult) (result ManagedInstanceVulnerabilityAssessmentListResult, err error) { + req, err := lastResults.managedInstanceVulnerabilityAssessmentListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.ManagedInstanceVulnerabilityAssessmentsClient", "listByInstanceNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByInstanceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.ManagedInstanceVulnerabilityAssessmentsClient", "listByInstanceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByInstanceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceVulnerabilityAssessmentsClient", "listByInstanceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByInstanceComplete enumerates all values, automatically crossing page boundaries as required. +func (client ManagedInstanceVulnerabilityAssessmentsClient) ListByInstanceComplete(ctx context.Context, resourceGroupName string, managedInstanceName string) (result ManagedInstanceVulnerabilityAssessmentListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceVulnerabilityAssessmentsClient.ListByInstance") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByInstance(ctx, resourceGroupName, managedInstanceName) + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/managedrestorabledroppeddatabasebackupshorttermretentionpolicies.go b/services/preview/sql/mgmt/v5.0/sql/managedrestorabledroppeddatabasebackupshorttermretentionpolicies.go new file mode 100644 index 000000000000..776104537f1c --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/managedrestorabledroppeddatabasebackupshorttermretentionpolicies.go @@ -0,0 +1,402 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient is the the Azure SQL Database management API +// provides a RESTful set of web services that interact with Azure SQL Database services to manage your databases. The +// API enables you to create, retrieve, update, and delete databases. +type ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient struct { + BaseClient +} + +// NewManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient creates an instance of the +// ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient client. +func NewManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient(subscriptionID string) ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient { + return NewManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClientWithBaseURI creates an instance of the +// ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClientWithBaseURI(baseURI string, subscriptionID string) ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient { + return ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate sets a database's short term retention policy. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// parameters - the short term retention policy info. +func (client ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, managedInstanceName string, restorableDroppedDatabaseID string, parameters ManagedBackupShortTermRetentionPolicy) (result ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, managedInstanceName, restorableDroppedDatabaseID, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient", "CreateOrUpdate", nil, "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, restorableDroppedDatabaseID string, parameters ManagedBackupShortTermRetentionPolicy) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "policyName": autorest.Encode("path", "default"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "restorableDroppedDatabaseId": autorest.Encode("path", restorableDroppedDatabaseID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/restorableDroppedDatabases/{restorableDroppedDatabaseId}/backupShortTermRetentionPolicies/{policyName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient) CreateOrUpdateSender(req *http.Request) (future ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient) CreateOrUpdateResponder(resp *http.Response) (result ManagedBackupShortTermRetentionPolicy, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets a dropped database's short term retention policy. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +func (client ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient) Get(ctx context.Context, resourceGroupName string, managedInstanceName string, restorableDroppedDatabaseID string) (result ManagedBackupShortTermRetentionPolicy, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, managedInstanceName, restorableDroppedDatabaseID) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient) GetPreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, restorableDroppedDatabaseID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "policyName": autorest.Encode("path", "default"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "restorableDroppedDatabaseId": autorest.Encode("path", restorableDroppedDatabaseID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/restorableDroppedDatabases/{restorableDroppedDatabaseId}/backupShortTermRetentionPolicies/{policyName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient) GetResponder(resp *http.Response) (result ManagedBackupShortTermRetentionPolicy, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByRestorableDroppedDatabase gets a dropped database's short term retention policy list. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +func (client ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient) ListByRestorableDroppedDatabase(ctx context.Context, resourceGroupName string, managedInstanceName string, restorableDroppedDatabaseID string) (result ManagedBackupShortTermRetentionPolicyListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient.ListByRestorableDroppedDatabase") + defer func() { + sc := -1 + if result.mbstrplr.Response.Response != nil { + sc = result.mbstrplr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByRestorableDroppedDatabaseNextResults + req, err := client.ListByRestorableDroppedDatabasePreparer(ctx, resourceGroupName, managedInstanceName, restorableDroppedDatabaseID) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient", "ListByRestorableDroppedDatabase", nil, "Failure preparing request") + return + } + + resp, err := client.ListByRestorableDroppedDatabaseSender(req) + if err != nil { + result.mbstrplr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient", "ListByRestorableDroppedDatabase", resp, "Failure sending request") + return + } + + result.mbstrplr, err = client.ListByRestorableDroppedDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient", "ListByRestorableDroppedDatabase", resp, "Failure responding to request") + return + } + if result.mbstrplr.hasNextLink() && result.mbstrplr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByRestorableDroppedDatabasePreparer prepares the ListByRestorableDroppedDatabase request. +func (client ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient) ListByRestorableDroppedDatabasePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, restorableDroppedDatabaseID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "restorableDroppedDatabaseId": autorest.Encode("path", restorableDroppedDatabaseID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/restorableDroppedDatabases/{restorableDroppedDatabaseId}/backupShortTermRetentionPolicies", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByRestorableDroppedDatabaseSender sends the ListByRestorableDroppedDatabase request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient) ListByRestorableDroppedDatabaseSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByRestorableDroppedDatabaseResponder handles the response to the ListByRestorableDroppedDatabase request. The method always +// closes the http.Response Body. +func (client ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient) ListByRestorableDroppedDatabaseResponder(resp *http.Response) (result ManagedBackupShortTermRetentionPolicyListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByRestorableDroppedDatabaseNextResults retrieves the next set of results, if any. +func (client ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient) listByRestorableDroppedDatabaseNextResults(ctx context.Context, lastResults ManagedBackupShortTermRetentionPolicyListResult) (result ManagedBackupShortTermRetentionPolicyListResult, err error) { + req, err := lastResults.managedBackupShortTermRetentionPolicyListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient", "listByRestorableDroppedDatabaseNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByRestorableDroppedDatabaseSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient", "listByRestorableDroppedDatabaseNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByRestorableDroppedDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient", "listByRestorableDroppedDatabaseNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByRestorableDroppedDatabaseComplete enumerates all values, automatically crossing page boundaries as required. +func (client ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient) ListByRestorableDroppedDatabaseComplete(ctx context.Context, resourceGroupName string, managedInstanceName string, restorableDroppedDatabaseID string) (result ManagedBackupShortTermRetentionPolicyListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient.ListByRestorableDroppedDatabase") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByRestorableDroppedDatabase(ctx, resourceGroupName, managedInstanceName, restorableDroppedDatabaseID) + return +} + +// Update sets a database's short term retention policy. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// parameters - the short term retention policy info. +func (client ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient) Update(ctx context.Context, resourceGroupName string, managedInstanceName string, restorableDroppedDatabaseID string, parameters ManagedBackupShortTermRetentionPolicy) (result ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient.Update") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.UpdatePreparer(ctx, resourceGroupName, managedInstanceName, restorableDroppedDatabaseID, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient", "Update", nil, "Failure sending request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient) UpdatePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, restorableDroppedDatabaseID string, parameters ManagedBackupShortTermRetentionPolicy) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "policyName": autorest.Encode("path", "default"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "restorableDroppedDatabaseId": autorest.Encode("path", restorableDroppedDatabaseID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/restorableDroppedDatabases/{restorableDroppedDatabaseId}/backupShortTermRetentionPolicies/{policyName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient) UpdateSender(req *http.Request) (future ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient) UpdateResponder(resp *http.Response) (result ManagedBackupShortTermRetentionPolicy, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/managedserversecurityalertpolicies.go b/services/preview/sql/mgmt/v5.0/sql/managedserversecurityalertpolicies.go new file mode 100644 index 000000000000..3b4e6232e516 --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/managedserversecurityalertpolicies.go @@ -0,0 +1,316 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ManagedServerSecurityAlertPoliciesClient is the the Azure SQL Database management API provides a RESTful set of web +// services that interact with Azure SQL Database services to manage your databases. The API enables you to create, +// retrieve, update, and delete databases. +type ManagedServerSecurityAlertPoliciesClient struct { + BaseClient +} + +// NewManagedServerSecurityAlertPoliciesClient creates an instance of the ManagedServerSecurityAlertPoliciesClient +// client. +func NewManagedServerSecurityAlertPoliciesClient(subscriptionID string) ManagedServerSecurityAlertPoliciesClient { + return NewManagedServerSecurityAlertPoliciesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewManagedServerSecurityAlertPoliciesClientWithBaseURI creates an instance of the +// ManagedServerSecurityAlertPoliciesClient client using a custom endpoint. Use this when interacting with an Azure +// cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewManagedServerSecurityAlertPoliciesClientWithBaseURI(baseURI string, subscriptionID string) ManagedServerSecurityAlertPoliciesClient { + return ManagedServerSecurityAlertPoliciesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a threat detection policy. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +// parameters - the managed server security alert policy. +func (client ManagedServerSecurityAlertPoliciesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, managedInstanceName string, parameters ManagedServerSecurityAlertPolicy) (result ManagedServerSecurityAlertPoliciesCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedServerSecurityAlertPoliciesClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, managedInstanceName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedServerSecurityAlertPoliciesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedServerSecurityAlertPoliciesClient", "CreateOrUpdate", nil, "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ManagedServerSecurityAlertPoliciesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, parameters ManagedServerSecurityAlertPolicy) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "securityAlertPolicyName": autorest.Encode("path", "Default"), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + parameters.SystemData = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/securityAlertPolicies/{securityAlertPolicyName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedServerSecurityAlertPoliciesClient) CreateOrUpdateSender(req *http.Request) (future ManagedServerSecurityAlertPoliciesCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ManagedServerSecurityAlertPoliciesClient) CreateOrUpdateResponder(resp *http.Response) (result ManagedServerSecurityAlertPolicy, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get get a managed server's threat detection policy. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +func (client ManagedServerSecurityAlertPoliciesClient) Get(ctx context.Context, resourceGroupName string, managedInstanceName string) (result ManagedServerSecurityAlertPolicy, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedServerSecurityAlertPoliciesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, managedInstanceName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedServerSecurityAlertPoliciesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ManagedServerSecurityAlertPoliciesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedServerSecurityAlertPoliciesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ManagedServerSecurityAlertPoliciesClient) GetPreparer(ctx context.Context, resourceGroupName string, managedInstanceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "securityAlertPolicyName": autorest.Encode("path", "Default"), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/securityAlertPolicies/{securityAlertPolicyName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedServerSecurityAlertPoliciesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ManagedServerSecurityAlertPoliciesClient) GetResponder(resp *http.Response) (result ManagedServerSecurityAlertPolicy, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByInstance get the managed server's threat detection policies. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +func (client ManagedServerSecurityAlertPoliciesClient) ListByInstance(ctx context.Context, resourceGroupName string, managedInstanceName string) (result ManagedServerSecurityAlertPolicyListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedServerSecurityAlertPoliciesClient.ListByInstance") + defer func() { + sc := -1 + if result.mssaplr.Response.Response != nil { + sc = result.mssaplr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByInstanceNextResults + req, err := client.ListByInstancePreparer(ctx, resourceGroupName, managedInstanceName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedServerSecurityAlertPoliciesClient", "ListByInstance", nil, "Failure preparing request") + return + } + + resp, err := client.ListByInstanceSender(req) + if err != nil { + result.mssaplr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ManagedServerSecurityAlertPoliciesClient", "ListByInstance", resp, "Failure sending request") + return + } + + result.mssaplr, err = client.ListByInstanceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedServerSecurityAlertPoliciesClient", "ListByInstance", resp, "Failure responding to request") + return + } + if result.mssaplr.hasNextLink() && result.mssaplr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByInstancePreparer prepares the ListByInstance request. +func (client ManagedServerSecurityAlertPoliciesClient) ListByInstancePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/securityAlertPolicies", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByInstanceSender sends the ListByInstance request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedServerSecurityAlertPoliciesClient) ListByInstanceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByInstanceResponder handles the response to the ListByInstance request. The method always +// closes the http.Response Body. +func (client ManagedServerSecurityAlertPoliciesClient) ListByInstanceResponder(resp *http.Response) (result ManagedServerSecurityAlertPolicyListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByInstanceNextResults retrieves the next set of results, if any. +func (client ManagedServerSecurityAlertPoliciesClient) listByInstanceNextResults(ctx context.Context, lastResults ManagedServerSecurityAlertPolicyListResult) (result ManagedServerSecurityAlertPolicyListResult, err error) { + req, err := lastResults.managedServerSecurityAlertPolicyListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.ManagedServerSecurityAlertPoliciesClient", "listByInstanceNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByInstanceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.ManagedServerSecurityAlertPoliciesClient", "listByInstanceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByInstanceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedServerSecurityAlertPoliciesClient", "listByInstanceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByInstanceComplete enumerates all values, automatically crossing page boundaries as required. +func (client ManagedServerSecurityAlertPoliciesClient) ListByInstanceComplete(ctx context.Context, resourceGroupName string, managedInstanceName string) (result ManagedServerSecurityAlertPolicyListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedServerSecurityAlertPoliciesClient.ListByInstance") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByInstance(ctx, resourceGroupName, managedInstanceName) + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/models.go b/services/preview/sql/mgmt/v5.0/sql/models.go new file mode 100644 index 000000000000..32af3e49022d --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/models.go @@ -0,0 +1,33763 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "encoding/json" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/date" + "github.com/Azure/go-autorest/autorest/to" + "github.com/Azure/go-autorest/tracing" + "github.com/gofrs/uuid" + "net/http" +) + +// The package's fully qualified name. +const fqdn = "github.com/Azure/azure-sdk-for-go/services/preview/sql/mgmt/v5.0/sql" + +// AdministratorListResult a list of active directory administrators. +type AdministratorListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]ServerAzureADAdministrator `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for AdministratorListResult. +func (alr AdministratorListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// AdministratorListResultIterator provides access to a complete listing of ServerAzureADAdministrator +// values. +type AdministratorListResultIterator struct { + i int + page AdministratorListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *AdministratorListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AdministratorListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *AdministratorListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter AdministratorListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter AdministratorListResultIterator) Response() AdministratorListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter AdministratorListResultIterator) Value() ServerAzureADAdministrator { + if !iter.page.NotDone() { + return ServerAzureADAdministrator{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the AdministratorListResultIterator type. +func NewAdministratorListResultIterator(page AdministratorListResultPage) AdministratorListResultIterator { + return AdministratorListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (alr AdministratorListResult) IsEmpty() bool { + return alr.Value == nil || len(*alr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (alr AdministratorListResult) hasNextLink() bool { + return alr.NextLink != nil && len(*alr.NextLink) != 0 +} + +// administratorListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (alr AdministratorListResult) administratorListResultPreparer(ctx context.Context) (*http.Request, error) { + if !alr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(alr.NextLink))) +} + +// AdministratorListResultPage contains a page of ServerAzureADAdministrator values. +type AdministratorListResultPage struct { + fn func(context.Context, AdministratorListResult) (AdministratorListResult, error) + alr AdministratorListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *AdministratorListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AdministratorListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.alr) + if err != nil { + return err + } + page.alr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *AdministratorListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page AdministratorListResultPage) NotDone() bool { + return !page.alr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page AdministratorListResultPage) Response() AdministratorListResult { + return page.alr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page AdministratorListResultPage) Values() []ServerAzureADAdministrator { + if page.alr.IsEmpty() { + return nil + } + return *page.alr.Value +} + +// Creates a new instance of the AdministratorListResultPage type. +func NewAdministratorListResultPage(cur AdministratorListResult, getNextPage func(context.Context, AdministratorListResult) (AdministratorListResult, error)) AdministratorListResultPage { + return AdministratorListResultPage{ + fn: getNextPage, + alr: cur, + } +} + +// AdministratorProperties properties of a active directory administrator. +type AdministratorProperties struct { + // AdministratorType - Type of the sever administrator. + AdministratorType *string `json:"administratorType,omitempty"` + // Login - Login name of the server administrator. + Login *string `json:"login,omitempty"` + // Sid - SID (object ID) of the server administrator. + Sid *uuid.UUID `json:"sid,omitempty"` + // TenantID - Tenant ID of the administrator. + TenantID *uuid.UUID `json:"tenantId,omitempty"` + // AzureADOnlyAuthentication - READ-ONLY; Azure Active Directory only Authentication enabled. + AzureADOnlyAuthentication *bool `json:"azureADOnlyAuthentication,omitempty"` +} + +// MarshalJSON is the custom marshaler for AdministratorProperties. +func (ap AdministratorProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ap.AdministratorType != nil { + objectMap["administratorType"] = ap.AdministratorType + } + if ap.Login != nil { + objectMap["login"] = ap.Login + } + if ap.Sid != nil { + objectMap["sid"] = ap.Sid + } + if ap.TenantID != nil { + objectMap["tenantId"] = ap.TenantID + } + return json.Marshal(objectMap) +} + +// Advisor database, Server or Elastic Pool Advisor. +type Advisor struct { + autorest.Response `json:"-"` + // Kind - READ-ONLY; Resource kind. + Kind *string `json:"kind,omitempty"` + // Location - READ-ONLY; Resource location. + Location *string `json:"location,omitempty"` + // AdvisorProperties - Resource properties. + *AdvisorProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Advisor. +func (a Advisor) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if a.AdvisorProperties != nil { + objectMap["properties"] = a.AdvisorProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Advisor struct. +func (a *Advisor) UnmarshalJSON(body []byte) error { + 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 + } + a.Kind = &kind + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + a.Location = &location + } + case "properties": + if v != nil { + var advisorProperties AdvisorProperties + err = json.Unmarshal(*v, &advisorProperties) + if err != nil { + return err + } + a.AdvisorProperties = &advisorProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + a.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + a.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + a.Type = &typeVar + } + } + } + + return nil +} + +// AdvisorProperties properties for a Database, Server or Elastic Pool Advisor. +type AdvisorProperties struct { + // AdvisorStatus - READ-ONLY; Gets the status of availability of this advisor to customers. Possible values are 'GA', 'PublicPreview', 'LimitedPublicPreview' and 'PrivatePreview'. Possible values include: 'AdvisorStatusGA', 'AdvisorStatusPublicPreview', 'AdvisorStatusLimitedPublicPreview', 'AdvisorStatusPrivatePreview' + AdvisorStatus AdvisorStatus `json:"advisorStatus,omitempty"` + // AutoExecuteStatus - Gets the auto-execute status (whether to let the system execute the recommendations) of this advisor. Possible values are 'Enabled' and 'Disabled'. Possible values include: 'AutoExecuteStatusEnabled', 'AutoExecuteStatusDisabled', 'AutoExecuteStatusDefault' + AutoExecuteStatus AutoExecuteStatus `json:"autoExecuteStatus,omitempty"` + // AutoExecuteStatusInheritedFrom - READ-ONLY; Gets the resource from which current value of auto-execute status is inherited. Auto-execute status can be set on (and inherited from) different levels in the resource hierarchy. Possible values are 'Subscription', 'Server', 'ElasticPool', 'Database' and 'Default' (when status is not explicitly set on any level). Possible values include: 'AutoExecuteStatusInheritedFromDefault', 'AutoExecuteStatusInheritedFromSubscription', 'AutoExecuteStatusInheritedFromServer', 'AutoExecuteStatusInheritedFromElasticPool', 'AutoExecuteStatusInheritedFromDatabase' + AutoExecuteStatusInheritedFrom AutoExecuteStatusInheritedFrom `json:"autoExecuteStatusInheritedFrom,omitempty"` + // RecommendationsStatus - READ-ONLY; Gets that status of recommendations for this advisor and reason for not having any recommendations. Possible values include, but are not limited to, 'Ok' (Recommendations available),LowActivity (not enough workload to analyze), 'DbSeemsTuned' (Database is doing well), etc. + RecommendationsStatus *string `json:"recommendationsStatus,omitempty"` + // LastChecked - READ-ONLY; Gets the time when the current resource was analyzed for recommendations by this advisor. + LastChecked *date.Time `json:"lastChecked,omitempty"` + // RecommendedActions - READ-ONLY; Gets the recommended actions for this advisor. + RecommendedActions *[]RecommendedAction `json:"recommendedActions,omitempty"` +} + +// MarshalJSON is the custom marshaler for AdvisorProperties. +func (ap AdvisorProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ap.AutoExecuteStatus != "" { + objectMap["autoExecuteStatus"] = ap.AutoExecuteStatus + } + return json.Marshal(objectMap) +} + +// AgentConfiguration a recoverable managed database resource. +type AgentConfiguration struct { + autorest.Response `json:"-"` + // AgentConfigurationProperties - Resource properties. + *AgentConfigurationProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for AgentConfiguration. +func (ac AgentConfiguration) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ac.AgentConfigurationProperties != nil { + objectMap["properties"] = ac.AgentConfigurationProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for AgentConfiguration struct. +func (ac *AgentConfiguration) UnmarshalJSON(body []byte) error { + 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 agentConfigurationProperties AgentConfigurationProperties + err = json.Unmarshal(*v, &agentConfigurationProperties) + if err != nil { + return err + } + ac.AgentConfigurationProperties = &agentConfigurationProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + ac.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ac.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ac.Type = &typeVar + } + } + } + + return nil +} + +// AgentConfigurationProperties sql agent configuration properties. +type AgentConfigurationProperties struct { + // State - The state of Sql Agent. Possible values include: 'StateEnabled', 'StateDisabled' + State State `json:"state,omitempty"` +} + +// AutomaticTuningOptions automatic tuning properties for individual advisors. +type AutomaticTuningOptions struct { + // DesiredState - Automatic tuning option desired state. Possible values include: 'AutomaticTuningOptionModeDesiredOff', 'AutomaticTuningOptionModeDesiredOn', 'AutomaticTuningOptionModeDesiredDefault' + DesiredState AutomaticTuningOptionModeDesired `json:"desiredState,omitempty"` + // ActualState - READ-ONLY; Automatic tuning option actual state. Possible values include: 'AutomaticTuningOptionModeActualOff', 'AutomaticTuningOptionModeActualOn' + ActualState AutomaticTuningOptionModeActual `json:"actualState,omitempty"` + // ReasonCode - READ-ONLY; Reason code if desired and actual state are different. + ReasonCode *int32 `json:"reasonCode,omitempty"` + // ReasonDesc - READ-ONLY; Reason description if desired and actual state are different. Possible values include: 'AutomaticTuningDisabledReasonDefault', 'AutomaticTuningDisabledReasonDisabled', 'AutomaticTuningDisabledReasonAutoConfigured', 'AutomaticTuningDisabledReasonInheritedFromServer', 'AutomaticTuningDisabledReasonQueryStoreOff', 'AutomaticTuningDisabledReasonQueryStoreReadOnly', 'AutomaticTuningDisabledReasonNotSupported' + ReasonDesc AutomaticTuningDisabledReason `json:"reasonDesc,omitempty"` +} + +// MarshalJSON is the custom marshaler for AutomaticTuningOptions. +func (ato AutomaticTuningOptions) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ato.DesiredState != "" { + objectMap["desiredState"] = ato.DesiredState + } + return json.Marshal(objectMap) +} + +// AutomaticTuningServerOptions automatic tuning properties for individual advisors. +type AutomaticTuningServerOptions struct { + // DesiredState - Automatic tuning option desired state. Possible values include: 'AutomaticTuningOptionModeDesiredOff', 'AutomaticTuningOptionModeDesiredOn', 'AutomaticTuningOptionModeDesiredDefault' + DesiredState AutomaticTuningOptionModeDesired `json:"desiredState,omitempty"` + // ActualState - READ-ONLY; Automatic tuning option actual state. Possible values include: 'AutomaticTuningOptionModeActualOff', 'AutomaticTuningOptionModeActualOn' + ActualState AutomaticTuningOptionModeActual `json:"actualState,omitempty"` + // ReasonCode - READ-ONLY; Reason code if desired and actual state are different. + ReasonCode *int32 `json:"reasonCode,omitempty"` + // ReasonDesc - READ-ONLY; Reason description if desired and actual state are different. Possible values include: 'AutomaticTuningServerReasonDefault', 'AutomaticTuningServerReasonDisabled', 'AutomaticTuningServerReasonAutoConfigured' + ReasonDesc AutomaticTuningServerReason `json:"reasonDesc,omitempty"` +} + +// MarshalJSON is the custom marshaler for AutomaticTuningServerOptions. +func (atso AutomaticTuningServerOptions) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if atso.DesiredState != "" { + objectMap["desiredState"] = atso.DesiredState + } + return json.Marshal(objectMap) +} + +// AutomaticTuningServerProperties server-level Automatic Tuning properties. +type AutomaticTuningServerProperties struct { + // DesiredState - Automatic tuning desired state. Possible values include: 'AutomaticTuningServerModeCustom', 'AutomaticTuningServerModeAuto', 'AutomaticTuningServerModeUnspecified' + DesiredState AutomaticTuningServerMode `json:"desiredState,omitempty"` + // ActualState - READ-ONLY; Automatic tuning actual state. Possible values include: 'AutomaticTuningServerModeCustom', 'AutomaticTuningServerModeAuto', 'AutomaticTuningServerModeUnspecified' + ActualState AutomaticTuningServerMode `json:"actualState,omitempty"` + // Options - Automatic tuning options definition. + Options map[string]*AutomaticTuningServerOptions `json:"options"` +} + +// MarshalJSON is the custom marshaler for AutomaticTuningServerProperties. +func (atsp AutomaticTuningServerProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if atsp.DesiredState != "" { + objectMap["desiredState"] = atsp.DesiredState + } + if atsp.Options != nil { + objectMap["options"] = atsp.Options + } + return json.Marshal(objectMap) +} + +// AutoPauseDelayTimeRange supported auto pause delay time range +type AutoPauseDelayTimeRange struct { + // MinValue - READ-ONLY; Minimum value + MinValue *int32 `json:"minValue,omitempty"` + // MaxValue - READ-ONLY; Maximum value + MaxValue *int32 `json:"maxValue,omitempty"` + // StepSize - READ-ONLY; Step value for discrete values between the minimum value and the maximum value. + StepSize *int32 `json:"stepSize,omitempty"` + // Default - READ-ONLY; Default value is no value is provided + Default *int32 `json:"default,omitempty"` + // Unit - READ-ONLY; Unit of time that delay is expressed in. Possible values include: 'PauseDelayTimeUnitMinutes' + Unit PauseDelayTimeUnit `json:"unit,omitempty"` + // DoNotPauseValue - READ-ONLY; Value that is used to not pause (infinite delay before pause) + DoNotPauseValue *int32 `json:"doNotPauseValue,omitempty"` +} + +// MarshalJSON is the custom marshaler for AutoPauseDelayTimeRange. +func (apdtr AutoPauseDelayTimeRange) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// AzureADOnlyAuthListResult a list of active directory only authentications. +type AzureADOnlyAuthListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]ServerAzureADOnlyAuthentication `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for AzureADOnlyAuthListResult. +func (aaoalr AzureADOnlyAuthListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// AzureADOnlyAuthListResultIterator provides access to a complete listing of +// ServerAzureADOnlyAuthentication values. +type AzureADOnlyAuthListResultIterator struct { + i int + page AzureADOnlyAuthListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *AzureADOnlyAuthListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AzureADOnlyAuthListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *AzureADOnlyAuthListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter AzureADOnlyAuthListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter AzureADOnlyAuthListResultIterator) Response() AzureADOnlyAuthListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter AzureADOnlyAuthListResultIterator) Value() ServerAzureADOnlyAuthentication { + if !iter.page.NotDone() { + return ServerAzureADOnlyAuthentication{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the AzureADOnlyAuthListResultIterator type. +func NewAzureADOnlyAuthListResultIterator(page AzureADOnlyAuthListResultPage) AzureADOnlyAuthListResultIterator { + return AzureADOnlyAuthListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (aaoalr AzureADOnlyAuthListResult) IsEmpty() bool { + return aaoalr.Value == nil || len(*aaoalr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (aaoalr AzureADOnlyAuthListResult) hasNextLink() bool { + return aaoalr.NextLink != nil && len(*aaoalr.NextLink) != 0 +} + +// azureADOnlyAuthListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (aaoalr AzureADOnlyAuthListResult) azureADOnlyAuthListResultPreparer(ctx context.Context) (*http.Request, error) { + if !aaoalr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(aaoalr.NextLink))) +} + +// AzureADOnlyAuthListResultPage contains a page of ServerAzureADOnlyAuthentication values. +type AzureADOnlyAuthListResultPage struct { + fn func(context.Context, AzureADOnlyAuthListResult) (AzureADOnlyAuthListResult, error) + aaoalr AzureADOnlyAuthListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *AzureADOnlyAuthListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AzureADOnlyAuthListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.aaoalr) + if err != nil { + return err + } + page.aaoalr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *AzureADOnlyAuthListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page AzureADOnlyAuthListResultPage) NotDone() bool { + return !page.aaoalr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page AzureADOnlyAuthListResultPage) Response() AzureADOnlyAuthListResult { + return page.aaoalr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page AzureADOnlyAuthListResultPage) Values() []ServerAzureADOnlyAuthentication { + if page.aaoalr.IsEmpty() { + return nil + } + return *page.aaoalr.Value +} + +// Creates a new instance of the AzureADOnlyAuthListResultPage type. +func NewAzureADOnlyAuthListResultPage(cur AzureADOnlyAuthListResult, getNextPage func(context.Context, AzureADOnlyAuthListResult) (AzureADOnlyAuthListResult, error)) AzureADOnlyAuthListResultPage { + return AzureADOnlyAuthListResultPage{ + fn: getNextPage, + aaoalr: cur, + } +} + +// AzureADOnlyAuthProperties properties of a active directory only authentication. +type AzureADOnlyAuthProperties struct { + // AzureADOnlyAuthentication - Azure Active Directory only Authentication enabled. + AzureADOnlyAuthentication *bool `json:"azureADOnlyAuthentication,omitempty"` +} + +// BackupShortTermRetentionPoliciesCreateOrUpdateFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type BackupShortTermRetentionPoliciesCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(BackupShortTermRetentionPoliciesClient) (BackupShortTermRetentionPolicy, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *BackupShortTermRetentionPoliciesCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for BackupShortTermRetentionPoliciesCreateOrUpdateFuture.Result. +func (future *BackupShortTermRetentionPoliciesCreateOrUpdateFuture) result(client BackupShortTermRetentionPoliciesClient) (bstrp BackupShortTermRetentionPolicy, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.BackupShortTermRetentionPoliciesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + bstrp.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.BackupShortTermRetentionPoliciesCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if bstrp.Response.Response, err = future.GetResult(sender); err == nil && bstrp.Response.Response.StatusCode != http.StatusNoContent { + bstrp, err = client.CreateOrUpdateResponder(bstrp.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.BackupShortTermRetentionPoliciesCreateOrUpdateFuture", "Result", bstrp.Response.Response, "Failure responding to request") + } + } + return +} + +// BackupShortTermRetentionPoliciesUpdateFuture an abstraction for monitoring and retrieving the results of +// a long-running operation. +type BackupShortTermRetentionPoliciesUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(BackupShortTermRetentionPoliciesClient) (BackupShortTermRetentionPolicy, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *BackupShortTermRetentionPoliciesUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for BackupShortTermRetentionPoliciesUpdateFuture.Result. +func (future *BackupShortTermRetentionPoliciesUpdateFuture) result(client BackupShortTermRetentionPoliciesClient) (bstrp BackupShortTermRetentionPolicy, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.BackupShortTermRetentionPoliciesUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + bstrp.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.BackupShortTermRetentionPoliciesUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if bstrp.Response.Response, err = future.GetResult(sender); err == nil && bstrp.Response.Response.StatusCode != http.StatusNoContent { + bstrp, err = client.UpdateResponder(bstrp.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.BackupShortTermRetentionPoliciesUpdateFuture", "Result", bstrp.Response.Response, "Failure responding to request") + } + } + return +} + +// BackupShortTermRetentionPolicy a short term retention policy. +type BackupShortTermRetentionPolicy struct { + autorest.Response `json:"-"` + // BackupShortTermRetentionPolicyProperties - Resource properties. + *BackupShortTermRetentionPolicyProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for BackupShortTermRetentionPolicy. +func (bstrp BackupShortTermRetentionPolicy) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if bstrp.BackupShortTermRetentionPolicyProperties != nil { + objectMap["properties"] = bstrp.BackupShortTermRetentionPolicyProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for BackupShortTermRetentionPolicy struct. +func (bstrp *BackupShortTermRetentionPolicy) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var backupShortTermRetentionPolicyProperties BackupShortTermRetentionPolicyProperties + err = json.Unmarshal(*v, &backupShortTermRetentionPolicyProperties) + if err != nil { + return err + } + bstrp.BackupShortTermRetentionPolicyProperties = &backupShortTermRetentionPolicyProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + bstrp.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + bstrp.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + bstrp.Type = &typeVar + } + } + } + + return nil +} + +// BackupShortTermRetentionPolicyListResult a list of short term retention policies. +type BackupShortTermRetentionPolicyListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]BackupShortTermRetentionPolicy `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for BackupShortTermRetentionPolicyListResult. +func (bstrplr BackupShortTermRetentionPolicyListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// BackupShortTermRetentionPolicyListResultIterator provides access to a complete listing of +// BackupShortTermRetentionPolicy values. +type BackupShortTermRetentionPolicyListResultIterator struct { + i int + page BackupShortTermRetentionPolicyListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *BackupShortTermRetentionPolicyListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/BackupShortTermRetentionPolicyListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *BackupShortTermRetentionPolicyListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter BackupShortTermRetentionPolicyListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter BackupShortTermRetentionPolicyListResultIterator) Response() BackupShortTermRetentionPolicyListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter BackupShortTermRetentionPolicyListResultIterator) Value() BackupShortTermRetentionPolicy { + if !iter.page.NotDone() { + return BackupShortTermRetentionPolicy{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the BackupShortTermRetentionPolicyListResultIterator type. +func NewBackupShortTermRetentionPolicyListResultIterator(page BackupShortTermRetentionPolicyListResultPage) BackupShortTermRetentionPolicyListResultIterator { + return BackupShortTermRetentionPolicyListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (bstrplr BackupShortTermRetentionPolicyListResult) IsEmpty() bool { + return bstrplr.Value == nil || len(*bstrplr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (bstrplr BackupShortTermRetentionPolicyListResult) hasNextLink() bool { + return bstrplr.NextLink != nil && len(*bstrplr.NextLink) != 0 +} + +// backupShortTermRetentionPolicyListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (bstrplr BackupShortTermRetentionPolicyListResult) backupShortTermRetentionPolicyListResultPreparer(ctx context.Context) (*http.Request, error) { + if !bstrplr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(bstrplr.NextLink))) +} + +// BackupShortTermRetentionPolicyListResultPage contains a page of BackupShortTermRetentionPolicy values. +type BackupShortTermRetentionPolicyListResultPage struct { + fn func(context.Context, BackupShortTermRetentionPolicyListResult) (BackupShortTermRetentionPolicyListResult, error) + bstrplr BackupShortTermRetentionPolicyListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *BackupShortTermRetentionPolicyListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/BackupShortTermRetentionPolicyListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.bstrplr) + if err != nil { + return err + } + page.bstrplr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *BackupShortTermRetentionPolicyListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page BackupShortTermRetentionPolicyListResultPage) NotDone() bool { + return !page.bstrplr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page BackupShortTermRetentionPolicyListResultPage) Response() BackupShortTermRetentionPolicyListResult { + return page.bstrplr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page BackupShortTermRetentionPolicyListResultPage) Values() []BackupShortTermRetentionPolicy { + if page.bstrplr.IsEmpty() { + return nil + } + return *page.bstrplr.Value +} + +// Creates a new instance of the BackupShortTermRetentionPolicyListResultPage type. +func NewBackupShortTermRetentionPolicyListResultPage(cur BackupShortTermRetentionPolicyListResult, getNextPage func(context.Context, BackupShortTermRetentionPolicyListResult) (BackupShortTermRetentionPolicyListResult, error)) BackupShortTermRetentionPolicyListResultPage { + return BackupShortTermRetentionPolicyListResultPage{ + fn: getNextPage, + bstrplr: cur, + } +} + +// BackupShortTermRetentionPolicyProperties properties of a short term retention policy +type BackupShortTermRetentionPolicyProperties struct { + // RetentionDays - The backup retention period in days. This is how many days Point-in-Time Restore will be supported. + RetentionDays *int32 `json:"retentionDays,omitempty"` + // DiffBackupIntervalInHours - The differential backup interval in hours. This is how many interval hours between each differential backup will be supported. This is only applicable to live databases but not dropped databases. + DiffBackupIntervalInHours *int32 `json:"diffBackupIntervalInHours,omitempty"` +} + +// BaseLongTermRetentionPolicyProperties properties of a long term retention policy +type BaseLongTermRetentionPolicyProperties struct { + // WeeklyRetention - The weekly retention policy for an LTR backup in an ISO 8601 format. + WeeklyRetention *string `json:"weeklyRetention,omitempty"` + // MonthlyRetention - The monthly retention policy for an LTR backup in an ISO 8601 format. + MonthlyRetention *string `json:"monthlyRetention,omitempty"` + // YearlyRetention - The yearly retention policy for an LTR backup in an ISO 8601 format. + YearlyRetention *string `json:"yearlyRetention,omitempty"` + // WeekOfYear - The week of year to take the yearly backup in an ISO 8601 format. + WeekOfYear *int32 `json:"weekOfYear,omitempty"` +} + +// CheckNameAvailabilityRequest a request to check whether the specified name for a resource is available. +type CheckNameAvailabilityRequest struct { + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` +} + +// CheckNameAvailabilityResponse the result of a name availability check. +type CheckNameAvailabilityResponse struct { + autorest.Response `json:"-"` + // Name - READ-ONLY; The name whose availability was checked. + Name *string `json:"name,omitempty"` + // Available - READ-ONLY; True if the name is available, otherwise false. + Available *bool `json:"available,omitempty"` + // Reason - READ-ONLY; The reason code explaining why the name is unavailable. Will be undefined if the name is available. Possible values include: 'CheckNameAvailabilityReasonInvalid', 'CheckNameAvailabilityReasonAlreadyExists' + Reason CheckNameAvailabilityReason `json:"reason,omitempty"` + // Message - READ-ONLY; A message explaining why the name is unavailable. Will be undefined if the name is available. + Message *string `json:"message,omitempty"` +} + +// MarshalJSON is the custom marshaler for CheckNameAvailabilityResponse. +func (cnar CheckNameAvailabilityResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// CompleteDatabaseRestoreDefinition contains the information necessary to perform a complete database +// restore operation. +type CompleteDatabaseRestoreDefinition struct { + // LastBackupName - The last backup name to apply + LastBackupName *string `json:"lastBackupName,omitempty"` +} + +// CopyLongTermRetentionBackupParameters contains the information necessary to perform long term retention +// backup copy operation. +type CopyLongTermRetentionBackupParameters struct { + // CopyLongTermRetentionBackupParametersProperties - Resource properties. + *CopyLongTermRetentionBackupParametersProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for CopyLongTermRetentionBackupParameters. +func (cltrbp CopyLongTermRetentionBackupParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if cltrbp.CopyLongTermRetentionBackupParametersProperties != nil { + objectMap["properties"] = cltrbp.CopyLongTermRetentionBackupParametersProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for CopyLongTermRetentionBackupParameters struct. +func (cltrbp *CopyLongTermRetentionBackupParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var copyLongTermRetentionBackupParametersProperties CopyLongTermRetentionBackupParametersProperties + err = json.Unmarshal(*v, ©LongTermRetentionBackupParametersProperties) + if err != nil { + return err + } + cltrbp.CopyLongTermRetentionBackupParametersProperties = ©LongTermRetentionBackupParametersProperties + } + } + } + + return nil +} + +// CopyLongTermRetentionBackupParametersProperties contains the properties to perform long term retention +// backup copy operation. +type CopyLongTermRetentionBackupParametersProperties struct { + // TargetSubscriptionID - The subscription that owns the target server + TargetSubscriptionID *string `json:"targetSubscriptionId,omitempty"` + // TargetResourceGroup - The resource group that owns the target server + TargetResourceGroup *string `json:"targetResourceGroup,omitempty"` + // TargetServerResourceID - The resource Id of the target server that owns the database + TargetServerResourceID *string `json:"targetServerResourceId,omitempty"` + // TargetServerFullyQualifiedDomainName - The fully qualified domain name of the target server + TargetServerFullyQualifiedDomainName *string `json:"targetServerFullyQualifiedDomainName,omitempty"` + // TargetDatabaseName - The name of the database owns the copied backup. + TargetDatabaseName *string `json:"targetDatabaseName,omitempty"` + // TargetBackupStorageRedundancy - The storage redundancy type of the copied backup. Possible values include: 'TargetBackupStorageRedundancyGeo', 'TargetBackupStorageRedundancyLocal', 'TargetBackupStorageRedundancyZone' + TargetBackupStorageRedundancy TargetBackupStorageRedundancy `json:"targetBackupStorageRedundancy,omitempty"` +} + +// CreateDatabaseRestorePointDefinition contains the information necessary to perform a create database +// restore point operation. +type CreateDatabaseRestorePointDefinition struct { + // RestorePointLabel - The restore point label to apply + RestorePointLabel *string `json:"restorePointLabel,omitempty"` +} + +// Database a database resource. +type Database struct { + autorest.Response `json:"-"` + // Sku - The database SKU. + // + // The list of SKUs may vary by region and support offer. To determine the SKUs (including the SKU name, tier/edition, family, and capacity) that are available to your subscription in an Azure region, use the `Capabilities_ListByLocation` REST API or one of the following commands: + // + // ```azurecli + // az sql db list-editions -l -o table + // ```` + // + // ```powershell + // Get-AzSqlServerServiceObjective -Location + // ```` + Sku *Sku `json:"sku,omitempty"` + // Kind - READ-ONLY; Kind of database. This is metadata used for the Azure portal experience. + Kind *string `json:"kind,omitempty"` + // ManagedBy - READ-ONLY; Resource that manages the database. + ManagedBy *string `json:"managedBy,omitempty"` + // DatabaseProperties - Resource properties. + *DatabaseProperties `json:"properties,omitempty"` + // Location - Resource location. + Location *string `json:"location,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Database. +func (d Database) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if d.Sku != nil { + objectMap["sku"] = d.Sku + } + if d.DatabaseProperties != nil { + objectMap["properties"] = d.DatabaseProperties + } + if d.Location != nil { + objectMap["location"] = d.Location + } + if d.Tags != nil { + objectMap["tags"] = d.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Database struct. +func (d *Database) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "sku": + if v != nil { + var sku Sku + err = json.Unmarshal(*v, &sku) + if err != nil { + return err + } + d.Sku = &sku + } + case "kind": + if v != nil { + var kind string + err = json.Unmarshal(*v, &kind) + if err != nil { + return err + } + d.Kind = &kind + } + case "managedBy": + if v != nil { + var managedBy string + err = json.Unmarshal(*v, &managedBy) + if err != nil { + return err + } + d.ManagedBy = &managedBy + } + case "properties": + if v != nil { + var databaseProperties DatabaseProperties + err = json.Unmarshal(*v, &databaseProperties) + if err != nil { + return err + } + d.DatabaseProperties = &databaseProperties + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + d.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + d.Tags = tags + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + d.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + d.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + d.Type = &typeVar + } + } + } + + return nil +} + +// DatabaseAutomaticTuning database-level Automatic Tuning. +type DatabaseAutomaticTuning struct { + autorest.Response `json:"-"` + // DatabaseAutomaticTuningProperties - Resource properties. + *DatabaseAutomaticTuningProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for DatabaseAutomaticTuning. +func (dat DatabaseAutomaticTuning) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dat.DatabaseAutomaticTuningProperties != nil { + objectMap["properties"] = dat.DatabaseAutomaticTuningProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for DatabaseAutomaticTuning struct. +func (dat *DatabaseAutomaticTuning) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var databaseAutomaticTuningProperties DatabaseAutomaticTuningProperties + err = json.Unmarshal(*v, &databaseAutomaticTuningProperties) + if err != nil { + return err + } + dat.DatabaseAutomaticTuningProperties = &databaseAutomaticTuningProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + dat.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + dat.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + dat.Type = &typeVar + } + } + } + + return nil +} + +// DatabaseAutomaticTuningProperties database-level Automatic Tuning properties. +type DatabaseAutomaticTuningProperties struct { + // DesiredState - Automatic tuning desired state. Possible values include: 'AutomaticTuningModeInherit', 'AutomaticTuningModeCustom', 'AutomaticTuningModeAuto', 'AutomaticTuningModeUnspecified' + DesiredState AutomaticTuningMode `json:"desiredState,omitempty"` + // ActualState - READ-ONLY; Automatic tuning actual state. Possible values include: 'AutomaticTuningModeInherit', 'AutomaticTuningModeCustom', 'AutomaticTuningModeAuto', 'AutomaticTuningModeUnspecified' + ActualState AutomaticTuningMode `json:"actualState,omitempty"` + // Options - Automatic tuning options definition. + Options map[string]*AutomaticTuningOptions `json:"options"` +} + +// MarshalJSON is the custom marshaler for DatabaseAutomaticTuningProperties. +func (datp DatabaseAutomaticTuningProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if datp.DesiredState != "" { + objectMap["desiredState"] = datp.DesiredState + } + if datp.Options != nil { + objectMap["options"] = datp.Options + } + return json.Marshal(objectMap) +} + +// DatabaseBlobAuditingPolicy a database blob auditing policy. +type DatabaseBlobAuditingPolicy struct { + autorest.Response `json:"-"` + // Kind - READ-ONLY; Resource kind. + Kind *string `json:"kind,omitempty"` + // DatabaseBlobAuditingPolicyProperties - Resource properties. + *DatabaseBlobAuditingPolicyProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for DatabaseBlobAuditingPolicy. +func (dbap DatabaseBlobAuditingPolicy) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dbap.DatabaseBlobAuditingPolicyProperties != nil { + objectMap["properties"] = dbap.DatabaseBlobAuditingPolicyProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for DatabaseBlobAuditingPolicy struct. +func (dbap *DatabaseBlobAuditingPolicy) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "kind": + if v != nil { + var kind string + err = json.Unmarshal(*v, &kind) + if err != nil { + return err + } + dbap.Kind = &kind + } + case "properties": + if v != nil { + var databaseBlobAuditingPolicyProperties DatabaseBlobAuditingPolicyProperties + err = json.Unmarshal(*v, &databaseBlobAuditingPolicyProperties) + if err != nil { + return err + } + dbap.DatabaseBlobAuditingPolicyProperties = &databaseBlobAuditingPolicyProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + dbap.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + dbap.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + dbap.Type = &typeVar + } + } + } + + return nil +} + +// DatabaseBlobAuditingPolicyListResult a list of database auditing settings. +type DatabaseBlobAuditingPolicyListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]DatabaseBlobAuditingPolicy `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for DatabaseBlobAuditingPolicyListResult. +func (dbaplr DatabaseBlobAuditingPolicyListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// DatabaseBlobAuditingPolicyListResultIterator provides access to a complete listing of +// DatabaseBlobAuditingPolicy values. +type DatabaseBlobAuditingPolicyListResultIterator struct { + i int + page DatabaseBlobAuditingPolicyListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *DatabaseBlobAuditingPolicyListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseBlobAuditingPolicyListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *DatabaseBlobAuditingPolicyListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter DatabaseBlobAuditingPolicyListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter DatabaseBlobAuditingPolicyListResultIterator) Response() DatabaseBlobAuditingPolicyListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter DatabaseBlobAuditingPolicyListResultIterator) Value() DatabaseBlobAuditingPolicy { + if !iter.page.NotDone() { + return DatabaseBlobAuditingPolicy{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the DatabaseBlobAuditingPolicyListResultIterator type. +func NewDatabaseBlobAuditingPolicyListResultIterator(page DatabaseBlobAuditingPolicyListResultPage) DatabaseBlobAuditingPolicyListResultIterator { + return DatabaseBlobAuditingPolicyListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (dbaplr DatabaseBlobAuditingPolicyListResult) IsEmpty() bool { + return dbaplr.Value == nil || len(*dbaplr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (dbaplr DatabaseBlobAuditingPolicyListResult) hasNextLink() bool { + return dbaplr.NextLink != nil && len(*dbaplr.NextLink) != 0 +} + +// databaseBlobAuditingPolicyListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (dbaplr DatabaseBlobAuditingPolicyListResult) databaseBlobAuditingPolicyListResultPreparer(ctx context.Context) (*http.Request, error) { + if !dbaplr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(dbaplr.NextLink))) +} + +// DatabaseBlobAuditingPolicyListResultPage contains a page of DatabaseBlobAuditingPolicy values. +type DatabaseBlobAuditingPolicyListResultPage struct { + fn func(context.Context, DatabaseBlobAuditingPolicyListResult) (DatabaseBlobAuditingPolicyListResult, error) + dbaplr DatabaseBlobAuditingPolicyListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *DatabaseBlobAuditingPolicyListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseBlobAuditingPolicyListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.dbaplr) + if err != nil { + return err + } + page.dbaplr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *DatabaseBlobAuditingPolicyListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page DatabaseBlobAuditingPolicyListResultPage) NotDone() bool { + return !page.dbaplr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page DatabaseBlobAuditingPolicyListResultPage) Response() DatabaseBlobAuditingPolicyListResult { + return page.dbaplr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page DatabaseBlobAuditingPolicyListResultPage) Values() []DatabaseBlobAuditingPolicy { + if page.dbaplr.IsEmpty() { + return nil + } + return *page.dbaplr.Value +} + +// Creates a new instance of the DatabaseBlobAuditingPolicyListResultPage type. +func NewDatabaseBlobAuditingPolicyListResultPage(cur DatabaseBlobAuditingPolicyListResult, getNextPage func(context.Context, DatabaseBlobAuditingPolicyListResult) (DatabaseBlobAuditingPolicyListResult, error)) DatabaseBlobAuditingPolicyListResultPage { + return DatabaseBlobAuditingPolicyListResultPage{ + fn: getNextPage, + dbaplr: cur, + } +} + +// DatabaseBlobAuditingPolicyProperties properties of a database blob auditing policy. +type DatabaseBlobAuditingPolicyProperties struct { + // RetentionDays - Specifies the number of days to keep in the audit logs in the storage account. + RetentionDays *int32 `json:"retentionDays,omitempty"` + // AuditActionsAndGroups - Specifies the Actions-Groups and Actions to audit. + // + // The recommended set of action groups to use is the following combination - this will audit all the queries and stored procedures executed against the database, as well as successful and failed logins: + // + // BATCH_COMPLETED_GROUP, + // SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP, + // FAILED_DATABASE_AUTHENTICATION_GROUP. + // + // This above combination is also the set that is configured by default when enabling auditing from the Azure portal. + // + // The supported action groups to audit are (note: choose only specific groups that cover your auditing needs. Using unnecessary groups could lead to very large quantities of audit records): + // + // APPLICATION_ROLE_CHANGE_PASSWORD_GROUP + // BACKUP_RESTORE_GROUP + // DATABASE_LOGOUT_GROUP + // DATABASE_OBJECT_CHANGE_GROUP + // DATABASE_OBJECT_OWNERSHIP_CHANGE_GROUP + // DATABASE_OBJECT_PERMISSION_CHANGE_GROUP + // DATABASE_OPERATION_GROUP + // DATABASE_PERMISSION_CHANGE_GROUP + // DATABASE_PRINCIPAL_CHANGE_GROUP + // DATABASE_PRINCIPAL_IMPERSONATION_GROUP + // DATABASE_ROLE_MEMBER_CHANGE_GROUP + // FAILED_DATABASE_AUTHENTICATION_GROUP + // SCHEMA_OBJECT_ACCESS_GROUP + // SCHEMA_OBJECT_CHANGE_GROUP + // SCHEMA_OBJECT_OWNERSHIP_CHANGE_GROUP + // SCHEMA_OBJECT_PERMISSION_CHANGE_GROUP + // SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP + // USER_CHANGE_PASSWORD_GROUP + // BATCH_STARTED_GROUP + // BATCH_COMPLETED_GROUP + // + // These are groups that cover all sql statements and stored procedures executed against the database, and should not be used in combination with other groups as this will result in duplicate audit logs. + // + // For more information, see [Database-Level Audit Action Groups](https://docs.microsoft.com/en-us/sql/relational-databases/security/auditing/sql-server-audit-action-groups-and-actions#database-level-audit-action-groups). + // + // For Database auditing policy, specific Actions can also be specified (note that Actions cannot be specified for Server auditing policy). The supported actions to audit are: + // SELECT + // UPDATE + // INSERT + // DELETE + // EXECUTE + // RECEIVE + // REFERENCES + // + // The general form for defining an action to be audited is: + // {action} ON {object} BY {principal} + // + // Note that in the above format can refer to an object like a table, view, or stored procedure, or an entire database or schema. For the latter cases, the forms DATABASE::{db_name} and SCHEMA::{schema_name} are used, respectively. + // + // For example: + // SELECT on dbo.myTable by public + // SELECT on DATABASE::myDatabase by public + // SELECT on SCHEMA::mySchema by public + // + // For more information, see [Database-Level Audit Actions](https://docs.microsoft.com/en-us/sql/relational-databases/security/auditing/sql-server-audit-action-groups-and-actions#database-level-audit-actions) + AuditActionsAndGroups *[]string `json:"auditActionsAndGroups,omitempty"` + // IsStorageSecondaryKeyInUse - Specifies whether storageAccountAccessKey value is the storage's secondary key. + IsStorageSecondaryKeyInUse *bool `json:"isStorageSecondaryKeyInUse,omitempty"` + // IsAzureMonitorTargetEnabled - Specifies whether audit events are sent to Azure Monitor. + // In order to send the events to Azure Monitor, specify 'State' as 'Enabled' and 'IsAzureMonitorTargetEnabled' as true. + // + // When using REST API to configure auditing, Diagnostic Settings with 'SQLSecurityAuditEvents' diagnostic logs category on the database should be also created. + // Note that for server level audit you should use the 'master' database as {databaseName}. + // + // Diagnostic Settings URI format: + // PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/providers/microsoft.insights/diagnosticSettings/{settingsName}?api-version=2017-05-01-preview + // + // For more information, see [Diagnostic Settings REST API](https://go.microsoft.com/fwlink/?linkid=2033207) + // or [Diagnostic Settings PowerShell](https://go.microsoft.com/fwlink/?linkid=2033043) + IsAzureMonitorTargetEnabled *bool `json:"isAzureMonitorTargetEnabled,omitempty"` + // QueueDelayMs - Specifies the amount of time in milliseconds that can elapse before audit actions are forced to be processed. + // The default minimum value is 1000 (1 second). The maximum is 2,147,483,647. + QueueDelayMs *int32 `json:"queueDelayMs,omitempty"` + // State - Specifies the state of the audit. If state is Enabled, storageEndpoint or isAzureMonitorTargetEnabled are required. Possible values include: 'BlobAuditingPolicyStateEnabled', 'BlobAuditingPolicyStateDisabled' + State BlobAuditingPolicyState `json:"state,omitempty"` + // StorageEndpoint - Specifies the blob storage endpoint (e.g. https://MyAccount.blob.core.windows.net). If state is Enabled, storageEndpoint or isAzureMonitorTargetEnabled is required. + StorageEndpoint *string `json:"storageEndpoint,omitempty"` + // StorageAccountAccessKey - Specifies the identifier key of the auditing storage account. + // If state is Enabled and storageEndpoint is specified, not specifying the storageAccountAccessKey will use SQL server system-assigned managed identity to access the storage. + // Prerequisites for using managed identity authentication: + // 1. Assign SQL Server a system-assigned managed identity in Azure Active Directory (AAD). + // 2. Grant SQL Server identity access to the storage account by adding 'Storage Blob Data Contributor' RBAC role to the server identity. + // For more information, see [Auditing to storage using Managed Identity authentication](https://go.microsoft.com/fwlink/?linkid=2114355) + StorageAccountAccessKey *string `json:"storageAccountAccessKey,omitempty"` + // StorageAccountSubscriptionID - Specifies the blob storage subscription Id. + StorageAccountSubscriptionID *uuid.UUID `json:"storageAccountSubscriptionId,omitempty"` +} + +// DatabaseColumn a database column resource. +type DatabaseColumn struct { + autorest.Response `json:"-"` + // DatabaseColumnProperties - Resource properties. + *DatabaseColumnProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for DatabaseColumn. +func (dc DatabaseColumn) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dc.DatabaseColumnProperties != nil { + objectMap["properties"] = dc.DatabaseColumnProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for DatabaseColumn struct. +func (dc *DatabaseColumn) UnmarshalJSON(body []byte) error { + 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 databaseColumnProperties DatabaseColumnProperties + err = json.Unmarshal(*v, &databaseColumnProperties) + if err != nil { + return err + } + dc.DatabaseColumnProperties = &databaseColumnProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + dc.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + dc.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + dc.Type = &typeVar + } + } + } + + return nil +} + +// DatabaseColumnListResult a list of database columns. +type DatabaseColumnListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]DatabaseColumn `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for DatabaseColumnListResult. +func (dclr DatabaseColumnListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// DatabaseColumnListResultIterator provides access to a complete listing of DatabaseColumn values. +type DatabaseColumnListResultIterator struct { + i int + page DatabaseColumnListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *DatabaseColumnListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseColumnListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *DatabaseColumnListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter DatabaseColumnListResultIterator) 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 DatabaseColumnListResultIterator) Response() DatabaseColumnListResult { + 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 DatabaseColumnListResultIterator) Value() DatabaseColumn { + if !iter.page.NotDone() { + return DatabaseColumn{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the DatabaseColumnListResultIterator type. +func NewDatabaseColumnListResultIterator(page DatabaseColumnListResultPage) DatabaseColumnListResultIterator { + return DatabaseColumnListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (dclr DatabaseColumnListResult) IsEmpty() bool { + return dclr.Value == nil || len(*dclr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (dclr DatabaseColumnListResult) hasNextLink() bool { + return dclr.NextLink != nil && len(*dclr.NextLink) != 0 +} + +// databaseColumnListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (dclr DatabaseColumnListResult) databaseColumnListResultPreparer(ctx context.Context) (*http.Request, error) { + if !dclr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(dclr.NextLink))) +} + +// DatabaseColumnListResultPage contains a page of DatabaseColumn values. +type DatabaseColumnListResultPage struct { + fn func(context.Context, DatabaseColumnListResult) (DatabaseColumnListResult, error) + dclr DatabaseColumnListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *DatabaseColumnListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseColumnListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.dclr) + if err != nil { + return err + } + page.dclr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *DatabaseColumnListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page DatabaseColumnListResultPage) NotDone() bool { + return !page.dclr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page DatabaseColumnListResultPage) Response() DatabaseColumnListResult { + return page.dclr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page DatabaseColumnListResultPage) Values() []DatabaseColumn { + if page.dclr.IsEmpty() { + return nil + } + return *page.dclr.Value +} + +// Creates a new instance of the DatabaseColumnListResultPage type. +func NewDatabaseColumnListResultPage(cur DatabaseColumnListResult, getNextPage func(context.Context, DatabaseColumnListResult) (DatabaseColumnListResult, error)) DatabaseColumnListResultPage { + return DatabaseColumnListResultPage{ + fn: getNextPage, + dclr: cur, + } +} + +// DatabaseColumnProperties database column properties. +type DatabaseColumnProperties struct { + // ColumnType - The column data type. Possible values include: 'ColumnDataTypeImage', 'ColumnDataTypeText', 'ColumnDataTypeUniqueidentifier', 'ColumnDataTypeDate', 'ColumnDataTypeTime', 'ColumnDataTypeDatetime2', 'ColumnDataTypeDatetimeoffset', 'ColumnDataTypeTinyint', 'ColumnDataTypeSmallint', 'ColumnDataTypeInt', 'ColumnDataTypeSmalldatetime', 'ColumnDataTypeReal', 'ColumnDataTypeMoney', 'ColumnDataTypeDatetime', 'ColumnDataTypeFloat', 'ColumnDataTypeSQLVariant', 'ColumnDataTypeNtext', 'ColumnDataTypeBit', 'ColumnDataTypeDecimal', 'ColumnDataTypeNumeric', 'ColumnDataTypeSmallmoney', 'ColumnDataTypeBigint', 'ColumnDataTypeHierarchyid', 'ColumnDataTypeGeometry', 'ColumnDataTypeGeography', 'ColumnDataTypeVarbinary', 'ColumnDataTypeVarchar', 'ColumnDataTypeBinary', 'ColumnDataTypeChar', 'ColumnDataTypeTimestamp', 'ColumnDataTypeNvarchar', 'ColumnDataTypeNchar', 'ColumnDataTypeXML', 'ColumnDataTypeSysname' + ColumnType ColumnDataType `json:"columnType,omitempty"` + // TemporalType - The table temporal type. Possible values include: 'TableTemporalTypeNonTemporalTable', 'TableTemporalTypeHistoryTable', 'TableTemporalTypeSystemVersionedTemporalTable' + TemporalType TableTemporalType `json:"temporalType,omitempty"` + // MemoryOptimized - Whether or not the column belongs to a memory optimized table. + MemoryOptimized *bool `json:"memoryOptimized,omitempty"` + // IsComputed - Whether or not the column is computed. + IsComputed *bool `json:"isComputed,omitempty"` +} + +// DatabaseExtensions an export managed database operation result resource. +type DatabaseExtensions struct { + // DatabaseExtensionsProperties - Resource properties. + *DatabaseExtensionsProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for DatabaseExtensions. +func (de DatabaseExtensions) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if de.DatabaseExtensionsProperties != nil { + objectMap["properties"] = de.DatabaseExtensionsProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for DatabaseExtensions struct. +func (de *DatabaseExtensions) UnmarshalJSON(body []byte) error { + 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 databaseExtensionsProperties DatabaseExtensionsProperties + err = json.Unmarshal(*v, &databaseExtensionsProperties) + if err != nil { + return err + } + de.DatabaseExtensionsProperties = &databaseExtensionsProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + de.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + de.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + de.Type = &typeVar + } + } + } + + return nil +} + +// DatabaseExtensionsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type DatabaseExtensionsCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(DatabaseExtensionsClient) (ImportExportExtensionsOperationResult, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *DatabaseExtensionsCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for DatabaseExtensionsCreateOrUpdateFuture.Result. +func (future *DatabaseExtensionsCreateOrUpdateFuture) result(client DatabaseExtensionsClient) (ieeor ImportExportExtensionsOperationResult, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseExtensionsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ieeor.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.DatabaseExtensionsCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if ieeor.Response.Response, err = future.GetResult(sender); err == nil && ieeor.Response.Response.StatusCode != http.StatusNoContent { + ieeor, err = client.CreateOrUpdateResponder(ieeor.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseExtensionsCreateOrUpdateFuture", "Result", ieeor.Response.Response, "Failure responding to request") + } + } + return +} + +// DatabaseExtensionsProperties contains the database information after successful export. +type DatabaseExtensionsProperties struct { + // OperationMode - Operation Mode. + OperationMode *string `json:"operationMode,omitempty"` + // StorageKeyType - Storage key type. Possible values include: 'StorageKeyTypeSharedAccessKey', 'StorageKeyTypeStorageAccessKey' + StorageKeyType StorageKeyType `json:"storageKeyType,omitempty"` + // StorageKey - Storage key. + StorageKey *string `json:"storageKey,omitempty"` + // StorageURI - Storage Uri. + StorageURI *string `json:"storageUri,omitempty"` +} + +// DatabaseListResult a list of databases. +type DatabaseListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]Database `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for DatabaseListResult. +func (dlr DatabaseListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// DatabaseListResultIterator provides access to a complete listing of Database values. +type DatabaseListResultIterator struct { + i int + page DatabaseListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *DatabaseListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *DatabaseListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter DatabaseListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter DatabaseListResultIterator) Response() DatabaseListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter DatabaseListResultIterator) Value() Database { + if !iter.page.NotDone() { + return Database{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the DatabaseListResultIterator type. +func NewDatabaseListResultIterator(page DatabaseListResultPage) DatabaseListResultIterator { + return DatabaseListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (dlr DatabaseListResult) IsEmpty() bool { + return dlr.Value == nil || len(*dlr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (dlr DatabaseListResult) hasNextLink() bool { + return dlr.NextLink != nil && len(*dlr.NextLink) != 0 +} + +// databaseListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (dlr DatabaseListResult) databaseListResultPreparer(ctx context.Context) (*http.Request, error) { + if !dlr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(dlr.NextLink))) +} + +// DatabaseListResultPage contains a page of Database values. +type DatabaseListResultPage struct { + fn func(context.Context, DatabaseListResult) (DatabaseListResult, error) + dlr DatabaseListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *DatabaseListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.dlr) + if err != nil { + return err + } + page.dlr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *DatabaseListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page DatabaseListResultPage) NotDone() bool { + return !page.dlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page DatabaseListResultPage) Response() DatabaseListResult { + return page.dlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page DatabaseListResultPage) Values() []Database { + if page.dlr.IsEmpty() { + return nil + } + return *page.dlr.Value +} + +// Creates a new instance of the DatabaseListResultPage type. +func NewDatabaseListResultPage(cur DatabaseListResult, getNextPage func(context.Context, DatabaseListResult) (DatabaseListResult, error)) DatabaseListResultPage { + return DatabaseListResultPage{ + fn: getNextPage, + dlr: cur, + } +} + +// DatabaseOperation a database operation. +type DatabaseOperation struct { + // DatabaseOperationProperties - Resource properties. + *DatabaseOperationProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for DatabaseOperation. +func (do DatabaseOperation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if do.DatabaseOperationProperties != nil { + objectMap["properties"] = do.DatabaseOperationProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for DatabaseOperation struct. +func (do *DatabaseOperation) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var databaseOperationProperties DatabaseOperationProperties + err = json.Unmarshal(*v, &databaseOperationProperties) + if err != nil { + return err + } + do.DatabaseOperationProperties = &databaseOperationProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + do.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + do.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + do.Type = &typeVar + } + } + } + + return nil +} + +// DatabaseOperationListResult the response to a list database operations request +type DatabaseOperationListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]DatabaseOperation `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for DatabaseOperationListResult. +func (dolr DatabaseOperationListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// DatabaseOperationListResultIterator provides access to a complete listing of DatabaseOperation values. +type DatabaseOperationListResultIterator struct { + i int + page DatabaseOperationListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *DatabaseOperationListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseOperationListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *DatabaseOperationListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter DatabaseOperationListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter DatabaseOperationListResultIterator) Response() DatabaseOperationListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter DatabaseOperationListResultIterator) Value() DatabaseOperation { + if !iter.page.NotDone() { + return DatabaseOperation{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the DatabaseOperationListResultIterator type. +func NewDatabaseOperationListResultIterator(page DatabaseOperationListResultPage) DatabaseOperationListResultIterator { + return DatabaseOperationListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (dolr DatabaseOperationListResult) IsEmpty() bool { + return dolr.Value == nil || len(*dolr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (dolr DatabaseOperationListResult) hasNextLink() bool { + return dolr.NextLink != nil && len(*dolr.NextLink) != 0 +} + +// databaseOperationListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (dolr DatabaseOperationListResult) databaseOperationListResultPreparer(ctx context.Context) (*http.Request, error) { + if !dolr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(dolr.NextLink))) +} + +// DatabaseOperationListResultPage contains a page of DatabaseOperation values. +type DatabaseOperationListResultPage struct { + fn func(context.Context, DatabaseOperationListResult) (DatabaseOperationListResult, error) + dolr DatabaseOperationListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *DatabaseOperationListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseOperationListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.dolr) + if err != nil { + return err + } + page.dolr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *DatabaseOperationListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page DatabaseOperationListResultPage) NotDone() bool { + return !page.dolr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page DatabaseOperationListResultPage) Response() DatabaseOperationListResult { + return page.dolr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page DatabaseOperationListResultPage) Values() []DatabaseOperation { + if page.dolr.IsEmpty() { + return nil + } + return *page.dolr.Value +} + +// Creates a new instance of the DatabaseOperationListResultPage type. +func NewDatabaseOperationListResultPage(cur DatabaseOperationListResult, getNextPage func(context.Context, DatabaseOperationListResult) (DatabaseOperationListResult, error)) DatabaseOperationListResultPage { + return DatabaseOperationListResultPage{ + fn: getNextPage, + dolr: cur, + } +} + +// DatabaseOperationProperties the properties of a database operation. +type DatabaseOperationProperties struct { + // DatabaseName - READ-ONLY; The name of the database the operation is being performed on. + DatabaseName *string `json:"databaseName,omitempty"` + // Operation - READ-ONLY; The name of operation. + Operation *string `json:"operation,omitempty"` + // OperationFriendlyName - READ-ONLY; The friendly name of operation. + OperationFriendlyName *string `json:"operationFriendlyName,omitempty"` + // PercentComplete - READ-ONLY; The percentage of the operation completed. + PercentComplete *int32 `json:"percentComplete,omitempty"` + // ServerName - READ-ONLY; The name of the server. + ServerName *string `json:"serverName,omitempty"` + // StartTime - READ-ONLY; The operation start time. + StartTime *date.Time `json:"startTime,omitempty"` + // State - READ-ONLY; The operation state. Possible values include: 'ManagementOperationStatePending', 'ManagementOperationStateInProgress', 'ManagementOperationStateSucceeded', 'ManagementOperationStateFailed', 'ManagementOperationStateCancelInProgress', 'ManagementOperationStateCancelled' + State ManagementOperationState `json:"state,omitempty"` + // ErrorCode - READ-ONLY; The operation error code. + ErrorCode *int32 `json:"errorCode,omitempty"` + // ErrorDescription - READ-ONLY; The operation error description. + ErrorDescription *string `json:"errorDescription,omitempty"` + // ErrorSeverity - READ-ONLY; The operation error severity. + ErrorSeverity *int32 `json:"errorSeverity,omitempty"` + // IsUserError - READ-ONLY; Whether or not the error is a user error. + IsUserError *bool `json:"isUserError,omitempty"` + // EstimatedCompletionTime - READ-ONLY; The estimated completion time of the operation. + EstimatedCompletionTime *date.Time `json:"estimatedCompletionTime,omitempty"` + // Description - READ-ONLY; The operation description. + Description *string `json:"description,omitempty"` + // IsCancellable - READ-ONLY; Whether the operation can be cancelled. + IsCancellable *bool `json:"isCancellable,omitempty"` +} + +// MarshalJSON is the custom marshaler for DatabaseOperationProperties. +func (dop DatabaseOperationProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// DatabaseProperties the database's properties. +type DatabaseProperties struct { + // CreateMode - Specifies the mode of database creation. + // + // Default: regular database creation. + // + // Copy: creates a database as a copy of an existing database. sourceDatabaseId must be specified as the resource ID of the source database. + // + // Secondary: creates a database as a secondary replica of an existing database. sourceDatabaseId must be specified as the resource ID of the existing primary database. + // + // PointInTimeRestore: Creates a database by restoring a point in time backup of an existing database. sourceDatabaseId must be specified as the resource ID of the existing database, and restorePointInTime must be specified. + // + // Recovery: Creates a database by restoring a geo-replicated backup. sourceDatabaseId must be specified as the recoverable database resource ID to restore. + // + // Restore: Creates a database by restoring a backup of a deleted database. sourceDatabaseId must be specified. If sourceDatabaseId is the database's original resource ID, then sourceDatabaseDeletionDate must be specified. Otherwise sourceDatabaseId must be the restorable dropped database resource ID and sourceDatabaseDeletionDate is ignored. restorePointInTime may also be specified to restore from an earlier point in time. + // + // RestoreLongTermRetentionBackup: Creates a database by restoring from a long term retention vault. recoveryServicesRecoveryPointResourceId must be specified as the recovery point resource ID. + // + // Copy, Secondary, and RestoreLongTermRetentionBackup are not supported for DataWarehouse edition. Possible values include: 'CreateModeDefault', 'CreateModeCopy', 'CreateModeSecondary', 'CreateModePointInTimeRestore', 'CreateModeRestore', 'CreateModeRecovery', 'CreateModeRestoreExternalBackup', 'CreateModeRestoreExternalBackupSecondary', 'CreateModeRestoreLongTermRetentionBackup', 'CreateModeOnlineSecondary' + CreateMode CreateMode `json:"createMode,omitempty"` + // Collation - The collation of the database. + Collation *string `json:"collation,omitempty"` + // MaxSizeBytes - The max size of the database expressed in bytes. + MaxSizeBytes *int64 `json:"maxSizeBytes,omitempty"` + // SampleName - The name of the sample schema to apply when creating this database. Possible values include: 'SampleNameAdventureWorksLT', 'SampleNameWideWorldImportersStd', 'SampleNameWideWorldImportersFull' + SampleName SampleName `json:"sampleName,omitempty"` + // ElasticPoolID - The resource identifier of the elastic pool containing this database. + ElasticPoolID *string `json:"elasticPoolId,omitempty"` + // SourceDatabaseID - The resource identifier of the source database associated with create operation of this database. + SourceDatabaseID *string `json:"sourceDatabaseId,omitempty"` + // Status - READ-ONLY; The status of the database. Possible values include: 'DatabaseStatusOnline', 'DatabaseStatusRestoring', 'DatabaseStatusRecoveryPending', 'DatabaseStatusRecovering', 'DatabaseStatusSuspect', 'DatabaseStatusOffline', 'DatabaseStatusStandby', 'DatabaseStatusShutdown', 'DatabaseStatusEmergencyMode', 'DatabaseStatusAutoClosed', 'DatabaseStatusCopying', 'DatabaseStatusCreating', 'DatabaseStatusInaccessible', 'DatabaseStatusOfflineSecondary', 'DatabaseStatusPausing', 'DatabaseStatusPaused', 'DatabaseStatusResuming', 'DatabaseStatusScaling', 'DatabaseStatusOfflineChangingDwPerformanceTiers', 'DatabaseStatusOnlineChangingDwPerformanceTiers', 'DatabaseStatusDisabled' + Status DatabaseStatus `json:"status,omitempty"` + // DatabaseID - READ-ONLY; The ID of the database. + DatabaseID *uuid.UUID `json:"databaseId,omitempty"` + // CreationDate - READ-ONLY; The creation date of the database (ISO8601 format). + CreationDate *date.Time `json:"creationDate,omitempty"` + // CurrentServiceObjectiveName - READ-ONLY; The current service level objective name of the database. + CurrentServiceObjectiveName *string `json:"currentServiceObjectiveName,omitempty"` + // RequestedServiceObjectiveName - READ-ONLY; The requested service level objective name of the database. + RequestedServiceObjectiveName *string `json:"requestedServiceObjectiveName,omitempty"` + // DefaultSecondaryLocation - READ-ONLY; The default secondary region for this database. + DefaultSecondaryLocation *string `json:"defaultSecondaryLocation,omitempty"` + // FailoverGroupID - READ-ONLY; Failover Group resource identifier that this database belongs to. + FailoverGroupID *string `json:"failoverGroupId,omitempty"` + // RestorePointInTime - Specifies the point in time (ISO8601 format) of the source database that will be restored to create the new database. + RestorePointInTime *date.Time `json:"restorePointInTime,omitempty"` + // SourceDatabaseDeletionDate - Specifies the time that the database was deleted. + SourceDatabaseDeletionDate *date.Time `json:"sourceDatabaseDeletionDate,omitempty"` + // RecoveryServicesRecoveryPointID - The resource identifier of the recovery point associated with create operation of this database. + RecoveryServicesRecoveryPointID *string `json:"recoveryServicesRecoveryPointId,omitempty"` + // LongTermRetentionBackupResourceID - The resource identifier of the long term retention backup associated with create operation of this database. + LongTermRetentionBackupResourceID *string `json:"longTermRetentionBackupResourceId,omitempty"` + // RecoverableDatabaseID - The resource identifier of the recoverable database associated with create operation of this database. + RecoverableDatabaseID *string `json:"recoverableDatabaseId,omitempty"` + // RestorableDroppedDatabaseID - The resource identifier of the restorable dropped database associated with create operation of this database. + RestorableDroppedDatabaseID *string `json:"restorableDroppedDatabaseId,omitempty"` + // CatalogCollation - Collation of the metadata catalog. Possible values include: 'CatalogCollationTypeDATABASEDEFAULT', 'CatalogCollationTypeSQLLatin1GeneralCP1CIAS' + CatalogCollation CatalogCollationType `json:"catalogCollation,omitempty"` + // ZoneRedundant - Whether or not this database is zone redundant, which means the replicas of this database will be spread across multiple availability zones. + ZoneRedundant *bool `json:"zoneRedundant,omitempty"` + // LicenseType - The license type to apply for this database. `LicenseIncluded` if you need a license, or `BasePrice` if you have a license and are eligible for the Azure Hybrid Benefit. Possible values include: 'DatabaseLicenseTypeLicenseIncluded', 'DatabaseLicenseTypeBasePrice' + LicenseType DatabaseLicenseType `json:"licenseType,omitempty"` + // MaxLogSizeBytes - READ-ONLY; The max log size for this database. + MaxLogSizeBytes *int64 `json:"maxLogSizeBytes,omitempty"` + // EarliestRestoreDate - READ-ONLY; This records the earliest start date and time that restore is available for this database (ISO8601 format). + EarliestRestoreDate *date.Time `json:"earliestRestoreDate,omitempty"` + // ReadScale - The state of read-only routing. If enabled, connections that have application intent set to readonly in their connection string may be routed to a readonly secondary replica in the same region. Possible values include: 'DatabaseReadScaleEnabled', 'DatabaseReadScaleDisabled' + ReadScale DatabaseReadScale `json:"readScale,omitempty"` + // HighAvailabilityReplicaCount - The number of secondary replicas associated with the database that are used to provide high availability. + HighAvailabilityReplicaCount *int32 `json:"highAvailabilityReplicaCount,omitempty"` + // SecondaryType - The secondary type of the database if it is a secondary. Valid values are Geo and Named. Possible values include: 'SecondaryTypeGeo', 'SecondaryTypeNamed' + SecondaryType SecondaryType `json:"secondaryType,omitempty"` + // CurrentSku - READ-ONLY; The name and tier of the SKU. + CurrentSku *Sku `json:"currentSku,omitempty"` + // AutoPauseDelay - Time in minutes after which database is automatically paused. A value of -1 means that automatic pause is disabled + AutoPauseDelay *int32 `json:"autoPauseDelay,omitempty"` + // CurrentBackupStorageRedundancy - READ-ONLY; The storage account type used to store backups for this database. Possible values include: 'CurrentBackupStorageRedundancyGeo', 'CurrentBackupStorageRedundancyLocal', 'CurrentBackupStorageRedundancyZone' + CurrentBackupStorageRedundancy CurrentBackupStorageRedundancy `json:"currentBackupStorageRedundancy,omitempty"` + // RequestedBackupStorageRedundancy - The storage account type to be used to store backups for this database. Possible values include: 'RequestedBackupStorageRedundancyGeo', 'RequestedBackupStorageRedundancyLocal', 'RequestedBackupStorageRedundancyZone' + RequestedBackupStorageRedundancy RequestedBackupStorageRedundancy `json:"requestedBackupStorageRedundancy,omitempty"` + // MinCapacity - Minimal capacity that database will always have allocated, if not paused + MinCapacity *float64 `json:"minCapacity,omitempty"` + // PausedDate - READ-ONLY; The date when database was paused by user configuration or action(ISO8601 format). Null if the database is ready. + PausedDate *date.Time `json:"pausedDate,omitempty"` + // ResumedDate - READ-ONLY; The date when database was resumed by user action or database login (ISO8601 format). Null if the database is paused. + ResumedDate *date.Time `json:"resumedDate,omitempty"` + // MaintenanceConfigurationID - Maintenance configuration id assigned to the database. This configuration defines the period when the maintenance updates will occur. + MaintenanceConfigurationID *string `json:"maintenanceConfigurationId,omitempty"` + // IsLedgerOn - Whether or not this database is a ledger database, which means all tables in the database are ledger tables. Note: the value of this property cannot be changed after the database has been created. + IsLedgerOn *bool `json:"isLedgerOn,omitempty"` + // IsInfraEncryptionEnabled - READ-ONLY; Infra encryption is enabled for this database. + IsInfraEncryptionEnabled *bool `json:"isInfraEncryptionEnabled,omitempty"` +} + +// MarshalJSON is the custom marshaler for DatabaseProperties. +func (dp DatabaseProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dp.CreateMode != "" { + objectMap["createMode"] = dp.CreateMode + } + if dp.Collation != nil { + objectMap["collation"] = dp.Collation + } + if dp.MaxSizeBytes != nil { + objectMap["maxSizeBytes"] = dp.MaxSizeBytes + } + if dp.SampleName != "" { + objectMap["sampleName"] = dp.SampleName + } + if dp.ElasticPoolID != nil { + objectMap["elasticPoolId"] = dp.ElasticPoolID + } + if dp.SourceDatabaseID != nil { + objectMap["sourceDatabaseId"] = dp.SourceDatabaseID + } + if dp.RestorePointInTime != nil { + objectMap["restorePointInTime"] = dp.RestorePointInTime + } + if dp.SourceDatabaseDeletionDate != nil { + objectMap["sourceDatabaseDeletionDate"] = dp.SourceDatabaseDeletionDate + } + if dp.RecoveryServicesRecoveryPointID != nil { + objectMap["recoveryServicesRecoveryPointId"] = dp.RecoveryServicesRecoveryPointID + } + if dp.LongTermRetentionBackupResourceID != nil { + objectMap["longTermRetentionBackupResourceId"] = dp.LongTermRetentionBackupResourceID + } + if dp.RecoverableDatabaseID != nil { + objectMap["recoverableDatabaseId"] = dp.RecoverableDatabaseID + } + if dp.RestorableDroppedDatabaseID != nil { + objectMap["restorableDroppedDatabaseId"] = dp.RestorableDroppedDatabaseID + } + if dp.CatalogCollation != "" { + objectMap["catalogCollation"] = dp.CatalogCollation + } + if dp.ZoneRedundant != nil { + objectMap["zoneRedundant"] = dp.ZoneRedundant + } + if dp.LicenseType != "" { + objectMap["licenseType"] = dp.LicenseType + } + if dp.ReadScale != "" { + objectMap["readScale"] = dp.ReadScale + } + if dp.HighAvailabilityReplicaCount != nil { + objectMap["highAvailabilityReplicaCount"] = dp.HighAvailabilityReplicaCount + } + if dp.SecondaryType != "" { + objectMap["secondaryType"] = dp.SecondaryType + } + if dp.AutoPauseDelay != nil { + objectMap["autoPauseDelay"] = dp.AutoPauseDelay + } + if dp.RequestedBackupStorageRedundancy != "" { + objectMap["requestedBackupStorageRedundancy"] = dp.RequestedBackupStorageRedundancy + } + if dp.MinCapacity != nil { + objectMap["minCapacity"] = dp.MinCapacity + } + if dp.MaintenanceConfigurationID != nil { + objectMap["maintenanceConfigurationId"] = dp.MaintenanceConfigurationID + } + if dp.IsLedgerOn != nil { + objectMap["isLedgerOn"] = dp.IsLedgerOn + } + return json.Marshal(objectMap) +} + +// DatabaseSchema a database schema resource. +type DatabaseSchema struct { + autorest.Response `json:"-"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for DatabaseSchema. +func (ds DatabaseSchema) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// DatabaseSchemaListResult a list of database schemas. +type DatabaseSchemaListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]DatabaseSchema `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for DatabaseSchemaListResult. +func (dslr DatabaseSchemaListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// DatabaseSchemaListResultIterator provides access to a complete listing of DatabaseSchema values. +type DatabaseSchemaListResultIterator struct { + i int + page DatabaseSchemaListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *DatabaseSchemaListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseSchemaListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *DatabaseSchemaListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter DatabaseSchemaListResultIterator) 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 DatabaseSchemaListResultIterator) Response() DatabaseSchemaListResult { + 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 DatabaseSchemaListResultIterator) Value() DatabaseSchema { + if !iter.page.NotDone() { + return DatabaseSchema{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the DatabaseSchemaListResultIterator type. +func NewDatabaseSchemaListResultIterator(page DatabaseSchemaListResultPage) DatabaseSchemaListResultIterator { + return DatabaseSchemaListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (dslr DatabaseSchemaListResult) IsEmpty() bool { + return dslr.Value == nil || len(*dslr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (dslr DatabaseSchemaListResult) hasNextLink() bool { + return dslr.NextLink != nil && len(*dslr.NextLink) != 0 +} + +// databaseSchemaListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (dslr DatabaseSchemaListResult) databaseSchemaListResultPreparer(ctx context.Context) (*http.Request, error) { + if !dslr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(dslr.NextLink))) +} + +// DatabaseSchemaListResultPage contains a page of DatabaseSchema values. +type DatabaseSchemaListResultPage struct { + fn func(context.Context, DatabaseSchemaListResult) (DatabaseSchemaListResult, error) + dslr DatabaseSchemaListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *DatabaseSchemaListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseSchemaListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.dslr) + if err != nil { + return err + } + page.dslr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *DatabaseSchemaListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page DatabaseSchemaListResultPage) NotDone() bool { + return !page.dslr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page DatabaseSchemaListResultPage) Response() DatabaseSchemaListResult { + return page.dslr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page DatabaseSchemaListResultPage) Values() []DatabaseSchema { + if page.dslr.IsEmpty() { + return nil + } + return *page.dslr.Value +} + +// Creates a new instance of the DatabaseSchemaListResultPage type. +func NewDatabaseSchemaListResultPage(cur DatabaseSchemaListResult, getNextPage func(context.Context, DatabaseSchemaListResult) (DatabaseSchemaListResult, error)) DatabaseSchemaListResultPage { + return DatabaseSchemaListResultPage{ + fn: getNextPage, + dslr: cur, + } +} + +// DatabasesCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type DatabasesCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(DatabasesClient) (Database, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *DatabasesCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for DatabasesCreateOrUpdateFuture.Result. +func (future *DatabasesCreateOrUpdateFuture) result(client DatabasesClient) (d Database, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + d.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.DatabasesCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if d.Response.Response, err = future.GetResult(sender); err == nil && d.Response.Response.StatusCode != http.StatusNoContent { + d, err = client.CreateOrUpdateResponder(d.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesCreateOrUpdateFuture", "Result", d.Response.Response, "Failure responding to request") + } + } + return +} + +// DatabasesDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type DatabasesDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(DatabasesClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *DatabasesDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for DatabasesDeleteFuture.Result. +func (future *DatabasesDeleteFuture) result(client DatabasesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.DatabasesDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// DatabaseSecurityAlertListResult a list of the database's security alert policies. +type DatabaseSecurityAlertListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]DatabaseSecurityAlertPolicy `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for DatabaseSecurityAlertListResult. +func (dsalr DatabaseSecurityAlertListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// DatabaseSecurityAlertListResultIterator provides access to a complete listing of +// DatabaseSecurityAlertPolicy values. +type DatabaseSecurityAlertListResultIterator struct { + i int + page DatabaseSecurityAlertListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *DatabaseSecurityAlertListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseSecurityAlertListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *DatabaseSecurityAlertListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter DatabaseSecurityAlertListResultIterator) 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 DatabaseSecurityAlertListResultIterator) Response() DatabaseSecurityAlertListResult { + 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 DatabaseSecurityAlertListResultIterator) Value() DatabaseSecurityAlertPolicy { + if !iter.page.NotDone() { + return DatabaseSecurityAlertPolicy{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the DatabaseSecurityAlertListResultIterator type. +func NewDatabaseSecurityAlertListResultIterator(page DatabaseSecurityAlertListResultPage) DatabaseSecurityAlertListResultIterator { + return DatabaseSecurityAlertListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (dsalr DatabaseSecurityAlertListResult) IsEmpty() bool { + return dsalr.Value == nil || len(*dsalr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (dsalr DatabaseSecurityAlertListResult) hasNextLink() bool { + return dsalr.NextLink != nil && len(*dsalr.NextLink) != 0 +} + +// databaseSecurityAlertListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (dsalr DatabaseSecurityAlertListResult) databaseSecurityAlertListResultPreparer(ctx context.Context) (*http.Request, error) { + if !dsalr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(dsalr.NextLink))) +} + +// DatabaseSecurityAlertListResultPage contains a page of DatabaseSecurityAlertPolicy values. +type DatabaseSecurityAlertListResultPage struct { + fn func(context.Context, DatabaseSecurityAlertListResult) (DatabaseSecurityAlertListResult, error) + dsalr DatabaseSecurityAlertListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *DatabaseSecurityAlertListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseSecurityAlertListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.dsalr) + if err != nil { + return err + } + page.dsalr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *DatabaseSecurityAlertListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page DatabaseSecurityAlertListResultPage) NotDone() bool { + return !page.dsalr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page DatabaseSecurityAlertListResultPage) Response() DatabaseSecurityAlertListResult { + return page.dsalr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page DatabaseSecurityAlertListResultPage) Values() []DatabaseSecurityAlertPolicy { + if page.dsalr.IsEmpty() { + return nil + } + return *page.dsalr.Value +} + +// Creates a new instance of the DatabaseSecurityAlertListResultPage type. +func NewDatabaseSecurityAlertListResultPage(cur DatabaseSecurityAlertListResult, getNextPage func(context.Context, DatabaseSecurityAlertListResult) (DatabaseSecurityAlertListResult, error)) DatabaseSecurityAlertListResultPage { + return DatabaseSecurityAlertListResultPage{ + fn: getNextPage, + dsalr: cur, + } +} + +// DatabaseSecurityAlertPolicy a database security alert policy. +type DatabaseSecurityAlertPolicy struct { + autorest.Response `json:"-"` + // SystemData - READ-ONLY; SystemData of SecurityAlertPolicyResource. + SystemData *SystemData `json:"systemData,omitempty"` + // SecurityAlertsPolicyProperties - Resource properties. + *SecurityAlertsPolicyProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for DatabaseSecurityAlertPolicy. +func (dsap DatabaseSecurityAlertPolicy) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dsap.SecurityAlertsPolicyProperties != nil { + objectMap["properties"] = dsap.SecurityAlertsPolicyProperties + } + 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 "systemData": + if v != nil { + var systemData SystemData + err = json.Unmarshal(*v, &systemData) + if err != nil { + return err + } + dsap.SystemData = &systemData + } + case "properties": + if v != nil { + var securityAlertsPolicyProperties SecurityAlertsPolicyProperties + err = json.Unmarshal(*v, &securityAlertsPolicyProperties) + if err != nil { + return err + } + dsap.SecurityAlertsPolicyProperties = &securityAlertsPolicyProperties + } + 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 +} + +// DatabasesExportFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type DatabasesExportFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(DatabasesClient) (ImportExportOperationResult, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *DatabasesExportFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for DatabasesExportFuture.Result. +func (future *DatabasesExportFuture) result(client DatabasesClient) (ieor ImportExportOperationResult, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesExportFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ieor.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.DatabasesExportFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if ieor.Response.Response, err = future.GetResult(sender); err == nil && ieor.Response.Response.StatusCode != http.StatusNoContent { + ieor, err = client.ExportResponder(ieor.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesExportFuture", "Result", ieor.Response.Response, "Failure responding to request") + } + } + return +} + +// DatabasesFailoverFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type DatabasesFailoverFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(DatabasesClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *DatabasesFailoverFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for DatabasesFailoverFuture.Result. +func (future *DatabasesFailoverFuture) result(client DatabasesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesFailoverFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.DatabasesFailoverFuture") + return + } + ar.Response = future.Response() + return +} + +// DatabasesImportFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type DatabasesImportFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(DatabasesClient) (ImportExportOperationResult, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *DatabasesImportFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for DatabasesImportFuture.Result. +func (future *DatabasesImportFuture) result(client DatabasesClient) (ieor ImportExportOperationResult, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesImportFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ieor.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.DatabasesImportFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if ieor.Response.Response, err = future.GetResult(sender); err == nil && ieor.Response.Response.StatusCode != http.StatusNoContent { + ieor, err = client.ImportResponder(ieor.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesImportFuture", "Result", ieor.Response.Response, "Failure responding to request") + } + } + return +} + +// DatabasesPauseFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type DatabasesPauseFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(DatabasesClient) (Database, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *DatabasesPauseFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for DatabasesPauseFuture.Result. +func (future *DatabasesPauseFuture) result(client DatabasesClient) (d Database, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesPauseFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + d.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.DatabasesPauseFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if d.Response.Response, err = future.GetResult(sender); err == nil && d.Response.Response.StatusCode != http.StatusNoContent { + d, err = client.PauseResponder(d.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesPauseFuture", "Result", d.Response.Response, "Failure responding to request") + } + } + return +} + +// DatabasesResumeFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type DatabasesResumeFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(DatabasesClient) (Database, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *DatabasesResumeFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for DatabasesResumeFuture.Result. +func (future *DatabasesResumeFuture) result(client DatabasesClient) (d Database, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesResumeFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + d.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.DatabasesResumeFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if d.Response.Response, err = future.GetResult(sender); err == nil && d.Response.Response.StatusCode != http.StatusNoContent { + d, err = client.ResumeResponder(d.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesResumeFuture", "Result", d.Response.Response, "Failure responding to request") + } + } + return +} + +// DatabasesUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type DatabasesUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(DatabasesClient) (Database, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *DatabasesUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for DatabasesUpdateFuture.Result. +func (future *DatabasesUpdateFuture) result(client DatabasesClient) (d Database, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + d.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.DatabasesUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if d.Response.Response, err = future.GetResult(sender); err == nil && d.Response.Response.StatusCode != http.StatusNoContent { + d, err = client.UpdateResponder(d.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesUpdateFuture", "Result", d.Response.Response, "Failure responding to request") + } + } + return +} + +// DatabasesUpgradeDataWarehouseFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type DatabasesUpgradeDataWarehouseFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(DatabasesClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *DatabasesUpgradeDataWarehouseFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for DatabasesUpgradeDataWarehouseFuture.Result. +func (future *DatabasesUpgradeDataWarehouseFuture) result(client DatabasesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabasesUpgradeDataWarehouseFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.DatabasesUpgradeDataWarehouseFuture") + return + } + ar.Response = future.Response() + return +} + +// DatabaseTable a database table resource. +type DatabaseTable struct { + autorest.Response `json:"-"` + // DatabaseTableProperties - Resource properties. + *DatabaseTableProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for DatabaseTable. +func (dt DatabaseTable) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dt.DatabaseTableProperties != nil { + objectMap["properties"] = dt.DatabaseTableProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for DatabaseTable struct. +func (dt *DatabaseTable) UnmarshalJSON(body []byte) error { + 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 databaseTableProperties DatabaseTableProperties + err = json.Unmarshal(*v, &databaseTableProperties) + if err != nil { + return err + } + dt.DatabaseTableProperties = &databaseTableProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + dt.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + dt.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + dt.Type = &typeVar + } + } + } + + return nil +} + +// DatabaseTableListResult a list of database tables. +type DatabaseTableListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]DatabaseTable `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for DatabaseTableListResult. +func (dtlr DatabaseTableListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// DatabaseTableListResultIterator provides access to a complete listing of DatabaseTable values. +type DatabaseTableListResultIterator struct { + i int + page DatabaseTableListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *DatabaseTableListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseTableListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *DatabaseTableListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter DatabaseTableListResultIterator) 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 DatabaseTableListResultIterator) Response() DatabaseTableListResult { + 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 DatabaseTableListResultIterator) Value() DatabaseTable { + if !iter.page.NotDone() { + return DatabaseTable{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the DatabaseTableListResultIterator type. +func NewDatabaseTableListResultIterator(page DatabaseTableListResultPage) DatabaseTableListResultIterator { + return DatabaseTableListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (dtlr DatabaseTableListResult) IsEmpty() bool { + return dtlr.Value == nil || len(*dtlr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (dtlr DatabaseTableListResult) hasNextLink() bool { + return dtlr.NextLink != nil && len(*dtlr.NextLink) != 0 +} + +// databaseTableListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (dtlr DatabaseTableListResult) databaseTableListResultPreparer(ctx context.Context) (*http.Request, error) { + if !dtlr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(dtlr.NextLink))) +} + +// DatabaseTableListResultPage contains a page of DatabaseTable values. +type DatabaseTableListResultPage struct { + fn func(context.Context, DatabaseTableListResult) (DatabaseTableListResult, error) + dtlr DatabaseTableListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *DatabaseTableListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseTableListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.dtlr) + if err != nil { + return err + } + page.dtlr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *DatabaseTableListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page DatabaseTableListResultPage) NotDone() bool { + return !page.dtlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page DatabaseTableListResultPage) Response() DatabaseTableListResult { + return page.dtlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page DatabaseTableListResultPage) Values() []DatabaseTable { + if page.dtlr.IsEmpty() { + return nil + } + return *page.dtlr.Value +} + +// Creates a new instance of the DatabaseTableListResultPage type. +func NewDatabaseTableListResultPage(cur DatabaseTableListResult, getNextPage func(context.Context, DatabaseTableListResult) (DatabaseTableListResult, error)) DatabaseTableListResultPage { + return DatabaseTableListResultPage{ + fn: getNextPage, + dtlr: cur, + } +} + +// DatabaseTableProperties database table properties. +type DatabaseTableProperties struct { + // TemporalType - The table temporal type. Possible values include: 'TableTemporalTypeNonTemporalTable', 'TableTemporalTypeHistoryTable', 'TableTemporalTypeSystemVersionedTemporalTable' + TemporalType TableTemporalType `json:"temporalType,omitempty"` + // MemoryOptimized - Whether or not the table is memory optimized. + MemoryOptimized *bool `json:"memoryOptimized,omitempty"` +} + +// 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 +} + +// DatabaseUsage usage metric of a database. +type DatabaseUsage struct { + // DatabaseUsageProperties - Resource properties. + *DatabaseUsageProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for DatabaseUsage. +func (du DatabaseUsage) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if du.DatabaseUsageProperties != nil { + objectMap["properties"] = du.DatabaseUsageProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for DatabaseUsage struct. +func (du *DatabaseUsage) UnmarshalJSON(body []byte) error { + 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 databaseUsageProperties DatabaseUsageProperties + err = json.Unmarshal(*v, &databaseUsageProperties) + if err != nil { + return err + } + du.DatabaseUsageProperties = &databaseUsageProperties + } + 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 +} + +// DatabaseUsageListResult a list of database usage metrics. +type DatabaseUsageListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]DatabaseUsage `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for DatabaseUsageListResult. +func (dulr DatabaseUsageListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// DatabaseUsageListResultIterator provides access to a complete listing of DatabaseUsage values. +type DatabaseUsageListResultIterator struct { + i int + page DatabaseUsageListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *DatabaseUsageListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseUsageListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *DatabaseUsageListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter DatabaseUsageListResultIterator) 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 DatabaseUsageListResultIterator) Response() DatabaseUsageListResult { + 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 DatabaseUsageListResultIterator) Value() DatabaseUsage { + if !iter.page.NotDone() { + return DatabaseUsage{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the DatabaseUsageListResultIterator type. +func NewDatabaseUsageListResultIterator(page DatabaseUsageListResultPage) DatabaseUsageListResultIterator { + return DatabaseUsageListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (dulr DatabaseUsageListResult) IsEmpty() bool { + return dulr.Value == nil || len(*dulr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (dulr DatabaseUsageListResult) hasNextLink() bool { + return dulr.NextLink != nil && len(*dulr.NextLink) != 0 +} + +// databaseUsageListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (dulr DatabaseUsageListResult) databaseUsageListResultPreparer(ctx context.Context) (*http.Request, error) { + if !dulr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(dulr.NextLink))) +} + +// DatabaseUsageListResultPage contains a page of DatabaseUsage values. +type DatabaseUsageListResultPage struct { + fn func(context.Context, DatabaseUsageListResult) (DatabaseUsageListResult, error) + dulr DatabaseUsageListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *DatabaseUsageListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseUsageListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.dulr) + if err != nil { + return err + } + page.dulr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *DatabaseUsageListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page DatabaseUsageListResultPage) NotDone() bool { + return !page.dulr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page DatabaseUsageListResultPage) Response() DatabaseUsageListResult { + return page.dulr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page DatabaseUsageListResultPage) Values() []DatabaseUsage { + if page.dulr.IsEmpty() { + return nil + } + return *page.dulr.Value +} + +// Creates a new instance of the DatabaseUsageListResultPage type. +func NewDatabaseUsageListResultPage(cur DatabaseUsageListResult, getNextPage func(context.Context, DatabaseUsageListResult) (DatabaseUsageListResult, error)) DatabaseUsageListResultPage { + return DatabaseUsageListResultPage{ + fn: getNextPage, + dulr: cur, + } +} + +// DatabaseUsageProperties properties of a database usage. +type DatabaseUsageProperties struct { + // DisplayName - READ-ONLY; User-readable name of the metric. + DisplayName *string `json:"displayName,omitempty"` + // CurrentValue - READ-ONLY; Current value of the metric. + CurrentValue *float64 `json:"currentValue,omitempty"` + // Limit - READ-ONLY; Boundary value of the metric. + Limit *float64 `json:"limit,omitempty"` + // Unit - READ-ONLY; Unit of the metric. + Unit *string `json:"unit,omitempty"` +} + +// MarshalJSON is the custom marshaler for DatabaseUsageProperties. +func (dup DatabaseUsageProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// DatabaseVulnerabilityAssessment a database vulnerability assessment. +type DatabaseVulnerabilityAssessment struct { + autorest.Response `json:"-"` + // DatabaseVulnerabilityAssessmentProperties - Resource properties. + *DatabaseVulnerabilityAssessmentProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for DatabaseVulnerabilityAssessment. +func (dva DatabaseVulnerabilityAssessment) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dva.DatabaseVulnerabilityAssessmentProperties != nil { + objectMap["properties"] = dva.DatabaseVulnerabilityAssessmentProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for DatabaseVulnerabilityAssessment struct. +func (dva *DatabaseVulnerabilityAssessment) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var databaseVulnerabilityAssessmentProperties DatabaseVulnerabilityAssessmentProperties + err = json.Unmarshal(*v, &databaseVulnerabilityAssessmentProperties) + if err != nil { + return err + } + dva.DatabaseVulnerabilityAssessmentProperties = &databaseVulnerabilityAssessmentProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + dva.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + dva.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + dva.Type = &typeVar + } + } + } + + return nil +} + +// DatabaseVulnerabilityAssessmentListResult a list of the database's vulnerability assessments. +type DatabaseVulnerabilityAssessmentListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]DatabaseVulnerabilityAssessment `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for DatabaseVulnerabilityAssessmentListResult. +func (dvalr DatabaseVulnerabilityAssessmentListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// DatabaseVulnerabilityAssessmentListResultIterator provides access to a complete listing of +// DatabaseVulnerabilityAssessment values. +type DatabaseVulnerabilityAssessmentListResultIterator struct { + i int + page DatabaseVulnerabilityAssessmentListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *DatabaseVulnerabilityAssessmentListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseVulnerabilityAssessmentListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *DatabaseVulnerabilityAssessmentListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter DatabaseVulnerabilityAssessmentListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter DatabaseVulnerabilityAssessmentListResultIterator) Response() DatabaseVulnerabilityAssessmentListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter DatabaseVulnerabilityAssessmentListResultIterator) Value() DatabaseVulnerabilityAssessment { + if !iter.page.NotDone() { + return DatabaseVulnerabilityAssessment{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the DatabaseVulnerabilityAssessmentListResultIterator type. +func NewDatabaseVulnerabilityAssessmentListResultIterator(page DatabaseVulnerabilityAssessmentListResultPage) DatabaseVulnerabilityAssessmentListResultIterator { + return DatabaseVulnerabilityAssessmentListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (dvalr DatabaseVulnerabilityAssessmentListResult) IsEmpty() bool { + return dvalr.Value == nil || len(*dvalr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (dvalr DatabaseVulnerabilityAssessmentListResult) hasNextLink() bool { + return dvalr.NextLink != nil && len(*dvalr.NextLink) != 0 +} + +// databaseVulnerabilityAssessmentListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (dvalr DatabaseVulnerabilityAssessmentListResult) databaseVulnerabilityAssessmentListResultPreparer(ctx context.Context) (*http.Request, error) { + if !dvalr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(dvalr.NextLink))) +} + +// DatabaseVulnerabilityAssessmentListResultPage contains a page of DatabaseVulnerabilityAssessment values. +type DatabaseVulnerabilityAssessmentListResultPage struct { + fn func(context.Context, DatabaseVulnerabilityAssessmentListResult) (DatabaseVulnerabilityAssessmentListResult, error) + dvalr DatabaseVulnerabilityAssessmentListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *DatabaseVulnerabilityAssessmentListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseVulnerabilityAssessmentListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.dvalr) + if err != nil { + return err + } + page.dvalr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *DatabaseVulnerabilityAssessmentListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page DatabaseVulnerabilityAssessmentListResultPage) NotDone() bool { + return !page.dvalr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page DatabaseVulnerabilityAssessmentListResultPage) Response() DatabaseVulnerabilityAssessmentListResult { + return page.dvalr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page DatabaseVulnerabilityAssessmentListResultPage) Values() []DatabaseVulnerabilityAssessment { + if page.dvalr.IsEmpty() { + return nil + } + return *page.dvalr.Value +} + +// Creates a new instance of the DatabaseVulnerabilityAssessmentListResultPage type. +func NewDatabaseVulnerabilityAssessmentListResultPage(cur DatabaseVulnerabilityAssessmentListResult, getNextPage func(context.Context, DatabaseVulnerabilityAssessmentListResult) (DatabaseVulnerabilityAssessmentListResult, error)) DatabaseVulnerabilityAssessmentListResultPage { + return DatabaseVulnerabilityAssessmentListResultPage{ + fn: getNextPage, + dvalr: cur, + } +} + +// DatabaseVulnerabilityAssessmentProperties properties of a database Vulnerability Assessment. +type DatabaseVulnerabilityAssessmentProperties struct { + // StorageContainerPath - A blob storage container path to hold the scan results (e.g. https://myStorage.blob.core.windows.net/VaScans/). It is required if server level vulnerability assessment policy doesn't set + StorageContainerPath *string `json:"storageContainerPath,omitempty"` + // StorageContainerSasKey - A shared access signature (SAS Key) that has write access to the blob container specified in 'storageContainerPath' parameter. If 'storageAccountAccessKey' isn't specified, StorageContainerSasKey is required. + StorageContainerSasKey *string `json:"storageContainerSasKey,omitempty"` + // StorageAccountAccessKey - Specifies the identifier key of the storage account for vulnerability assessment scan results. If 'StorageContainerSasKey' isn't specified, storageAccountAccessKey is required. + StorageAccountAccessKey *string `json:"storageAccountAccessKey,omitempty"` + // RecurringScans - The recurring scans settings + RecurringScans *VulnerabilityAssessmentRecurringScansProperties `json:"recurringScans,omitempty"` +} + +// DatabaseVulnerabilityAssessmentRuleBaseline a database vulnerability assessment rule baseline. +type DatabaseVulnerabilityAssessmentRuleBaseline struct { + autorest.Response `json:"-"` + // DatabaseVulnerabilityAssessmentRuleBaselineProperties - Resource properties. + *DatabaseVulnerabilityAssessmentRuleBaselineProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for DatabaseVulnerabilityAssessmentRuleBaseline. +func (dvarb DatabaseVulnerabilityAssessmentRuleBaseline) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dvarb.DatabaseVulnerabilityAssessmentRuleBaselineProperties != nil { + objectMap["properties"] = dvarb.DatabaseVulnerabilityAssessmentRuleBaselineProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for DatabaseVulnerabilityAssessmentRuleBaseline struct. +func (dvarb *DatabaseVulnerabilityAssessmentRuleBaseline) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var databaseVulnerabilityAssessmentRuleBaselineProperties DatabaseVulnerabilityAssessmentRuleBaselineProperties + err = json.Unmarshal(*v, &databaseVulnerabilityAssessmentRuleBaselineProperties) + if err != nil { + return err + } + dvarb.DatabaseVulnerabilityAssessmentRuleBaselineProperties = &databaseVulnerabilityAssessmentRuleBaselineProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + dvarb.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + dvarb.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + dvarb.Type = &typeVar + } + } + } + + return nil +} + +// DatabaseVulnerabilityAssessmentRuleBaselineItem properties for an Azure SQL Database Vulnerability +// Assessment rule baseline's result. +type DatabaseVulnerabilityAssessmentRuleBaselineItem struct { + // Result - The rule baseline result + Result *[]string `json:"result,omitempty"` +} + +// DatabaseVulnerabilityAssessmentRuleBaselineProperties properties of a database Vulnerability Assessment +// rule baseline. +type DatabaseVulnerabilityAssessmentRuleBaselineProperties struct { + // BaselineResults - The rule baseline result + BaselineResults *[]DatabaseVulnerabilityAssessmentRuleBaselineItem `json:"baselineResults,omitempty"` +} + +// DatabaseVulnerabilityAssessmentScanExportProperties properties of the export operation's result. +type DatabaseVulnerabilityAssessmentScanExportProperties struct { + // ExportedReportLocation - READ-ONLY; Location of the exported report (e.g. https://myStorage.blob.core.windows.net/VaScans/scans/serverName/databaseName/scan_scanId.xlsx). + ExportedReportLocation *string `json:"exportedReportLocation,omitempty"` +} + +// MarshalJSON is the custom marshaler for DatabaseVulnerabilityAssessmentScanExportProperties. +func (dvasep DatabaseVulnerabilityAssessmentScanExportProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// DatabaseVulnerabilityAssessmentScansExport a database Vulnerability Assessment scan export resource. +type DatabaseVulnerabilityAssessmentScansExport struct { + autorest.Response `json:"-"` + // DatabaseVulnerabilityAssessmentScanExportProperties - Resource properties. + *DatabaseVulnerabilityAssessmentScanExportProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for DatabaseVulnerabilityAssessmentScansExport. +func (dvase DatabaseVulnerabilityAssessmentScansExport) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dvase.DatabaseVulnerabilityAssessmentScanExportProperties != nil { + objectMap["properties"] = dvase.DatabaseVulnerabilityAssessmentScanExportProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for DatabaseVulnerabilityAssessmentScansExport struct. +func (dvase *DatabaseVulnerabilityAssessmentScansExport) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var databaseVulnerabilityAssessmentScanExportProperties DatabaseVulnerabilityAssessmentScanExportProperties + err = json.Unmarshal(*v, &databaseVulnerabilityAssessmentScanExportProperties) + if err != nil { + return err + } + dvase.DatabaseVulnerabilityAssessmentScanExportProperties = &databaseVulnerabilityAssessmentScanExportProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + dvase.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + dvase.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + dvase.Type = &typeVar + } + } + } + + return nil +} + +// DatabaseVulnerabilityAssessmentScansInitiateScanFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type DatabaseVulnerabilityAssessmentScansInitiateScanFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(DatabaseVulnerabilityAssessmentScansClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *DatabaseVulnerabilityAssessmentScansInitiateScanFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for DatabaseVulnerabilityAssessmentScansInitiateScanFuture.Result. +func (future *DatabaseVulnerabilityAssessmentScansInitiateScanFuture) result(client DatabaseVulnerabilityAssessmentScansClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DatabaseVulnerabilityAssessmentScansInitiateScanFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.DatabaseVulnerabilityAssessmentScansInitiateScanFuture") + return + } + ar.Response = future.Response() + return +} + +// DataMaskingPolicy represents a database data masking policy. +type DataMaskingPolicy struct { + autorest.Response `json:"-"` + // DataMaskingPolicyProperties - The properties of the data masking policy. + *DataMaskingPolicyProperties `json:"properties,omitempty"` + // Location - READ-ONLY; The location of the data masking policy. + Location *string `json:"location,omitempty"` + // Kind - READ-ONLY; The kind of data masking policy. Metadata, used for Azure portal. + Kind *string `json:"kind,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for DataMaskingPolicy. +func (dmp DataMaskingPolicy) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dmp.DataMaskingPolicyProperties != nil { + objectMap["properties"] = dmp.DataMaskingPolicyProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for DataMaskingPolicy struct. +func (dmp *DataMaskingPolicy) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var dataMaskingPolicyProperties DataMaskingPolicyProperties + err = json.Unmarshal(*v, &dataMaskingPolicyProperties) + if err != nil { + return err + } + dmp.DataMaskingPolicyProperties = &dataMaskingPolicyProperties + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + dmp.Location = &location + } + case "kind": + if v != nil { + var kind string + err = json.Unmarshal(*v, &kind) + if err != nil { + return err + } + dmp.Kind = &kind + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + dmp.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + dmp.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + dmp.Type = &typeVar + } + } + } + + return nil +} + +// DataMaskingPolicyProperties the properties of a database data masking policy. +type DataMaskingPolicyProperties struct { + // DataMaskingState - The state of the data masking policy. Possible values include: 'DataMaskingStateDisabled', 'DataMaskingStateEnabled' + DataMaskingState DataMaskingState `json:"dataMaskingState,omitempty"` + // ExemptPrincipals - The list of the exempt principals. Specifies the semicolon-separated list of database users for which the data masking policy does not apply. The specified users receive data results without masking for all of the database queries. + ExemptPrincipals *string `json:"exemptPrincipals,omitempty"` + // ApplicationPrincipals - READ-ONLY; The list of the application principals. This is a legacy parameter and is no longer used. + ApplicationPrincipals *string `json:"applicationPrincipals,omitempty"` + // MaskingLevel - READ-ONLY; The masking level. This is a legacy parameter and is no longer used. + MaskingLevel *string `json:"maskingLevel,omitempty"` +} + +// MarshalJSON is the custom marshaler for DataMaskingPolicyProperties. +func (dmpp DataMaskingPolicyProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dmpp.DataMaskingState != "" { + objectMap["dataMaskingState"] = dmpp.DataMaskingState + } + if dmpp.ExemptPrincipals != nil { + objectMap["exemptPrincipals"] = dmpp.ExemptPrincipals + } + return json.Marshal(objectMap) +} + +// DataMaskingRule represents a database data masking rule. +type DataMaskingRule struct { + autorest.Response `json:"-"` + // DataMaskingRuleProperties - The properties of the resource. + *DataMaskingRuleProperties `json:"properties,omitempty"` + // Location - READ-ONLY; The location of the data masking rule. + Location *string `json:"location,omitempty"` + // Kind - READ-ONLY; The kind of Data Masking Rule. Metadata, used for Azure portal. + Kind *string `json:"kind,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for DataMaskingRule. +func (dmr DataMaskingRule) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dmr.DataMaskingRuleProperties != nil { + objectMap["properties"] = dmr.DataMaskingRuleProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for DataMaskingRule struct. +func (dmr *DataMaskingRule) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var dataMaskingRuleProperties DataMaskingRuleProperties + err = json.Unmarshal(*v, &dataMaskingRuleProperties) + if err != nil { + return err + } + dmr.DataMaskingRuleProperties = &dataMaskingRuleProperties + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + dmr.Location = &location + } + case "kind": + if v != nil { + var kind string + err = json.Unmarshal(*v, &kind) + if err != nil { + return err + } + dmr.Kind = &kind + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + dmr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + dmr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + dmr.Type = &typeVar + } + } + } + + return nil +} + +// DataMaskingRuleListResult the response to a list data masking rules request. +type DataMaskingRuleListResult struct { + autorest.Response `json:"-"` + // Value - The list of database data masking rules. + Value *[]DataMaskingRule `json:"value,omitempty"` +} + +// DataMaskingRuleProperties the properties of a database data masking rule. +type DataMaskingRuleProperties struct { + // ID - READ-ONLY; The rule Id. + ID *string `json:"id,omitempty"` + // AliasName - The alias name. This is a legacy parameter and is no longer used. + AliasName *string `json:"aliasName,omitempty"` + // RuleState - The rule state. Used to delete a rule. To delete an existing rule, specify the schemaName, tableName, columnName, maskingFunction, and specify ruleState as disabled. However, if the rule doesn't already exist, the rule will be created with ruleState set to enabled, regardless of the provided value of ruleState. Possible values include: 'DataMaskingRuleStateDisabled', 'DataMaskingRuleStateEnabled' + RuleState DataMaskingRuleState `json:"ruleState,omitempty"` + // SchemaName - The schema name on which the data masking rule is applied. + SchemaName *string `json:"schemaName,omitempty"` + // TableName - The table name on which the data masking rule is applied. + TableName *string `json:"tableName,omitempty"` + // ColumnName - The column name on which the data masking rule is applied. + ColumnName *string `json:"columnName,omitempty"` + // MaskingFunction - The masking function that is used for the data masking rule. Possible values include: 'DataMaskingFunctionDefault', 'DataMaskingFunctionCCN', 'DataMaskingFunctionEmail', 'DataMaskingFunctionNumber', 'DataMaskingFunctionSSN', 'DataMaskingFunctionText' + MaskingFunction DataMaskingFunction `json:"maskingFunction,omitempty"` + // NumberFrom - The numberFrom property of the masking rule. Required if maskingFunction is set to Number, otherwise this parameter will be ignored. + NumberFrom *string `json:"numberFrom,omitempty"` + // NumberTo - The numberTo property of the data masking rule. Required if maskingFunction is set to Number, otherwise this parameter will be ignored. + NumberTo *string `json:"numberTo,omitempty"` + // PrefixSize - If maskingFunction is set to Text, the number of characters to show unmasked in the beginning of the string. Otherwise, this parameter will be ignored. + PrefixSize *string `json:"prefixSize,omitempty"` + // SuffixSize - If maskingFunction is set to Text, the number of characters to show unmasked at the end of the string. Otherwise, this parameter will be ignored. + SuffixSize *string `json:"suffixSize,omitempty"` + // ReplacementString - If maskingFunction is set to Text, the character to use for masking the unexposed part of the string. Otherwise, this parameter will be ignored. + ReplacementString *string `json:"replacementString,omitempty"` +} + +// MarshalJSON is the custom marshaler for DataMaskingRuleProperties. +func (dmrp DataMaskingRuleProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dmrp.AliasName != nil { + objectMap["aliasName"] = dmrp.AliasName + } + if dmrp.RuleState != "" { + objectMap["ruleState"] = dmrp.RuleState + } + if dmrp.SchemaName != nil { + objectMap["schemaName"] = dmrp.SchemaName + } + if dmrp.TableName != nil { + objectMap["tableName"] = dmrp.TableName + } + if dmrp.ColumnName != nil { + objectMap["columnName"] = dmrp.ColumnName + } + if dmrp.MaskingFunction != "" { + objectMap["maskingFunction"] = dmrp.MaskingFunction + } + if dmrp.NumberFrom != nil { + objectMap["numberFrom"] = dmrp.NumberFrom + } + if dmrp.NumberTo != nil { + objectMap["numberTo"] = dmrp.NumberTo + } + if dmrp.PrefixSize != nil { + objectMap["prefixSize"] = dmrp.PrefixSize + } + if dmrp.SuffixSize != nil { + objectMap["suffixSize"] = dmrp.SuffixSize + } + if dmrp.ReplacementString != nil { + objectMap["replacementString"] = dmrp.ReplacementString + } + return json.Marshal(objectMap) +} + +// DataWarehouseUserActivities user activities of a data warehouse +type DataWarehouseUserActivities struct { + autorest.Response `json:"-"` + // DataWarehouseUserActivitiesProperties - Resource properties. + *DataWarehouseUserActivitiesProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for DataWarehouseUserActivities. +func (dwua DataWarehouseUserActivities) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dwua.DataWarehouseUserActivitiesProperties != nil { + objectMap["properties"] = dwua.DataWarehouseUserActivitiesProperties + } + 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 +} + +// DataWarehouseUserActivitiesListResult user activities of a data warehouse +type DataWarehouseUserActivitiesListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]DataWarehouseUserActivities `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for DataWarehouseUserActivitiesListResult. +func (dwualr DataWarehouseUserActivitiesListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// DataWarehouseUserActivitiesListResultIterator provides access to a complete listing of +// DataWarehouseUserActivities values. +type DataWarehouseUserActivitiesListResultIterator struct { + i int + page DataWarehouseUserActivitiesListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *DataWarehouseUserActivitiesListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DataWarehouseUserActivitiesListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *DataWarehouseUserActivitiesListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter DataWarehouseUserActivitiesListResultIterator) 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 DataWarehouseUserActivitiesListResultIterator) Response() DataWarehouseUserActivitiesListResult { + 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 DataWarehouseUserActivitiesListResultIterator) Value() DataWarehouseUserActivities { + if !iter.page.NotDone() { + return DataWarehouseUserActivities{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the DataWarehouseUserActivitiesListResultIterator type. +func NewDataWarehouseUserActivitiesListResultIterator(page DataWarehouseUserActivitiesListResultPage) DataWarehouseUserActivitiesListResultIterator { + return DataWarehouseUserActivitiesListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (dwualr DataWarehouseUserActivitiesListResult) IsEmpty() bool { + return dwualr.Value == nil || len(*dwualr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (dwualr DataWarehouseUserActivitiesListResult) hasNextLink() bool { + return dwualr.NextLink != nil && len(*dwualr.NextLink) != 0 +} + +// dataWarehouseUserActivitiesListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (dwualr DataWarehouseUserActivitiesListResult) dataWarehouseUserActivitiesListResultPreparer(ctx context.Context) (*http.Request, error) { + if !dwualr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(dwualr.NextLink))) +} + +// DataWarehouseUserActivitiesListResultPage contains a page of DataWarehouseUserActivities values. +type DataWarehouseUserActivitiesListResultPage struct { + fn func(context.Context, DataWarehouseUserActivitiesListResult) (DataWarehouseUserActivitiesListResult, error) + dwualr DataWarehouseUserActivitiesListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *DataWarehouseUserActivitiesListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DataWarehouseUserActivitiesListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.dwualr) + if err != nil { + return err + } + page.dwualr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *DataWarehouseUserActivitiesListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page DataWarehouseUserActivitiesListResultPage) NotDone() bool { + return !page.dwualr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page DataWarehouseUserActivitiesListResultPage) Response() DataWarehouseUserActivitiesListResult { + return page.dwualr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page DataWarehouseUserActivitiesListResultPage) Values() []DataWarehouseUserActivities { + if page.dwualr.IsEmpty() { + return nil + } + return *page.dwualr.Value +} + +// Creates a new instance of the DataWarehouseUserActivitiesListResultPage type. +func NewDataWarehouseUserActivitiesListResultPage(cur DataWarehouseUserActivitiesListResult, getNextPage func(context.Context, DataWarehouseUserActivitiesListResult) (DataWarehouseUserActivitiesListResult, error)) DataWarehouseUserActivitiesListResultPage { + return DataWarehouseUserActivitiesListResultPage{ + fn: getNextPage, + dwualr: cur, + } +} + +// 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 - READ-ONLY; Count of running and suspended queries. + ActiveQueriesCount *int32 `json:"activeQueriesCount,omitempty"` +} + +// MarshalJSON is the custom marshaler for DataWarehouseUserActivitiesProperties. +func (dwuap DataWarehouseUserActivitiesProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// DeletedServer a deleted server. +type DeletedServer struct { + autorest.Response `json:"-"` + // DeletedServerProperties - Resource properties. + *DeletedServerProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for DeletedServer. +func (ds DeletedServer) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ds.DeletedServerProperties != nil { + objectMap["properties"] = ds.DeletedServerProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for DeletedServer struct. +func (ds *DeletedServer) UnmarshalJSON(body []byte) error { + 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 deletedServerProperties DeletedServerProperties + err = json.Unmarshal(*v, &deletedServerProperties) + if err != nil { + return err + } + ds.DeletedServerProperties = &deletedServerProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + ds.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ds.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ds.Type = &typeVar + } + } + } + + return nil +} + +// DeletedServerListResult a list of deleted servers. +type DeletedServerListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]DeletedServer `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for DeletedServerListResult. +func (dslr DeletedServerListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// DeletedServerListResultIterator provides access to a complete listing of DeletedServer values. +type DeletedServerListResultIterator struct { + i int + page DeletedServerListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *DeletedServerListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DeletedServerListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *DeletedServerListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter DeletedServerListResultIterator) 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 DeletedServerListResultIterator) Response() DeletedServerListResult { + 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 DeletedServerListResultIterator) Value() DeletedServer { + if !iter.page.NotDone() { + return DeletedServer{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the DeletedServerListResultIterator type. +func NewDeletedServerListResultIterator(page DeletedServerListResultPage) DeletedServerListResultIterator { + return DeletedServerListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (dslr DeletedServerListResult) IsEmpty() bool { + return dslr.Value == nil || len(*dslr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (dslr DeletedServerListResult) hasNextLink() bool { + return dslr.NextLink != nil && len(*dslr.NextLink) != 0 +} + +// deletedServerListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (dslr DeletedServerListResult) deletedServerListResultPreparer(ctx context.Context) (*http.Request, error) { + if !dslr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(dslr.NextLink))) +} + +// DeletedServerListResultPage contains a page of DeletedServer values. +type DeletedServerListResultPage struct { + fn func(context.Context, DeletedServerListResult) (DeletedServerListResult, error) + dslr DeletedServerListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *DeletedServerListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DeletedServerListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.dslr) + if err != nil { + return err + } + page.dslr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *DeletedServerListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page DeletedServerListResultPage) NotDone() bool { + return !page.dslr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page DeletedServerListResultPage) Response() DeletedServerListResult { + return page.dslr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page DeletedServerListResultPage) Values() []DeletedServer { + if page.dslr.IsEmpty() { + return nil + } + return *page.dslr.Value +} + +// Creates a new instance of the DeletedServerListResultPage type. +func NewDeletedServerListResultPage(cur DeletedServerListResult, getNextPage func(context.Context, DeletedServerListResult) (DeletedServerListResult, error)) DeletedServerListResultPage { + return DeletedServerListResultPage{ + fn: getNextPage, + dslr: cur, + } +} + +// DeletedServerProperties the properties of a deleted server. +type DeletedServerProperties struct { + // Version - READ-ONLY; The version of the deleted server. + Version *string `json:"version,omitempty"` + // DeletionTime - READ-ONLY; The deletion time of the deleted server. + DeletionTime *date.Time `json:"deletionTime,omitempty"` + // OriginalID - READ-ONLY; The original ID of the server before deletion. + OriginalID *string `json:"originalId,omitempty"` + // FullyQualifiedDomainName - READ-ONLY; The fully qualified domain name of the server. + FullyQualifiedDomainName *string `json:"fullyQualifiedDomainName,omitempty"` +} + +// MarshalJSON is the custom marshaler for DeletedServerProperties. +func (dsp DeletedServerProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// DeletedServersRecoverFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type DeletedServersRecoverFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(DeletedServersClient) (DeletedServer, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *DeletedServersRecoverFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for DeletedServersRecoverFuture.Result. +func (future *DeletedServersRecoverFuture) result(client DeletedServersClient) (ds DeletedServer, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DeletedServersRecoverFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ds.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.DeletedServersRecoverFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if ds.Response.Response, err = future.GetResult(sender); err == nil && ds.Response.Response.StatusCode != http.StatusNoContent { + ds, err = client.RecoverResponder(ds.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.DeletedServersRecoverFuture", "Result", ds.Response.Response, "Failure responding to request") + } + } + return +} + +// DNSRefreshConfigurationProperties DNS refresh configuration properties. +type DNSRefreshConfigurationProperties struct { + // Status - READ-ONLY; The status of the DNS refresh operation. Possible values include: 'Status1Succeeded', 'Status1Failed' + Status Status1 `json:"status,omitempty"` +} + +// MarshalJSON is the custom marshaler for DNSRefreshConfigurationProperties. +func (drcp DNSRefreshConfigurationProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// EditionCapability the edition capability. +type EditionCapability struct { + // Name - READ-ONLY; The database edition name. + Name *string `json:"name,omitempty"` + // SupportedServiceLevelObjectives - READ-ONLY; The list of supported service objectives for the edition. + SupportedServiceLevelObjectives *[]ServiceObjectiveCapability `json:"supportedServiceLevelObjectives,omitempty"` + // ZoneRedundant - READ-ONLY; Whether or not zone redundancy is supported for the edition. + ZoneRedundant *bool `json:"zoneRedundant,omitempty"` + // ReadScale - READ-ONLY; The read scale capability for the edition. + ReadScale *ReadScaleCapability `json:"readScale,omitempty"` + // SupportedStorageCapabilities - READ-ONLY; The list of supported storage capabilities for this edition + SupportedStorageCapabilities *[]StorageCapability `json:"supportedStorageCapabilities,omitempty"` + // Status - READ-ONLY; The status of the capability. Possible values include: 'CapabilityStatusVisible', 'CapabilityStatusAvailable', 'CapabilityStatusDefault', 'CapabilityStatusDisabled' + Status CapabilityStatus `json:"status,omitempty"` + // Reason - The reason for the capability not being available. + Reason *string `json:"reason,omitempty"` +} + +// MarshalJSON is the custom marshaler for EditionCapability. +func (ec EditionCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ec.Reason != nil { + objectMap["reason"] = ec.Reason + } + return json.Marshal(objectMap) +} + +// ElasticPool an elastic pool. +type ElasticPool struct { + autorest.Response `json:"-"` + // Sku - The elastic pool SKU. + // + // The list of SKUs may vary by region and support offer. To determine the SKUs (including the SKU name, tier/edition, family, and capacity) that are available to your subscription in an Azure region, use the `Capabilities_ListByLocation` REST API or the following command: + // + // ```azurecli + // az sql elastic-pool list-editions -l -o table + // ```` + Sku *Sku `json:"sku,omitempty"` + // Kind - READ-ONLY; Kind of elastic pool. This is metadata used for the Azure portal experience. + Kind *string `json:"kind,omitempty"` + // ElasticPoolProperties - Resource properties. + *ElasticPoolProperties `json:"properties,omitempty"` + // Location - Resource location. + Location *string `json:"location,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ElasticPool. +func (ep ElasticPool) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ep.Sku != nil { + objectMap["sku"] = ep.Sku + } + if ep.ElasticPoolProperties != nil { + objectMap["properties"] = ep.ElasticPoolProperties + } + if ep.Location != nil { + objectMap["location"] = ep.Location + } + if ep.Tags != nil { + objectMap["tags"] = ep.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ElasticPool struct. +func (ep *ElasticPool) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "sku": + if v != nil { + var sku Sku + err = json.Unmarshal(*v, &sku) + if err != nil { + return err + } + ep.Sku = &sku + } + case "kind": + if v != nil { + var kind string + err = json.Unmarshal(*v, &kind) + if err != nil { + return err + } + ep.Kind = &kind + } + case "properties": + if v != nil { + var elasticPoolProperties ElasticPoolProperties + err = json.Unmarshal(*v, &elasticPoolProperties) + if err != nil { + return err + } + ep.ElasticPoolProperties = &elasticPoolProperties + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + ep.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + ep.Tags = tags + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + ep.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ep.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ep.Type = &typeVar + } + } + } + + return nil +} + +// ElasticPoolActivity represents the activity on an elastic pool. +type ElasticPoolActivity struct { + // Location - The geo-location where the resource lives + Location *string `json:"location,omitempty"` + // ElasticPoolActivityProperties - The properties representing the resource. + *ElasticPoolActivityProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ElasticPoolActivity. +func (epa ElasticPoolActivity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if epa.Location != nil { + objectMap["location"] = epa.Location + } + if epa.ElasticPoolActivityProperties != nil { + objectMap["properties"] = epa.ElasticPoolActivityProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ElasticPoolActivity struct. +func (epa *ElasticPoolActivity) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + epa.Location = &location + } + case "properties": + if v != nil { + var elasticPoolActivityProperties ElasticPoolActivityProperties + err = json.Unmarshal(*v, &elasticPoolActivityProperties) + if err != nil { + return err + } + epa.ElasticPoolActivityProperties = &elasticPoolActivityProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + epa.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + epa.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + epa.Type = &typeVar + } + } + } + + return nil +} + +// ElasticPoolActivityListResult represents the response to a list elastic pool activity request. +type ElasticPoolActivityListResult struct { + autorest.Response `json:"-"` + // Value - The list of elastic pool activities. + Value *[]ElasticPoolActivity `json:"value,omitempty"` +} + +// ElasticPoolActivityProperties represents the properties of an elastic pool. +type ElasticPoolActivityProperties struct { + // EndTime - READ-ONLY; The time the operation finished (ISO8601 format). + EndTime *date.Time `json:"endTime,omitempty"` + // ErrorCode - READ-ONLY; The error code if available. + ErrorCode *int32 `json:"errorCode,omitempty"` + // ErrorMessage - READ-ONLY; The error message if available. + ErrorMessage *string `json:"errorMessage,omitempty"` + // ErrorSeverity - READ-ONLY; The error severity if available. + ErrorSeverity *int32 `json:"errorSeverity,omitempty"` + // Operation - READ-ONLY; The operation name. + Operation *string `json:"operation,omitempty"` + // OperationID - READ-ONLY; The unique operation ID. + OperationID *uuid.UUID `json:"operationId,omitempty"` + // PercentComplete - READ-ONLY; The percentage complete if available. + PercentComplete *int32 `json:"percentComplete,omitempty"` + // RequestedDatabaseDtuMax - READ-ONLY; The requested max DTU per database if available. + RequestedDatabaseDtuMax *int32 `json:"requestedDatabaseDtuMax,omitempty"` + // RequestedDatabaseDtuMin - READ-ONLY; The requested min DTU per database if available. + RequestedDatabaseDtuMin *int32 `json:"requestedDatabaseDtuMin,omitempty"` + // RequestedDtu - READ-ONLY; The requested DTU for the pool if available. + RequestedDtu *int32 `json:"requestedDtu,omitempty"` + // RequestedElasticPoolName - READ-ONLY; The requested name for the elastic pool if available. + RequestedElasticPoolName *string `json:"requestedElasticPoolName,omitempty"` + // RequestedStorageLimitInGB - READ-ONLY; The requested storage limit for the pool in GB if available. + RequestedStorageLimitInGB *int64 `json:"requestedStorageLimitInGB,omitempty"` + // ElasticPoolName - READ-ONLY; The name of the elastic pool. + ElasticPoolName *string `json:"elasticPoolName,omitempty"` + // ServerName - READ-ONLY; The name of the server the elastic pool is in. + ServerName *string `json:"serverName,omitempty"` + // StartTime - READ-ONLY; The time the operation started (ISO8601 format). + StartTime *date.Time `json:"startTime,omitempty"` + // State - READ-ONLY; The current state of the operation. + State *string `json:"state,omitempty"` + // RequestedStorageLimitInMB - READ-ONLY; The requested storage limit in MB. + RequestedStorageLimitInMB *int32 `json:"requestedStorageLimitInMB,omitempty"` + // RequestedDatabaseDtuGuarantee - READ-ONLY; The requested per database DTU guarantee. + RequestedDatabaseDtuGuarantee *int32 `json:"requestedDatabaseDtuGuarantee,omitempty"` + // RequestedDatabaseDtuCap - READ-ONLY; The requested per database DTU cap. + RequestedDatabaseDtuCap *int32 `json:"requestedDatabaseDtuCap,omitempty"` + // RequestedDtuGuarantee - READ-ONLY; The requested DTU guarantee. + RequestedDtuGuarantee *int32 `json:"requestedDtuGuarantee,omitempty"` +} + +// MarshalJSON is the custom marshaler for ElasticPoolActivityProperties. +func (epap ElasticPoolActivityProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ElasticPoolDatabaseActivity represents the activity on an elastic pool. +type ElasticPoolDatabaseActivity struct { + // Location - The geo-location where the resource lives + Location *string `json:"location,omitempty"` + // ElasticPoolDatabaseActivityProperties - The properties representing the resource. + *ElasticPoolDatabaseActivityProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ElasticPoolDatabaseActivity. +func (epda ElasticPoolDatabaseActivity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if epda.Location != nil { + objectMap["location"] = epda.Location + } + if epda.ElasticPoolDatabaseActivityProperties != nil { + objectMap["properties"] = epda.ElasticPoolDatabaseActivityProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ElasticPoolDatabaseActivity struct. +func (epda *ElasticPoolDatabaseActivity) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + epda.Location = &location + } + case "properties": + if v != nil { + var elasticPoolDatabaseActivityProperties ElasticPoolDatabaseActivityProperties + err = json.Unmarshal(*v, &elasticPoolDatabaseActivityProperties) + if err != nil { + return err + } + epda.ElasticPoolDatabaseActivityProperties = &elasticPoolDatabaseActivityProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + epda.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + epda.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + epda.Type = &typeVar + } + } + } + + return nil +} + +// ElasticPoolDatabaseActivityListResult represents the response to a list elastic pool database activity +// request. +type ElasticPoolDatabaseActivityListResult struct { + autorest.Response `json:"-"` + // Value - The list of elastic pool database activities. + Value *[]ElasticPoolDatabaseActivity `json:"value,omitempty"` +} + +// ElasticPoolDatabaseActivityProperties represents the properties of an elastic pool database activity. +type ElasticPoolDatabaseActivityProperties struct { + // DatabaseName - READ-ONLY; The database name. + DatabaseName *string `json:"databaseName,omitempty"` + // EndTime - READ-ONLY; The time the operation finished (ISO8601 format). + EndTime *date.Time `json:"endTime,omitempty"` + // ErrorCode - READ-ONLY; The error code if available. + ErrorCode *int32 `json:"errorCode,omitempty"` + // ErrorMessage - READ-ONLY; The error message if available. + ErrorMessage *string `json:"errorMessage,omitempty"` + // ErrorSeverity - READ-ONLY; The error severity if available. + ErrorSeverity *int32 `json:"errorSeverity,omitempty"` + // Operation - READ-ONLY; The operation name. + Operation *string `json:"operation,omitempty"` + // OperationID - READ-ONLY; The unique operation ID. + OperationID *uuid.UUID `json:"operationId,omitempty"` + // PercentComplete - READ-ONLY; The percentage complete if available. + PercentComplete *int32 `json:"percentComplete,omitempty"` + // RequestedElasticPoolName - READ-ONLY; The name for the elastic pool the database is moving into if available. + RequestedElasticPoolName *string `json:"requestedElasticPoolName,omitempty"` + // CurrentElasticPoolName - READ-ONLY; The name of the current elastic pool the database is in if available. + CurrentElasticPoolName *string `json:"currentElasticPoolName,omitempty"` + // CurrentServiceObjective - READ-ONLY; The name of the current service objective if available. + CurrentServiceObjective *string `json:"currentServiceObjective,omitempty"` + // RequestedServiceObjective - READ-ONLY; The name of the requested service objective if available. + RequestedServiceObjective *string `json:"requestedServiceObjective,omitempty"` + // ServerName - READ-ONLY; The name of the server the elastic pool is in. + ServerName *string `json:"serverName,omitempty"` + // StartTime - READ-ONLY; The time the operation started (ISO8601 format). + StartTime *date.Time `json:"startTime,omitempty"` + // State - READ-ONLY; The current state of the operation. + State *string `json:"state,omitempty"` +} + +// MarshalJSON is the custom marshaler for ElasticPoolDatabaseActivityProperties. +func (epdap ElasticPoolDatabaseActivityProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ElasticPoolEditionCapability the elastic pool edition capability. +type ElasticPoolEditionCapability struct { + // Name - READ-ONLY; The elastic pool edition name. + Name *string `json:"name,omitempty"` + // SupportedElasticPoolPerformanceLevels - READ-ONLY; The list of supported elastic pool DTU levels for the edition. + SupportedElasticPoolPerformanceLevels *[]ElasticPoolPerformanceLevelCapability `json:"supportedElasticPoolPerformanceLevels,omitempty"` + // ZoneRedundant - READ-ONLY; Whether or not zone redundancy is supported for the edition. + ZoneRedundant *bool `json:"zoneRedundant,omitempty"` + // Status - READ-ONLY; The status of the capability. Possible values include: 'CapabilityStatusVisible', 'CapabilityStatusAvailable', 'CapabilityStatusDefault', 'CapabilityStatusDisabled' + Status CapabilityStatus `json:"status,omitempty"` + // Reason - The reason for the capability not being available. + Reason *string `json:"reason,omitempty"` +} + +// MarshalJSON is the custom marshaler for ElasticPoolEditionCapability. +func (epec ElasticPoolEditionCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if epec.Reason != nil { + objectMap["reason"] = epec.Reason + } + return json.Marshal(objectMap) +} + +// ElasticPoolListResult the result of an elastic pool list request. +type ElasticPoolListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]ElasticPool `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for ElasticPoolListResult. +func (eplr ElasticPoolListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ElasticPoolListResultIterator provides access to a complete listing of ElasticPool values. +type ElasticPoolListResultIterator struct { + i int + page ElasticPoolListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *ElasticPoolListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ElasticPoolListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ElasticPoolListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ElasticPoolListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter ElasticPoolListResultIterator) Response() ElasticPoolListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter ElasticPoolListResultIterator) Value() ElasticPool { + if !iter.page.NotDone() { + return ElasticPool{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ElasticPoolListResultIterator type. +func NewElasticPoolListResultIterator(page ElasticPoolListResultPage) ElasticPoolListResultIterator { + return ElasticPoolListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (eplr ElasticPoolListResult) IsEmpty() bool { + return eplr.Value == nil || len(*eplr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (eplr ElasticPoolListResult) hasNextLink() bool { + return eplr.NextLink != nil && len(*eplr.NextLink) != 0 +} + +// elasticPoolListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (eplr ElasticPoolListResult) elasticPoolListResultPreparer(ctx context.Context) (*http.Request, error) { + if !eplr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(eplr.NextLink))) +} + +// ElasticPoolListResultPage contains a page of ElasticPool values. +type ElasticPoolListResultPage struct { + fn func(context.Context, ElasticPoolListResult) (ElasticPoolListResult, error) + eplr ElasticPoolListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *ElasticPoolListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ElasticPoolListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.eplr) + if err != nil { + return err + } + page.eplr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *ElasticPoolListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ElasticPoolListResultPage) NotDone() bool { + return !page.eplr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ElasticPoolListResultPage) Response() ElasticPoolListResult { + return page.eplr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ElasticPoolListResultPage) Values() []ElasticPool { + if page.eplr.IsEmpty() { + return nil + } + return *page.eplr.Value +} + +// Creates a new instance of the ElasticPoolListResultPage type. +func NewElasticPoolListResultPage(cur ElasticPoolListResult, getNextPage func(context.Context, ElasticPoolListResult) (ElasticPoolListResult, error)) ElasticPoolListResultPage { + return ElasticPoolListResultPage{ + fn: getNextPage, + eplr: cur, + } +} + +// ElasticPoolOperation a elastic pool operation. +type ElasticPoolOperation struct { + // ElasticPoolOperationProperties - Resource properties. + *ElasticPoolOperationProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ElasticPoolOperation. +func (epo ElasticPoolOperation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if epo.ElasticPoolOperationProperties != nil { + objectMap["properties"] = epo.ElasticPoolOperationProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ElasticPoolOperation struct. +func (epo *ElasticPoolOperation) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var elasticPoolOperationProperties ElasticPoolOperationProperties + err = json.Unmarshal(*v, &elasticPoolOperationProperties) + if err != nil { + return err + } + epo.ElasticPoolOperationProperties = &elasticPoolOperationProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + epo.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + epo.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + epo.Type = &typeVar + } + } + } + + return nil +} + +// ElasticPoolOperationListResult the response to a list elastic pool operations request +type ElasticPoolOperationListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]ElasticPoolOperation `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for ElasticPoolOperationListResult. +func (epolr ElasticPoolOperationListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ElasticPoolOperationListResultIterator provides access to a complete listing of ElasticPoolOperation +// values. +type ElasticPoolOperationListResultIterator struct { + i int + page ElasticPoolOperationListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *ElasticPoolOperationListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ElasticPoolOperationListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ElasticPoolOperationListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ElasticPoolOperationListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter ElasticPoolOperationListResultIterator) Response() ElasticPoolOperationListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter ElasticPoolOperationListResultIterator) Value() ElasticPoolOperation { + if !iter.page.NotDone() { + return ElasticPoolOperation{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ElasticPoolOperationListResultIterator type. +func NewElasticPoolOperationListResultIterator(page ElasticPoolOperationListResultPage) ElasticPoolOperationListResultIterator { + return ElasticPoolOperationListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (epolr ElasticPoolOperationListResult) IsEmpty() bool { + return epolr.Value == nil || len(*epolr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (epolr ElasticPoolOperationListResult) hasNextLink() bool { + return epolr.NextLink != nil && len(*epolr.NextLink) != 0 +} + +// elasticPoolOperationListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (epolr ElasticPoolOperationListResult) elasticPoolOperationListResultPreparer(ctx context.Context) (*http.Request, error) { + if !epolr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(epolr.NextLink))) +} + +// ElasticPoolOperationListResultPage contains a page of ElasticPoolOperation values. +type ElasticPoolOperationListResultPage struct { + fn func(context.Context, ElasticPoolOperationListResult) (ElasticPoolOperationListResult, error) + epolr ElasticPoolOperationListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *ElasticPoolOperationListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ElasticPoolOperationListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.epolr) + if err != nil { + return err + } + page.epolr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *ElasticPoolOperationListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ElasticPoolOperationListResultPage) NotDone() bool { + return !page.epolr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ElasticPoolOperationListResultPage) Response() ElasticPoolOperationListResult { + return page.epolr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ElasticPoolOperationListResultPage) Values() []ElasticPoolOperation { + if page.epolr.IsEmpty() { + return nil + } + return *page.epolr.Value +} + +// Creates a new instance of the ElasticPoolOperationListResultPage type. +func NewElasticPoolOperationListResultPage(cur ElasticPoolOperationListResult, getNextPage func(context.Context, ElasticPoolOperationListResult) (ElasticPoolOperationListResult, error)) ElasticPoolOperationListResultPage { + return ElasticPoolOperationListResultPage{ + fn: getNextPage, + epolr: cur, + } +} + +// ElasticPoolOperationProperties the properties of a elastic pool operation. +type ElasticPoolOperationProperties struct { + // ElasticPoolName - READ-ONLY; The name of the elastic pool the operation is being performed on. + ElasticPoolName *string `json:"elasticPoolName,omitempty"` + // Operation - READ-ONLY; The name of operation. + Operation *string `json:"operation,omitempty"` + // OperationFriendlyName - READ-ONLY; The friendly name of operation. + OperationFriendlyName *string `json:"operationFriendlyName,omitempty"` + // PercentComplete - READ-ONLY; The percentage of the operation completed. + PercentComplete *int32 `json:"percentComplete,omitempty"` + // ServerName - READ-ONLY; The name of the server. + ServerName *string `json:"serverName,omitempty"` + // StartTime - READ-ONLY; The operation start time. + StartTime *date.Time `json:"startTime,omitempty"` + // State - READ-ONLY; The operation state. + State *string `json:"state,omitempty"` + // ErrorCode - READ-ONLY; The operation error code. + ErrorCode *int32 `json:"errorCode,omitempty"` + // ErrorDescription - READ-ONLY; The operation error description. + ErrorDescription *string `json:"errorDescription,omitempty"` + // ErrorSeverity - READ-ONLY; The operation error severity. + ErrorSeverity *int32 `json:"errorSeverity,omitempty"` + // IsUserError - READ-ONLY; Whether or not the error is a user error. + IsUserError *bool `json:"isUserError,omitempty"` + // EstimatedCompletionTime - READ-ONLY; The estimated completion time of the operation. + EstimatedCompletionTime *date.Time `json:"estimatedCompletionTime,omitempty"` + // Description - READ-ONLY; The operation description. + Description *string `json:"description,omitempty"` + // IsCancellable - READ-ONLY; Whether the operation can be cancelled. + IsCancellable *bool `json:"isCancellable,omitempty"` +} + +// MarshalJSON is the custom marshaler for ElasticPoolOperationProperties. +func (epop ElasticPoolOperationProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ElasticPoolPerDatabaseMaxPerformanceLevelCapability the max per-database performance level capability. +type ElasticPoolPerDatabaseMaxPerformanceLevelCapability struct { + // Limit - READ-ONLY; The maximum performance level per database. + Limit *float64 `json:"limit,omitempty"` + // Unit - READ-ONLY; Unit type used to measure performance level. Possible values include: 'PerformanceLevelUnitDTU', 'PerformanceLevelUnitVCores' + Unit PerformanceLevelUnit `json:"unit,omitempty"` + // SupportedPerDatabaseMinPerformanceLevels - READ-ONLY; The list of supported min database performance levels. + SupportedPerDatabaseMinPerformanceLevels *[]ElasticPoolPerDatabaseMinPerformanceLevelCapability `json:"supportedPerDatabaseMinPerformanceLevels,omitempty"` + // Status - READ-ONLY; The status of the capability. Possible values include: 'CapabilityStatusVisible', 'CapabilityStatusAvailable', 'CapabilityStatusDefault', 'CapabilityStatusDisabled' + Status CapabilityStatus `json:"status,omitempty"` + // Reason - The reason for the capability not being available. + Reason *string `json:"reason,omitempty"` +} + +// MarshalJSON is the custom marshaler for ElasticPoolPerDatabaseMaxPerformanceLevelCapability. +func (eppdmplc ElasticPoolPerDatabaseMaxPerformanceLevelCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if eppdmplc.Reason != nil { + objectMap["reason"] = eppdmplc.Reason + } + return json.Marshal(objectMap) +} + +// ElasticPoolPerDatabaseMinPerformanceLevelCapability the minimum per-database performance level +// capability. +type ElasticPoolPerDatabaseMinPerformanceLevelCapability struct { + // Limit - READ-ONLY; The minimum performance level per database. + Limit *float64 `json:"limit,omitempty"` + // Unit - READ-ONLY; Unit type used to measure performance level. Possible values include: 'PerformanceLevelUnitDTU', 'PerformanceLevelUnitVCores' + Unit PerformanceLevelUnit `json:"unit,omitempty"` + // Status - READ-ONLY; The status of the capability. Possible values include: 'CapabilityStatusVisible', 'CapabilityStatusAvailable', 'CapabilityStatusDefault', 'CapabilityStatusDisabled' + Status CapabilityStatus `json:"status,omitempty"` + // Reason - The reason for the capability not being available. + Reason *string `json:"reason,omitempty"` +} + +// MarshalJSON is the custom marshaler for ElasticPoolPerDatabaseMinPerformanceLevelCapability. +func (eppdmplc ElasticPoolPerDatabaseMinPerformanceLevelCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if eppdmplc.Reason != nil { + objectMap["reason"] = eppdmplc.Reason + } + return json.Marshal(objectMap) +} + +// ElasticPoolPerDatabaseSettings per database settings of an elastic pool. +type ElasticPoolPerDatabaseSettings struct { + // MinCapacity - The minimum capacity all databases are guaranteed. + MinCapacity *float64 `json:"minCapacity,omitempty"` + // MaxCapacity - The maximum capacity any one database can consume. + MaxCapacity *float64 `json:"maxCapacity,omitempty"` +} + +// ElasticPoolPerformanceLevelCapability the Elastic Pool performance level capability. +type ElasticPoolPerformanceLevelCapability struct { + // PerformanceLevel - READ-ONLY; The performance level for the pool. + PerformanceLevel *PerformanceLevelCapability `json:"performanceLevel,omitempty"` + // Sku - READ-ONLY; The sku. + Sku *Sku `json:"sku,omitempty"` + // SupportedLicenseTypes - READ-ONLY; List of supported license types. + SupportedLicenseTypes *[]LicenseTypeCapability `json:"supportedLicenseTypes,omitempty"` + // MaxDatabaseCount - READ-ONLY; The maximum number of databases supported. + MaxDatabaseCount *int32 `json:"maxDatabaseCount,omitempty"` + // IncludedMaxSize - READ-ONLY; The included (free) max size for this performance level. + IncludedMaxSize *MaxSizeCapability `json:"includedMaxSize,omitempty"` + // SupportedMaxSizes - READ-ONLY; The list of supported max sizes. + SupportedMaxSizes *[]MaxSizeRangeCapability `json:"supportedMaxSizes,omitempty"` + // SupportedPerDatabaseMaxSizes - READ-ONLY; The list of supported per database max sizes. + SupportedPerDatabaseMaxSizes *[]MaxSizeRangeCapability `json:"supportedPerDatabaseMaxSizes,omitempty"` + // SupportedPerDatabaseMaxPerformanceLevels - READ-ONLY; The list of supported per database max performance levels. + SupportedPerDatabaseMaxPerformanceLevels *[]ElasticPoolPerDatabaseMaxPerformanceLevelCapability `json:"supportedPerDatabaseMaxPerformanceLevels,omitempty"` + // ZoneRedundant - READ-ONLY; Whether or not zone redundancy is supported for the performance level. + ZoneRedundant *bool `json:"zoneRedundant,omitempty"` + // SupportedMaintenanceConfigurations - READ-ONLY; List of supported maintenance configurations + SupportedMaintenanceConfigurations *[]MaintenanceConfigurationCapability `json:"supportedMaintenanceConfigurations,omitempty"` + // Status - READ-ONLY; The status of the capability. Possible values include: 'CapabilityStatusVisible', 'CapabilityStatusAvailable', 'CapabilityStatusDefault', 'CapabilityStatusDisabled' + Status CapabilityStatus `json:"status,omitempty"` + // Reason - The reason for the capability not being available. + Reason *string `json:"reason,omitempty"` +} + +// MarshalJSON is the custom marshaler for ElasticPoolPerformanceLevelCapability. +func (epplc ElasticPoolPerformanceLevelCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if epplc.Reason != nil { + objectMap["reason"] = epplc.Reason + } + return json.Marshal(objectMap) +} + +// ElasticPoolProperties properties of an elastic pool +type ElasticPoolProperties struct { + // State - READ-ONLY; The state of the elastic pool. Possible values include: 'ElasticPoolStateCreating', 'ElasticPoolStateReady', 'ElasticPoolStateDisabled' + State ElasticPoolState `json:"state,omitempty"` + // CreationDate - READ-ONLY; The creation date of the elastic pool (ISO8601 format). + CreationDate *date.Time `json:"creationDate,omitempty"` + // MaxSizeBytes - The storage limit for the database elastic pool in bytes. + MaxSizeBytes *int64 `json:"maxSizeBytes,omitempty"` + // PerDatabaseSettings - The per database settings for the elastic pool. + PerDatabaseSettings *ElasticPoolPerDatabaseSettings `json:"perDatabaseSettings,omitempty"` + // ZoneRedundant - Whether or not this elastic pool is zone redundant, which means the replicas of this elastic pool will be spread across multiple availability zones. + ZoneRedundant *bool `json:"zoneRedundant,omitempty"` + // LicenseType - The license type to apply for this elastic pool. Possible values include: 'ElasticPoolLicenseTypeLicenseIncluded', 'ElasticPoolLicenseTypeBasePrice' + LicenseType ElasticPoolLicenseType `json:"licenseType,omitempty"` + // MaintenanceConfigurationID - Maintenance configuration id assigned to the elastic pool. This configuration defines the period when the maintenance updates will will occur. + MaintenanceConfigurationID *string `json:"maintenanceConfigurationId,omitempty"` +} + +// MarshalJSON is the custom marshaler for ElasticPoolProperties. +func (epp ElasticPoolProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if epp.MaxSizeBytes != nil { + objectMap["maxSizeBytes"] = epp.MaxSizeBytes + } + if epp.PerDatabaseSettings != nil { + objectMap["perDatabaseSettings"] = epp.PerDatabaseSettings + } + if epp.ZoneRedundant != nil { + objectMap["zoneRedundant"] = epp.ZoneRedundant + } + if epp.LicenseType != "" { + objectMap["licenseType"] = epp.LicenseType + } + if epp.MaintenanceConfigurationID != nil { + objectMap["maintenanceConfigurationId"] = epp.MaintenanceConfigurationID + } + return json.Marshal(objectMap) +} + +// ElasticPoolsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type ElasticPoolsCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ElasticPoolsClient) (ElasticPool, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ElasticPoolsCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ElasticPoolsCreateOrUpdateFuture.Result. +func (future *ElasticPoolsCreateOrUpdateFuture) result(client ElasticPoolsClient) (ep ElasticPool, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ep.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ElasticPoolsCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if ep.Response.Response, err = future.GetResult(sender); err == nil && ep.Response.Response.StatusCode != http.StatusNoContent { + ep, err = client.CreateOrUpdateResponder(ep.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsCreateOrUpdateFuture", "Result", ep.Response.Response, "Failure responding to request") + } + } + return +} + +// ElasticPoolsDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ElasticPoolsDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ElasticPoolsClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ElasticPoolsDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ElasticPoolsDeleteFuture.Result. +func (future *ElasticPoolsDeleteFuture) result(client ElasticPoolsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ElasticPoolsDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// ElasticPoolsFailoverFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ElasticPoolsFailoverFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ElasticPoolsClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ElasticPoolsFailoverFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ElasticPoolsFailoverFuture.Result. +func (future *ElasticPoolsFailoverFuture) result(client ElasticPoolsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsFailoverFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ElasticPoolsFailoverFuture") + return + } + ar.Response = future.Response() + return +} + +// ElasticPoolsUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ElasticPoolsUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ElasticPoolsClient) (ElasticPool, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ElasticPoolsUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ElasticPoolsUpdateFuture.Result. +func (future *ElasticPoolsUpdateFuture) result(client ElasticPoolsClient) (ep ElasticPool, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ep.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ElasticPoolsUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if ep.Response.Response, err = future.GetResult(sender); err == nil && ep.Response.Response.StatusCode != http.StatusNoContent { + ep, err = client.UpdateResponder(ep.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ElasticPoolsUpdateFuture", "Result", ep.Response.Response, "Failure responding to request") + } + } + return +} + +// ElasticPoolUpdate an elastic pool update. +type ElasticPoolUpdate struct { + Sku *Sku `json:"sku,omitempty"` + // ElasticPoolUpdateProperties - Resource properties. + *ElasticPoolUpdateProperties `json:"properties,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for ElasticPoolUpdate. +func (epu ElasticPoolUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if epu.Sku != nil { + objectMap["sku"] = epu.Sku + } + if epu.ElasticPoolUpdateProperties != nil { + objectMap["properties"] = epu.ElasticPoolUpdateProperties + } + if epu.Tags != nil { + objectMap["tags"] = epu.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ElasticPoolUpdate struct. +func (epu *ElasticPoolUpdate) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "sku": + if v != nil { + var sku Sku + err = json.Unmarshal(*v, &sku) + if err != nil { + return err + } + epu.Sku = &sku + } + case "properties": + if v != nil { + var elasticPoolUpdateProperties ElasticPoolUpdateProperties + err = json.Unmarshal(*v, &elasticPoolUpdateProperties) + if err != nil { + return err + } + epu.ElasticPoolUpdateProperties = &elasticPoolUpdateProperties + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + epu.Tags = tags + } + } + } + + return nil +} + +// ElasticPoolUpdateProperties properties of an elastic pool +type ElasticPoolUpdateProperties struct { + // MaxSizeBytes - The storage limit for the database elastic pool in bytes. + MaxSizeBytes *int64 `json:"maxSizeBytes,omitempty"` + // PerDatabaseSettings - The per database settings for the elastic pool. + PerDatabaseSettings *ElasticPoolPerDatabaseSettings `json:"perDatabaseSettings,omitempty"` + // ZoneRedundant - Whether or not this elastic pool is zone redundant, which means the replicas of this elastic pool will be spread across multiple availability zones. + ZoneRedundant *bool `json:"zoneRedundant,omitempty"` + // LicenseType - The license type to apply for this elastic pool. Possible values include: 'ElasticPoolLicenseTypeLicenseIncluded', 'ElasticPoolLicenseTypeBasePrice' + LicenseType ElasticPoolLicenseType `json:"licenseType,omitempty"` + // MaintenanceConfigurationID - Maintenance configuration id assigned to the elastic pool. This configuration defines the period when the maintenance updates will will occur. + MaintenanceConfigurationID *string `json:"maintenanceConfigurationId,omitempty"` +} + +// EncryptionProtector the server encryption protector. +type EncryptionProtector struct { + autorest.Response `json:"-"` + // Kind - READ-ONLY; Kind of encryption protector. This is metadata used for the Azure portal experience. + Kind *string `json:"kind,omitempty"` + // Location - READ-ONLY; Resource location. + Location *string `json:"location,omitempty"` + // EncryptionProtectorProperties - Resource properties. + *EncryptionProtectorProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for EncryptionProtector. +func (ep EncryptionProtector) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ep.EncryptionProtectorProperties != nil { + objectMap["properties"] = ep.EncryptionProtectorProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for EncryptionProtector struct. +func (ep *EncryptionProtector) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "kind": + if v != nil { + var kind string + err = json.Unmarshal(*v, &kind) + if err != nil { + return err + } + ep.Kind = &kind + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + ep.Location = &location + } + case "properties": + if v != nil { + var encryptionProtectorProperties EncryptionProtectorProperties + err = json.Unmarshal(*v, &encryptionProtectorProperties) + if err != nil { + return err + } + ep.EncryptionProtectorProperties = &encryptionProtectorProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + ep.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ep.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ep.Type = &typeVar + } + } + } + + return nil +} + +// EncryptionProtectorListResult a list of server encryption protectors. +type EncryptionProtectorListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]EncryptionProtector `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for EncryptionProtectorListResult. +func (eplr EncryptionProtectorListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// EncryptionProtectorListResultIterator provides access to a complete listing of EncryptionProtector +// values. +type EncryptionProtectorListResultIterator struct { + i int + page EncryptionProtectorListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *EncryptionProtectorListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/EncryptionProtectorListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *EncryptionProtectorListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter EncryptionProtectorListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter EncryptionProtectorListResultIterator) Response() EncryptionProtectorListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter EncryptionProtectorListResultIterator) Value() EncryptionProtector { + if !iter.page.NotDone() { + return EncryptionProtector{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the EncryptionProtectorListResultIterator type. +func NewEncryptionProtectorListResultIterator(page EncryptionProtectorListResultPage) EncryptionProtectorListResultIterator { + return EncryptionProtectorListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (eplr EncryptionProtectorListResult) IsEmpty() bool { + return eplr.Value == nil || len(*eplr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (eplr EncryptionProtectorListResult) hasNextLink() bool { + return eplr.NextLink != nil && len(*eplr.NextLink) != 0 +} + +// encryptionProtectorListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (eplr EncryptionProtectorListResult) encryptionProtectorListResultPreparer(ctx context.Context) (*http.Request, error) { + if !eplr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(eplr.NextLink))) +} + +// EncryptionProtectorListResultPage contains a page of EncryptionProtector values. +type EncryptionProtectorListResultPage struct { + fn func(context.Context, EncryptionProtectorListResult) (EncryptionProtectorListResult, error) + eplr EncryptionProtectorListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *EncryptionProtectorListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/EncryptionProtectorListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.eplr) + if err != nil { + return err + } + page.eplr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *EncryptionProtectorListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page EncryptionProtectorListResultPage) NotDone() bool { + return !page.eplr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page EncryptionProtectorListResultPage) Response() EncryptionProtectorListResult { + return page.eplr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page EncryptionProtectorListResultPage) Values() []EncryptionProtector { + if page.eplr.IsEmpty() { + return nil + } + return *page.eplr.Value +} + +// Creates a new instance of the EncryptionProtectorListResultPage type. +func NewEncryptionProtectorListResultPage(cur EncryptionProtectorListResult, getNextPage func(context.Context, EncryptionProtectorListResult) (EncryptionProtectorListResult, error)) EncryptionProtectorListResultPage { + return EncryptionProtectorListResultPage{ + fn: getNextPage, + eplr: cur, + } +} + +// EncryptionProtectorProperties properties for an encryption protector execution. +type EncryptionProtectorProperties struct { + // Subregion - READ-ONLY; Subregion of the encryption protector. + Subregion *string `json:"subregion,omitempty"` + // ServerKeyName - The name of the server key. + ServerKeyName *string `json:"serverKeyName,omitempty"` + // ServerKeyType - The encryption protector type like 'ServiceManaged', 'AzureKeyVault'. Possible values include: 'ServerKeyTypeServiceManaged', 'ServerKeyTypeAzureKeyVault' + ServerKeyType ServerKeyType `json:"serverKeyType,omitempty"` + // URI - READ-ONLY; The URI of the server key. + URI *string `json:"uri,omitempty"` + // Thumbprint - READ-ONLY; Thumbprint of the server key. + Thumbprint *string `json:"thumbprint,omitempty"` + // AutoRotationEnabled - Key auto rotation opt-in flag. Either true or false. + AutoRotationEnabled *bool `json:"autoRotationEnabled,omitempty"` +} + +// MarshalJSON is the custom marshaler for EncryptionProtectorProperties. +func (epp EncryptionProtectorProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if epp.ServerKeyName != nil { + objectMap["serverKeyName"] = epp.ServerKeyName + } + if epp.ServerKeyType != "" { + objectMap["serverKeyType"] = epp.ServerKeyType + } + if epp.AutoRotationEnabled != nil { + objectMap["autoRotationEnabled"] = epp.AutoRotationEnabled + } + return json.Marshal(objectMap) +} + +// EncryptionProtectorsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type EncryptionProtectorsCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(EncryptionProtectorsClient) (EncryptionProtector, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *EncryptionProtectorsCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for EncryptionProtectorsCreateOrUpdateFuture.Result. +func (future *EncryptionProtectorsCreateOrUpdateFuture) result(client EncryptionProtectorsClient) (ep EncryptionProtector, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.EncryptionProtectorsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ep.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.EncryptionProtectorsCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if ep.Response.Response, err = future.GetResult(sender); err == nil && ep.Response.Response.StatusCode != http.StatusNoContent { + ep, err = client.CreateOrUpdateResponder(ep.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.EncryptionProtectorsCreateOrUpdateFuture", "Result", ep.Response.Response, "Failure responding to request") + } + } + return +} + +// EncryptionProtectorsRevalidateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type EncryptionProtectorsRevalidateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(EncryptionProtectorsClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *EncryptionProtectorsRevalidateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for EncryptionProtectorsRevalidateFuture.Result. +func (future *EncryptionProtectorsRevalidateFuture) result(client EncryptionProtectorsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.EncryptionProtectorsRevalidateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.EncryptionProtectorsRevalidateFuture") + return + } + ar.Response = future.Response() + return +} + +// ExportDatabaseDefinition contains the information necessary to perform export database operation. +type ExportDatabaseDefinition struct { + // StorageKeyType - Storage key type. Possible values include: 'StorageKeyTypeSharedAccessKey', 'StorageKeyTypeStorageAccessKey' + StorageKeyType StorageKeyType `json:"storageKeyType,omitempty"` + // StorageKey - Storage key. + StorageKey *string `json:"storageKey,omitempty"` + // StorageURI - Storage Uri. + StorageURI *string `json:"storageUri,omitempty"` + // AdministratorLogin - Administrator login name. + AdministratorLogin *string `json:"administratorLogin,omitempty"` + // AdministratorLoginPassword - Administrator login password. + AdministratorLoginPassword *string `json:"administratorLoginPassword,omitempty"` + // AuthenticationType - Authentication type. + AuthenticationType *string `json:"authenticationType,omitempty"` + // NetworkIsolation - Optional resource information to enable network isolation for request. + NetworkIsolation *NetworkIsolationSettings `json:"networkIsolation,omitempty"` +} + +// ExtendedDatabaseBlobAuditingPolicy an extended database blob auditing policy. +type ExtendedDatabaseBlobAuditingPolicy struct { + autorest.Response `json:"-"` + // ExtendedDatabaseBlobAuditingPolicyProperties - Resource properties. + *ExtendedDatabaseBlobAuditingPolicyProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ExtendedDatabaseBlobAuditingPolicy. +func (edbap ExtendedDatabaseBlobAuditingPolicy) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if edbap.ExtendedDatabaseBlobAuditingPolicyProperties != nil { + objectMap["properties"] = edbap.ExtendedDatabaseBlobAuditingPolicyProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ExtendedDatabaseBlobAuditingPolicy struct. +func (edbap *ExtendedDatabaseBlobAuditingPolicy) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var extendedDatabaseBlobAuditingPolicyProperties ExtendedDatabaseBlobAuditingPolicyProperties + err = json.Unmarshal(*v, &extendedDatabaseBlobAuditingPolicyProperties) + if err != nil { + return err + } + edbap.ExtendedDatabaseBlobAuditingPolicyProperties = &extendedDatabaseBlobAuditingPolicyProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + edbap.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + edbap.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + edbap.Type = &typeVar + } + } + } + + return nil +} + +// ExtendedDatabaseBlobAuditingPolicyListResult a list of database extended auditing settings. +type ExtendedDatabaseBlobAuditingPolicyListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]ExtendedDatabaseBlobAuditingPolicy `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for ExtendedDatabaseBlobAuditingPolicyListResult. +func (edbaplr ExtendedDatabaseBlobAuditingPolicyListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ExtendedDatabaseBlobAuditingPolicyListResultIterator provides access to a complete listing of +// ExtendedDatabaseBlobAuditingPolicy values. +type ExtendedDatabaseBlobAuditingPolicyListResultIterator struct { + i int + page ExtendedDatabaseBlobAuditingPolicyListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *ExtendedDatabaseBlobAuditingPolicyListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ExtendedDatabaseBlobAuditingPolicyListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ExtendedDatabaseBlobAuditingPolicyListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ExtendedDatabaseBlobAuditingPolicyListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter ExtendedDatabaseBlobAuditingPolicyListResultIterator) Response() ExtendedDatabaseBlobAuditingPolicyListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter ExtendedDatabaseBlobAuditingPolicyListResultIterator) Value() ExtendedDatabaseBlobAuditingPolicy { + if !iter.page.NotDone() { + return ExtendedDatabaseBlobAuditingPolicy{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ExtendedDatabaseBlobAuditingPolicyListResultIterator type. +func NewExtendedDatabaseBlobAuditingPolicyListResultIterator(page ExtendedDatabaseBlobAuditingPolicyListResultPage) ExtendedDatabaseBlobAuditingPolicyListResultIterator { + return ExtendedDatabaseBlobAuditingPolicyListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (edbaplr ExtendedDatabaseBlobAuditingPolicyListResult) IsEmpty() bool { + return edbaplr.Value == nil || len(*edbaplr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (edbaplr ExtendedDatabaseBlobAuditingPolicyListResult) hasNextLink() bool { + return edbaplr.NextLink != nil && len(*edbaplr.NextLink) != 0 +} + +// extendedDatabaseBlobAuditingPolicyListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (edbaplr ExtendedDatabaseBlobAuditingPolicyListResult) extendedDatabaseBlobAuditingPolicyListResultPreparer(ctx context.Context) (*http.Request, error) { + if !edbaplr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(edbaplr.NextLink))) +} + +// ExtendedDatabaseBlobAuditingPolicyListResultPage contains a page of ExtendedDatabaseBlobAuditingPolicy +// values. +type ExtendedDatabaseBlobAuditingPolicyListResultPage struct { + fn func(context.Context, ExtendedDatabaseBlobAuditingPolicyListResult) (ExtendedDatabaseBlobAuditingPolicyListResult, error) + edbaplr ExtendedDatabaseBlobAuditingPolicyListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *ExtendedDatabaseBlobAuditingPolicyListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ExtendedDatabaseBlobAuditingPolicyListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.edbaplr) + if err != nil { + return err + } + page.edbaplr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *ExtendedDatabaseBlobAuditingPolicyListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ExtendedDatabaseBlobAuditingPolicyListResultPage) NotDone() bool { + return !page.edbaplr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ExtendedDatabaseBlobAuditingPolicyListResultPage) Response() ExtendedDatabaseBlobAuditingPolicyListResult { + return page.edbaplr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ExtendedDatabaseBlobAuditingPolicyListResultPage) Values() []ExtendedDatabaseBlobAuditingPolicy { + if page.edbaplr.IsEmpty() { + return nil + } + return *page.edbaplr.Value +} + +// Creates a new instance of the ExtendedDatabaseBlobAuditingPolicyListResultPage type. +func NewExtendedDatabaseBlobAuditingPolicyListResultPage(cur ExtendedDatabaseBlobAuditingPolicyListResult, getNextPage func(context.Context, ExtendedDatabaseBlobAuditingPolicyListResult) (ExtendedDatabaseBlobAuditingPolicyListResult, error)) ExtendedDatabaseBlobAuditingPolicyListResultPage { + return ExtendedDatabaseBlobAuditingPolicyListResultPage{ + fn: getNextPage, + edbaplr: cur, + } +} + +// ExtendedDatabaseBlobAuditingPolicyProperties properties of an extended database blob auditing policy. +type ExtendedDatabaseBlobAuditingPolicyProperties struct { + // PredicateExpression - Specifies condition of where clause when creating an audit. + PredicateExpression *string `json:"predicateExpression,omitempty"` + // RetentionDays - Specifies the number of days to keep in the audit logs in the storage account. + RetentionDays *int32 `json:"retentionDays,omitempty"` + // AuditActionsAndGroups - Specifies the Actions-Groups and Actions to audit. + // + // The recommended set of action groups to use is the following combination - this will audit all the queries and stored procedures executed against the database, as well as successful and failed logins: + // + // BATCH_COMPLETED_GROUP, + // SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP, + // FAILED_DATABASE_AUTHENTICATION_GROUP. + // + // This above combination is also the set that is configured by default when enabling auditing from the Azure portal. + // + // The supported action groups to audit are (note: choose only specific groups that cover your auditing needs. Using unnecessary groups could lead to very large quantities of audit records): + // + // APPLICATION_ROLE_CHANGE_PASSWORD_GROUP + // BACKUP_RESTORE_GROUP + // DATABASE_LOGOUT_GROUP + // DATABASE_OBJECT_CHANGE_GROUP + // DATABASE_OBJECT_OWNERSHIP_CHANGE_GROUP + // DATABASE_OBJECT_PERMISSION_CHANGE_GROUP + // DATABASE_OPERATION_GROUP + // DATABASE_PERMISSION_CHANGE_GROUP + // DATABASE_PRINCIPAL_CHANGE_GROUP + // DATABASE_PRINCIPAL_IMPERSONATION_GROUP + // DATABASE_ROLE_MEMBER_CHANGE_GROUP + // FAILED_DATABASE_AUTHENTICATION_GROUP + // SCHEMA_OBJECT_ACCESS_GROUP + // SCHEMA_OBJECT_CHANGE_GROUP + // SCHEMA_OBJECT_OWNERSHIP_CHANGE_GROUP + // SCHEMA_OBJECT_PERMISSION_CHANGE_GROUP + // SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP + // USER_CHANGE_PASSWORD_GROUP + // BATCH_STARTED_GROUP + // BATCH_COMPLETED_GROUP + // + // These are groups that cover all sql statements and stored procedures executed against the database, and should not be used in combination with other groups as this will result in duplicate audit logs. + // + // For more information, see [Database-Level Audit Action Groups](https://docs.microsoft.com/en-us/sql/relational-databases/security/auditing/sql-server-audit-action-groups-and-actions#database-level-audit-action-groups). + // + // For Database auditing policy, specific Actions can also be specified (note that Actions cannot be specified for Server auditing policy). The supported actions to audit are: + // SELECT + // UPDATE + // INSERT + // DELETE + // EXECUTE + // RECEIVE + // REFERENCES + // + // The general form for defining an action to be audited is: + // {action} ON {object} BY {principal} + // + // Note that in the above format can refer to an object like a table, view, or stored procedure, or an entire database or schema. For the latter cases, the forms DATABASE::{db_name} and SCHEMA::{schema_name} are used, respectively. + // + // For example: + // SELECT on dbo.myTable by public + // SELECT on DATABASE::myDatabase by public + // SELECT on SCHEMA::mySchema by public + // + // For more information, see [Database-Level Audit Actions](https://docs.microsoft.com/en-us/sql/relational-databases/security/auditing/sql-server-audit-action-groups-and-actions#database-level-audit-actions) + AuditActionsAndGroups *[]string `json:"auditActionsAndGroups,omitempty"` + // IsStorageSecondaryKeyInUse - Specifies whether storageAccountAccessKey value is the storage's secondary key. + IsStorageSecondaryKeyInUse *bool `json:"isStorageSecondaryKeyInUse,omitempty"` + // IsAzureMonitorTargetEnabled - Specifies whether audit events are sent to Azure Monitor. + // In order to send the events to Azure Monitor, specify 'State' as 'Enabled' and 'IsAzureMonitorTargetEnabled' as true. + // + // When using REST API to configure auditing, Diagnostic Settings with 'SQLSecurityAuditEvents' diagnostic logs category on the database should be also created. + // Note that for server level audit you should use the 'master' database as {databaseName}. + // + // Diagnostic Settings URI format: + // PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/providers/microsoft.insights/diagnosticSettings/{settingsName}?api-version=2017-05-01-preview + // + // For more information, see [Diagnostic Settings REST API](https://go.microsoft.com/fwlink/?linkid=2033207) + // or [Diagnostic Settings PowerShell](https://go.microsoft.com/fwlink/?linkid=2033043) + IsAzureMonitorTargetEnabled *bool `json:"isAzureMonitorTargetEnabled,omitempty"` + // QueueDelayMs - Specifies the amount of time in milliseconds that can elapse before audit actions are forced to be processed. + // The default minimum value is 1000 (1 second). The maximum is 2,147,483,647. + QueueDelayMs *int32 `json:"queueDelayMs,omitempty"` + // State - Specifies the state of the audit. If state is Enabled, storageEndpoint or isAzureMonitorTargetEnabled are required. Possible values include: 'BlobAuditingPolicyStateEnabled', 'BlobAuditingPolicyStateDisabled' + State BlobAuditingPolicyState `json:"state,omitempty"` + // StorageEndpoint - Specifies the blob storage endpoint (e.g. https://MyAccount.blob.core.windows.net). If state is Enabled, storageEndpoint or isAzureMonitorTargetEnabled is required. + StorageEndpoint *string `json:"storageEndpoint,omitempty"` + // StorageAccountAccessKey - Specifies the identifier key of the auditing storage account. + // If state is Enabled and storageEndpoint is specified, not specifying the storageAccountAccessKey will use SQL server system-assigned managed identity to access the storage. + // Prerequisites for using managed identity authentication: + // 1. Assign SQL Server a system-assigned managed identity in Azure Active Directory (AAD). + // 2. Grant SQL Server identity access to the storage account by adding 'Storage Blob Data Contributor' RBAC role to the server identity. + // For more information, see [Auditing to storage using Managed Identity authentication](https://go.microsoft.com/fwlink/?linkid=2114355) + StorageAccountAccessKey *string `json:"storageAccountAccessKey,omitempty"` + // StorageAccountSubscriptionID - Specifies the blob storage subscription Id. + StorageAccountSubscriptionID *uuid.UUID `json:"storageAccountSubscriptionId,omitempty"` +} + +// ExtendedServerBlobAuditingPoliciesCreateOrUpdateFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type ExtendedServerBlobAuditingPoliciesCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ExtendedServerBlobAuditingPoliciesClient) (ExtendedServerBlobAuditingPolicy, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ExtendedServerBlobAuditingPoliciesCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ExtendedServerBlobAuditingPoliciesCreateOrUpdateFuture.Result. +func (future *ExtendedServerBlobAuditingPoliciesCreateOrUpdateFuture) result(client ExtendedServerBlobAuditingPoliciesClient) (esbap ExtendedServerBlobAuditingPolicy, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ExtendedServerBlobAuditingPoliciesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + esbap.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ExtendedServerBlobAuditingPoliciesCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if esbap.Response.Response, err = future.GetResult(sender); err == nil && esbap.Response.Response.StatusCode != http.StatusNoContent { + esbap, err = client.CreateOrUpdateResponder(esbap.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ExtendedServerBlobAuditingPoliciesCreateOrUpdateFuture", "Result", esbap.Response.Response, "Failure responding to request") + } + } + return +} + +// ExtendedServerBlobAuditingPolicy an extended server blob auditing policy. +type ExtendedServerBlobAuditingPolicy struct { + autorest.Response `json:"-"` + // ExtendedServerBlobAuditingPolicyProperties - Resource properties. + *ExtendedServerBlobAuditingPolicyProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ExtendedServerBlobAuditingPolicy. +func (esbap ExtendedServerBlobAuditingPolicy) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if esbap.ExtendedServerBlobAuditingPolicyProperties != nil { + objectMap["properties"] = esbap.ExtendedServerBlobAuditingPolicyProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ExtendedServerBlobAuditingPolicy struct. +func (esbap *ExtendedServerBlobAuditingPolicy) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var extendedServerBlobAuditingPolicyProperties ExtendedServerBlobAuditingPolicyProperties + err = json.Unmarshal(*v, &extendedServerBlobAuditingPolicyProperties) + if err != nil { + return err + } + esbap.ExtendedServerBlobAuditingPolicyProperties = &extendedServerBlobAuditingPolicyProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + esbap.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + esbap.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + esbap.Type = &typeVar + } + } + } + + return nil +} + +// ExtendedServerBlobAuditingPolicyListResult a list of server extended auditing settings. +type ExtendedServerBlobAuditingPolicyListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]ExtendedServerBlobAuditingPolicy `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for ExtendedServerBlobAuditingPolicyListResult. +func (esbaplr ExtendedServerBlobAuditingPolicyListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ExtendedServerBlobAuditingPolicyListResultIterator provides access to a complete listing of +// ExtendedServerBlobAuditingPolicy values. +type ExtendedServerBlobAuditingPolicyListResultIterator struct { + i int + page ExtendedServerBlobAuditingPolicyListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *ExtendedServerBlobAuditingPolicyListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ExtendedServerBlobAuditingPolicyListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ExtendedServerBlobAuditingPolicyListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ExtendedServerBlobAuditingPolicyListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter ExtendedServerBlobAuditingPolicyListResultIterator) Response() ExtendedServerBlobAuditingPolicyListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter ExtendedServerBlobAuditingPolicyListResultIterator) Value() ExtendedServerBlobAuditingPolicy { + if !iter.page.NotDone() { + return ExtendedServerBlobAuditingPolicy{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ExtendedServerBlobAuditingPolicyListResultIterator type. +func NewExtendedServerBlobAuditingPolicyListResultIterator(page ExtendedServerBlobAuditingPolicyListResultPage) ExtendedServerBlobAuditingPolicyListResultIterator { + return ExtendedServerBlobAuditingPolicyListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (esbaplr ExtendedServerBlobAuditingPolicyListResult) IsEmpty() bool { + return esbaplr.Value == nil || len(*esbaplr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (esbaplr ExtendedServerBlobAuditingPolicyListResult) hasNextLink() bool { + return esbaplr.NextLink != nil && len(*esbaplr.NextLink) != 0 +} + +// extendedServerBlobAuditingPolicyListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (esbaplr ExtendedServerBlobAuditingPolicyListResult) extendedServerBlobAuditingPolicyListResultPreparer(ctx context.Context) (*http.Request, error) { + if !esbaplr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(esbaplr.NextLink))) +} + +// ExtendedServerBlobAuditingPolicyListResultPage contains a page of ExtendedServerBlobAuditingPolicy +// values. +type ExtendedServerBlobAuditingPolicyListResultPage struct { + fn func(context.Context, ExtendedServerBlobAuditingPolicyListResult) (ExtendedServerBlobAuditingPolicyListResult, error) + esbaplr ExtendedServerBlobAuditingPolicyListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *ExtendedServerBlobAuditingPolicyListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ExtendedServerBlobAuditingPolicyListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.esbaplr) + if err != nil { + return err + } + page.esbaplr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *ExtendedServerBlobAuditingPolicyListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ExtendedServerBlobAuditingPolicyListResultPage) NotDone() bool { + return !page.esbaplr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ExtendedServerBlobAuditingPolicyListResultPage) Response() ExtendedServerBlobAuditingPolicyListResult { + return page.esbaplr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ExtendedServerBlobAuditingPolicyListResultPage) Values() []ExtendedServerBlobAuditingPolicy { + if page.esbaplr.IsEmpty() { + return nil + } + return *page.esbaplr.Value +} + +// Creates a new instance of the ExtendedServerBlobAuditingPolicyListResultPage type. +func NewExtendedServerBlobAuditingPolicyListResultPage(cur ExtendedServerBlobAuditingPolicyListResult, getNextPage func(context.Context, ExtendedServerBlobAuditingPolicyListResult) (ExtendedServerBlobAuditingPolicyListResult, error)) ExtendedServerBlobAuditingPolicyListResultPage { + return ExtendedServerBlobAuditingPolicyListResultPage{ + fn: getNextPage, + esbaplr: cur, + } +} + +// ExtendedServerBlobAuditingPolicyProperties properties of an extended server blob auditing policy. +type ExtendedServerBlobAuditingPolicyProperties struct { + // IsDevopsAuditEnabled - Specifies the state of devops audit. If state is Enabled, devops logs will be sent to Azure Monitor. + // In order to send the events to Azure Monitor, specify 'State' as 'Enabled', 'IsAzureMonitorTargetEnabled' as true and 'IsDevopsAuditEnabled' as true + // + // When using REST API to configure auditing, Diagnostic Settings with 'DevOpsOperationsAudit' diagnostic logs category on the master database should also be created. + // + // Diagnostic Settings URI format: + // PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Sql/servers/{serverName}/databases/master/providers/microsoft.insights/diagnosticSettings/{settingsName}?api-version=2017-05-01-preview + // + // For more information, see [Diagnostic Settings REST API](https://go.microsoft.com/fwlink/?linkid=2033207) + // or [Diagnostic Settings PowerShell](https://go.microsoft.com/fwlink/?linkid=2033043) + IsDevopsAuditEnabled *bool `json:"isDevopsAuditEnabled,omitempty"` + // PredicateExpression - Specifies condition of where clause when creating an audit. + PredicateExpression *string `json:"predicateExpression,omitempty"` + // RetentionDays - Specifies the number of days to keep in the audit logs in the storage account. + RetentionDays *int32 `json:"retentionDays,omitempty"` + // AuditActionsAndGroups - Specifies the Actions-Groups and Actions to audit. + // + // The recommended set of action groups to use is the following combination - this will audit all the queries and stored procedures executed against the database, as well as successful and failed logins: + // + // BATCH_COMPLETED_GROUP, + // SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP, + // FAILED_DATABASE_AUTHENTICATION_GROUP. + // + // This above combination is also the set that is configured by default when enabling auditing from the Azure portal. + // + // The supported action groups to audit are (note: choose only specific groups that cover your auditing needs. Using unnecessary groups could lead to very large quantities of audit records): + // + // APPLICATION_ROLE_CHANGE_PASSWORD_GROUP + // BACKUP_RESTORE_GROUP + // DATABASE_LOGOUT_GROUP + // DATABASE_OBJECT_CHANGE_GROUP + // DATABASE_OBJECT_OWNERSHIP_CHANGE_GROUP + // DATABASE_OBJECT_PERMISSION_CHANGE_GROUP + // DATABASE_OPERATION_GROUP + // DATABASE_PERMISSION_CHANGE_GROUP + // DATABASE_PRINCIPAL_CHANGE_GROUP + // DATABASE_PRINCIPAL_IMPERSONATION_GROUP + // DATABASE_ROLE_MEMBER_CHANGE_GROUP + // FAILED_DATABASE_AUTHENTICATION_GROUP + // SCHEMA_OBJECT_ACCESS_GROUP + // SCHEMA_OBJECT_CHANGE_GROUP + // SCHEMA_OBJECT_OWNERSHIP_CHANGE_GROUP + // SCHEMA_OBJECT_PERMISSION_CHANGE_GROUP + // SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP + // USER_CHANGE_PASSWORD_GROUP + // BATCH_STARTED_GROUP + // BATCH_COMPLETED_GROUP + // + // These are groups that cover all sql statements and stored procedures executed against the database, and should not be used in combination with other groups as this will result in duplicate audit logs. + // + // For more information, see [Database-Level Audit Action Groups](https://docs.microsoft.com/en-us/sql/relational-databases/security/auditing/sql-server-audit-action-groups-and-actions#database-level-audit-action-groups). + // + // For Database auditing policy, specific Actions can also be specified (note that Actions cannot be specified for Server auditing policy). The supported actions to audit are: + // SELECT + // UPDATE + // INSERT + // DELETE + // EXECUTE + // RECEIVE + // REFERENCES + // + // The general form for defining an action to be audited is: + // {action} ON {object} BY {principal} + // + // Note that in the above format can refer to an object like a table, view, or stored procedure, or an entire database or schema. For the latter cases, the forms DATABASE::{db_name} and SCHEMA::{schema_name} are used, respectively. + // + // For example: + // SELECT on dbo.myTable by public + // SELECT on DATABASE::myDatabase by public + // SELECT on SCHEMA::mySchema by public + // + // For more information, see [Database-Level Audit Actions](https://docs.microsoft.com/en-us/sql/relational-databases/security/auditing/sql-server-audit-action-groups-and-actions#database-level-audit-actions) + AuditActionsAndGroups *[]string `json:"auditActionsAndGroups,omitempty"` + // IsStorageSecondaryKeyInUse - Specifies whether storageAccountAccessKey value is the storage's secondary key. + IsStorageSecondaryKeyInUse *bool `json:"isStorageSecondaryKeyInUse,omitempty"` + // IsAzureMonitorTargetEnabled - Specifies whether audit events are sent to Azure Monitor. + // In order to send the events to Azure Monitor, specify 'State' as 'Enabled' and 'IsAzureMonitorTargetEnabled' as true. + // + // When using REST API to configure auditing, Diagnostic Settings with 'SQLSecurityAuditEvents' diagnostic logs category on the database should be also created. + // Note that for server level audit you should use the 'master' database as {databaseName}. + // + // Diagnostic Settings URI format: + // PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/providers/microsoft.insights/diagnosticSettings/{settingsName}?api-version=2017-05-01-preview + // + // For more information, see [Diagnostic Settings REST API](https://go.microsoft.com/fwlink/?linkid=2033207) + // or [Diagnostic Settings PowerShell](https://go.microsoft.com/fwlink/?linkid=2033043) + IsAzureMonitorTargetEnabled *bool `json:"isAzureMonitorTargetEnabled,omitempty"` + // QueueDelayMs - Specifies the amount of time in milliseconds that can elapse before audit actions are forced to be processed. + // The default minimum value is 1000 (1 second). The maximum is 2,147,483,647. + QueueDelayMs *int32 `json:"queueDelayMs,omitempty"` + // State - Specifies the state of the audit. If state is Enabled, storageEndpoint or isAzureMonitorTargetEnabled are required. Possible values include: 'BlobAuditingPolicyStateEnabled', 'BlobAuditingPolicyStateDisabled' + State BlobAuditingPolicyState `json:"state,omitempty"` + // StorageEndpoint - Specifies the blob storage endpoint (e.g. https://MyAccount.blob.core.windows.net). If state is Enabled, storageEndpoint or isAzureMonitorTargetEnabled is required. + StorageEndpoint *string `json:"storageEndpoint,omitempty"` + // StorageAccountAccessKey - Specifies the identifier key of the auditing storage account. + // If state is Enabled and storageEndpoint is specified, not specifying the storageAccountAccessKey will use SQL server system-assigned managed identity to access the storage. + // Prerequisites for using managed identity authentication: + // 1. Assign SQL Server a system-assigned managed identity in Azure Active Directory (AAD). + // 2. Grant SQL Server identity access to the storage account by adding 'Storage Blob Data Contributor' RBAC role to the server identity. + // For more information, see [Auditing to storage using Managed Identity authentication](https://go.microsoft.com/fwlink/?linkid=2114355) + StorageAccountAccessKey *string `json:"storageAccountAccessKey,omitempty"` + // StorageAccountSubscriptionID - Specifies the blob storage subscription Id. + StorageAccountSubscriptionID *uuid.UUID `json:"storageAccountSubscriptionId,omitempty"` +} + +// FailoverGroup a failover group. +type FailoverGroup struct { + autorest.Response `json:"-"` + // Location - READ-ONLY; Resource location. + Location *string `json:"location,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // FailoverGroupProperties - Resource properties. + *FailoverGroupProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for FailoverGroup. +func (fg FailoverGroup) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if fg.Tags != nil { + objectMap["tags"] = fg.Tags + } + if fg.FailoverGroupProperties != nil { + objectMap["properties"] = fg.FailoverGroupProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for FailoverGroup struct. +func (fg *FailoverGroup) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + fg.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + fg.Tags = tags + } + case "properties": + if v != nil { + var failoverGroupProperties FailoverGroupProperties + err = json.Unmarshal(*v, &failoverGroupProperties) + if err != nil { + return err + } + fg.FailoverGroupProperties = &failoverGroupProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + fg.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + fg.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + fg.Type = &typeVar + } + } + } + + return nil +} + +// FailoverGroupListResult a list of failover groups. +type FailoverGroupListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]FailoverGroup `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for FailoverGroupListResult. +func (fglr FailoverGroupListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// FailoverGroupListResultIterator provides access to a complete listing of FailoverGroup values. +type FailoverGroupListResultIterator struct { + i int + page FailoverGroupListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *FailoverGroupListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/FailoverGroupListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *FailoverGroupListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter FailoverGroupListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter FailoverGroupListResultIterator) Response() FailoverGroupListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter FailoverGroupListResultIterator) Value() FailoverGroup { + if !iter.page.NotDone() { + return FailoverGroup{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the FailoverGroupListResultIterator type. +func NewFailoverGroupListResultIterator(page FailoverGroupListResultPage) FailoverGroupListResultIterator { + return FailoverGroupListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (fglr FailoverGroupListResult) IsEmpty() bool { + return fglr.Value == nil || len(*fglr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (fglr FailoverGroupListResult) hasNextLink() bool { + return fglr.NextLink != nil && len(*fglr.NextLink) != 0 +} + +// failoverGroupListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (fglr FailoverGroupListResult) failoverGroupListResultPreparer(ctx context.Context) (*http.Request, error) { + if !fglr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(fglr.NextLink))) +} + +// FailoverGroupListResultPage contains a page of FailoverGroup values. +type FailoverGroupListResultPage struct { + fn func(context.Context, FailoverGroupListResult) (FailoverGroupListResult, error) + fglr FailoverGroupListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *FailoverGroupListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/FailoverGroupListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.fglr) + if err != nil { + return err + } + page.fglr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *FailoverGroupListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page FailoverGroupListResultPage) NotDone() bool { + return !page.fglr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page FailoverGroupListResultPage) Response() FailoverGroupListResult { + return page.fglr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page FailoverGroupListResultPage) Values() []FailoverGroup { + if page.fglr.IsEmpty() { + return nil + } + return *page.fglr.Value +} + +// Creates a new instance of the FailoverGroupListResultPage type. +func NewFailoverGroupListResultPage(cur FailoverGroupListResult, getNextPage func(context.Context, FailoverGroupListResult) (FailoverGroupListResult, error)) FailoverGroupListResultPage { + return FailoverGroupListResultPage{ + fn: getNextPage, + fglr: cur, + } +} + +// FailoverGroupProperties properties of a failover group. +type FailoverGroupProperties struct { + // ReadWriteEndpoint - Read-write endpoint of the failover group instance. + ReadWriteEndpoint *FailoverGroupReadWriteEndpoint `json:"readWriteEndpoint,omitempty"` + // ReadOnlyEndpoint - Read-only endpoint of the failover group instance. + ReadOnlyEndpoint *FailoverGroupReadOnlyEndpoint `json:"readOnlyEndpoint,omitempty"` + // ReplicationRole - READ-ONLY; Local replication role of the failover group instance. Possible values include: 'FailoverGroupReplicationRolePrimary', 'FailoverGroupReplicationRoleSecondary' + ReplicationRole FailoverGroupReplicationRole `json:"replicationRole,omitempty"` + // ReplicationState - READ-ONLY; Replication state of the failover group instance. + ReplicationState *string `json:"replicationState,omitempty"` + // PartnerServers - List of partner server information for the failover group. + PartnerServers *[]PartnerInfo `json:"partnerServers,omitempty"` + // Databases - List of databases in the failover group. + Databases *[]string `json:"databases,omitempty"` +} + +// MarshalJSON is the custom marshaler for FailoverGroupProperties. +func (fgp FailoverGroupProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if fgp.ReadWriteEndpoint != nil { + objectMap["readWriteEndpoint"] = fgp.ReadWriteEndpoint + } + if fgp.ReadOnlyEndpoint != nil { + objectMap["readOnlyEndpoint"] = fgp.ReadOnlyEndpoint + } + if fgp.PartnerServers != nil { + objectMap["partnerServers"] = fgp.PartnerServers + } + if fgp.Databases != nil { + objectMap["databases"] = fgp.Databases + } + return json.Marshal(objectMap) +} + +// FailoverGroupReadOnlyEndpoint read-only endpoint of the failover group instance. +type FailoverGroupReadOnlyEndpoint struct { + // FailoverPolicy - Failover policy of the read-only endpoint for the failover group. Possible values include: 'ReadOnlyEndpointFailoverPolicyDisabled', 'ReadOnlyEndpointFailoverPolicyEnabled' + FailoverPolicy ReadOnlyEndpointFailoverPolicy `json:"failoverPolicy,omitempty"` +} + +// FailoverGroupReadWriteEndpoint read-write endpoint of the failover group instance. +type FailoverGroupReadWriteEndpoint struct { + // FailoverPolicy - Failover policy of the read-write endpoint for the failover group. If failoverPolicy is Automatic then failoverWithDataLossGracePeriodMinutes is required. Possible values include: 'ReadWriteEndpointFailoverPolicyManual', 'ReadWriteEndpointFailoverPolicyAutomatic' + FailoverPolicy ReadWriteEndpointFailoverPolicy `json:"failoverPolicy,omitempty"` + // FailoverWithDataLossGracePeriodMinutes - Grace period before failover with data loss is attempted for the read-write endpoint. If failoverPolicy is Automatic then failoverWithDataLossGracePeriodMinutes is required. + FailoverWithDataLossGracePeriodMinutes *int32 `json:"failoverWithDataLossGracePeriodMinutes,omitempty"` +} + +// FailoverGroupsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type FailoverGroupsCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(FailoverGroupsClient) (FailoverGroup, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *FailoverGroupsCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for FailoverGroupsCreateOrUpdateFuture.Result. +func (future *FailoverGroupsCreateOrUpdateFuture) result(client FailoverGroupsClient) (fg FailoverGroup, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + fg.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.FailoverGroupsCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if fg.Response.Response, err = future.GetResult(sender); err == nil && fg.Response.Response.StatusCode != http.StatusNoContent { + fg, err = client.CreateOrUpdateResponder(fg.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsCreateOrUpdateFuture", "Result", fg.Response.Response, "Failure responding to request") + } + } + return +} + +// FailoverGroupsDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type FailoverGroupsDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(FailoverGroupsClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *FailoverGroupsDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for FailoverGroupsDeleteFuture.Result. +func (future *FailoverGroupsDeleteFuture) result(client FailoverGroupsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.FailoverGroupsDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// FailoverGroupsFailoverFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type FailoverGroupsFailoverFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(FailoverGroupsClient) (FailoverGroup, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *FailoverGroupsFailoverFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for FailoverGroupsFailoverFuture.Result. +func (future *FailoverGroupsFailoverFuture) result(client FailoverGroupsClient) (fg FailoverGroup, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsFailoverFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + fg.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.FailoverGroupsFailoverFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if fg.Response.Response, err = future.GetResult(sender); err == nil && fg.Response.Response.StatusCode != http.StatusNoContent { + fg, err = client.FailoverResponder(fg.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsFailoverFuture", "Result", fg.Response.Response, "Failure responding to request") + } + } + return +} + +// FailoverGroupsForceFailoverAllowDataLossFuture an abstraction for monitoring and retrieving the results +// of a long-running operation. +type FailoverGroupsForceFailoverAllowDataLossFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(FailoverGroupsClient) (FailoverGroup, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *FailoverGroupsForceFailoverAllowDataLossFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for FailoverGroupsForceFailoverAllowDataLossFuture.Result. +func (future *FailoverGroupsForceFailoverAllowDataLossFuture) result(client FailoverGroupsClient) (fg FailoverGroup, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsForceFailoverAllowDataLossFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + fg.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.FailoverGroupsForceFailoverAllowDataLossFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if fg.Response.Response, err = future.GetResult(sender); err == nil && fg.Response.Response.StatusCode != http.StatusNoContent { + fg, err = client.ForceFailoverAllowDataLossResponder(fg.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsForceFailoverAllowDataLossFuture", "Result", fg.Response.Response, "Failure responding to request") + } + } + return +} + +// FailoverGroupsUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type FailoverGroupsUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(FailoverGroupsClient) (FailoverGroup, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *FailoverGroupsUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for FailoverGroupsUpdateFuture.Result. +func (future *FailoverGroupsUpdateFuture) result(client FailoverGroupsClient) (fg FailoverGroup, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + fg.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.FailoverGroupsUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if fg.Response.Response, err = future.GetResult(sender); err == nil && fg.Response.Response.StatusCode != http.StatusNoContent { + fg, err = client.UpdateResponder(fg.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.FailoverGroupsUpdateFuture", "Result", fg.Response.Response, "Failure responding to request") + } + } + return +} + +// FailoverGroupUpdate a failover group update request. +type FailoverGroupUpdate struct { + // FailoverGroupUpdateProperties - Resource properties. + *FailoverGroupUpdateProperties `json:"properties,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for FailoverGroupUpdate. +func (fgu FailoverGroupUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if fgu.FailoverGroupUpdateProperties != nil { + objectMap["properties"] = fgu.FailoverGroupUpdateProperties + } + if fgu.Tags != nil { + objectMap["tags"] = fgu.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for FailoverGroupUpdate struct. +func (fgu *FailoverGroupUpdate) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var failoverGroupUpdateProperties FailoverGroupUpdateProperties + err = json.Unmarshal(*v, &failoverGroupUpdateProperties) + if err != nil { + return err + } + fgu.FailoverGroupUpdateProperties = &failoverGroupUpdateProperties + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + fgu.Tags = tags + } + } + } + + return nil +} + +// FailoverGroupUpdateProperties properties of a failover group update. +type FailoverGroupUpdateProperties struct { + // ReadWriteEndpoint - Read-write endpoint of the failover group instance. + ReadWriteEndpoint *FailoverGroupReadWriteEndpoint `json:"readWriteEndpoint,omitempty"` + // ReadOnlyEndpoint - Read-only endpoint of the failover group instance. + ReadOnlyEndpoint *FailoverGroupReadOnlyEndpoint `json:"readOnlyEndpoint,omitempty"` + // Databases - List of databases in the failover group. + Databases *[]string `json:"databases,omitempty"` +} + +// FirewallRule a server firewall rule. +type FirewallRule struct { + autorest.Response `json:"-"` + // ServerFirewallRuleProperties - Resource properties. + *ServerFirewallRuleProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for FirewallRule. +func (fr FirewallRule) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if fr.ServerFirewallRuleProperties != nil { + objectMap["properties"] = fr.ServerFirewallRuleProperties + } + if fr.Name != nil { + objectMap["name"] = fr.Name + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for FirewallRule struct. +func (fr *FirewallRule) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var serverFirewallRuleProperties ServerFirewallRuleProperties + err = json.Unmarshal(*v, &serverFirewallRuleProperties) + if err != nil { + return err + } + fr.ServerFirewallRuleProperties = &serverFirewallRuleProperties + } + case "id": + if v != nil { + 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 +} + +// FirewallRuleList a list of server firewall rules. +type FirewallRuleList struct { + Values *[]FirewallRule `json:"values,omitempty"` +} + +// FirewallRuleListResult the response to a list firewall rules request +type FirewallRuleListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]FirewallRule `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for FirewallRuleListResult. +func (frlr FirewallRuleListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// FirewallRuleListResultIterator provides access to a complete listing of FirewallRule values. +type FirewallRuleListResultIterator struct { + i int + page FirewallRuleListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *FirewallRuleListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/FirewallRuleListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *FirewallRuleListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter FirewallRuleListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter FirewallRuleListResultIterator) Response() FirewallRuleListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter FirewallRuleListResultIterator) Value() FirewallRule { + if !iter.page.NotDone() { + return FirewallRule{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the FirewallRuleListResultIterator type. +func NewFirewallRuleListResultIterator(page FirewallRuleListResultPage) FirewallRuleListResultIterator { + return FirewallRuleListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (frlr FirewallRuleListResult) IsEmpty() bool { + return frlr.Value == nil || len(*frlr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (frlr FirewallRuleListResult) hasNextLink() bool { + return frlr.NextLink != nil && len(*frlr.NextLink) != 0 +} + +// firewallRuleListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (frlr FirewallRuleListResult) firewallRuleListResultPreparer(ctx context.Context) (*http.Request, error) { + if !frlr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(frlr.NextLink))) +} + +// FirewallRuleListResultPage contains a page of FirewallRule values. +type FirewallRuleListResultPage struct { + fn func(context.Context, FirewallRuleListResult) (FirewallRuleListResult, error) + frlr FirewallRuleListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *FirewallRuleListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/FirewallRuleListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.frlr) + if err != nil { + return err + } + page.frlr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *FirewallRuleListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page FirewallRuleListResultPage) NotDone() bool { + return !page.frlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page FirewallRuleListResultPage) Response() FirewallRuleListResult { + return page.frlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page FirewallRuleListResultPage) Values() []FirewallRule { + if page.frlr.IsEmpty() { + return nil + } + return *page.frlr.Value +} + +// Creates a new instance of the FirewallRuleListResultPage type. +func NewFirewallRuleListResultPage(cur FirewallRuleListResult, getNextPage func(context.Context, FirewallRuleListResult) (FirewallRuleListResult, error)) FirewallRuleListResultPage { + return FirewallRuleListResultPage{ + fn: getNextPage, + frlr: cur, + } +} + +// GeoBackupPolicy a database geo backup policy. +type GeoBackupPolicy struct { + autorest.Response `json:"-"` + // GeoBackupPolicyProperties - The properties of the geo backup policy. + *GeoBackupPolicyProperties `json:"properties,omitempty"` + // Kind - READ-ONLY; Kind of geo backup policy. This is metadata used for the Azure portal experience. + Kind *string `json:"kind,omitempty"` + // Location - READ-ONLY; Backup policy location. + Location *string `json:"location,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for GeoBackupPolicy. +func (gbp GeoBackupPolicy) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if gbp.GeoBackupPolicyProperties != nil { + objectMap["properties"] = gbp.GeoBackupPolicyProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for GeoBackupPolicy struct. +func (gbp *GeoBackupPolicy) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var geoBackupPolicyProperties GeoBackupPolicyProperties + err = json.Unmarshal(*v, &geoBackupPolicyProperties) + if err != nil { + return err + } + gbp.GeoBackupPolicyProperties = &geoBackupPolicyProperties + } + case "kind": + if v != nil { + var kind string + err = json.Unmarshal(*v, &kind) + if err != nil { + return err + } + gbp.Kind = &kind + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + gbp.Location = &location + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + gbp.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + gbp.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + gbp.Type = &typeVar + } + } + } + + return nil +} + +// GeoBackupPolicyListResult the response to a list geo backup policies request. +type GeoBackupPolicyListResult struct { + autorest.Response `json:"-"` + // Value - The list of geo backup policies. + Value *[]GeoBackupPolicy `json:"value,omitempty"` +} + +// GeoBackupPolicyProperties the properties of the geo backup policy. +type GeoBackupPolicyProperties struct { + // State - The state of the geo backup policy. Possible values include: 'GeoBackupPolicyStateDisabled', 'GeoBackupPolicyStateEnabled' + State GeoBackupPolicyState `json:"state,omitempty"` + // StorageType - READ-ONLY; The storage type of the geo backup policy. + StorageType *string `json:"storageType,omitempty"` +} + +// MarshalJSON is the custom marshaler for GeoBackupPolicyProperties. +func (gbpp GeoBackupPolicyProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if gbpp.State != "" { + objectMap["state"] = gbpp.State + } + return json.Marshal(objectMap) +} + +// ImportExistingDatabaseDefinition contains the information necessary to perform import operation for +// existing database. +type ImportExistingDatabaseDefinition struct { + // StorageKeyType - Storage key type. Possible values include: 'StorageKeyTypeSharedAccessKey', 'StorageKeyTypeStorageAccessKey' + StorageKeyType StorageKeyType `json:"storageKeyType,omitempty"` + // StorageKey - Storage key. + StorageKey *string `json:"storageKey,omitempty"` + // StorageURI - Storage Uri. + StorageURI *string `json:"storageUri,omitempty"` + // AdministratorLogin - Administrator login name. + AdministratorLogin *string `json:"administratorLogin,omitempty"` + // AdministratorLoginPassword - Administrator login password. + AdministratorLoginPassword *string `json:"administratorLoginPassword,omitempty"` + // AuthenticationType - Authentication type. + AuthenticationType *string `json:"authenticationType,omitempty"` + // NetworkIsolation - Optional resource information to enable network isolation for request. + NetworkIsolation *NetworkIsolationSettings `json:"networkIsolation,omitempty"` +} + +// ImportExportExtensionsOperationListResult import export operation extensions list. +type ImportExportExtensionsOperationListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]ImportExportExtensionsOperationResult `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for ImportExportExtensionsOperationListResult. +func (ieeolr ImportExportExtensionsOperationListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ImportExportExtensionsOperationListResultIterator provides access to a complete listing of +// ImportExportExtensionsOperationResult values. +type ImportExportExtensionsOperationListResultIterator struct { + i int + page ImportExportExtensionsOperationListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *ImportExportExtensionsOperationListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ImportExportExtensionsOperationListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ImportExportExtensionsOperationListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ImportExportExtensionsOperationListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter ImportExportExtensionsOperationListResultIterator) Response() ImportExportExtensionsOperationListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter ImportExportExtensionsOperationListResultIterator) Value() ImportExportExtensionsOperationResult { + if !iter.page.NotDone() { + return ImportExportExtensionsOperationResult{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ImportExportExtensionsOperationListResultIterator type. +func NewImportExportExtensionsOperationListResultIterator(page ImportExportExtensionsOperationListResultPage) ImportExportExtensionsOperationListResultIterator { + return ImportExportExtensionsOperationListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (ieeolr ImportExportExtensionsOperationListResult) IsEmpty() bool { + return ieeolr.Value == nil || len(*ieeolr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (ieeolr ImportExportExtensionsOperationListResult) hasNextLink() bool { + return ieeolr.NextLink != nil && len(*ieeolr.NextLink) != 0 +} + +// importExportExtensionsOperationListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (ieeolr ImportExportExtensionsOperationListResult) importExportExtensionsOperationListResultPreparer(ctx context.Context) (*http.Request, error) { + if !ieeolr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(ieeolr.NextLink))) +} + +// ImportExportExtensionsOperationListResultPage contains a page of ImportExportExtensionsOperationResult +// values. +type ImportExportExtensionsOperationListResultPage struct { + fn func(context.Context, ImportExportExtensionsOperationListResult) (ImportExportExtensionsOperationListResult, error) + ieeolr ImportExportExtensionsOperationListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *ImportExportExtensionsOperationListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ImportExportExtensionsOperationListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.ieeolr) + if err != nil { + return err + } + page.ieeolr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *ImportExportExtensionsOperationListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ImportExportExtensionsOperationListResultPage) NotDone() bool { + return !page.ieeolr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ImportExportExtensionsOperationListResultPage) Response() ImportExportExtensionsOperationListResult { + return page.ieeolr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ImportExportExtensionsOperationListResultPage) Values() []ImportExportExtensionsOperationResult { + if page.ieeolr.IsEmpty() { + return nil + } + return *page.ieeolr.Value +} + +// Creates a new instance of the ImportExportExtensionsOperationListResultPage type. +func NewImportExportExtensionsOperationListResultPage(cur ImportExportExtensionsOperationListResult, getNextPage func(context.Context, ImportExportExtensionsOperationListResult) (ImportExportExtensionsOperationListResult, error)) ImportExportExtensionsOperationListResultPage { + return ImportExportExtensionsOperationListResultPage{ + fn: getNextPage, + ieeolr: cur, + } +} + +// ImportExportExtensionsOperationResult an Extension operation result resource. +type ImportExportExtensionsOperationResult struct { + autorest.Response `json:"-"` + // ImportExportExtensionsOperationResultProperties - Resource properties. + *ImportExportExtensionsOperationResultProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ImportExportExtensionsOperationResult. +func (ieeor ImportExportExtensionsOperationResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ieeor.ImportExportExtensionsOperationResultProperties != nil { + objectMap["properties"] = ieeor.ImportExportExtensionsOperationResultProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ImportExportExtensionsOperationResult struct. +func (ieeor *ImportExportExtensionsOperationResult) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var importExportExtensionsOperationResultProperties ImportExportExtensionsOperationResultProperties + err = json.Unmarshal(*v, &importExportExtensionsOperationResultProperties) + if err != nil { + return err + } + ieeor.ImportExportExtensionsOperationResultProperties = &importExportExtensionsOperationResultProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + ieeor.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ieeor.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ieeor.Type = &typeVar + } + } + } + + return nil +} + +// ImportExportExtensionsOperationResultProperties contains the operation result properties for +// import/export operation. +type ImportExportExtensionsOperationResultProperties struct { + // RequestID - READ-ONLY; Request Id. + RequestID *uuid.UUID `json:"requestId,omitempty"` + // RequestType - READ-ONLY; Request type. + RequestType *string `json:"requestType,omitempty"` + // LastModifiedTime - READ-ONLY; Last modified time. + LastModifiedTime *string `json:"lastModifiedTime,omitempty"` + // ServerName - READ-ONLY; Server name. + ServerName *string `json:"serverName,omitempty"` + // DatabaseName - READ-ONLY; Database name. + DatabaseName *string `json:"databaseName,omitempty"` + // Status - READ-ONLY; Operation status. + Status *string `json:"status,omitempty"` + // ErrorMessage - READ-ONLY; Error message. + ErrorMessage *string `json:"errorMessage,omitempty"` +} + +// MarshalJSON is the custom marshaler for ImportExportExtensionsOperationResultProperties. +func (ieeorp ImportExportExtensionsOperationResultProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ImportExportOperationResult an ImportExport operation result resource. +type ImportExportOperationResult struct { + autorest.Response `json:"-"` + // ImportExportOperationResultProperties - Resource properties. + *ImportExportOperationResultProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ImportExportOperationResult. +func (ieor ImportExportOperationResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ieor.ImportExportOperationResultProperties != nil { + objectMap["properties"] = ieor.ImportExportOperationResultProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ImportExportOperationResult struct. +func (ieor *ImportExportOperationResult) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var importExportOperationResultProperties ImportExportOperationResultProperties + err = json.Unmarshal(*v, &importExportOperationResultProperties) + if err != nil { + return err + } + ieor.ImportExportOperationResultProperties = &importExportOperationResultProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + ieor.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ieor.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ieor.Type = &typeVar + } + } + } + + return nil +} + +// ImportExportOperationResultProperties contains the operation result properties for import/export +// operation. +type ImportExportOperationResultProperties struct { + // RequestID - READ-ONLY; Request Id. + RequestID *uuid.UUID `json:"requestId,omitempty"` + // RequestType - READ-ONLY; Request type. + RequestType *string `json:"requestType,omitempty"` + // QueuedTime - READ-ONLY; Queued time. + QueuedTime *string `json:"queuedTime,omitempty"` + // LastModifiedTime - READ-ONLY; Last modified time. + LastModifiedTime *string `json:"lastModifiedTime,omitempty"` + // BlobURI - READ-ONLY; Blob Uri. + BlobURI *string `json:"blobUri,omitempty"` + // ServerName - READ-ONLY; Server name. + ServerName *string `json:"serverName,omitempty"` + // DatabaseName - READ-ONLY; Database name. + DatabaseName *string `json:"databaseName,omitempty"` + // Status - READ-ONLY; Operation status. + Status *string `json:"status,omitempty"` + // ErrorMessage - READ-ONLY; Error message. + ErrorMessage *string `json:"errorMessage,omitempty"` + // PrivateEndpointConnections - READ-ONLY; Gets the status of private endpoints associated with this request. + PrivateEndpointConnections *[]PrivateEndpointConnectionRequestStatus `json:"privateEndpointConnections,omitempty"` +} + +// MarshalJSON is the custom marshaler for ImportExportOperationResultProperties. +func (ieorp ImportExportOperationResultProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ImportNewDatabaseDefinition contains the information necessary to perform import operation for new +// database. +type ImportNewDatabaseDefinition struct { + // DatabaseName - Name of the import database. + DatabaseName *string `json:"databaseName,omitempty"` + // Edition - Edition of the import database. + Edition *string `json:"edition,omitempty"` + // ServiceObjectiveName - Service level objective name of the import database. + ServiceObjectiveName *string `json:"serviceObjectiveName,omitempty"` + // MaxSizeBytes - Max size in bytes for the import database. + MaxSizeBytes *string `json:"maxSizeBytes,omitempty"` + // StorageKeyType - Storage key type. Possible values include: 'StorageKeyTypeSharedAccessKey', 'StorageKeyTypeStorageAccessKey' + StorageKeyType StorageKeyType `json:"storageKeyType,omitempty"` + // StorageKey - Storage key. + StorageKey *string `json:"storageKey,omitempty"` + // StorageURI - Storage Uri. + StorageURI *string `json:"storageUri,omitempty"` + // AdministratorLogin - Administrator login name. + AdministratorLogin *string `json:"administratorLogin,omitempty"` + // AdministratorLoginPassword - Administrator login password. + AdministratorLoginPassword *string `json:"administratorLoginPassword,omitempty"` + // AuthenticationType - Authentication type. + AuthenticationType *string `json:"authenticationType,omitempty"` + // NetworkIsolation - Optional resource information to enable network isolation for request. + NetworkIsolation *NetworkIsolationSettings `json:"networkIsolation,omitempty"` +} + +// InstanceFailoverGroup an instance failover group. +type InstanceFailoverGroup struct { + autorest.Response `json:"-"` + // InstanceFailoverGroupProperties - Resource properties. + *InstanceFailoverGroupProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for InstanceFailoverGroup. +func (ifg InstanceFailoverGroup) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ifg.InstanceFailoverGroupProperties != nil { + objectMap["properties"] = ifg.InstanceFailoverGroupProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for InstanceFailoverGroup struct. +func (ifg *InstanceFailoverGroup) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var instanceFailoverGroupProperties InstanceFailoverGroupProperties + err = json.Unmarshal(*v, &instanceFailoverGroupProperties) + if err != nil { + return err + } + ifg.InstanceFailoverGroupProperties = &instanceFailoverGroupProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + ifg.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ifg.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ifg.Type = &typeVar + } + } + } + + return nil +} + +// InstanceFailoverGroupListResult a list of instance failover groups. +type InstanceFailoverGroupListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]InstanceFailoverGroup `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for InstanceFailoverGroupListResult. +func (ifglr InstanceFailoverGroupListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// InstanceFailoverGroupListResultIterator provides access to a complete listing of InstanceFailoverGroup +// values. +type InstanceFailoverGroupListResultIterator struct { + i int + page InstanceFailoverGroupListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *InstanceFailoverGroupListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/InstanceFailoverGroupListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *InstanceFailoverGroupListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter InstanceFailoverGroupListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter InstanceFailoverGroupListResultIterator) Response() InstanceFailoverGroupListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter InstanceFailoverGroupListResultIterator) Value() InstanceFailoverGroup { + if !iter.page.NotDone() { + return InstanceFailoverGroup{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the InstanceFailoverGroupListResultIterator type. +func NewInstanceFailoverGroupListResultIterator(page InstanceFailoverGroupListResultPage) InstanceFailoverGroupListResultIterator { + return InstanceFailoverGroupListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (ifglr InstanceFailoverGroupListResult) IsEmpty() bool { + return ifglr.Value == nil || len(*ifglr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (ifglr InstanceFailoverGroupListResult) hasNextLink() bool { + return ifglr.NextLink != nil && len(*ifglr.NextLink) != 0 +} + +// instanceFailoverGroupListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (ifglr InstanceFailoverGroupListResult) instanceFailoverGroupListResultPreparer(ctx context.Context) (*http.Request, error) { + if !ifglr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(ifglr.NextLink))) +} + +// InstanceFailoverGroupListResultPage contains a page of InstanceFailoverGroup values. +type InstanceFailoverGroupListResultPage struct { + fn func(context.Context, InstanceFailoverGroupListResult) (InstanceFailoverGroupListResult, error) + ifglr InstanceFailoverGroupListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *InstanceFailoverGroupListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/InstanceFailoverGroupListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.ifglr) + if err != nil { + return err + } + page.ifglr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *InstanceFailoverGroupListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page InstanceFailoverGroupListResultPage) NotDone() bool { + return !page.ifglr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page InstanceFailoverGroupListResultPage) Response() InstanceFailoverGroupListResult { + return page.ifglr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page InstanceFailoverGroupListResultPage) Values() []InstanceFailoverGroup { + if page.ifglr.IsEmpty() { + return nil + } + return *page.ifglr.Value +} + +// Creates a new instance of the InstanceFailoverGroupListResultPage type. +func NewInstanceFailoverGroupListResultPage(cur InstanceFailoverGroupListResult, getNextPage func(context.Context, InstanceFailoverGroupListResult) (InstanceFailoverGroupListResult, error)) InstanceFailoverGroupListResultPage { + return InstanceFailoverGroupListResultPage{ + fn: getNextPage, + ifglr: cur, + } +} + +// InstanceFailoverGroupProperties properties of a instance failover group. +type InstanceFailoverGroupProperties struct { + // ReadWriteEndpoint - Read-write endpoint of the failover group instance. + ReadWriteEndpoint *InstanceFailoverGroupReadWriteEndpoint `json:"readWriteEndpoint,omitempty"` + // ReadOnlyEndpoint - Read-only endpoint of the failover group instance. + ReadOnlyEndpoint *InstanceFailoverGroupReadOnlyEndpoint `json:"readOnlyEndpoint,omitempty"` + // ReplicationRole - READ-ONLY; Local replication role of the failover group instance. Possible values include: 'InstanceFailoverGroupReplicationRolePrimary', 'InstanceFailoverGroupReplicationRoleSecondary' + ReplicationRole InstanceFailoverGroupReplicationRole `json:"replicationRole,omitempty"` + // ReplicationState - READ-ONLY; Replication state of the failover group instance. + ReplicationState *string `json:"replicationState,omitempty"` + // PartnerRegions - Partner region information for the failover group. + PartnerRegions *[]PartnerRegionInfo `json:"partnerRegions,omitempty"` + // ManagedInstancePairs - List of managed instance pairs in the failover group. + ManagedInstancePairs *[]ManagedInstancePairInfo `json:"managedInstancePairs,omitempty"` +} + +// MarshalJSON is the custom marshaler for InstanceFailoverGroupProperties. +func (ifgp InstanceFailoverGroupProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ifgp.ReadWriteEndpoint != nil { + objectMap["readWriteEndpoint"] = ifgp.ReadWriteEndpoint + } + if ifgp.ReadOnlyEndpoint != nil { + objectMap["readOnlyEndpoint"] = ifgp.ReadOnlyEndpoint + } + if ifgp.PartnerRegions != nil { + objectMap["partnerRegions"] = ifgp.PartnerRegions + } + if ifgp.ManagedInstancePairs != nil { + objectMap["managedInstancePairs"] = ifgp.ManagedInstancePairs + } + return json.Marshal(objectMap) +} + +// InstanceFailoverGroupReadOnlyEndpoint read-only endpoint of the failover group instance. +type InstanceFailoverGroupReadOnlyEndpoint struct { + // FailoverPolicy - Failover policy of the read-only endpoint for the failover group. Possible values include: 'ReadOnlyEndpointFailoverPolicyDisabled', 'ReadOnlyEndpointFailoverPolicyEnabled' + FailoverPolicy ReadOnlyEndpointFailoverPolicy `json:"failoverPolicy,omitempty"` +} + +// InstanceFailoverGroupReadWriteEndpoint read-write endpoint of the failover group instance. +type InstanceFailoverGroupReadWriteEndpoint struct { + // FailoverPolicy - Failover policy of the read-write endpoint for the failover group. If failoverPolicy is Automatic then failoverWithDataLossGracePeriodMinutes is required. Possible values include: 'ReadWriteEndpointFailoverPolicyManual', 'ReadWriteEndpointFailoverPolicyAutomatic' + FailoverPolicy ReadWriteEndpointFailoverPolicy `json:"failoverPolicy,omitempty"` + // FailoverWithDataLossGracePeriodMinutes - Grace period before failover with data loss is attempted for the read-write endpoint. If failoverPolicy is Automatic then failoverWithDataLossGracePeriodMinutes is required. + FailoverWithDataLossGracePeriodMinutes *int32 `json:"failoverWithDataLossGracePeriodMinutes,omitempty"` +} + +// InstanceFailoverGroupsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type InstanceFailoverGroupsCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(InstanceFailoverGroupsClient) (InstanceFailoverGroup, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *InstanceFailoverGroupsCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for InstanceFailoverGroupsCreateOrUpdateFuture.Result. +func (future *InstanceFailoverGroupsCreateOrUpdateFuture) result(client InstanceFailoverGroupsClient) (ifg InstanceFailoverGroup, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ifg.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.InstanceFailoverGroupsCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if ifg.Response.Response, err = future.GetResult(sender); err == nil && ifg.Response.Response.StatusCode != http.StatusNoContent { + ifg, err = client.CreateOrUpdateResponder(ifg.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsCreateOrUpdateFuture", "Result", ifg.Response.Response, "Failure responding to request") + } + } + return +} + +// InstanceFailoverGroupsDeleteFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type InstanceFailoverGroupsDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(InstanceFailoverGroupsClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *InstanceFailoverGroupsDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for InstanceFailoverGroupsDeleteFuture.Result. +func (future *InstanceFailoverGroupsDeleteFuture) result(client InstanceFailoverGroupsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.InstanceFailoverGroupsDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// InstanceFailoverGroupsFailoverFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type InstanceFailoverGroupsFailoverFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(InstanceFailoverGroupsClient) (InstanceFailoverGroup, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *InstanceFailoverGroupsFailoverFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for InstanceFailoverGroupsFailoverFuture.Result. +func (future *InstanceFailoverGroupsFailoverFuture) result(client InstanceFailoverGroupsClient) (ifg InstanceFailoverGroup, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsFailoverFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ifg.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.InstanceFailoverGroupsFailoverFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if ifg.Response.Response, err = future.GetResult(sender); err == nil && ifg.Response.Response.StatusCode != http.StatusNoContent { + ifg, err = client.FailoverResponder(ifg.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsFailoverFuture", "Result", ifg.Response.Response, "Failure responding to request") + } + } + return +} + +// InstanceFailoverGroupsForceFailoverAllowDataLossFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type InstanceFailoverGroupsForceFailoverAllowDataLossFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(InstanceFailoverGroupsClient) (InstanceFailoverGroup, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *InstanceFailoverGroupsForceFailoverAllowDataLossFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for InstanceFailoverGroupsForceFailoverAllowDataLossFuture.Result. +func (future *InstanceFailoverGroupsForceFailoverAllowDataLossFuture) result(client InstanceFailoverGroupsClient) (ifg InstanceFailoverGroup, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsForceFailoverAllowDataLossFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ifg.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.InstanceFailoverGroupsForceFailoverAllowDataLossFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if ifg.Response.Response, err = future.GetResult(sender); err == nil && ifg.Response.Response.StatusCode != http.StatusNoContent { + ifg, err = client.ForceFailoverAllowDataLossResponder(ifg.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstanceFailoverGroupsForceFailoverAllowDataLossFuture", "Result", ifg.Response.Response, "Failure responding to request") + } + } + return +} + +// InstancePool an Azure SQL instance pool. +type InstancePool struct { + autorest.Response `json:"-"` + // Sku - The name and tier of the SKU. + Sku *Sku `json:"sku,omitempty"` + // InstancePoolProperties - Resource properties. + *InstancePoolProperties `json:"properties,omitempty"` + // Location - Resource location. + Location *string `json:"location,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for InstancePool. +func (IP InstancePool) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if IP.Sku != nil { + objectMap["sku"] = IP.Sku + } + if IP.InstancePoolProperties != nil { + objectMap["properties"] = IP.InstancePoolProperties + } + if IP.Location != nil { + objectMap["location"] = IP.Location + } + if IP.Tags != nil { + objectMap["tags"] = IP.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for InstancePool struct. +func (IP *InstancePool) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "sku": + if v != nil { + var sku Sku + err = json.Unmarshal(*v, &sku) + if err != nil { + return err + } + IP.Sku = &sku + } + case "properties": + if v != nil { + var instancePoolProperties InstancePoolProperties + err = json.Unmarshal(*v, &instancePoolProperties) + if err != nil { + return err + } + IP.InstancePoolProperties = &instancePoolProperties + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + IP.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + IP.Tags = tags + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + IP.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + IP.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + IP.Type = &typeVar + } + } + } + + return nil +} + +// InstancePoolEditionCapability the instance pool capability +type InstancePoolEditionCapability struct { + // Name - READ-ONLY; The instance pool version name. + Name *string `json:"name,omitempty"` + // SupportedFamilies - READ-ONLY; The supported families. + SupportedFamilies *[]InstancePoolFamilyCapability `json:"supportedFamilies,omitempty"` + // Status - READ-ONLY; The status of the capability. Possible values include: 'CapabilityStatusVisible', 'CapabilityStatusAvailable', 'CapabilityStatusDefault', 'CapabilityStatusDisabled' + Status CapabilityStatus `json:"status,omitempty"` + // Reason - The reason for the capability not being available. + Reason *string `json:"reason,omitempty"` +} + +// MarshalJSON is the custom marshaler for InstancePoolEditionCapability. +func (ipec InstancePoolEditionCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ipec.Reason != nil { + objectMap["reason"] = ipec.Reason + } + return json.Marshal(objectMap) +} + +// InstancePoolFamilyCapability the instance pool family capability. +type InstancePoolFamilyCapability struct { + // Name - READ-ONLY; Family name. + Name *string `json:"name,omitempty"` + // SupportedLicenseTypes - READ-ONLY; List of supported license types. + SupportedLicenseTypes *[]LicenseTypeCapability `json:"supportedLicenseTypes,omitempty"` + // SupportedVcoresValues - READ-ONLY; List of supported virtual cores values. + SupportedVcoresValues *[]InstancePoolVcoresCapability `json:"supportedVcoresValues,omitempty"` + // Status - READ-ONLY; The status of the capability. Possible values include: 'CapabilityStatusVisible', 'CapabilityStatusAvailable', 'CapabilityStatusDefault', 'CapabilityStatusDisabled' + Status CapabilityStatus `json:"status,omitempty"` + // Reason - The reason for the capability not being available. + Reason *string `json:"reason,omitempty"` +} + +// MarshalJSON is the custom marshaler for InstancePoolFamilyCapability. +func (ipfc InstancePoolFamilyCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ipfc.Reason != nil { + objectMap["reason"] = ipfc.Reason + } + return json.Marshal(objectMap) +} + +// InstancePoolListResult a list of Azure SQL instance pools. +type InstancePoolListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]InstancePool `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for InstancePoolListResult. +func (iplr InstancePoolListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// InstancePoolListResultIterator provides access to a complete listing of InstancePool values. +type InstancePoolListResultIterator struct { + i int + page InstancePoolListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *InstancePoolListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/InstancePoolListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *InstancePoolListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter InstancePoolListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter InstancePoolListResultIterator) Response() InstancePoolListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter InstancePoolListResultIterator) Value() InstancePool { + if !iter.page.NotDone() { + return InstancePool{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the InstancePoolListResultIterator type. +func NewInstancePoolListResultIterator(page InstancePoolListResultPage) InstancePoolListResultIterator { + return InstancePoolListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (iplr InstancePoolListResult) IsEmpty() bool { + return iplr.Value == nil || len(*iplr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (iplr InstancePoolListResult) hasNextLink() bool { + return iplr.NextLink != nil && len(*iplr.NextLink) != 0 +} + +// instancePoolListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (iplr InstancePoolListResult) instancePoolListResultPreparer(ctx context.Context) (*http.Request, error) { + if !iplr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(iplr.NextLink))) +} + +// InstancePoolListResultPage contains a page of InstancePool values. +type InstancePoolListResultPage struct { + fn func(context.Context, InstancePoolListResult) (InstancePoolListResult, error) + iplr InstancePoolListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *InstancePoolListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/InstancePoolListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.iplr) + if err != nil { + return err + } + page.iplr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *InstancePoolListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page InstancePoolListResultPage) NotDone() bool { + return !page.iplr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page InstancePoolListResultPage) Response() InstancePoolListResult { + return page.iplr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page InstancePoolListResultPage) Values() []InstancePool { + if page.iplr.IsEmpty() { + return nil + } + return *page.iplr.Value +} + +// Creates a new instance of the InstancePoolListResultPage type. +func NewInstancePoolListResultPage(cur InstancePoolListResult, getNextPage func(context.Context, InstancePoolListResult) (InstancePoolListResult, error)) InstancePoolListResultPage { + return InstancePoolListResultPage{ + fn: getNextPage, + iplr: cur, + } +} + +// InstancePoolProperties properties of an instance pool. +type InstancePoolProperties struct { + // SubnetID - Resource ID of the subnet to place this instance pool in. + SubnetID *string `json:"subnetId,omitempty"` + // VCores - Count of vCores belonging to this instance pool. + VCores *int32 `json:"vCores,omitempty"` + // LicenseType - The license type. Possible values are 'LicenseIncluded' (price for SQL license is included) and 'BasePrice' (without SQL license price). Possible values include: 'InstancePoolLicenseTypeLicenseIncluded', 'InstancePoolLicenseTypeBasePrice' + LicenseType InstancePoolLicenseType `json:"licenseType,omitempty"` +} + +// InstancePoolsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type InstancePoolsCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(InstancePoolsClient) (InstancePool, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *InstancePoolsCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for InstancePoolsCreateOrUpdateFuture.Result. +func (future *InstancePoolsCreateOrUpdateFuture) result(client InstancePoolsClient) (IP InstancePool, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstancePoolsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + IP.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.InstancePoolsCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if IP.Response.Response, err = future.GetResult(sender); err == nil && IP.Response.Response.StatusCode != http.StatusNoContent { + IP, err = client.CreateOrUpdateResponder(IP.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstancePoolsCreateOrUpdateFuture", "Result", IP.Response.Response, "Failure responding to request") + } + } + return +} + +// InstancePoolsDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type InstancePoolsDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(InstancePoolsClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *InstancePoolsDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for InstancePoolsDeleteFuture.Result. +func (future *InstancePoolsDeleteFuture) result(client InstancePoolsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstancePoolsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.InstancePoolsDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// InstancePoolsUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type InstancePoolsUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(InstancePoolsClient) (InstancePool, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *InstancePoolsUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for InstancePoolsUpdateFuture.Result. +func (future *InstancePoolsUpdateFuture) result(client InstancePoolsClient) (IP InstancePool, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstancePoolsUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + IP.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.InstancePoolsUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if IP.Response.Response, err = future.GetResult(sender); err == nil && IP.Response.Response.StatusCode != http.StatusNoContent { + IP, err = client.UpdateResponder(IP.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.InstancePoolsUpdateFuture", "Result", IP.Response.Response, "Failure responding to request") + } + } + return +} + +// InstancePoolUpdate an update to an Instance pool. +type InstancePoolUpdate struct { + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for InstancePoolUpdate. +func (ipu InstancePoolUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ipu.Tags != nil { + objectMap["tags"] = ipu.Tags + } + return json.Marshal(objectMap) +} + +// InstancePoolVcoresCapability the managed instance virtual cores capability. +type InstancePoolVcoresCapability struct { + // Name - READ-ONLY; The virtual cores identifier. + Name *string `json:"name,omitempty"` + // Value - READ-ONLY; The virtual cores value. + Value *int32 `json:"value,omitempty"` + // StorageLimit - READ-ONLY; Storage limit. + StorageLimit *MaxSizeCapability `json:"storageLimit,omitempty"` + // Status - READ-ONLY; The status of the capability. Possible values include: 'CapabilityStatusVisible', 'CapabilityStatusAvailable', 'CapabilityStatusDefault', 'CapabilityStatusDisabled' + Status CapabilityStatus `json:"status,omitempty"` + // Reason - The reason for the capability not being available. + Reason *string `json:"reason,omitempty"` +} + +// MarshalJSON is the custom marshaler for InstancePoolVcoresCapability. +func (ipvc InstancePoolVcoresCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ipvc.Reason != nil { + objectMap["reason"] = ipvc.Reason + } + return json.Marshal(objectMap) +} + +// Job a job. +type Job struct { + autorest.Response `json:"-"` + // JobProperties - Resource properties. + *JobProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Job. +func (j Job) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if j.JobProperties != nil { + objectMap["properties"] = j.JobProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Job struct. +func (j *Job) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var jobProperties JobProperties + err = json.Unmarshal(*v, &jobProperties) + if err != nil { + return err + } + j.JobProperties = &jobProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + j.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + j.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + j.Type = &typeVar + } + } + } + + return nil +} + +// JobAgent an Azure SQL job agent. +type JobAgent struct { + autorest.Response `json:"-"` + // Sku - The name and tier of the SKU. + Sku *Sku `json:"sku,omitempty"` + // JobAgentProperties - Resource properties. + *JobAgentProperties `json:"properties,omitempty"` + // Location - Resource location. + Location *string `json:"location,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for JobAgent. +func (ja JobAgent) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ja.Sku != nil { + objectMap["sku"] = ja.Sku + } + if ja.JobAgentProperties != nil { + objectMap["properties"] = ja.JobAgentProperties + } + if ja.Location != nil { + objectMap["location"] = ja.Location + } + if ja.Tags != nil { + objectMap["tags"] = ja.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for JobAgent struct. +func (ja *JobAgent) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "sku": + if v != nil { + var sku Sku + err = json.Unmarshal(*v, &sku) + if err != nil { + return err + } + ja.Sku = &sku + } + case "properties": + if v != nil { + var jobAgentProperties JobAgentProperties + err = json.Unmarshal(*v, &jobAgentProperties) + if err != nil { + return err + } + ja.JobAgentProperties = &jobAgentProperties + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + ja.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + ja.Tags = tags + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + ja.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ja.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ja.Type = &typeVar + } + } + } + + return nil +} + +// JobAgentListResult a list of Azure SQL job agents. +type JobAgentListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]JobAgent `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for JobAgentListResult. +func (jalr JobAgentListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// JobAgentListResultIterator provides access to a complete listing of JobAgent values. +type JobAgentListResultIterator struct { + i int + page JobAgentListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *JobAgentListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobAgentListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *JobAgentListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter JobAgentListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter JobAgentListResultIterator) Response() JobAgentListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter JobAgentListResultIterator) Value() JobAgent { + if !iter.page.NotDone() { + return JobAgent{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the JobAgentListResultIterator type. +func NewJobAgentListResultIterator(page JobAgentListResultPage) JobAgentListResultIterator { + return JobAgentListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (jalr JobAgentListResult) IsEmpty() bool { + return jalr.Value == nil || len(*jalr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (jalr JobAgentListResult) hasNextLink() bool { + return jalr.NextLink != nil && len(*jalr.NextLink) != 0 +} + +// jobAgentListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (jalr JobAgentListResult) jobAgentListResultPreparer(ctx context.Context) (*http.Request, error) { + if !jalr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(jalr.NextLink))) +} + +// JobAgentListResultPage contains a page of JobAgent values. +type JobAgentListResultPage struct { + fn func(context.Context, JobAgentListResult) (JobAgentListResult, error) + jalr JobAgentListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *JobAgentListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobAgentListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.jalr) + if err != nil { + return err + } + page.jalr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *JobAgentListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page JobAgentListResultPage) NotDone() bool { + return !page.jalr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page JobAgentListResultPage) Response() JobAgentListResult { + return page.jalr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page JobAgentListResultPage) Values() []JobAgent { + if page.jalr.IsEmpty() { + return nil + } + return *page.jalr.Value +} + +// Creates a new instance of the JobAgentListResultPage type. +func NewJobAgentListResultPage(cur JobAgentListResult, getNextPage func(context.Context, JobAgentListResult) (JobAgentListResult, error)) JobAgentListResultPage { + return JobAgentListResultPage{ + fn: getNextPage, + jalr: cur, + } +} + +// JobAgentProperties properties of a job agent. +type JobAgentProperties struct { + // DatabaseID - Resource ID of the database to store job metadata in. + DatabaseID *string `json:"databaseId,omitempty"` + // State - READ-ONLY; The state of the job agent. Possible values include: 'JobAgentStateCreating', 'JobAgentStateReady', 'JobAgentStateUpdating', 'JobAgentStateDeleting', 'JobAgentStateDisabled' + State JobAgentState `json:"state,omitempty"` +} + +// MarshalJSON is the custom marshaler for JobAgentProperties. +func (jap JobAgentProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if jap.DatabaseID != nil { + objectMap["databaseId"] = jap.DatabaseID + } + return json.Marshal(objectMap) +} + +// JobAgentsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type JobAgentsCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(JobAgentsClient) (JobAgent, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *JobAgentsCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for JobAgentsCreateOrUpdateFuture.Result. +func (future *JobAgentsCreateOrUpdateFuture) result(client JobAgentsClient) (ja JobAgent, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobAgentsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ja.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.JobAgentsCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if ja.Response.Response, err = future.GetResult(sender); err == nil && ja.Response.Response.StatusCode != http.StatusNoContent { + ja, err = client.CreateOrUpdateResponder(ja.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobAgentsCreateOrUpdateFuture", "Result", ja.Response.Response, "Failure responding to request") + } + } + return +} + +// JobAgentsDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type JobAgentsDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(JobAgentsClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *JobAgentsDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for JobAgentsDeleteFuture.Result. +func (future *JobAgentsDeleteFuture) result(client JobAgentsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobAgentsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.JobAgentsDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// JobAgentsUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type JobAgentsUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(JobAgentsClient) (JobAgent, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *JobAgentsUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for JobAgentsUpdateFuture.Result. +func (future *JobAgentsUpdateFuture) result(client JobAgentsClient) (ja JobAgent, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobAgentsUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ja.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.JobAgentsUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if ja.Response.Response, err = future.GetResult(sender); err == nil && ja.Response.Response.StatusCode != http.StatusNoContent { + ja, err = client.UpdateResponder(ja.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobAgentsUpdateFuture", "Result", ja.Response.Response, "Failure responding to request") + } + } + return +} + +// JobAgentUpdate an update to an Azure SQL job agent. +type JobAgentUpdate struct { + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for JobAgentUpdate. +func (jau JobAgentUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if jau.Tags != nil { + objectMap["tags"] = jau.Tags + } + return json.Marshal(objectMap) +} + +// JobCredential a stored credential that can be used by a job to connect to target databases. +type JobCredential struct { + autorest.Response `json:"-"` + // JobCredentialProperties - Resource properties. + *JobCredentialProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for JobCredential. +func (jc JobCredential) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if jc.JobCredentialProperties != nil { + objectMap["properties"] = jc.JobCredentialProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for JobCredential struct. +func (jc *JobCredential) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var jobCredentialProperties JobCredentialProperties + err = json.Unmarshal(*v, &jobCredentialProperties) + if err != nil { + return err + } + jc.JobCredentialProperties = &jobCredentialProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + jc.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + jc.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + jc.Type = &typeVar + } + } + } + + return nil +} + +// JobCredentialListResult a list of job credentials. +type JobCredentialListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]JobCredential `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for JobCredentialListResult. +func (jclr JobCredentialListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// JobCredentialListResultIterator provides access to a complete listing of JobCredential values. +type JobCredentialListResultIterator struct { + i int + page JobCredentialListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *JobCredentialListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobCredentialListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *JobCredentialListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter JobCredentialListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter JobCredentialListResultIterator) Response() JobCredentialListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter JobCredentialListResultIterator) Value() JobCredential { + if !iter.page.NotDone() { + return JobCredential{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the JobCredentialListResultIterator type. +func NewJobCredentialListResultIterator(page JobCredentialListResultPage) JobCredentialListResultIterator { + return JobCredentialListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (jclr JobCredentialListResult) IsEmpty() bool { + return jclr.Value == nil || len(*jclr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (jclr JobCredentialListResult) hasNextLink() bool { + return jclr.NextLink != nil && len(*jclr.NextLink) != 0 +} + +// jobCredentialListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (jclr JobCredentialListResult) jobCredentialListResultPreparer(ctx context.Context) (*http.Request, error) { + if !jclr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(jclr.NextLink))) +} + +// JobCredentialListResultPage contains a page of JobCredential values. +type JobCredentialListResultPage struct { + fn func(context.Context, JobCredentialListResult) (JobCredentialListResult, error) + jclr JobCredentialListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *JobCredentialListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobCredentialListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.jclr) + if err != nil { + return err + } + page.jclr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *JobCredentialListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page JobCredentialListResultPage) NotDone() bool { + return !page.jclr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page JobCredentialListResultPage) Response() JobCredentialListResult { + return page.jclr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page JobCredentialListResultPage) Values() []JobCredential { + if page.jclr.IsEmpty() { + return nil + } + return *page.jclr.Value +} + +// Creates a new instance of the JobCredentialListResultPage type. +func NewJobCredentialListResultPage(cur JobCredentialListResult, getNextPage func(context.Context, JobCredentialListResult) (JobCredentialListResult, error)) JobCredentialListResultPage { + return JobCredentialListResultPage{ + fn: getNextPage, + jclr: cur, + } +} + +// JobCredentialProperties properties of a job credential. +type JobCredentialProperties struct { + // Username - The credential user name. + Username *string `json:"username,omitempty"` + // Password - The credential password. + Password *string `json:"password,omitempty"` +} + +// JobExecution an execution of a job +type JobExecution struct { + autorest.Response `json:"-"` + // JobExecutionProperties - Resource properties. + *JobExecutionProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for JobExecution. +func (je JobExecution) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if je.JobExecutionProperties != nil { + objectMap["properties"] = je.JobExecutionProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for JobExecution struct. +func (je *JobExecution) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var jobExecutionProperties JobExecutionProperties + err = json.Unmarshal(*v, &jobExecutionProperties) + if err != nil { + return err + } + je.JobExecutionProperties = &jobExecutionProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + je.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + je.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + je.Type = &typeVar + } + } + } + + return nil +} + +// JobExecutionListResult a list of job executions. +type JobExecutionListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]JobExecution `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for JobExecutionListResult. +func (jelr JobExecutionListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// JobExecutionListResultIterator provides access to a complete listing of JobExecution values. +type JobExecutionListResultIterator struct { + i int + page JobExecutionListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *JobExecutionListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobExecutionListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *JobExecutionListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter JobExecutionListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter JobExecutionListResultIterator) Response() JobExecutionListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter JobExecutionListResultIterator) Value() JobExecution { + if !iter.page.NotDone() { + return JobExecution{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the JobExecutionListResultIterator type. +func NewJobExecutionListResultIterator(page JobExecutionListResultPage) JobExecutionListResultIterator { + return JobExecutionListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (jelr JobExecutionListResult) IsEmpty() bool { + return jelr.Value == nil || len(*jelr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (jelr JobExecutionListResult) hasNextLink() bool { + return jelr.NextLink != nil && len(*jelr.NextLink) != 0 +} + +// jobExecutionListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (jelr JobExecutionListResult) jobExecutionListResultPreparer(ctx context.Context) (*http.Request, error) { + if !jelr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(jelr.NextLink))) +} + +// JobExecutionListResultPage contains a page of JobExecution values. +type JobExecutionListResultPage struct { + fn func(context.Context, JobExecutionListResult) (JobExecutionListResult, error) + jelr JobExecutionListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *JobExecutionListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobExecutionListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.jelr) + if err != nil { + return err + } + page.jelr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *JobExecutionListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page JobExecutionListResultPage) NotDone() bool { + return !page.jelr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page JobExecutionListResultPage) Response() JobExecutionListResult { + return page.jelr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page JobExecutionListResultPage) Values() []JobExecution { + if page.jelr.IsEmpty() { + return nil + } + return *page.jelr.Value +} + +// Creates a new instance of the JobExecutionListResultPage type. +func NewJobExecutionListResultPage(cur JobExecutionListResult, getNextPage func(context.Context, JobExecutionListResult) (JobExecutionListResult, error)) JobExecutionListResultPage { + return JobExecutionListResultPage{ + fn: getNextPage, + jelr: cur, + } +} + +// JobExecutionProperties properties for an Azure SQL Database Elastic job execution. +type JobExecutionProperties struct { + // JobVersion - READ-ONLY; The job version number. + JobVersion *int32 `json:"jobVersion,omitempty"` + // StepName - READ-ONLY; The job step name. + StepName *string `json:"stepName,omitempty"` + // StepID - READ-ONLY; The job step id. + StepID *int32 `json:"stepId,omitempty"` + // JobExecutionID - READ-ONLY; The unique identifier of the job execution. + JobExecutionID *uuid.UUID `json:"jobExecutionId,omitempty"` + // Lifecycle - READ-ONLY; The detailed state of the job execution. Possible values include: 'JobExecutionLifecycleCreated', 'JobExecutionLifecycleInProgress', 'JobExecutionLifecycleWaitingForChildJobExecutions', 'JobExecutionLifecycleWaitingForRetry', 'JobExecutionLifecycleSucceeded', 'JobExecutionLifecycleSucceededWithSkipped', 'JobExecutionLifecycleFailed', 'JobExecutionLifecycleTimedOut', 'JobExecutionLifecycleCanceled', 'JobExecutionLifecycleSkipped' + Lifecycle JobExecutionLifecycle `json:"lifecycle,omitempty"` + // ProvisioningState - READ-ONLY; The ARM provisioning state of the job execution. Possible values include: 'ProvisioningStateCreated', 'ProvisioningStateInProgress', 'ProvisioningStateSucceeded', 'ProvisioningStateFailed', 'ProvisioningStateCanceled' + ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` + // CreateTime - READ-ONLY; The time that the job execution was created. + CreateTime *date.Time `json:"createTime,omitempty"` + // StartTime - READ-ONLY; The time that the job execution started. + StartTime *date.Time `json:"startTime,omitempty"` + // EndTime - READ-ONLY; The time that the job execution completed. + EndTime *date.Time `json:"endTime,omitempty"` + // CurrentAttempts - Number of times the job execution has been attempted. + CurrentAttempts *int32 `json:"currentAttempts,omitempty"` + // CurrentAttemptStartTime - READ-ONLY; Start time of the current attempt. + CurrentAttemptStartTime *date.Time `json:"currentAttemptStartTime,omitempty"` + // LastMessage - READ-ONLY; The last status or error message. + LastMessage *string `json:"lastMessage,omitempty"` + // Target - READ-ONLY; The target that this execution is executed on. + Target *JobExecutionTarget `json:"target,omitempty"` +} + +// MarshalJSON is the custom marshaler for JobExecutionProperties. +func (jep JobExecutionProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if jep.CurrentAttempts != nil { + objectMap["currentAttempts"] = jep.CurrentAttempts + } + return json.Marshal(objectMap) +} + +// JobExecutionsCreateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type JobExecutionsCreateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(JobExecutionsClient) (JobExecution, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *JobExecutionsCreateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for JobExecutionsCreateFuture.Result. +func (future *JobExecutionsCreateFuture) result(client JobExecutionsClient) (je JobExecution, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobExecutionsCreateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + je.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.JobExecutionsCreateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if je.Response.Response, err = future.GetResult(sender); err == nil && je.Response.Response.StatusCode != http.StatusNoContent { + je, err = client.CreateResponder(je.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobExecutionsCreateFuture", "Result", je.Response.Response, "Failure responding to request") + } + } + return +} + +// JobExecutionsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type JobExecutionsCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(JobExecutionsClient) (JobExecution, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *JobExecutionsCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for JobExecutionsCreateOrUpdateFuture.Result. +func (future *JobExecutionsCreateOrUpdateFuture) result(client JobExecutionsClient) (je JobExecution, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobExecutionsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + je.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.JobExecutionsCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if je.Response.Response, err = future.GetResult(sender); err == nil && je.Response.Response.StatusCode != http.StatusNoContent { + je, err = client.CreateOrUpdateResponder(je.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.JobExecutionsCreateOrUpdateFuture", "Result", je.Response.Response, "Failure responding to request") + } + } + return +} + +// JobExecutionTarget the target that a job execution is executed on. +type JobExecutionTarget struct { + // Type - READ-ONLY; The type of the target. Possible values include: 'JobTargetTypeTargetGroup', 'JobTargetTypeSQLDatabase', 'JobTargetTypeSQLElasticPool', 'JobTargetTypeSQLShardMap', 'JobTargetTypeSQLServer' + Type JobTargetType `json:"type,omitempty"` + // ServerName - READ-ONLY; The server name. + ServerName *string `json:"serverName,omitempty"` + // DatabaseName - READ-ONLY; The database name. + DatabaseName *string `json:"databaseName,omitempty"` +} + +// MarshalJSON is the custom marshaler for JobExecutionTarget. +func (jet JobExecutionTarget) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// JobListResult a list of jobs. +type JobListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]Job `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for JobListResult. +func (jlr JobListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// JobListResultIterator provides access to a complete listing of Job values. +type JobListResultIterator struct { + i int + page JobListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *JobListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *JobListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter JobListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter JobListResultIterator) Response() JobListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter JobListResultIterator) Value() Job { + if !iter.page.NotDone() { + return Job{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the JobListResultIterator type. +func NewJobListResultIterator(page JobListResultPage) JobListResultIterator { + return JobListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (jlr JobListResult) IsEmpty() bool { + return jlr.Value == nil || len(*jlr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (jlr JobListResult) hasNextLink() bool { + return jlr.NextLink != nil && len(*jlr.NextLink) != 0 +} + +// jobListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (jlr JobListResult) jobListResultPreparer(ctx context.Context) (*http.Request, error) { + if !jlr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(jlr.NextLink))) +} + +// JobListResultPage contains a page of Job values. +type JobListResultPage struct { + fn func(context.Context, JobListResult) (JobListResult, error) + jlr JobListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *JobListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.jlr) + if err != nil { + return err + } + page.jlr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *JobListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page JobListResultPage) NotDone() bool { + return !page.jlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page JobListResultPage) Response() JobListResult { + return page.jlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page JobListResultPage) Values() []Job { + if page.jlr.IsEmpty() { + return nil + } + return *page.jlr.Value +} + +// Creates a new instance of the JobListResultPage type. +func NewJobListResultPage(cur JobListResult, getNextPage func(context.Context, JobListResult) (JobListResult, error)) JobListResultPage { + return JobListResultPage{ + fn: getNextPage, + jlr: cur, + } +} + +// JobProperties properties of a job. +type JobProperties struct { + // Description - User-defined description of the job. + Description *string `json:"description,omitempty"` + // Version - READ-ONLY; The job version number. + Version *int32 `json:"version,omitempty"` + // Schedule - Schedule properties of the job. + Schedule *JobSchedule `json:"schedule,omitempty"` +} + +// MarshalJSON is the custom marshaler for JobProperties. +func (jp JobProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if jp.Description != nil { + objectMap["description"] = jp.Description + } + if jp.Schedule != nil { + objectMap["schedule"] = jp.Schedule + } + return json.Marshal(objectMap) +} + +// JobSchedule scheduling properties of a job. +type JobSchedule struct { + // StartTime - Schedule start time. + StartTime *date.Time `json:"startTime,omitempty"` + // EndTime - Schedule end time. + EndTime *date.Time `json:"endTime,omitempty"` + // Type - Schedule interval type. Possible values include: 'JobScheduleTypeOnce', 'JobScheduleTypeRecurring' + Type JobScheduleType `json:"type,omitempty"` + // Enabled - Whether or not the schedule is enabled. + Enabled *bool `json:"enabled,omitempty"` + // Interval - Value of the schedule's recurring interval, if the ScheduleType is recurring. ISO8601 duration format. + Interval *string `json:"interval,omitempty"` +} + +// JobStep a job step. +type JobStep struct { + autorest.Response `json:"-"` + // JobStepProperties - Resource properties. + *JobStepProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for JobStep. +func (js JobStep) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if js.JobStepProperties != nil { + objectMap["properties"] = js.JobStepProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for JobStep struct. +func (js *JobStep) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var jobStepProperties JobStepProperties + err = json.Unmarshal(*v, &jobStepProperties) + if err != nil { + return err + } + js.JobStepProperties = &jobStepProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + js.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + js.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + js.Type = &typeVar + } + } + } + + return nil +} + +// JobStepAction the action to be executed by a job step. +type JobStepAction struct { + // Type - Type of action being executed by the job step. Possible values include: 'JobStepActionTypeTSQL' + Type JobStepActionType `json:"type,omitempty"` + // Source - The source of the action to execute. Possible values include: 'JobStepActionSourceInline' + Source JobStepActionSource `json:"source,omitempty"` + // Value - The action value, for example the text of the T-SQL script to execute. + Value *string `json:"value,omitempty"` +} + +// JobStepExecutionOptions the execution options of a job step. +type JobStepExecutionOptions struct { + // TimeoutSeconds - Execution timeout for the job step. + TimeoutSeconds *int32 `json:"timeoutSeconds,omitempty"` + // RetryAttempts - Maximum number of times the job step will be reattempted if the first attempt fails. + RetryAttempts *int32 `json:"retryAttempts,omitempty"` + // InitialRetryIntervalSeconds - Initial delay between retries for job step execution. + InitialRetryIntervalSeconds *int32 `json:"initialRetryIntervalSeconds,omitempty"` + // MaximumRetryIntervalSeconds - The maximum amount of time to wait between retries for job step execution. + MaximumRetryIntervalSeconds *int32 `json:"maximumRetryIntervalSeconds,omitempty"` + // RetryIntervalBackoffMultiplier - The backoff multiplier for the time between retries. + RetryIntervalBackoffMultiplier *float64 `json:"retryIntervalBackoffMultiplier,omitempty"` +} + +// JobStepListResult a list of job steps. +type JobStepListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]JobStep `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for JobStepListResult. +func (jslr JobStepListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// JobStepListResultIterator provides access to a complete listing of JobStep values. +type JobStepListResultIterator struct { + i int + page JobStepListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *JobStepListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobStepListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *JobStepListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter JobStepListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter JobStepListResultIterator) Response() JobStepListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter JobStepListResultIterator) Value() JobStep { + if !iter.page.NotDone() { + return JobStep{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the JobStepListResultIterator type. +func NewJobStepListResultIterator(page JobStepListResultPage) JobStepListResultIterator { + return JobStepListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (jslr JobStepListResult) IsEmpty() bool { + return jslr.Value == nil || len(*jslr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (jslr JobStepListResult) hasNextLink() bool { + return jslr.NextLink != nil && len(*jslr.NextLink) != 0 +} + +// jobStepListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (jslr JobStepListResult) jobStepListResultPreparer(ctx context.Context) (*http.Request, error) { + if !jslr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(jslr.NextLink))) +} + +// JobStepListResultPage contains a page of JobStep values. +type JobStepListResultPage struct { + fn func(context.Context, JobStepListResult) (JobStepListResult, error) + jslr JobStepListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *JobStepListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobStepListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.jslr) + if err != nil { + return err + } + page.jslr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *JobStepListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page JobStepListResultPage) NotDone() bool { + return !page.jslr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page JobStepListResultPage) Response() JobStepListResult { + return page.jslr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page JobStepListResultPage) Values() []JobStep { + if page.jslr.IsEmpty() { + return nil + } + return *page.jslr.Value +} + +// Creates a new instance of the JobStepListResultPage type. +func NewJobStepListResultPage(cur JobStepListResult, getNextPage func(context.Context, JobStepListResult) (JobStepListResult, error)) JobStepListResultPage { + return JobStepListResultPage{ + fn: getNextPage, + jslr: cur, + } +} + +// JobStepOutput the output configuration of a job step. +type JobStepOutput struct { + // Type - The output destination type. Possible values include: 'JobStepOutputTypeSQLDatabase' + Type JobStepOutputType `json:"type,omitempty"` + // SubscriptionID - The output destination subscription id. + SubscriptionID *uuid.UUID `json:"subscriptionId,omitempty"` + // ResourceGroupName - The output destination resource group. + ResourceGroupName *string `json:"resourceGroupName,omitempty"` + // ServerName - The output destination server name. + ServerName *string `json:"serverName,omitempty"` + // DatabaseName - The output destination database. + DatabaseName *string `json:"databaseName,omitempty"` + // SchemaName - The output destination schema. + SchemaName *string `json:"schemaName,omitempty"` + // TableName - The output destination table. + TableName *string `json:"tableName,omitempty"` + // Credential - The resource ID of the credential to use to connect to the output destination. + Credential *string `json:"credential,omitempty"` +} + +// JobStepProperties properties of a job step. +type JobStepProperties struct { + // StepID - The job step's index within the job. If not specified when creating the job step, it will be created as the last step. If not specified when updating the job step, the step id is not modified. + StepID *int32 `json:"stepId,omitempty"` + // TargetGroup - The resource ID of the target group that the job step will be executed on. + TargetGroup *string `json:"targetGroup,omitempty"` + // Credential - The resource ID of the job credential that will be used to connect to the targets. + Credential *string `json:"credential,omitempty"` + // Action - The action payload of the job step. + Action *JobStepAction `json:"action,omitempty"` + // Output - Output destination properties of the job step. + Output *JobStepOutput `json:"output,omitempty"` + // ExecutionOptions - Execution options for the job step. + ExecutionOptions *JobStepExecutionOptions `json:"executionOptions,omitempty"` +} + +// JobTarget a job target, for example a specific database or a container of databases that is evaluated +// during job execution. +type JobTarget struct { + // MembershipType - Whether the target is included or excluded from the group. Possible values include: 'JobTargetGroupMembershipTypeInclude', 'JobTargetGroupMembershipTypeExclude' + MembershipType JobTargetGroupMembershipType `json:"membershipType,omitempty"` + // Type - The target type. Possible values include: 'JobTargetTypeTargetGroup', 'JobTargetTypeSQLDatabase', 'JobTargetTypeSQLElasticPool', 'JobTargetTypeSQLShardMap', 'JobTargetTypeSQLServer' + Type JobTargetType `json:"type,omitempty"` + // ServerName - The target server name. + ServerName *string `json:"serverName,omitempty"` + // DatabaseName - The target database name. + DatabaseName *string `json:"databaseName,omitempty"` + // ElasticPoolName - The target elastic pool name. + ElasticPoolName *string `json:"elasticPoolName,omitempty"` + // ShardMapName - The target shard map. + ShardMapName *string `json:"shardMapName,omitempty"` + // RefreshCredential - The resource ID of the credential that is used during job execution to connect to the target and determine the list of databases inside the target. + RefreshCredential *string `json:"refreshCredential,omitempty"` +} + +// JobTargetGroup a group of job targets. +type JobTargetGroup struct { + autorest.Response `json:"-"` + // JobTargetGroupProperties - Resource properties. + *JobTargetGroupProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for JobTargetGroup. +func (jtg JobTargetGroup) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if jtg.JobTargetGroupProperties != nil { + objectMap["properties"] = jtg.JobTargetGroupProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for JobTargetGroup struct. +func (jtg *JobTargetGroup) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var jobTargetGroupProperties JobTargetGroupProperties + err = json.Unmarshal(*v, &jobTargetGroupProperties) + if err != nil { + return err + } + jtg.JobTargetGroupProperties = &jobTargetGroupProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + jtg.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + jtg.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + jtg.Type = &typeVar + } + } + } + + return nil +} + +// JobTargetGroupListResult a list of target groups. +type JobTargetGroupListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]JobTargetGroup `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for JobTargetGroupListResult. +func (jtglr JobTargetGroupListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// JobTargetGroupListResultIterator provides access to a complete listing of JobTargetGroup values. +type JobTargetGroupListResultIterator struct { + i int + page JobTargetGroupListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *JobTargetGroupListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobTargetGroupListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *JobTargetGroupListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter JobTargetGroupListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter JobTargetGroupListResultIterator) Response() JobTargetGroupListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter JobTargetGroupListResultIterator) Value() JobTargetGroup { + if !iter.page.NotDone() { + return JobTargetGroup{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the JobTargetGroupListResultIterator type. +func NewJobTargetGroupListResultIterator(page JobTargetGroupListResultPage) JobTargetGroupListResultIterator { + return JobTargetGroupListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (jtglr JobTargetGroupListResult) IsEmpty() bool { + return jtglr.Value == nil || len(*jtglr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (jtglr JobTargetGroupListResult) hasNextLink() bool { + return jtglr.NextLink != nil && len(*jtglr.NextLink) != 0 +} + +// jobTargetGroupListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (jtglr JobTargetGroupListResult) jobTargetGroupListResultPreparer(ctx context.Context) (*http.Request, error) { + if !jtglr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(jtglr.NextLink))) +} + +// JobTargetGroupListResultPage contains a page of JobTargetGroup values. +type JobTargetGroupListResultPage struct { + fn func(context.Context, JobTargetGroupListResult) (JobTargetGroupListResult, error) + jtglr JobTargetGroupListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *JobTargetGroupListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobTargetGroupListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.jtglr) + if err != nil { + return err + } + page.jtglr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *JobTargetGroupListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page JobTargetGroupListResultPage) NotDone() bool { + return !page.jtglr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page JobTargetGroupListResultPage) Response() JobTargetGroupListResult { + return page.jtglr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page JobTargetGroupListResultPage) Values() []JobTargetGroup { + if page.jtglr.IsEmpty() { + return nil + } + return *page.jtglr.Value +} + +// Creates a new instance of the JobTargetGroupListResultPage type. +func NewJobTargetGroupListResultPage(cur JobTargetGroupListResult, getNextPage func(context.Context, JobTargetGroupListResult) (JobTargetGroupListResult, error)) JobTargetGroupListResultPage { + return JobTargetGroupListResultPage{ + fn: getNextPage, + jtglr: cur, + } +} + +// JobTargetGroupProperties properties of job target group. +type JobTargetGroupProperties struct { + // Members - Members of the target group. + Members *[]JobTarget `json:"members,omitempty"` +} + +// JobVersion a job version. +type JobVersion struct { + autorest.Response `json:"-"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for JobVersion. +func (jv JobVersion) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// JobVersionListResult a list of job versions. +type JobVersionListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]JobVersion `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for JobVersionListResult. +func (jvlr JobVersionListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// JobVersionListResultIterator provides access to a complete listing of JobVersion values. +type JobVersionListResultIterator struct { + i int + page JobVersionListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *JobVersionListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobVersionListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *JobVersionListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter JobVersionListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter JobVersionListResultIterator) Response() JobVersionListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter JobVersionListResultIterator) Value() JobVersion { + if !iter.page.NotDone() { + return JobVersion{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the JobVersionListResultIterator type. +func NewJobVersionListResultIterator(page JobVersionListResultPage) JobVersionListResultIterator { + return JobVersionListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (jvlr JobVersionListResult) IsEmpty() bool { + return jvlr.Value == nil || len(*jvlr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (jvlr JobVersionListResult) hasNextLink() bool { + return jvlr.NextLink != nil && len(*jvlr.NextLink) != 0 +} + +// jobVersionListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (jvlr JobVersionListResult) jobVersionListResultPreparer(ctx context.Context) (*http.Request, error) { + if !jvlr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(jvlr.NextLink))) +} + +// JobVersionListResultPage contains a page of JobVersion values. +type JobVersionListResultPage struct { + fn func(context.Context, JobVersionListResult) (JobVersionListResult, error) + jvlr JobVersionListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *JobVersionListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/JobVersionListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.jvlr) + if err != nil { + return err + } + page.jvlr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *JobVersionListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page JobVersionListResultPage) NotDone() bool { + return !page.jvlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page JobVersionListResultPage) Response() JobVersionListResult { + return page.jvlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page JobVersionListResultPage) Values() []JobVersion { + if page.jvlr.IsEmpty() { + return nil + } + return *page.jvlr.Value +} + +// Creates a new instance of the JobVersionListResultPage type. +func NewJobVersionListResultPage(cur JobVersionListResult, getNextPage func(context.Context, JobVersionListResult) (JobVersionListResult, error)) JobVersionListResultPage { + return JobVersionListResultPage{ + fn: getNextPage, + jvlr: cur, + } +} + +// LedgerDigestUploads azure SQL Database ledger digest upload settings. +type LedgerDigestUploads struct { + autorest.Response `json:"-"` + // LedgerDigestUploadsProperties - Resource properties. + *LedgerDigestUploadsProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for LedgerDigestUploads. +func (ldu LedgerDigestUploads) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ldu.LedgerDigestUploadsProperties != nil { + objectMap["properties"] = ldu.LedgerDigestUploadsProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for LedgerDigestUploads struct. +func (ldu *LedgerDigestUploads) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var ledgerDigestUploadsProperties LedgerDigestUploadsProperties + err = json.Unmarshal(*v, &ledgerDigestUploadsProperties) + if err != nil { + return err + } + ldu.LedgerDigestUploadsProperties = &ledgerDigestUploadsProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + ldu.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ldu.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ldu.Type = &typeVar + } + } + } + + return nil +} + +// LedgerDigestUploadsListResult a list of ledger digest upload settings. +type LedgerDigestUploadsListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]LedgerDigestUploads `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for LedgerDigestUploadsListResult. +func (ldulr LedgerDigestUploadsListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// LedgerDigestUploadsListResultIterator provides access to a complete listing of LedgerDigestUploads +// values. +type LedgerDigestUploadsListResultIterator struct { + i int + page LedgerDigestUploadsListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *LedgerDigestUploadsListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LedgerDigestUploadsListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *LedgerDigestUploadsListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter LedgerDigestUploadsListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter LedgerDigestUploadsListResultIterator) Response() LedgerDigestUploadsListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter LedgerDigestUploadsListResultIterator) Value() LedgerDigestUploads { + if !iter.page.NotDone() { + return LedgerDigestUploads{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the LedgerDigestUploadsListResultIterator type. +func NewLedgerDigestUploadsListResultIterator(page LedgerDigestUploadsListResultPage) LedgerDigestUploadsListResultIterator { + return LedgerDigestUploadsListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (ldulr LedgerDigestUploadsListResult) IsEmpty() bool { + return ldulr.Value == nil || len(*ldulr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (ldulr LedgerDigestUploadsListResult) hasNextLink() bool { + return ldulr.NextLink != nil && len(*ldulr.NextLink) != 0 +} + +// ledgerDigestUploadsListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (ldulr LedgerDigestUploadsListResult) ledgerDigestUploadsListResultPreparer(ctx context.Context) (*http.Request, error) { + if !ldulr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(ldulr.NextLink))) +} + +// LedgerDigestUploadsListResultPage contains a page of LedgerDigestUploads values. +type LedgerDigestUploadsListResultPage struct { + fn func(context.Context, LedgerDigestUploadsListResult) (LedgerDigestUploadsListResult, error) + ldulr LedgerDigestUploadsListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *LedgerDigestUploadsListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LedgerDigestUploadsListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.ldulr) + if err != nil { + return err + } + page.ldulr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *LedgerDigestUploadsListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page LedgerDigestUploadsListResultPage) NotDone() bool { + return !page.ldulr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page LedgerDigestUploadsListResultPage) Response() LedgerDigestUploadsListResult { + return page.ldulr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page LedgerDigestUploadsListResultPage) Values() []LedgerDigestUploads { + if page.ldulr.IsEmpty() { + return nil + } + return *page.ldulr.Value +} + +// Creates a new instance of the LedgerDigestUploadsListResultPage type. +func NewLedgerDigestUploadsListResultPage(cur LedgerDigestUploadsListResult, getNextPage func(context.Context, LedgerDigestUploadsListResult) (LedgerDigestUploadsListResult, error)) LedgerDigestUploadsListResultPage { + return LedgerDigestUploadsListResultPage{ + fn: getNextPage, + ldulr: cur, + } +} + +// LedgerDigestUploadsProperties the properties of a database ledger digest upload settings. +type LedgerDigestUploadsProperties struct { + // DigestStorageEndpoint - The digest storage endpoint, which must be either an Azure blob storage endpoint or an URI for Azure Confidential Ledger. + DigestStorageEndpoint *string `json:"digestStorageEndpoint,omitempty"` + // State - READ-ONLY; Specifies the state of ledger digest upload. Possible values include: 'LedgerDigestUploadsStateEnabled', 'LedgerDigestUploadsStateDisabled' + State LedgerDigestUploadsState `json:"state,omitempty"` +} + +// MarshalJSON is the custom marshaler for LedgerDigestUploadsProperties. +func (ldup LedgerDigestUploadsProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ldup.DigestStorageEndpoint != nil { + objectMap["digestStorageEndpoint"] = ldup.DigestStorageEndpoint + } + return json.Marshal(objectMap) +} + +// LicenseTypeCapability the license type capability +type LicenseTypeCapability struct { + // Name - READ-ONLY; License type identifier. + Name *string `json:"name,omitempty"` + // Status - READ-ONLY; The status of the capability. Possible values include: 'CapabilityStatusVisible', 'CapabilityStatusAvailable', 'CapabilityStatusDefault', 'CapabilityStatusDisabled' + Status CapabilityStatus `json:"status,omitempty"` + // Reason - The reason for the capability not being available. + Reason *string `json:"reason,omitempty"` +} + +// MarshalJSON is the custom marshaler for LicenseTypeCapability. +func (ltc LicenseTypeCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ltc.Reason != nil { + objectMap["reason"] = ltc.Reason + } + return json.Marshal(objectMap) +} + +// ListAdvisor ... +type ListAdvisor struct { + autorest.Response `json:"-"` + Value *[]Advisor `json:"value,omitempty"` +} + +// ListRecommendedAction ... +type ListRecommendedAction struct { + autorest.Response `json:"-"` + Value *[]RecommendedAction `json:"value,omitempty"` +} + +// LocationCapabilities the location capability. +type LocationCapabilities struct { + autorest.Response `json:"-"` + // Name - READ-ONLY; The location name. + Name *string `json:"name,omitempty"` + // SupportedServerVersions - READ-ONLY; The list of supported server versions. + SupportedServerVersions *[]ServerVersionCapability `json:"supportedServerVersions,omitempty"` + // SupportedManagedInstanceVersions - READ-ONLY; The list of supported managed instance versions. + SupportedManagedInstanceVersions *[]ManagedInstanceVersionCapability `json:"supportedManagedInstanceVersions,omitempty"` + // Status - READ-ONLY; The status of the capability. Possible values include: 'CapabilityStatusVisible', 'CapabilityStatusAvailable', 'CapabilityStatusDefault', 'CapabilityStatusDisabled' + Status CapabilityStatus `json:"status,omitempty"` + // Reason - The reason for the capability not being available. + Reason *string `json:"reason,omitempty"` +} + +// MarshalJSON is the custom marshaler for LocationCapabilities. +func (lc LocationCapabilities) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if lc.Reason != nil { + objectMap["reason"] = lc.Reason + } + return json.Marshal(objectMap) +} + +// LogicalServerSecurityAlertPolicyListResult a list of the server's security alert policies. +type LogicalServerSecurityAlertPolicyListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]ServerSecurityAlertPolicy `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for LogicalServerSecurityAlertPolicyListResult. +func (lssaplr LogicalServerSecurityAlertPolicyListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// LogicalServerSecurityAlertPolicyListResultIterator provides access to a complete listing of +// ServerSecurityAlertPolicy values. +type LogicalServerSecurityAlertPolicyListResultIterator struct { + i int + page LogicalServerSecurityAlertPolicyListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *LogicalServerSecurityAlertPolicyListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LogicalServerSecurityAlertPolicyListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *LogicalServerSecurityAlertPolicyListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter LogicalServerSecurityAlertPolicyListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter LogicalServerSecurityAlertPolicyListResultIterator) Response() LogicalServerSecurityAlertPolicyListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter LogicalServerSecurityAlertPolicyListResultIterator) Value() ServerSecurityAlertPolicy { + if !iter.page.NotDone() { + return ServerSecurityAlertPolicy{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the LogicalServerSecurityAlertPolicyListResultIterator type. +func NewLogicalServerSecurityAlertPolicyListResultIterator(page LogicalServerSecurityAlertPolicyListResultPage) LogicalServerSecurityAlertPolicyListResultIterator { + return LogicalServerSecurityAlertPolicyListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (lssaplr LogicalServerSecurityAlertPolicyListResult) IsEmpty() bool { + return lssaplr.Value == nil || len(*lssaplr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (lssaplr LogicalServerSecurityAlertPolicyListResult) hasNextLink() bool { + return lssaplr.NextLink != nil && len(*lssaplr.NextLink) != 0 +} + +// logicalServerSecurityAlertPolicyListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (lssaplr LogicalServerSecurityAlertPolicyListResult) logicalServerSecurityAlertPolicyListResultPreparer(ctx context.Context) (*http.Request, error) { + if !lssaplr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(lssaplr.NextLink))) +} + +// LogicalServerSecurityAlertPolicyListResultPage contains a page of ServerSecurityAlertPolicy values. +type LogicalServerSecurityAlertPolicyListResultPage struct { + fn func(context.Context, LogicalServerSecurityAlertPolicyListResult) (LogicalServerSecurityAlertPolicyListResult, error) + lssaplr LogicalServerSecurityAlertPolicyListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *LogicalServerSecurityAlertPolicyListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LogicalServerSecurityAlertPolicyListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.lssaplr) + if err != nil { + return err + } + page.lssaplr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *LogicalServerSecurityAlertPolicyListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page LogicalServerSecurityAlertPolicyListResultPage) NotDone() bool { + return !page.lssaplr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page LogicalServerSecurityAlertPolicyListResultPage) Response() LogicalServerSecurityAlertPolicyListResult { + return page.lssaplr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page LogicalServerSecurityAlertPolicyListResultPage) Values() []ServerSecurityAlertPolicy { + if page.lssaplr.IsEmpty() { + return nil + } + return *page.lssaplr.Value +} + +// Creates a new instance of the LogicalServerSecurityAlertPolicyListResultPage type. +func NewLogicalServerSecurityAlertPolicyListResultPage(cur LogicalServerSecurityAlertPolicyListResult, getNextPage func(context.Context, LogicalServerSecurityAlertPolicyListResult) (LogicalServerSecurityAlertPolicyListResult, error)) LogicalServerSecurityAlertPolicyListResultPage { + return LogicalServerSecurityAlertPolicyListResultPage{ + fn: getNextPage, + lssaplr: cur, + } +} + +// LogSizeCapability the log size capability. +type LogSizeCapability struct { + // Limit - READ-ONLY; The log size limit (see 'unit' for the units). + Limit *int32 `json:"limit,omitempty"` + // Unit - READ-ONLY; The units that the limit is expressed in. Possible values include: 'LogSizeUnitMegabytes', 'LogSizeUnitGigabytes', 'LogSizeUnitTerabytes', 'LogSizeUnitPetabytes', 'LogSizeUnitPercent' + Unit LogSizeUnit `json:"unit,omitempty"` +} + +// MarshalJSON is the custom marshaler for LogSizeCapability. +func (lsc LogSizeCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// LongTermRetentionBackup a long term retention backup. +type LongTermRetentionBackup struct { + autorest.Response `json:"-"` + // LongTermRetentionBackupProperties - Resource properties. + *LongTermRetentionBackupProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for LongTermRetentionBackup. +func (ltrb LongTermRetentionBackup) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ltrb.LongTermRetentionBackupProperties != nil { + objectMap["properties"] = ltrb.LongTermRetentionBackupProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for LongTermRetentionBackup struct. +func (ltrb *LongTermRetentionBackup) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var longTermRetentionBackupProperties LongTermRetentionBackupProperties + err = json.Unmarshal(*v, &longTermRetentionBackupProperties) + if err != nil { + return err + } + ltrb.LongTermRetentionBackupProperties = &longTermRetentionBackupProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + ltrb.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ltrb.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ltrb.Type = &typeVar + } + } + } + + return nil +} + +// LongTermRetentionBackupListResult a list of long term retention backups. +type LongTermRetentionBackupListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]LongTermRetentionBackup `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for LongTermRetentionBackupListResult. +func (ltrblr LongTermRetentionBackupListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// LongTermRetentionBackupListResultIterator provides access to a complete listing of +// LongTermRetentionBackup values. +type LongTermRetentionBackupListResultIterator struct { + i int + page LongTermRetentionBackupListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *LongTermRetentionBackupListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionBackupListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *LongTermRetentionBackupListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter LongTermRetentionBackupListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter LongTermRetentionBackupListResultIterator) Response() LongTermRetentionBackupListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter LongTermRetentionBackupListResultIterator) Value() LongTermRetentionBackup { + if !iter.page.NotDone() { + return LongTermRetentionBackup{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the LongTermRetentionBackupListResultIterator type. +func NewLongTermRetentionBackupListResultIterator(page LongTermRetentionBackupListResultPage) LongTermRetentionBackupListResultIterator { + return LongTermRetentionBackupListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (ltrblr LongTermRetentionBackupListResult) IsEmpty() bool { + return ltrblr.Value == nil || len(*ltrblr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (ltrblr LongTermRetentionBackupListResult) hasNextLink() bool { + return ltrblr.NextLink != nil && len(*ltrblr.NextLink) != 0 +} + +// longTermRetentionBackupListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (ltrblr LongTermRetentionBackupListResult) longTermRetentionBackupListResultPreparer(ctx context.Context) (*http.Request, error) { + if !ltrblr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(ltrblr.NextLink))) +} + +// LongTermRetentionBackupListResultPage contains a page of LongTermRetentionBackup values. +type LongTermRetentionBackupListResultPage struct { + fn func(context.Context, LongTermRetentionBackupListResult) (LongTermRetentionBackupListResult, error) + ltrblr LongTermRetentionBackupListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *LongTermRetentionBackupListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionBackupListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.ltrblr) + if err != nil { + return err + } + page.ltrblr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *LongTermRetentionBackupListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page LongTermRetentionBackupListResultPage) NotDone() bool { + return !page.ltrblr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page LongTermRetentionBackupListResultPage) Response() LongTermRetentionBackupListResult { + return page.ltrblr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page LongTermRetentionBackupListResultPage) Values() []LongTermRetentionBackup { + if page.ltrblr.IsEmpty() { + return nil + } + return *page.ltrblr.Value +} + +// Creates a new instance of the LongTermRetentionBackupListResultPage type. +func NewLongTermRetentionBackupListResultPage(cur LongTermRetentionBackupListResult, getNextPage func(context.Context, LongTermRetentionBackupListResult) (LongTermRetentionBackupListResult, error)) LongTermRetentionBackupListResultPage { + return LongTermRetentionBackupListResultPage{ + fn: getNextPage, + ltrblr: cur, + } +} + +// LongTermRetentionBackupOperationResult a LongTermRetentionBackup operation result resource. +type LongTermRetentionBackupOperationResult struct { + autorest.Response `json:"-"` + // LongTermRetentionOperationResultProperties - Resource properties. + *LongTermRetentionOperationResultProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for LongTermRetentionBackupOperationResult. +func (ltrbor LongTermRetentionBackupOperationResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ltrbor.LongTermRetentionOperationResultProperties != nil { + objectMap["properties"] = ltrbor.LongTermRetentionOperationResultProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for LongTermRetentionBackupOperationResult struct. +func (ltrbor *LongTermRetentionBackupOperationResult) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var longTermRetentionOperationResultProperties LongTermRetentionOperationResultProperties + err = json.Unmarshal(*v, &longTermRetentionOperationResultProperties) + if err != nil { + return err + } + ltrbor.LongTermRetentionOperationResultProperties = &longTermRetentionOperationResultProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + ltrbor.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ltrbor.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ltrbor.Type = &typeVar + } + } + } + + return nil +} + +// LongTermRetentionBackupProperties properties of a long term retention backup +type LongTermRetentionBackupProperties struct { + // ServerName - READ-ONLY; The server name that the backup database belong to. + ServerName *string `json:"serverName,omitempty"` + // ServerCreateTime - READ-ONLY; The create time of the server. + ServerCreateTime *date.Time `json:"serverCreateTime,omitempty"` + // DatabaseName - READ-ONLY; The name of the database the backup belong to + DatabaseName *string `json:"databaseName,omitempty"` + // DatabaseDeletionTime - READ-ONLY; The delete time of the database + DatabaseDeletionTime *date.Time `json:"databaseDeletionTime,omitempty"` + // BackupTime - READ-ONLY; The time the backup was taken + BackupTime *date.Time `json:"backupTime,omitempty"` + // BackupExpirationTime - READ-ONLY; The time the long term retention backup will expire. + BackupExpirationTime *date.Time `json:"backupExpirationTime,omitempty"` + // BackupStorageRedundancy - READ-ONLY; The storage redundancy type of the backup. Possible values include: 'BackupStorageRedundancyGeo', 'BackupStorageRedundancyLocal', 'BackupStorageRedundancyZone' + BackupStorageRedundancy BackupStorageRedundancy `json:"backupStorageRedundancy,omitempty"` + // RequestedBackupStorageRedundancy - The storage redundancy type of the backup. Possible values include: 'BackupStorageRedundancyGeo', 'BackupStorageRedundancyLocal', 'BackupStorageRedundancyZone' + RequestedBackupStorageRedundancy BackupStorageRedundancy `json:"requestedBackupStorageRedundancy,omitempty"` +} + +// MarshalJSON is the custom marshaler for LongTermRetentionBackupProperties. +func (ltrbp LongTermRetentionBackupProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ltrbp.RequestedBackupStorageRedundancy != "" { + objectMap["requestedBackupStorageRedundancy"] = ltrbp.RequestedBackupStorageRedundancy + } + return json.Marshal(objectMap) +} + +// LongTermRetentionBackupsCopyByResourceGroupFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type LongTermRetentionBackupsCopyByResourceGroupFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(LongTermRetentionBackupsClient) (LongTermRetentionBackupOperationResult, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *LongTermRetentionBackupsCopyByResourceGroupFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for LongTermRetentionBackupsCopyByResourceGroupFuture.Result. +func (future *LongTermRetentionBackupsCopyByResourceGroupFuture) result(client LongTermRetentionBackupsClient) (ltrbor LongTermRetentionBackupOperationResult, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsCopyByResourceGroupFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ltrbor.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.LongTermRetentionBackupsCopyByResourceGroupFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if ltrbor.Response.Response, err = future.GetResult(sender); err == nil && ltrbor.Response.Response.StatusCode != http.StatusNoContent { + ltrbor, err = client.CopyByResourceGroupResponder(ltrbor.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsCopyByResourceGroupFuture", "Result", ltrbor.Response.Response, "Failure responding to request") + } + } + return +} + +// LongTermRetentionBackupsCopyFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type LongTermRetentionBackupsCopyFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(LongTermRetentionBackupsClient) (LongTermRetentionBackupOperationResult, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *LongTermRetentionBackupsCopyFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for LongTermRetentionBackupsCopyFuture.Result. +func (future *LongTermRetentionBackupsCopyFuture) result(client LongTermRetentionBackupsClient) (ltrbor LongTermRetentionBackupOperationResult, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsCopyFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ltrbor.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.LongTermRetentionBackupsCopyFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if ltrbor.Response.Response, err = future.GetResult(sender); err == nil && ltrbor.Response.Response.StatusCode != http.StatusNoContent { + ltrbor, err = client.CopyResponder(ltrbor.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsCopyFuture", "Result", ltrbor.Response.Response, "Failure responding to request") + } + } + return +} + +// LongTermRetentionBackupsDeleteByResourceGroupFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type LongTermRetentionBackupsDeleteByResourceGroupFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(LongTermRetentionBackupsClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *LongTermRetentionBackupsDeleteByResourceGroupFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for LongTermRetentionBackupsDeleteByResourceGroupFuture.Result. +func (future *LongTermRetentionBackupsDeleteByResourceGroupFuture) result(client LongTermRetentionBackupsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsDeleteByResourceGroupFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.LongTermRetentionBackupsDeleteByResourceGroupFuture") + return + } + ar.Response = future.Response() + return +} + +// LongTermRetentionBackupsDeleteFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type LongTermRetentionBackupsDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(LongTermRetentionBackupsClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *LongTermRetentionBackupsDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for LongTermRetentionBackupsDeleteFuture.Result. +func (future *LongTermRetentionBackupsDeleteFuture) result(client LongTermRetentionBackupsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.LongTermRetentionBackupsDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// LongTermRetentionBackupsUpdateByResourceGroupFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type LongTermRetentionBackupsUpdateByResourceGroupFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(LongTermRetentionBackupsClient) (LongTermRetentionBackupOperationResult, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *LongTermRetentionBackupsUpdateByResourceGroupFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for LongTermRetentionBackupsUpdateByResourceGroupFuture.Result. +func (future *LongTermRetentionBackupsUpdateByResourceGroupFuture) result(client LongTermRetentionBackupsClient) (ltrbor LongTermRetentionBackupOperationResult, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsUpdateByResourceGroupFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ltrbor.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.LongTermRetentionBackupsUpdateByResourceGroupFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if ltrbor.Response.Response, err = future.GetResult(sender); err == nil && ltrbor.Response.Response.StatusCode != http.StatusNoContent { + ltrbor, err = client.UpdateByResourceGroupResponder(ltrbor.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsUpdateByResourceGroupFuture", "Result", ltrbor.Response.Response, "Failure responding to request") + } + } + return +} + +// LongTermRetentionBackupsUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type LongTermRetentionBackupsUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(LongTermRetentionBackupsClient) (LongTermRetentionBackupOperationResult, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *LongTermRetentionBackupsUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for LongTermRetentionBackupsUpdateFuture.Result. +func (future *LongTermRetentionBackupsUpdateFuture) result(client LongTermRetentionBackupsClient) (ltrbor LongTermRetentionBackupOperationResult, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ltrbor.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.LongTermRetentionBackupsUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if ltrbor.Response.Response, err = future.GetResult(sender); err == nil && ltrbor.Response.Response.StatusCode != http.StatusNoContent { + ltrbor, err = client.UpdateResponder(ltrbor.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionBackupsUpdateFuture", "Result", ltrbor.Response.Response, "Failure responding to request") + } + } + return +} + +// LongTermRetentionManagedInstanceBackupsDeleteByResourceGroupFuture an abstraction for monitoring and +// retrieving the results of a long-running operation. +type LongTermRetentionManagedInstanceBackupsDeleteByResourceGroupFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(LongTermRetentionManagedInstanceBackupsClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *LongTermRetentionManagedInstanceBackupsDeleteByResourceGroupFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for LongTermRetentionManagedInstanceBackupsDeleteByResourceGroupFuture.Result. +func (future *LongTermRetentionManagedInstanceBackupsDeleteByResourceGroupFuture) result(client LongTermRetentionManagedInstanceBackupsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionManagedInstanceBackupsDeleteByResourceGroupFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.LongTermRetentionManagedInstanceBackupsDeleteByResourceGroupFuture") + return + } + ar.Response = future.Response() + return +} + +// LongTermRetentionManagedInstanceBackupsDeleteFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type LongTermRetentionManagedInstanceBackupsDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(LongTermRetentionManagedInstanceBackupsClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *LongTermRetentionManagedInstanceBackupsDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for LongTermRetentionManagedInstanceBackupsDeleteFuture.Result. +func (future *LongTermRetentionManagedInstanceBackupsDeleteFuture) result(client LongTermRetentionManagedInstanceBackupsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionManagedInstanceBackupsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.LongTermRetentionManagedInstanceBackupsDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// LongTermRetentionOperationResultProperties contains the operation result properties for long term +// retention backup operation. +type LongTermRetentionOperationResultProperties struct { + // RequestID - READ-ONLY; Request Id. + RequestID *uuid.UUID `json:"requestId,omitempty"` + // OperationType - READ-ONLY; Operation type. + OperationType *string `json:"operationType,omitempty"` + // FromBackupResourceID - READ-ONLY; Source backup resource id + FromBackupResourceID *string `json:"fromBackupResourceId,omitempty"` + // ToBackupResourceID - READ-ONLY; Target backup resource id + ToBackupResourceID *string `json:"toBackupResourceId,omitempty"` + // TargetBackupStorageRedundancy - READ-ONLY; The storage redundancy type of the copied backup. Possible values include: 'BackupStorageRedundancyGeo', 'BackupStorageRedundancyLocal', 'BackupStorageRedundancyZone' + TargetBackupStorageRedundancy BackupStorageRedundancy `json:"targetBackupStorageRedundancy,omitempty"` + // Status - READ-ONLY; Operation status + Status *string `json:"status,omitempty"` + // Message - READ-ONLY; Progress message + Message *string `json:"message,omitempty"` +} + +// MarshalJSON is the custom marshaler for LongTermRetentionOperationResultProperties. +func (ltrorp LongTermRetentionOperationResultProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// LongTermRetentionPoliciesCreateOrUpdateFuture an abstraction for monitoring and retrieving the results +// of a long-running operation. +type LongTermRetentionPoliciesCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(LongTermRetentionPoliciesClient) (LongTermRetentionPolicy, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *LongTermRetentionPoliciesCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for LongTermRetentionPoliciesCreateOrUpdateFuture.Result. +func (future *LongTermRetentionPoliciesCreateOrUpdateFuture) result(client LongTermRetentionPoliciesClient) (ltrp LongTermRetentionPolicy, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionPoliciesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ltrp.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.LongTermRetentionPoliciesCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if ltrp.Response.Response, err = future.GetResult(sender); err == nil && ltrp.Response.Response.StatusCode != http.StatusNoContent { + ltrp, err = client.CreateOrUpdateResponder(ltrp.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.LongTermRetentionPoliciesCreateOrUpdateFuture", "Result", ltrp.Response.Response, "Failure responding to request") + } + } + return +} + +// LongTermRetentionPolicy a long term retention policy. +type LongTermRetentionPolicy struct { + autorest.Response `json:"-"` + // BaseLongTermRetentionPolicyProperties - Resource properties. + *BaseLongTermRetentionPolicyProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for LongTermRetentionPolicy. +func (ltrp LongTermRetentionPolicy) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ltrp.BaseLongTermRetentionPolicyProperties != nil { + objectMap["properties"] = ltrp.BaseLongTermRetentionPolicyProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for LongTermRetentionPolicy struct. +func (ltrp *LongTermRetentionPolicy) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var baseLongTermRetentionPolicyProperties BaseLongTermRetentionPolicyProperties + err = json.Unmarshal(*v, &baseLongTermRetentionPolicyProperties) + if err != nil { + return err + } + ltrp.BaseLongTermRetentionPolicyProperties = &baseLongTermRetentionPolicyProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + ltrp.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ltrp.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ltrp.Type = &typeVar + } + } + } + + return nil +} + +// LongTermRetentionPolicyListResult a list of long term retention policies. +type LongTermRetentionPolicyListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]LongTermRetentionPolicy `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for LongTermRetentionPolicyListResult. +func (ltrplr LongTermRetentionPolicyListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// LongTermRetentionPolicyListResultIterator provides access to a complete listing of +// LongTermRetentionPolicy values. +type LongTermRetentionPolicyListResultIterator struct { + i int + page LongTermRetentionPolicyListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *LongTermRetentionPolicyListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionPolicyListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *LongTermRetentionPolicyListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter LongTermRetentionPolicyListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter LongTermRetentionPolicyListResultIterator) Response() LongTermRetentionPolicyListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter LongTermRetentionPolicyListResultIterator) Value() LongTermRetentionPolicy { + if !iter.page.NotDone() { + return LongTermRetentionPolicy{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the LongTermRetentionPolicyListResultIterator type. +func NewLongTermRetentionPolicyListResultIterator(page LongTermRetentionPolicyListResultPage) LongTermRetentionPolicyListResultIterator { + return LongTermRetentionPolicyListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (ltrplr LongTermRetentionPolicyListResult) IsEmpty() bool { + return ltrplr.Value == nil || len(*ltrplr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (ltrplr LongTermRetentionPolicyListResult) hasNextLink() bool { + return ltrplr.NextLink != nil && len(*ltrplr.NextLink) != 0 +} + +// longTermRetentionPolicyListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (ltrplr LongTermRetentionPolicyListResult) longTermRetentionPolicyListResultPreparer(ctx context.Context) (*http.Request, error) { + if !ltrplr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(ltrplr.NextLink))) +} + +// LongTermRetentionPolicyListResultPage contains a page of LongTermRetentionPolicy values. +type LongTermRetentionPolicyListResultPage struct { + fn func(context.Context, LongTermRetentionPolicyListResult) (LongTermRetentionPolicyListResult, error) + ltrplr LongTermRetentionPolicyListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *LongTermRetentionPolicyListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LongTermRetentionPolicyListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.ltrplr) + if err != nil { + return err + } + page.ltrplr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *LongTermRetentionPolicyListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page LongTermRetentionPolicyListResultPage) NotDone() bool { + return !page.ltrplr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page LongTermRetentionPolicyListResultPage) Response() LongTermRetentionPolicyListResult { + return page.ltrplr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page LongTermRetentionPolicyListResultPage) Values() []LongTermRetentionPolicy { + if page.ltrplr.IsEmpty() { + return nil + } + return *page.ltrplr.Value +} + +// Creates a new instance of the LongTermRetentionPolicyListResultPage type. +func NewLongTermRetentionPolicyListResultPage(cur LongTermRetentionPolicyListResult, getNextPage func(context.Context, LongTermRetentionPolicyListResult) (LongTermRetentionPolicyListResult, error)) LongTermRetentionPolicyListResultPage { + return LongTermRetentionPolicyListResultPage{ + fn: getNextPage, + ltrplr: cur, + } +} + +// MaintenanceConfigurationCapability the maintenance configuration capability +type MaintenanceConfigurationCapability struct { + // Name - READ-ONLY; Maintenance configuration name + Name *string `json:"name,omitempty"` + // ZoneRedundant - READ-ONLY; Whether or not zone redundancy is supported for the maintenance configuration. + ZoneRedundant *bool `json:"zoneRedundant,omitempty"` + // Status - READ-ONLY; The status of the capability. Possible values include: 'CapabilityStatusVisible', 'CapabilityStatusAvailable', 'CapabilityStatusDefault', 'CapabilityStatusDisabled' + Status CapabilityStatus `json:"status,omitempty"` + // Reason - The reason for the capability not being available. + Reason *string `json:"reason,omitempty"` +} + +// MarshalJSON is the custom marshaler for MaintenanceConfigurationCapability. +func (mcc MaintenanceConfigurationCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mcc.Reason != nil { + objectMap["reason"] = mcc.Reason + } + return json.Marshal(objectMap) +} + +// MaintenanceWindowOptions maintenance window options. +type MaintenanceWindowOptions struct { + autorest.Response `json:"-"` + // MaintenanceWindowOptionsProperties - Resource properties. + *MaintenanceWindowOptionsProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for MaintenanceWindowOptions. +func (mwo MaintenanceWindowOptions) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mwo.MaintenanceWindowOptionsProperties != nil { + objectMap["properties"] = mwo.MaintenanceWindowOptionsProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for MaintenanceWindowOptions struct. +func (mwo *MaintenanceWindowOptions) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var maintenanceWindowOptionsProperties MaintenanceWindowOptionsProperties + err = json.Unmarshal(*v, &maintenanceWindowOptionsProperties) + if err != nil { + return err + } + mwo.MaintenanceWindowOptionsProperties = &maintenanceWindowOptionsProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + mwo.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + mwo.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + mwo.Type = &typeVar + } + } + } + + return nil +} + +// MaintenanceWindowOptionsProperties maintenance window options properties. +type MaintenanceWindowOptionsProperties struct { + // IsEnabled - Whether maintenance windows are enabled for the database. + IsEnabled *bool `json:"isEnabled,omitempty"` + // MaintenanceWindowCycles - Available maintenance cycles e.g. {Saturday, 0, 48*60}, {Wednesday, 0, 24*60}. + MaintenanceWindowCycles *[]MaintenanceWindowTimeRange `json:"maintenanceWindowCycles,omitempty"` + // MinDurationInMinutes - Minimum duration of maintenance window. + MinDurationInMinutes *int32 `json:"minDurationInMinutes,omitempty"` + // DefaultDurationInMinutes - Default duration for maintenance window. + DefaultDurationInMinutes *int32 `json:"defaultDurationInMinutes,omitempty"` + // MinCycles - Minimum number of maintenance windows cycles to be set on the database. + MinCycles *int32 `json:"minCycles,omitempty"` + // TimeGranularityInMinutes - Time granularity in minutes for maintenance windows. + TimeGranularityInMinutes *int32 `json:"timeGranularityInMinutes,omitempty"` + // AllowMultipleMaintenanceWindowsPerCycle - Whether we allow multiple maintenance windows per cycle. + AllowMultipleMaintenanceWindowsPerCycle *bool `json:"allowMultipleMaintenanceWindowsPerCycle,omitempty"` +} + +// MaintenanceWindows maintenance windows. +type MaintenanceWindows struct { + autorest.Response `json:"-"` + // MaintenanceWindowsProperties - Resource properties. + *MaintenanceWindowsProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for MaintenanceWindows. +func (mw MaintenanceWindows) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mw.MaintenanceWindowsProperties != nil { + objectMap["properties"] = mw.MaintenanceWindowsProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for MaintenanceWindows struct. +func (mw *MaintenanceWindows) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var maintenanceWindowsProperties MaintenanceWindowsProperties + err = json.Unmarshal(*v, &maintenanceWindowsProperties) + if err != nil { + return err + } + mw.MaintenanceWindowsProperties = &maintenanceWindowsProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + mw.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + mw.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + mw.Type = &typeVar + } + } + } + + return nil +} + +// MaintenanceWindowsProperties maintenance windows resource properties. +type MaintenanceWindowsProperties struct { + TimeRanges *[]MaintenanceWindowTimeRange `json:"timeRanges,omitempty"` +} + +// MaintenanceWindowTimeRange maintenance window time range. +type MaintenanceWindowTimeRange struct { + // DayOfWeek - Day of maintenance window. Possible values include: 'DayOfWeekSunday', 'DayOfWeekMonday', 'DayOfWeekTuesday', 'DayOfWeekWednesday', 'DayOfWeekThursday', 'DayOfWeekFriday', 'DayOfWeekSaturday' + DayOfWeek DayOfWeek `json:"dayOfWeek,omitempty"` + // StartTime - Start time minutes offset from 12am. + StartTime *string `json:"startTime,omitempty"` + // Duration - Duration of maintenance window in minutes. + Duration *string `json:"duration,omitempty"` +} + +// ManagedBackupShortTermRetentionPoliciesCreateOrUpdateFuture an abstraction for monitoring and retrieving +// the results of a long-running operation. +type ManagedBackupShortTermRetentionPoliciesCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ManagedBackupShortTermRetentionPoliciesClient) (ManagedBackupShortTermRetentionPolicy, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ManagedBackupShortTermRetentionPoliciesCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ManagedBackupShortTermRetentionPoliciesCreateOrUpdateFuture.Result. +func (future *ManagedBackupShortTermRetentionPoliciesCreateOrUpdateFuture) result(client ManagedBackupShortTermRetentionPoliciesClient) (mbstrp ManagedBackupShortTermRetentionPolicy, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedBackupShortTermRetentionPoliciesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + mbstrp.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ManagedBackupShortTermRetentionPoliciesCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if mbstrp.Response.Response, err = future.GetResult(sender); err == nil && mbstrp.Response.Response.StatusCode != http.StatusNoContent { + mbstrp, err = client.CreateOrUpdateResponder(mbstrp.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedBackupShortTermRetentionPoliciesCreateOrUpdateFuture", "Result", mbstrp.Response.Response, "Failure responding to request") + } + } + return +} + +// ManagedBackupShortTermRetentionPoliciesUpdateFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type ManagedBackupShortTermRetentionPoliciesUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ManagedBackupShortTermRetentionPoliciesClient) (ManagedBackupShortTermRetentionPolicy, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ManagedBackupShortTermRetentionPoliciesUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ManagedBackupShortTermRetentionPoliciesUpdateFuture.Result. +func (future *ManagedBackupShortTermRetentionPoliciesUpdateFuture) result(client ManagedBackupShortTermRetentionPoliciesClient) (mbstrp ManagedBackupShortTermRetentionPolicy, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedBackupShortTermRetentionPoliciesUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + mbstrp.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ManagedBackupShortTermRetentionPoliciesUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if mbstrp.Response.Response, err = future.GetResult(sender); err == nil && mbstrp.Response.Response.StatusCode != http.StatusNoContent { + mbstrp, err = client.UpdateResponder(mbstrp.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedBackupShortTermRetentionPoliciesUpdateFuture", "Result", mbstrp.Response.Response, "Failure responding to request") + } + } + return +} + +// ManagedBackupShortTermRetentionPolicy a short term retention policy. +type ManagedBackupShortTermRetentionPolicy struct { + autorest.Response `json:"-"` + // ManagedBackupShortTermRetentionPolicyProperties - Resource properties. + *ManagedBackupShortTermRetentionPolicyProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedBackupShortTermRetentionPolicy. +func (mbstrp ManagedBackupShortTermRetentionPolicy) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mbstrp.ManagedBackupShortTermRetentionPolicyProperties != nil { + objectMap["properties"] = mbstrp.ManagedBackupShortTermRetentionPolicyProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ManagedBackupShortTermRetentionPolicy struct. +func (mbstrp *ManagedBackupShortTermRetentionPolicy) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var managedBackupShortTermRetentionPolicyProperties ManagedBackupShortTermRetentionPolicyProperties + err = json.Unmarshal(*v, &managedBackupShortTermRetentionPolicyProperties) + if err != nil { + return err + } + mbstrp.ManagedBackupShortTermRetentionPolicyProperties = &managedBackupShortTermRetentionPolicyProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + mbstrp.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + mbstrp.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + mbstrp.Type = &typeVar + } + } + } + + return nil +} + +// ManagedBackupShortTermRetentionPolicyListResult a list of short term retention policies. +type ManagedBackupShortTermRetentionPolicyListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]ManagedBackupShortTermRetentionPolicy `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedBackupShortTermRetentionPolicyListResult. +func (mbstrplr ManagedBackupShortTermRetentionPolicyListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ManagedBackupShortTermRetentionPolicyListResultIterator provides access to a complete listing of +// ManagedBackupShortTermRetentionPolicy values. +type ManagedBackupShortTermRetentionPolicyListResultIterator struct { + i int + page ManagedBackupShortTermRetentionPolicyListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *ManagedBackupShortTermRetentionPolicyListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedBackupShortTermRetentionPolicyListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ManagedBackupShortTermRetentionPolicyListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ManagedBackupShortTermRetentionPolicyListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter ManagedBackupShortTermRetentionPolicyListResultIterator) Response() ManagedBackupShortTermRetentionPolicyListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter ManagedBackupShortTermRetentionPolicyListResultIterator) Value() ManagedBackupShortTermRetentionPolicy { + if !iter.page.NotDone() { + return ManagedBackupShortTermRetentionPolicy{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ManagedBackupShortTermRetentionPolicyListResultIterator type. +func NewManagedBackupShortTermRetentionPolicyListResultIterator(page ManagedBackupShortTermRetentionPolicyListResultPage) ManagedBackupShortTermRetentionPolicyListResultIterator { + return ManagedBackupShortTermRetentionPolicyListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (mbstrplr ManagedBackupShortTermRetentionPolicyListResult) IsEmpty() bool { + return mbstrplr.Value == nil || len(*mbstrplr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (mbstrplr ManagedBackupShortTermRetentionPolicyListResult) hasNextLink() bool { + return mbstrplr.NextLink != nil && len(*mbstrplr.NextLink) != 0 +} + +// managedBackupShortTermRetentionPolicyListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (mbstrplr ManagedBackupShortTermRetentionPolicyListResult) managedBackupShortTermRetentionPolicyListResultPreparer(ctx context.Context) (*http.Request, error) { + if !mbstrplr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(mbstrplr.NextLink))) +} + +// ManagedBackupShortTermRetentionPolicyListResultPage contains a page of +// ManagedBackupShortTermRetentionPolicy values. +type ManagedBackupShortTermRetentionPolicyListResultPage struct { + fn func(context.Context, ManagedBackupShortTermRetentionPolicyListResult) (ManagedBackupShortTermRetentionPolicyListResult, error) + mbstrplr ManagedBackupShortTermRetentionPolicyListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *ManagedBackupShortTermRetentionPolicyListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedBackupShortTermRetentionPolicyListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.mbstrplr) + if err != nil { + return err + } + page.mbstrplr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *ManagedBackupShortTermRetentionPolicyListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ManagedBackupShortTermRetentionPolicyListResultPage) NotDone() bool { + return !page.mbstrplr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ManagedBackupShortTermRetentionPolicyListResultPage) Response() ManagedBackupShortTermRetentionPolicyListResult { + return page.mbstrplr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ManagedBackupShortTermRetentionPolicyListResultPage) Values() []ManagedBackupShortTermRetentionPolicy { + if page.mbstrplr.IsEmpty() { + return nil + } + return *page.mbstrplr.Value +} + +// Creates a new instance of the ManagedBackupShortTermRetentionPolicyListResultPage type. +func NewManagedBackupShortTermRetentionPolicyListResultPage(cur ManagedBackupShortTermRetentionPolicyListResult, getNextPage func(context.Context, ManagedBackupShortTermRetentionPolicyListResult) (ManagedBackupShortTermRetentionPolicyListResult, error)) ManagedBackupShortTermRetentionPolicyListResultPage { + return ManagedBackupShortTermRetentionPolicyListResultPage{ + fn: getNextPage, + mbstrplr: cur, + } +} + +// ManagedBackupShortTermRetentionPolicyProperties properties of a short term retention policy +type ManagedBackupShortTermRetentionPolicyProperties struct { + // RetentionDays - The backup retention period in days. This is how many days Point-in-Time Restore will be supported. + RetentionDays *int32 `json:"retentionDays,omitempty"` +} + +// ManagedDatabase a managed database resource. +type ManagedDatabase struct { + autorest.Response `json:"-"` + // ManagedDatabaseProperties - Resource properties. + *ManagedDatabaseProperties `json:"properties,omitempty"` + // Location - Resource location. + Location *string `json:"location,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedDatabase. +func (md ManagedDatabase) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if md.ManagedDatabaseProperties != nil { + objectMap["properties"] = md.ManagedDatabaseProperties + } + if md.Location != nil { + objectMap["location"] = md.Location + } + if md.Tags != nil { + objectMap["tags"] = md.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ManagedDatabase struct. +func (md *ManagedDatabase) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var managedDatabaseProperties ManagedDatabaseProperties + err = json.Unmarshal(*v, &managedDatabaseProperties) + if err != nil { + return err + } + md.ManagedDatabaseProperties = &managedDatabaseProperties + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + md.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + md.Tags = tags + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + md.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + md.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + md.Type = &typeVar + } + } + } + + return nil +} + +// ManagedDatabaseListResult a list of managed databases. +type ManagedDatabaseListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]ManagedDatabase `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedDatabaseListResult. +func (mdlr ManagedDatabaseListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ManagedDatabaseListResultIterator provides access to a complete listing of ManagedDatabase values. +type ManagedDatabaseListResultIterator struct { + i int + page ManagedDatabaseListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *ManagedDatabaseListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabaseListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ManagedDatabaseListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ManagedDatabaseListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter ManagedDatabaseListResultIterator) Response() ManagedDatabaseListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter ManagedDatabaseListResultIterator) Value() ManagedDatabase { + if !iter.page.NotDone() { + return ManagedDatabase{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ManagedDatabaseListResultIterator type. +func NewManagedDatabaseListResultIterator(page ManagedDatabaseListResultPage) ManagedDatabaseListResultIterator { + return ManagedDatabaseListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (mdlr ManagedDatabaseListResult) IsEmpty() bool { + return mdlr.Value == nil || len(*mdlr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (mdlr ManagedDatabaseListResult) hasNextLink() bool { + return mdlr.NextLink != nil && len(*mdlr.NextLink) != 0 +} + +// managedDatabaseListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (mdlr ManagedDatabaseListResult) managedDatabaseListResultPreparer(ctx context.Context) (*http.Request, error) { + if !mdlr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(mdlr.NextLink))) +} + +// ManagedDatabaseListResultPage contains a page of ManagedDatabase values. +type ManagedDatabaseListResultPage struct { + fn func(context.Context, ManagedDatabaseListResult) (ManagedDatabaseListResult, error) + mdlr ManagedDatabaseListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *ManagedDatabaseListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabaseListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.mdlr) + if err != nil { + return err + } + page.mdlr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *ManagedDatabaseListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ManagedDatabaseListResultPage) NotDone() bool { + return !page.mdlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ManagedDatabaseListResultPage) Response() ManagedDatabaseListResult { + return page.mdlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ManagedDatabaseListResultPage) Values() []ManagedDatabase { + if page.mdlr.IsEmpty() { + return nil + } + return *page.mdlr.Value +} + +// Creates a new instance of the ManagedDatabaseListResultPage type. +func NewManagedDatabaseListResultPage(cur ManagedDatabaseListResult, getNextPage func(context.Context, ManagedDatabaseListResult) (ManagedDatabaseListResult, error)) ManagedDatabaseListResultPage { + return ManagedDatabaseListResultPage{ + fn: getNextPage, + mdlr: cur, + } +} + +// ManagedDatabaseProperties the managed database's properties. +type ManagedDatabaseProperties struct { + // Collation - Collation of the managed database. + Collation *string `json:"collation,omitempty"` + // Status - READ-ONLY; Status of the database. Possible values include: 'ManagedDatabaseStatusOnline', 'ManagedDatabaseStatusOffline', 'ManagedDatabaseStatusShutdown', 'ManagedDatabaseStatusCreating', 'ManagedDatabaseStatusInaccessible', 'ManagedDatabaseStatusRestoring', 'ManagedDatabaseStatusUpdating' + Status ManagedDatabaseStatus `json:"status,omitempty"` + // CreationDate - READ-ONLY; Creation date of the database. + CreationDate *date.Time `json:"creationDate,omitempty"` + // EarliestRestorePoint - READ-ONLY; Earliest restore point in time for point in time restore. + EarliestRestorePoint *date.Time `json:"earliestRestorePoint,omitempty"` + // RestorePointInTime - Conditional. If createMode is PointInTimeRestore, this value is required. Specifies the point in time (ISO8601 format) of the source database that will be restored to create the new database. + RestorePointInTime *date.Time `json:"restorePointInTime,omitempty"` + // DefaultSecondaryLocation - READ-ONLY; Geo paired region. + DefaultSecondaryLocation *string `json:"defaultSecondaryLocation,omitempty"` + // CatalogCollation - Collation of the metadata catalog. Possible values include: 'CatalogCollationTypeDATABASEDEFAULT', 'CatalogCollationTypeSQLLatin1GeneralCP1CIAS' + CatalogCollation CatalogCollationType `json:"catalogCollation,omitempty"` + // CreateMode - Managed database create mode. PointInTimeRestore: Create a database by restoring a point in time backup of an existing database. SourceDatabaseName, SourceManagedInstanceName and PointInTime must be specified. RestoreExternalBackup: Create a database by restoring from external backup files. Collation, StorageContainerUri and StorageContainerSasToken must be specified. Recovery: Creates a database by restoring a geo-replicated backup. RecoverableDatabaseId must be specified as the recoverable database resource ID to restore. RestoreLongTermRetentionBackup: Create a database by restoring from a long term retention backup (longTermRetentionBackupResourceId required). Possible values include: 'ManagedDatabaseCreateModeDefault', 'ManagedDatabaseCreateModeRestoreExternalBackup', 'ManagedDatabaseCreateModePointInTimeRestore', 'ManagedDatabaseCreateModeRecovery', 'ManagedDatabaseCreateModeRestoreLongTermRetentionBackup' + CreateMode ManagedDatabaseCreateMode `json:"createMode,omitempty"` + // StorageContainerURI - Conditional. If createMode is RestoreExternalBackup, this value is required. Specifies the uri of the storage container where backups for this restore are stored. + StorageContainerURI *string `json:"storageContainerUri,omitempty"` + // SourceDatabaseID - The resource identifier of the source database associated with create operation of this database. + SourceDatabaseID *string `json:"sourceDatabaseId,omitempty"` + // RestorableDroppedDatabaseID - The restorable dropped database resource id to restore when creating this database. + RestorableDroppedDatabaseID *string `json:"restorableDroppedDatabaseId,omitempty"` + // StorageContainerSasToken - Conditional. If createMode is RestoreExternalBackup, this value is required. Specifies the storage container sas token. + StorageContainerSasToken *string `json:"storageContainerSasToken,omitempty"` + // FailoverGroupID - READ-ONLY; Instance Failover Group resource identifier that this managed database belongs to. + FailoverGroupID *string `json:"failoverGroupId,omitempty"` + // RecoverableDatabaseID - The resource identifier of the recoverable database associated with create operation of this database. + RecoverableDatabaseID *string `json:"recoverableDatabaseId,omitempty"` + // LongTermRetentionBackupResourceID - The name of the Long Term Retention backup to be used for restore of this managed database. + LongTermRetentionBackupResourceID *string `json:"longTermRetentionBackupResourceId,omitempty"` + // AutoCompleteRestore - Whether to auto complete restore of this managed database. + AutoCompleteRestore *bool `json:"autoCompleteRestore,omitempty"` + // LastBackupName - Last backup file name for restore of this managed database. + LastBackupName *string `json:"lastBackupName,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedDatabaseProperties. +func (mdp ManagedDatabaseProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mdp.Collation != nil { + objectMap["collation"] = mdp.Collation + } + if mdp.RestorePointInTime != nil { + objectMap["restorePointInTime"] = mdp.RestorePointInTime + } + if mdp.CatalogCollation != "" { + objectMap["catalogCollation"] = mdp.CatalogCollation + } + if mdp.CreateMode != "" { + objectMap["createMode"] = mdp.CreateMode + } + if mdp.StorageContainerURI != nil { + objectMap["storageContainerUri"] = mdp.StorageContainerURI + } + if mdp.SourceDatabaseID != nil { + objectMap["sourceDatabaseId"] = mdp.SourceDatabaseID + } + if mdp.RestorableDroppedDatabaseID != nil { + objectMap["restorableDroppedDatabaseId"] = mdp.RestorableDroppedDatabaseID + } + if mdp.StorageContainerSasToken != nil { + objectMap["storageContainerSasToken"] = mdp.StorageContainerSasToken + } + if mdp.RecoverableDatabaseID != nil { + objectMap["recoverableDatabaseId"] = mdp.RecoverableDatabaseID + } + if mdp.LongTermRetentionBackupResourceID != nil { + objectMap["longTermRetentionBackupResourceId"] = mdp.LongTermRetentionBackupResourceID + } + if mdp.AutoCompleteRestore != nil { + objectMap["autoCompleteRestore"] = mdp.AutoCompleteRestore + } + if mdp.LastBackupName != nil { + objectMap["lastBackupName"] = mdp.LastBackupName + } + return json.Marshal(objectMap) +} + +// ManagedDatabaseRestoreDetailsProperties the managed database's restore details properties. +type ManagedDatabaseRestoreDetailsProperties struct { + // Status - READ-ONLY; Restore status. + Status *string `json:"status,omitempty"` + // CurrentRestoringFileName - READ-ONLY; Current restoring file name. + CurrentRestoringFileName *string `json:"currentRestoringFileName,omitempty"` + // LastRestoredFileName - READ-ONLY; Last restored file name. + LastRestoredFileName *string `json:"lastRestoredFileName,omitempty"` + // LastRestoredFileTime - READ-ONLY; Last restored file time. + LastRestoredFileTime *date.Time `json:"lastRestoredFileTime,omitempty"` + // PercentCompleted - READ-ONLY; Percent completed. + PercentCompleted *float64 `json:"percentCompleted,omitempty"` + // UnrestorableFiles - READ-ONLY; List of unrestorable files. + UnrestorableFiles *[]string `json:"unrestorableFiles,omitempty"` + // NumberOfFilesDetected - READ-ONLY; Number of files detected. + NumberOfFilesDetected *int64 `json:"numberOfFilesDetected,omitempty"` + // LastUploadedFileName - READ-ONLY; Last uploaded file name. + LastUploadedFileName *string `json:"lastUploadedFileName,omitempty"` + // LastUploadedFileTime - READ-ONLY; Last uploaded file time. + LastUploadedFileTime *date.Time `json:"lastUploadedFileTime,omitempty"` + // BlockReason - READ-ONLY; The reason why restore is in Blocked state. + BlockReason *string `json:"blockReason,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedDatabaseRestoreDetailsProperties. +func (mdrdp ManagedDatabaseRestoreDetailsProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ManagedDatabaseRestoreDetailsResult a managed database restore details. +type ManagedDatabaseRestoreDetailsResult struct { + autorest.Response `json:"-"` + // ManagedDatabaseRestoreDetailsProperties - Resource properties. + *ManagedDatabaseRestoreDetailsProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedDatabaseRestoreDetailsResult. +func (mdrdr ManagedDatabaseRestoreDetailsResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mdrdr.ManagedDatabaseRestoreDetailsProperties != nil { + objectMap["properties"] = mdrdr.ManagedDatabaseRestoreDetailsProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ManagedDatabaseRestoreDetailsResult struct. +func (mdrdr *ManagedDatabaseRestoreDetailsResult) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var managedDatabaseRestoreDetailsProperties ManagedDatabaseRestoreDetailsProperties + err = json.Unmarshal(*v, &managedDatabaseRestoreDetailsProperties) + if err != nil { + return err + } + mdrdr.ManagedDatabaseRestoreDetailsProperties = &managedDatabaseRestoreDetailsProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + mdrdr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + mdrdr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + mdrdr.Type = &typeVar + } + } + } + + return nil +} + +// ManagedDatabasesCompleteRestoreFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type ManagedDatabasesCompleteRestoreFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ManagedDatabasesClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ManagedDatabasesCompleteRestoreFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ManagedDatabasesCompleteRestoreFuture.Result. +func (future *ManagedDatabasesCompleteRestoreFuture) result(client ManagedDatabasesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabasesCompleteRestoreFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ManagedDatabasesCompleteRestoreFuture") + return + } + ar.Response = future.Response() + return +} + +// ManagedDatabasesCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type ManagedDatabasesCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ManagedDatabasesClient) (ManagedDatabase, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ManagedDatabasesCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ManagedDatabasesCreateOrUpdateFuture.Result. +func (future *ManagedDatabasesCreateOrUpdateFuture) result(client ManagedDatabasesClient) (md ManagedDatabase, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabasesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + md.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ManagedDatabasesCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if md.Response.Response, err = future.GetResult(sender); err == nil && md.Response.Response.StatusCode != http.StatusNoContent { + md, err = client.CreateOrUpdateResponder(md.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabasesCreateOrUpdateFuture", "Result", md.Response.Response, "Failure responding to request") + } + } + return +} + +// ManagedDatabasesDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ManagedDatabasesDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ManagedDatabasesClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ManagedDatabasesDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ManagedDatabasesDeleteFuture.Result. +func (future *ManagedDatabasesDeleteFuture) result(client ManagedDatabasesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabasesDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ManagedDatabasesDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// ManagedDatabaseSecurityAlertPolicy a managed database security alert policy. +type ManagedDatabaseSecurityAlertPolicy struct { + autorest.Response `json:"-"` + // SecurityAlertPolicyProperties - Resource properties. + *SecurityAlertPolicyProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedDatabaseSecurityAlertPolicy. +func (mdsap ManagedDatabaseSecurityAlertPolicy) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mdsap.SecurityAlertPolicyProperties != nil { + objectMap["properties"] = mdsap.SecurityAlertPolicyProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ManagedDatabaseSecurityAlertPolicy struct. +func (mdsap *ManagedDatabaseSecurityAlertPolicy) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var securityAlertPolicyProperties SecurityAlertPolicyProperties + err = json.Unmarshal(*v, &securityAlertPolicyProperties) + if err != nil { + return err + } + mdsap.SecurityAlertPolicyProperties = &securityAlertPolicyProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + mdsap.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + mdsap.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + mdsap.Type = &typeVar + } + } + } + + return nil +} + +// ManagedDatabaseSecurityAlertPolicyListResult a list of the managed database's security alert policies. +type ManagedDatabaseSecurityAlertPolicyListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]ManagedDatabaseSecurityAlertPolicy `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedDatabaseSecurityAlertPolicyListResult. +func (mdsaplr ManagedDatabaseSecurityAlertPolicyListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ManagedDatabaseSecurityAlertPolicyListResultIterator provides access to a complete listing of +// ManagedDatabaseSecurityAlertPolicy values. +type ManagedDatabaseSecurityAlertPolicyListResultIterator struct { + i int + page ManagedDatabaseSecurityAlertPolicyListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *ManagedDatabaseSecurityAlertPolicyListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabaseSecurityAlertPolicyListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ManagedDatabaseSecurityAlertPolicyListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ManagedDatabaseSecurityAlertPolicyListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter ManagedDatabaseSecurityAlertPolicyListResultIterator) Response() ManagedDatabaseSecurityAlertPolicyListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter ManagedDatabaseSecurityAlertPolicyListResultIterator) Value() ManagedDatabaseSecurityAlertPolicy { + if !iter.page.NotDone() { + return ManagedDatabaseSecurityAlertPolicy{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ManagedDatabaseSecurityAlertPolicyListResultIterator type. +func NewManagedDatabaseSecurityAlertPolicyListResultIterator(page ManagedDatabaseSecurityAlertPolicyListResultPage) ManagedDatabaseSecurityAlertPolicyListResultIterator { + return ManagedDatabaseSecurityAlertPolicyListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (mdsaplr ManagedDatabaseSecurityAlertPolicyListResult) IsEmpty() bool { + return mdsaplr.Value == nil || len(*mdsaplr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (mdsaplr ManagedDatabaseSecurityAlertPolicyListResult) hasNextLink() bool { + return mdsaplr.NextLink != nil && len(*mdsaplr.NextLink) != 0 +} + +// managedDatabaseSecurityAlertPolicyListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (mdsaplr ManagedDatabaseSecurityAlertPolicyListResult) managedDatabaseSecurityAlertPolicyListResultPreparer(ctx context.Context) (*http.Request, error) { + if !mdsaplr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(mdsaplr.NextLink))) +} + +// ManagedDatabaseSecurityAlertPolicyListResultPage contains a page of ManagedDatabaseSecurityAlertPolicy +// values. +type ManagedDatabaseSecurityAlertPolicyListResultPage struct { + fn func(context.Context, ManagedDatabaseSecurityAlertPolicyListResult) (ManagedDatabaseSecurityAlertPolicyListResult, error) + mdsaplr ManagedDatabaseSecurityAlertPolicyListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *ManagedDatabaseSecurityAlertPolicyListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedDatabaseSecurityAlertPolicyListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.mdsaplr) + if err != nil { + return err + } + page.mdsaplr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *ManagedDatabaseSecurityAlertPolicyListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ManagedDatabaseSecurityAlertPolicyListResultPage) NotDone() bool { + return !page.mdsaplr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ManagedDatabaseSecurityAlertPolicyListResultPage) Response() ManagedDatabaseSecurityAlertPolicyListResult { + return page.mdsaplr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ManagedDatabaseSecurityAlertPolicyListResultPage) Values() []ManagedDatabaseSecurityAlertPolicy { + if page.mdsaplr.IsEmpty() { + return nil + } + return *page.mdsaplr.Value +} + +// Creates a new instance of the ManagedDatabaseSecurityAlertPolicyListResultPage type. +func NewManagedDatabaseSecurityAlertPolicyListResultPage(cur ManagedDatabaseSecurityAlertPolicyListResult, getNextPage func(context.Context, ManagedDatabaseSecurityAlertPolicyListResult) (ManagedDatabaseSecurityAlertPolicyListResult, error)) ManagedDatabaseSecurityAlertPolicyListResultPage { + return ManagedDatabaseSecurityAlertPolicyListResultPage{ + fn: getNextPage, + mdsaplr: cur, + } +} + +// ManagedDatabasesUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ManagedDatabasesUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ManagedDatabasesClient) (ManagedDatabase, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ManagedDatabasesUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ManagedDatabasesUpdateFuture.Result. +func (future *ManagedDatabasesUpdateFuture) result(client ManagedDatabasesClient) (md ManagedDatabase, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabasesUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + md.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ManagedDatabasesUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if md.Response.Response, err = future.GetResult(sender); err == nil && md.Response.Response.StatusCode != http.StatusNoContent { + md, err = client.UpdateResponder(md.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabasesUpdateFuture", "Result", md.Response.Response, "Failure responding to request") + } + } + return +} + +// ManagedDatabaseUpdate an managed database update. +type ManagedDatabaseUpdate struct { + // ManagedDatabaseProperties - Resource properties. + *ManagedDatabaseProperties `json:"properties,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for ManagedDatabaseUpdate. +func (mdu ManagedDatabaseUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mdu.ManagedDatabaseProperties != nil { + objectMap["properties"] = mdu.ManagedDatabaseProperties + } + if mdu.Tags != nil { + objectMap["tags"] = mdu.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ManagedDatabaseUpdate struct. +func (mdu *ManagedDatabaseUpdate) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var managedDatabaseProperties ManagedDatabaseProperties + err = json.Unmarshal(*v, &managedDatabaseProperties) + if err != nil { + return err + } + mdu.ManagedDatabaseProperties = &managedDatabaseProperties + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + mdu.Tags = tags + } + } + } + + return nil +} + +// ManagedDatabaseVulnerabilityAssessmentScansInitiateScanFuture an abstraction for monitoring and +// retrieving the results of a long-running operation. +type ManagedDatabaseVulnerabilityAssessmentScansInitiateScanFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ManagedDatabaseVulnerabilityAssessmentScansClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ManagedDatabaseVulnerabilityAssessmentScansInitiateScanFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ManagedDatabaseVulnerabilityAssessmentScansInitiateScanFuture.Result. +func (future *ManagedDatabaseVulnerabilityAssessmentScansInitiateScanFuture) result(client ManagedDatabaseVulnerabilityAssessmentScansClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedDatabaseVulnerabilityAssessmentScansInitiateScanFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ManagedDatabaseVulnerabilityAssessmentScansInitiateScanFuture") + return + } + ar.Response = future.Response() + return +} + +// ManagedInstance an Azure SQL managed instance. +type ManagedInstance struct { + autorest.Response `json:"-"` + // Identity - The Azure Active Directory identity of the managed instance. + Identity *ResourceIdentity `json:"identity,omitempty"` + // Sku - Managed instance SKU. Allowed values for sku.name: GP_Gen4, GP_Gen5, BC_Gen4, BC_Gen5 + Sku *Sku `json:"sku,omitempty"` + // ManagedInstanceProperties - Resource properties. + *ManagedInstanceProperties `json:"properties,omitempty"` + // Location - Resource location. + Location *string `json:"location,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstance. +func (mi ManagedInstance) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mi.Identity != nil { + objectMap["identity"] = mi.Identity + } + if mi.Sku != nil { + objectMap["sku"] = mi.Sku + } + if mi.ManagedInstanceProperties != nil { + objectMap["properties"] = mi.ManagedInstanceProperties + } + if mi.Location != nil { + objectMap["location"] = mi.Location + } + if mi.Tags != nil { + objectMap["tags"] = mi.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ManagedInstance struct. +func (mi *ManagedInstance) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "identity": + if v != nil { + var identity ResourceIdentity + err = json.Unmarshal(*v, &identity) + if err != nil { + return err + } + mi.Identity = &identity + } + case "sku": + if v != nil { + var sku Sku + err = json.Unmarshal(*v, &sku) + if err != nil { + return err + } + mi.Sku = &sku + } + case "properties": + if v != nil { + var managedInstanceProperties ManagedInstanceProperties + err = json.Unmarshal(*v, &managedInstanceProperties) + if err != nil { + return err + } + mi.ManagedInstanceProperties = &managedInstanceProperties + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + mi.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + mi.Tags = tags + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + mi.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + mi.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + mi.Type = &typeVar + } + } + } + + return nil +} + +// ManagedInstanceAdministrator an Azure SQL managed instance administrator. +type ManagedInstanceAdministrator struct { + autorest.Response `json:"-"` + // ManagedInstanceAdministratorProperties - Resource properties. + *ManagedInstanceAdministratorProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstanceAdministrator. +func (mia ManagedInstanceAdministrator) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mia.ManagedInstanceAdministratorProperties != nil { + objectMap["properties"] = mia.ManagedInstanceAdministratorProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ManagedInstanceAdministrator struct. +func (mia *ManagedInstanceAdministrator) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var managedInstanceAdministratorProperties ManagedInstanceAdministratorProperties + err = json.Unmarshal(*v, &managedInstanceAdministratorProperties) + if err != nil { + return err + } + mia.ManagedInstanceAdministratorProperties = &managedInstanceAdministratorProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + mia.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + mia.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + mia.Type = &typeVar + } + } + } + + return nil +} + +// ManagedInstanceAdministratorListResult a list of managed instance administrators. +type ManagedInstanceAdministratorListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]ManagedInstanceAdministrator `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstanceAdministratorListResult. +func (mialr ManagedInstanceAdministratorListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ManagedInstanceAdministratorListResultIterator provides access to a complete listing of +// ManagedInstanceAdministrator values. +type ManagedInstanceAdministratorListResultIterator struct { + i int + page ManagedInstanceAdministratorListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *ManagedInstanceAdministratorListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceAdministratorListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ManagedInstanceAdministratorListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ManagedInstanceAdministratorListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter ManagedInstanceAdministratorListResultIterator) Response() ManagedInstanceAdministratorListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter ManagedInstanceAdministratorListResultIterator) Value() ManagedInstanceAdministrator { + if !iter.page.NotDone() { + return ManagedInstanceAdministrator{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ManagedInstanceAdministratorListResultIterator type. +func NewManagedInstanceAdministratorListResultIterator(page ManagedInstanceAdministratorListResultPage) ManagedInstanceAdministratorListResultIterator { + return ManagedInstanceAdministratorListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (mialr ManagedInstanceAdministratorListResult) IsEmpty() bool { + return mialr.Value == nil || len(*mialr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (mialr ManagedInstanceAdministratorListResult) hasNextLink() bool { + return mialr.NextLink != nil && len(*mialr.NextLink) != 0 +} + +// managedInstanceAdministratorListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (mialr ManagedInstanceAdministratorListResult) managedInstanceAdministratorListResultPreparer(ctx context.Context) (*http.Request, error) { + if !mialr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(mialr.NextLink))) +} + +// ManagedInstanceAdministratorListResultPage contains a page of ManagedInstanceAdministrator values. +type ManagedInstanceAdministratorListResultPage struct { + fn func(context.Context, ManagedInstanceAdministratorListResult) (ManagedInstanceAdministratorListResult, error) + mialr ManagedInstanceAdministratorListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *ManagedInstanceAdministratorListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceAdministratorListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.mialr) + if err != nil { + return err + } + page.mialr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *ManagedInstanceAdministratorListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ManagedInstanceAdministratorListResultPage) NotDone() bool { + return !page.mialr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ManagedInstanceAdministratorListResultPage) Response() ManagedInstanceAdministratorListResult { + return page.mialr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ManagedInstanceAdministratorListResultPage) Values() []ManagedInstanceAdministrator { + if page.mialr.IsEmpty() { + return nil + } + return *page.mialr.Value +} + +// Creates a new instance of the ManagedInstanceAdministratorListResultPage type. +func NewManagedInstanceAdministratorListResultPage(cur ManagedInstanceAdministratorListResult, getNextPage func(context.Context, ManagedInstanceAdministratorListResult) (ManagedInstanceAdministratorListResult, error)) ManagedInstanceAdministratorListResultPage { + return ManagedInstanceAdministratorListResultPage{ + fn: getNextPage, + mialr: cur, + } +} + +// ManagedInstanceAdministratorProperties the properties of a managed instance administrator. +type ManagedInstanceAdministratorProperties struct { + // AdministratorType - Type of the managed instance administrator. + AdministratorType *string `json:"administratorType,omitempty"` + // Login - Login name of the managed instance administrator. + Login *string `json:"login,omitempty"` + // Sid - SID (object ID) of the managed instance administrator. + Sid *uuid.UUID `json:"sid,omitempty"` + // TenantID - Tenant ID of the managed instance administrator. + TenantID *uuid.UUID `json:"tenantId,omitempty"` +} + +// ManagedInstanceAdministratorsCreateOrUpdateFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type ManagedInstanceAdministratorsCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ManagedInstanceAdministratorsClient) (ManagedInstanceAdministrator, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ManagedInstanceAdministratorsCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ManagedInstanceAdministratorsCreateOrUpdateFuture.Result. +func (future *ManagedInstanceAdministratorsCreateOrUpdateFuture) result(client ManagedInstanceAdministratorsClient) (mia ManagedInstanceAdministrator, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceAdministratorsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + mia.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ManagedInstanceAdministratorsCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if mia.Response.Response, err = future.GetResult(sender); err == nil && mia.Response.Response.StatusCode != http.StatusNoContent { + mia, err = client.CreateOrUpdateResponder(mia.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceAdministratorsCreateOrUpdateFuture", "Result", mia.Response.Response, "Failure responding to request") + } + } + return +} + +// ManagedInstanceAdministratorsDeleteFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type ManagedInstanceAdministratorsDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ManagedInstanceAdministratorsClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ManagedInstanceAdministratorsDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ManagedInstanceAdministratorsDeleteFuture.Result. +func (future *ManagedInstanceAdministratorsDeleteFuture) result(client ManagedInstanceAdministratorsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceAdministratorsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ManagedInstanceAdministratorsDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// ManagedInstanceAzureADOnlyAuthentication azure Active Directory only authentication. +type ManagedInstanceAzureADOnlyAuthentication struct { + autorest.Response `json:"-"` + // ManagedInstanceAzureADOnlyAuthProperties - Resource properties. + *ManagedInstanceAzureADOnlyAuthProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstanceAzureADOnlyAuthentication. +func (miaaoa ManagedInstanceAzureADOnlyAuthentication) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if miaaoa.ManagedInstanceAzureADOnlyAuthProperties != nil { + objectMap["properties"] = miaaoa.ManagedInstanceAzureADOnlyAuthProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ManagedInstanceAzureADOnlyAuthentication struct. +func (miaaoa *ManagedInstanceAzureADOnlyAuthentication) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var managedInstanceAzureADOnlyAuthProperties ManagedInstanceAzureADOnlyAuthProperties + err = json.Unmarshal(*v, &managedInstanceAzureADOnlyAuthProperties) + if err != nil { + return err + } + miaaoa.ManagedInstanceAzureADOnlyAuthProperties = &managedInstanceAzureADOnlyAuthProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + miaaoa.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + miaaoa.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + miaaoa.Type = &typeVar + } + } + } + + return nil +} + +// ManagedInstanceAzureADOnlyAuthenticationsCreateOrUpdateFuture an abstraction for monitoring and +// retrieving the results of a long-running operation. +type ManagedInstanceAzureADOnlyAuthenticationsCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ManagedInstanceAzureADOnlyAuthenticationsClient) (ManagedInstanceAzureADOnlyAuthentication, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ManagedInstanceAzureADOnlyAuthenticationsCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ManagedInstanceAzureADOnlyAuthenticationsCreateOrUpdateFuture.Result. +func (future *ManagedInstanceAzureADOnlyAuthenticationsCreateOrUpdateFuture) result(client ManagedInstanceAzureADOnlyAuthenticationsClient) (miaaoa ManagedInstanceAzureADOnlyAuthentication, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceAzureADOnlyAuthenticationsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + miaaoa.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ManagedInstanceAzureADOnlyAuthenticationsCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if miaaoa.Response.Response, err = future.GetResult(sender); err == nil && miaaoa.Response.Response.StatusCode != http.StatusNoContent { + miaaoa, err = client.CreateOrUpdateResponder(miaaoa.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceAzureADOnlyAuthenticationsCreateOrUpdateFuture", "Result", miaaoa.Response.Response, "Failure responding to request") + } + } + return +} + +// ManagedInstanceAzureADOnlyAuthenticationsDeleteFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type ManagedInstanceAzureADOnlyAuthenticationsDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ManagedInstanceAzureADOnlyAuthenticationsClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ManagedInstanceAzureADOnlyAuthenticationsDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ManagedInstanceAzureADOnlyAuthenticationsDeleteFuture.Result. +func (future *ManagedInstanceAzureADOnlyAuthenticationsDeleteFuture) result(client ManagedInstanceAzureADOnlyAuthenticationsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceAzureADOnlyAuthenticationsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ManagedInstanceAzureADOnlyAuthenticationsDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// ManagedInstanceAzureADOnlyAuthListResult a list of active directory only authentications. +type ManagedInstanceAzureADOnlyAuthListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]ManagedInstanceAzureADOnlyAuthentication `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstanceAzureADOnlyAuthListResult. +func (miaaoalr ManagedInstanceAzureADOnlyAuthListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ManagedInstanceAzureADOnlyAuthListResultIterator provides access to a complete listing of +// ManagedInstanceAzureADOnlyAuthentication values. +type ManagedInstanceAzureADOnlyAuthListResultIterator struct { + i int + page ManagedInstanceAzureADOnlyAuthListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *ManagedInstanceAzureADOnlyAuthListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceAzureADOnlyAuthListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ManagedInstanceAzureADOnlyAuthListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ManagedInstanceAzureADOnlyAuthListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter ManagedInstanceAzureADOnlyAuthListResultIterator) Response() ManagedInstanceAzureADOnlyAuthListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter ManagedInstanceAzureADOnlyAuthListResultIterator) Value() ManagedInstanceAzureADOnlyAuthentication { + if !iter.page.NotDone() { + return ManagedInstanceAzureADOnlyAuthentication{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ManagedInstanceAzureADOnlyAuthListResultIterator type. +func NewManagedInstanceAzureADOnlyAuthListResultIterator(page ManagedInstanceAzureADOnlyAuthListResultPage) ManagedInstanceAzureADOnlyAuthListResultIterator { + return ManagedInstanceAzureADOnlyAuthListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (miaaoalr ManagedInstanceAzureADOnlyAuthListResult) IsEmpty() bool { + return miaaoalr.Value == nil || len(*miaaoalr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (miaaoalr ManagedInstanceAzureADOnlyAuthListResult) hasNextLink() bool { + return miaaoalr.NextLink != nil && len(*miaaoalr.NextLink) != 0 +} + +// managedInstanceAzureADOnlyAuthListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (miaaoalr ManagedInstanceAzureADOnlyAuthListResult) managedInstanceAzureADOnlyAuthListResultPreparer(ctx context.Context) (*http.Request, error) { + if !miaaoalr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(miaaoalr.NextLink))) +} + +// ManagedInstanceAzureADOnlyAuthListResultPage contains a page of ManagedInstanceAzureADOnlyAuthentication +// values. +type ManagedInstanceAzureADOnlyAuthListResultPage struct { + fn func(context.Context, ManagedInstanceAzureADOnlyAuthListResult) (ManagedInstanceAzureADOnlyAuthListResult, error) + miaaoalr ManagedInstanceAzureADOnlyAuthListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *ManagedInstanceAzureADOnlyAuthListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceAzureADOnlyAuthListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.miaaoalr) + if err != nil { + return err + } + page.miaaoalr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *ManagedInstanceAzureADOnlyAuthListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ManagedInstanceAzureADOnlyAuthListResultPage) NotDone() bool { + return !page.miaaoalr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ManagedInstanceAzureADOnlyAuthListResultPage) Response() ManagedInstanceAzureADOnlyAuthListResult { + return page.miaaoalr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ManagedInstanceAzureADOnlyAuthListResultPage) Values() []ManagedInstanceAzureADOnlyAuthentication { + if page.miaaoalr.IsEmpty() { + return nil + } + return *page.miaaoalr.Value +} + +// Creates a new instance of the ManagedInstanceAzureADOnlyAuthListResultPage type. +func NewManagedInstanceAzureADOnlyAuthListResultPage(cur ManagedInstanceAzureADOnlyAuthListResult, getNextPage func(context.Context, ManagedInstanceAzureADOnlyAuthListResult) (ManagedInstanceAzureADOnlyAuthListResult, error)) ManagedInstanceAzureADOnlyAuthListResultPage { + return ManagedInstanceAzureADOnlyAuthListResultPage{ + fn: getNextPage, + miaaoalr: cur, + } +} + +// ManagedInstanceAzureADOnlyAuthProperties properties of a active directory only authentication for +// Managed Instance. +type ManagedInstanceAzureADOnlyAuthProperties struct { + // AzureADOnlyAuthentication - Azure Active Directory only Authentication enabled. + AzureADOnlyAuthentication *bool `json:"azureADOnlyAuthentication,omitempty"` +} + +// ManagedInstanceEditionCapability the managed server capability +type ManagedInstanceEditionCapability struct { + // Name - READ-ONLY; The managed server version name. + Name *string `json:"name,omitempty"` + // SupportedFamilies - READ-ONLY; The supported families. + SupportedFamilies *[]ManagedInstanceFamilyCapability `json:"supportedFamilies,omitempty"` + // SupportedStorageCapabilities - READ-ONLY; The list of supported storage capabilities for this edition + SupportedStorageCapabilities *[]StorageCapability `json:"supportedStorageCapabilities,omitempty"` + // ZoneRedundant - READ-ONLY; Whether or not zone redundancy is supported for the edition. + ZoneRedundant *bool `json:"zoneRedundant,omitempty"` + // Status - READ-ONLY; The status of the capability. Possible values include: 'CapabilityStatusVisible', 'CapabilityStatusAvailable', 'CapabilityStatusDefault', 'CapabilityStatusDisabled' + Status CapabilityStatus `json:"status,omitempty"` + // Reason - The reason for the capability not being available. + Reason *string `json:"reason,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstanceEditionCapability. +func (miec ManagedInstanceEditionCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if miec.Reason != nil { + objectMap["reason"] = miec.Reason + } + return json.Marshal(objectMap) +} + +// ManagedInstanceEncryptionProtector the managed instance encryption protector. +type ManagedInstanceEncryptionProtector struct { + autorest.Response `json:"-"` + // Kind - READ-ONLY; Kind of encryption protector. This is metadata used for the Azure portal experience. + Kind *string `json:"kind,omitempty"` + // ManagedInstanceEncryptionProtectorProperties - Resource properties. + *ManagedInstanceEncryptionProtectorProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstanceEncryptionProtector. +func (miep ManagedInstanceEncryptionProtector) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if miep.ManagedInstanceEncryptionProtectorProperties != nil { + objectMap["properties"] = miep.ManagedInstanceEncryptionProtectorProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ManagedInstanceEncryptionProtector struct. +func (miep *ManagedInstanceEncryptionProtector) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "kind": + if v != nil { + var kind string + err = json.Unmarshal(*v, &kind) + if err != nil { + return err + } + miep.Kind = &kind + } + case "properties": + if v != nil { + var managedInstanceEncryptionProtectorProperties ManagedInstanceEncryptionProtectorProperties + err = json.Unmarshal(*v, &managedInstanceEncryptionProtectorProperties) + if err != nil { + return err + } + miep.ManagedInstanceEncryptionProtectorProperties = &managedInstanceEncryptionProtectorProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + miep.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + miep.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + miep.Type = &typeVar + } + } + } + + return nil +} + +// ManagedInstanceEncryptionProtectorListResult a list of managed instance encryption protectors. +type ManagedInstanceEncryptionProtectorListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]ManagedInstanceEncryptionProtector `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstanceEncryptionProtectorListResult. +func (mieplr ManagedInstanceEncryptionProtectorListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ManagedInstanceEncryptionProtectorListResultIterator provides access to a complete listing of +// ManagedInstanceEncryptionProtector values. +type ManagedInstanceEncryptionProtectorListResultIterator struct { + i int + page ManagedInstanceEncryptionProtectorListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *ManagedInstanceEncryptionProtectorListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceEncryptionProtectorListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ManagedInstanceEncryptionProtectorListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ManagedInstanceEncryptionProtectorListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter ManagedInstanceEncryptionProtectorListResultIterator) Response() ManagedInstanceEncryptionProtectorListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter ManagedInstanceEncryptionProtectorListResultIterator) Value() ManagedInstanceEncryptionProtector { + if !iter.page.NotDone() { + return ManagedInstanceEncryptionProtector{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ManagedInstanceEncryptionProtectorListResultIterator type. +func NewManagedInstanceEncryptionProtectorListResultIterator(page ManagedInstanceEncryptionProtectorListResultPage) ManagedInstanceEncryptionProtectorListResultIterator { + return ManagedInstanceEncryptionProtectorListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (mieplr ManagedInstanceEncryptionProtectorListResult) IsEmpty() bool { + return mieplr.Value == nil || len(*mieplr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (mieplr ManagedInstanceEncryptionProtectorListResult) hasNextLink() bool { + return mieplr.NextLink != nil && len(*mieplr.NextLink) != 0 +} + +// managedInstanceEncryptionProtectorListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (mieplr ManagedInstanceEncryptionProtectorListResult) managedInstanceEncryptionProtectorListResultPreparer(ctx context.Context) (*http.Request, error) { + if !mieplr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(mieplr.NextLink))) +} + +// ManagedInstanceEncryptionProtectorListResultPage contains a page of ManagedInstanceEncryptionProtector +// values. +type ManagedInstanceEncryptionProtectorListResultPage struct { + fn func(context.Context, ManagedInstanceEncryptionProtectorListResult) (ManagedInstanceEncryptionProtectorListResult, error) + mieplr ManagedInstanceEncryptionProtectorListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *ManagedInstanceEncryptionProtectorListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceEncryptionProtectorListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.mieplr) + if err != nil { + return err + } + page.mieplr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *ManagedInstanceEncryptionProtectorListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ManagedInstanceEncryptionProtectorListResultPage) NotDone() bool { + return !page.mieplr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ManagedInstanceEncryptionProtectorListResultPage) Response() ManagedInstanceEncryptionProtectorListResult { + return page.mieplr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ManagedInstanceEncryptionProtectorListResultPage) Values() []ManagedInstanceEncryptionProtector { + if page.mieplr.IsEmpty() { + return nil + } + return *page.mieplr.Value +} + +// Creates a new instance of the ManagedInstanceEncryptionProtectorListResultPage type. +func NewManagedInstanceEncryptionProtectorListResultPage(cur ManagedInstanceEncryptionProtectorListResult, getNextPage func(context.Context, ManagedInstanceEncryptionProtectorListResult) (ManagedInstanceEncryptionProtectorListResult, error)) ManagedInstanceEncryptionProtectorListResultPage { + return ManagedInstanceEncryptionProtectorListResultPage{ + fn: getNextPage, + mieplr: cur, + } +} + +// ManagedInstanceEncryptionProtectorProperties properties for an encryption protector execution. +type ManagedInstanceEncryptionProtectorProperties struct { + // ServerKeyName - The name of the managed instance key. + ServerKeyName *string `json:"serverKeyName,omitempty"` + // ServerKeyType - The encryption protector type like 'ServiceManaged', 'AzureKeyVault'. Possible values include: 'ServerKeyTypeServiceManaged', 'ServerKeyTypeAzureKeyVault' + ServerKeyType ServerKeyType `json:"serverKeyType,omitempty"` + // URI - READ-ONLY; The URI of the server key. + URI *string `json:"uri,omitempty"` + // Thumbprint - READ-ONLY; Thumbprint of the server key. + Thumbprint *string `json:"thumbprint,omitempty"` + // AutoRotationEnabled - Key auto rotation opt-in flag. Either true or false. + AutoRotationEnabled *bool `json:"autoRotationEnabled,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstanceEncryptionProtectorProperties. +func (miepp ManagedInstanceEncryptionProtectorProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if miepp.ServerKeyName != nil { + objectMap["serverKeyName"] = miepp.ServerKeyName + } + if miepp.ServerKeyType != "" { + objectMap["serverKeyType"] = miepp.ServerKeyType + } + if miepp.AutoRotationEnabled != nil { + objectMap["autoRotationEnabled"] = miepp.AutoRotationEnabled + } + return json.Marshal(objectMap) +} + +// ManagedInstanceEncryptionProtectorsCreateOrUpdateFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type ManagedInstanceEncryptionProtectorsCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ManagedInstanceEncryptionProtectorsClient) (ManagedInstanceEncryptionProtector, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ManagedInstanceEncryptionProtectorsCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ManagedInstanceEncryptionProtectorsCreateOrUpdateFuture.Result. +func (future *ManagedInstanceEncryptionProtectorsCreateOrUpdateFuture) result(client ManagedInstanceEncryptionProtectorsClient) (miep ManagedInstanceEncryptionProtector, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceEncryptionProtectorsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + miep.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ManagedInstanceEncryptionProtectorsCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if miep.Response.Response, err = future.GetResult(sender); err == nil && miep.Response.Response.StatusCode != http.StatusNoContent { + miep, err = client.CreateOrUpdateResponder(miep.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceEncryptionProtectorsCreateOrUpdateFuture", "Result", miep.Response.Response, "Failure responding to request") + } + } + return +} + +// ManagedInstanceEncryptionProtectorsRevalidateFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type ManagedInstanceEncryptionProtectorsRevalidateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ManagedInstanceEncryptionProtectorsClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ManagedInstanceEncryptionProtectorsRevalidateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ManagedInstanceEncryptionProtectorsRevalidateFuture.Result. +func (future *ManagedInstanceEncryptionProtectorsRevalidateFuture) result(client ManagedInstanceEncryptionProtectorsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceEncryptionProtectorsRevalidateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ManagedInstanceEncryptionProtectorsRevalidateFuture") + return + } + ar.Response = future.Response() + return +} + +// ManagedInstanceExternalAdministrator properties of a active directory administrator. +type ManagedInstanceExternalAdministrator struct { + // AdministratorType - Type of the sever administrator. Possible values include: 'AdministratorTypeActiveDirectory' + AdministratorType AdministratorType `json:"administratorType,omitempty"` + // PrincipalType - Principal Type of the sever administrator. Possible values include: 'PrincipalTypeUser', 'PrincipalTypeGroup', 'PrincipalTypeApplication' + PrincipalType PrincipalType `json:"principalType,omitempty"` + // Login - Login name of the server administrator. + Login *string `json:"login,omitempty"` + // Sid - SID (object ID) of the server administrator. + Sid *uuid.UUID `json:"sid,omitempty"` + // TenantID - Tenant ID of the administrator. + TenantID *uuid.UUID `json:"tenantId,omitempty"` + // AzureADOnlyAuthentication - Azure Active Directory only Authentication enabled. + AzureADOnlyAuthentication *bool `json:"azureADOnlyAuthentication,omitempty"` +} + +// ManagedInstanceFamilyCapability the managed server family capability. +type ManagedInstanceFamilyCapability struct { + // Name - READ-ONLY; Family name. + Name *string `json:"name,omitempty"` + // Sku - READ-ONLY; SKU name. + Sku *string `json:"sku,omitempty"` + // SupportedLicenseTypes - READ-ONLY; List of supported license types. + SupportedLicenseTypes *[]LicenseTypeCapability `json:"supportedLicenseTypes,omitempty"` + // SupportedVcoresValues - READ-ONLY; List of supported virtual cores values. + SupportedVcoresValues *[]ManagedInstanceVcoresCapability `json:"supportedVcoresValues,omitempty"` + // Status - READ-ONLY; The status of the capability. Possible values include: 'CapabilityStatusVisible', 'CapabilityStatusAvailable', 'CapabilityStatusDefault', 'CapabilityStatusDisabled' + Status CapabilityStatus `json:"status,omitempty"` + // Reason - The reason for the capability not being available. + Reason *string `json:"reason,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstanceFamilyCapability. +func (mifc ManagedInstanceFamilyCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mifc.Reason != nil { + objectMap["reason"] = mifc.Reason + } + return json.Marshal(objectMap) +} + +// ManagedInstanceKey a managed instance key. +type ManagedInstanceKey struct { + autorest.Response `json:"-"` + // Kind - READ-ONLY; Kind of encryption protector. This is metadata used for the Azure portal experience. + Kind *string `json:"kind,omitempty"` + // ManagedInstanceKeyProperties - Resource properties. + *ManagedInstanceKeyProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstanceKey. +func (mik ManagedInstanceKey) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mik.ManagedInstanceKeyProperties != nil { + objectMap["properties"] = mik.ManagedInstanceKeyProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ManagedInstanceKey struct. +func (mik *ManagedInstanceKey) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "kind": + if v != nil { + var kind string + err = json.Unmarshal(*v, &kind) + if err != nil { + return err + } + mik.Kind = &kind + } + case "properties": + if v != nil { + var managedInstanceKeyProperties ManagedInstanceKeyProperties + err = json.Unmarshal(*v, &managedInstanceKeyProperties) + if err != nil { + return err + } + mik.ManagedInstanceKeyProperties = &managedInstanceKeyProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + mik.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + mik.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + mik.Type = &typeVar + } + } + } + + return nil +} + +// ManagedInstanceKeyListResult a list of managed instance keys. +type ManagedInstanceKeyListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]ManagedInstanceKey `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstanceKeyListResult. +func (miklr ManagedInstanceKeyListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ManagedInstanceKeyListResultIterator provides access to a complete listing of ManagedInstanceKey values. +type ManagedInstanceKeyListResultIterator struct { + i int + page ManagedInstanceKeyListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *ManagedInstanceKeyListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceKeyListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ManagedInstanceKeyListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ManagedInstanceKeyListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter ManagedInstanceKeyListResultIterator) Response() ManagedInstanceKeyListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter ManagedInstanceKeyListResultIterator) Value() ManagedInstanceKey { + if !iter.page.NotDone() { + return ManagedInstanceKey{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ManagedInstanceKeyListResultIterator type. +func NewManagedInstanceKeyListResultIterator(page ManagedInstanceKeyListResultPage) ManagedInstanceKeyListResultIterator { + return ManagedInstanceKeyListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (miklr ManagedInstanceKeyListResult) IsEmpty() bool { + return miklr.Value == nil || len(*miklr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (miklr ManagedInstanceKeyListResult) hasNextLink() bool { + return miklr.NextLink != nil && len(*miklr.NextLink) != 0 +} + +// managedInstanceKeyListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (miklr ManagedInstanceKeyListResult) managedInstanceKeyListResultPreparer(ctx context.Context) (*http.Request, error) { + if !miklr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(miklr.NextLink))) +} + +// ManagedInstanceKeyListResultPage contains a page of ManagedInstanceKey values. +type ManagedInstanceKeyListResultPage struct { + fn func(context.Context, ManagedInstanceKeyListResult) (ManagedInstanceKeyListResult, error) + miklr ManagedInstanceKeyListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *ManagedInstanceKeyListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceKeyListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.miklr) + if err != nil { + return err + } + page.miklr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *ManagedInstanceKeyListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ManagedInstanceKeyListResultPage) NotDone() bool { + return !page.miklr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ManagedInstanceKeyListResultPage) Response() ManagedInstanceKeyListResult { + return page.miklr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ManagedInstanceKeyListResultPage) Values() []ManagedInstanceKey { + if page.miklr.IsEmpty() { + return nil + } + return *page.miklr.Value +} + +// Creates a new instance of the ManagedInstanceKeyListResultPage type. +func NewManagedInstanceKeyListResultPage(cur ManagedInstanceKeyListResult, getNextPage func(context.Context, ManagedInstanceKeyListResult) (ManagedInstanceKeyListResult, error)) ManagedInstanceKeyListResultPage { + return ManagedInstanceKeyListResultPage{ + fn: getNextPage, + miklr: cur, + } +} + +// ManagedInstanceKeyProperties properties for a key execution. +type ManagedInstanceKeyProperties struct { + // ServerKeyType - The key type like 'ServiceManaged', 'AzureKeyVault'. Possible values include: 'ServerKeyTypeServiceManaged', 'ServerKeyTypeAzureKeyVault' + ServerKeyType ServerKeyType `json:"serverKeyType,omitempty"` + // URI - The URI of the key. If the ServerKeyType is AzureKeyVault, then the URI is required. + URI *string `json:"uri,omitempty"` + // Thumbprint - READ-ONLY; Thumbprint of the key. + Thumbprint *string `json:"thumbprint,omitempty"` + // CreationDate - READ-ONLY; The key creation date. + CreationDate *date.Time `json:"creationDate,omitempty"` + // AutoRotationEnabled - READ-ONLY; Key auto rotation opt-in flag. Either true or false. + AutoRotationEnabled *bool `json:"autoRotationEnabled,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstanceKeyProperties. +func (mikp ManagedInstanceKeyProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mikp.ServerKeyType != "" { + objectMap["serverKeyType"] = mikp.ServerKeyType + } + if mikp.URI != nil { + objectMap["uri"] = mikp.URI + } + return json.Marshal(objectMap) +} + +// ManagedInstanceKeysCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type ManagedInstanceKeysCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ManagedInstanceKeysClient) (ManagedInstanceKey, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ManagedInstanceKeysCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ManagedInstanceKeysCreateOrUpdateFuture.Result. +func (future *ManagedInstanceKeysCreateOrUpdateFuture) result(client ManagedInstanceKeysClient) (mik ManagedInstanceKey, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceKeysCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + mik.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ManagedInstanceKeysCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if mik.Response.Response, err = future.GetResult(sender); err == nil && mik.Response.Response.StatusCode != http.StatusNoContent { + mik, err = client.CreateOrUpdateResponder(mik.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceKeysCreateOrUpdateFuture", "Result", mik.Response.Response, "Failure responding to request") + } + } + return +} + +// ManagedInstanceKeysDeleteFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type ManagedInstanceKeysDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ManagedInstanceKeysClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ManagedInstanceKeysDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ManagedInstanceKeysDeleteFuture.Result. +func (future *ManagedInstanceKeysDeleteFuture) result(client ManagedInstanceKeysClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceKeysDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ManagedInstanceKeysDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// ManagedInstanceListResult a list of managed instances. +type ManagedInstanceListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]ManagedInstance `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstanceListResult. +func (milr ManagedInstanceListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ManagedInstanceListResultIterator provides access to a complete listing of ManagedInstance values. +type ManagedInstanceListResultIterator struct { + i int + page ManagedInstanceListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *ManagedInstanceListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ManagedInstanceListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ManagedInstanceListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter ManagedInstanceListResultIterator) Response() ManagedInstanceListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter ManagedInstanceListResultIterator) Value() ManagedInstance { + if !iter.page.NotDone() { + return ManagedInstance{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ManagedInstanceListResultIterator type. +func NewManagedInstanceListResultIterator(page ManagedInstanceListResultPage) ManagedInstanceListResultIterator { + return ManagedInstanceListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (milr ManagedInstanceListResult) IsEmpty() bool { + return milr.Value == nil || len(*milr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (milr ManagedInstanceListResult) hasNextLink() bool { + return milr.NextLink != nil && len(*milr.NextLink) != 0 +} + +// managedInstanceListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (milr ManagedInstanceListResult) managedInstanceListResultPreparer(ctx context.Context) (*http.Request, error) { + if !milr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(milr.NextLink))) +} + +// ManagedInstanceListResultPage contains a page of ManagedInstance values. +type ManagedInstanceListResultPage struct { + fn func(context.Context, ManagedInstanceListResult) (ManagedInstanceListResult, error) + milr ManagedInstanceListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *ManagedInstanceListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.milr) + if err != nil { + return err + } + page.milr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *ManagedInstanceListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ManagedInstanceListResultPage) NotDone() bool { + return !page.milr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ManagedInstanceListResultPage) Response() ManagedInstanceListResult { + return page.milr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ManagedInstanceListResultPage) Values() []ManagedInstance { + if page.milr.IsEmpty() { + return nil + } + return *page.milr.Value +} + +// Creates a new instance of the ManagedInstanceListResultPage type. +func NewManagedInstanceListResultPage(cur ManagedInstanceListResult, getNextPage func(context.Context, ManagedInstanceListResult) (ManagedInstanceListResult, error)) ManagedInstanceListResultPage { + return ManagedInstanceListResultPage{ + fn: getNextPage, + milr: cur, + } +} + +// ManagedInstanceLongTermRetentionBackup a long term retention backup for a managed database. +type ManagedInstanceLongTermRetentionBackup struct { + autorest.Response `json:"-"` + // ManagedInstanceLongTermRetentionBackupProperties - Resource properties. + *ManagedInstanceLongTermRetentionBackupProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstanceLongTermRetentionBackup. +func (miltrb ManagedInstanceLongTermRetentionBackup) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if miltrb.ManagedInstanceLongTermRetentionBackupProperties != nil { + objectMap["properties"] = miltrb.ManagedInstanceLongTermRetentionBackupProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ManagedInstanceLongTermRetentionBackup struct. +func (miltrb *ManagedInstanceLongTermRetentionBackup) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var managedInstanceLongTermRetentionBackupProperties ManagedInstanceLongTermRetentionBackupProperties + err = json.Unmarshal(*v, &managedInstanceLongTermRetentionBackupProperties) + if err != nil { + return err + } + miltrb.ManagedInstanceLongTermRetentionBackupProperties = &managedInstanceLongTermRetentionBackupProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + miltrb.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + miltrb.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + miltrb.Type = &typeVar + } + } + } + + return nil +} + +// ManagedInstanceLongTermRetentionBackupListResult a list of long term retention backups for managed +// database(s). +type ManagedInstanceLongTermRetentionBackupListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]ManagedInstanceLongTermRetentionBackup `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstanceLongTermRetentionBackupListResult. +func (miltrblr ManagedInstanceLongTermRetentionBackupListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ManagedInstanceLongTermRetentionBackupListResultIterator provides access to a complete listing of +// ManagedInstanceLongTermRetentionBackup values. +type ManagedInstanceLongTermRetentionBackupListResultIterator struct { + i int + page ManagedInstanceLongTermRetentionBackupListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *ManagedInstanceLongTermRetentionBackupListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceLongTermRetentionBackupListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ManagedInstanceLongTermRetentionBackupListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ManagedInstanceLongTermRetentionBackupListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter ManagedInstanceLongTermRetentionBackupListResultIterator) Response() ManagedInstanceLongTermRetentionBackupListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter ManagedInstanceLongTermRetentionBackupListResultIterator) Value() ManagedInstanceLongTermRetentionBackup { + if !iter.page.NotDone() { + return ManagedInstanceLongTermRetentionBackup{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ManagedInstanceLongTermRetentionBackupListResultIterator type. +func NewManagedInstanceLongTermRetentionBackupListResultIterator(page ManagedInstanceLongTermRetentionBackupListResultPage) ManagedInstanceLongTermRetentionBackupListResultIterator { + return ManagedInstanceLongTermRetentionBackupListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (miltrblr ManagedInstanceLongTermRetentionBackupListResult) IsEmpty() bool { + return miltrblr.Value == nil || len(*miltrblr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (miltrblr ManagedInstanceLongTermRetentionBackupListResult) hasNextLink() bool { + return miltrblr.NextLink != nil && len(*miltrblr.NextLink) != 0 +} + +// managedInstanceLongTermRetentionBackupListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (miltrblr ManagedInstanceLongTermRetentionBackupListResult) managedInstanceLongTermRetentionBackupListResultPreparer(ctx context.Context) (*http.Request, error) { + if !miltrblr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(miltrblr.NextLink))) +} + +// ManagedInstanceLongTermRetentionBackupListResultPage contains a page of +// ManagedInstanceLongTermRetentionBackup values. +type ManagedInstanceLongTermRetentionBackupListResultPage struct { + fn func(context.Context, ManagedInstanceLongTermRetentionBackupListResult) (ManagedInstanceLongTermRetentionBackupListResult, error) + miltrblr ManagedInstanceLongTermRetentionBackupListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *ManagedInstanceLongTermRetentionBackupListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceLongTermRetentionBackupListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.miltrblr) + if err != nil { + return err + } + page.miltrblr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *ManagedInstanceLongTermRetentionBackupListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ManagedInstanceLongTermRetentionBackupListResultPage) NotDone() bool { + return !page.miltrblr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ManagedInstanceLongTermRetentionBackupListResultPage) Response() ManagedInstanceLongTermRetentionBackupListResult { + return page.miltrblr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ManagedInstanceLongTermRetentionBackupListResultPage) Values() []ManagedInstanceLongTermRetentionBackup { + if page.miltrblr.IsEmpty() { + return nil + } + return *page.miltrblr.Value +} + +// Creates a new instance of the ManagedInstanceLongTermRetentionBackupListResultPage type. +func NewManagedInstanceLongTermRetentionBackupListResultPage(cur ManagedInstanceLongTermRetentionBackupListResult, getNextPage func(context.Context, ManagedInstanceLongTermRetentionBackupListResult) (ManagedInstanceLongTermRetentionBackupListResult, error)) ManagedInstanceLongTermRetentionBackupListResultPage { + return ManagedInstanceLongTermRetentionBackupListResultPage{ + fn: getNextPage, + miltrblr: cur, + } +} + +// ManagedInstanceLongTermRetentionBackupProperties properties of a long term retention backup +type ManagedInstanceLongTermRetentionBackupProperties struct { + // ManagedInstanceName - READ-ONLY; The managed instance that the backup database belongs to. + ManagedInstanceName *string `json:"managedInstanceName,omitempty"` + // ManagedInstanceCreateTime - READ-ONLY; The create time of the instance. + ManagedInstanceCreateTime *date.Time `json:"managedInstanceCreateTime,omitempty"` + // DatabaseName - READ-ONLY; The name of the database the backup belong to + DatabaseName *string `json:"databaseName,omitempty"` + // DatabaseDeletionTime - READ-ONLY; The delete time of the database + DatabaseDeletionTime *date.Time `json:"databaseDeletionTime,omitempty"` + // BackupTime - READ-ONLY; The time the backup was taken + BackupTime *date.Time `json:"backupTime,omitempty"` + // BackupExpirationTime - READ-ONLY; The time the long term retention backup will expire. + BackupExpirationTime *date.Time `json:"backupExpirationTime,omitempty"` + // BackupStorageRedundancy - READ-ONLY; The storage redundancy type of the backup. Possible values include: 'BackupStorageRedundancyGeo', 'BackupStorageRedundancyLocal', 'BackupStorageRedundancyZone' + BackupStorageRedundancy BackupStorageRedundancy `json:"backupStorageRedundancy,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstanceLongTermRetentionBackupProperties. +func (miltrbp ManagedInstanceLongTermRetentionBackupProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ManagedInstanceLongTermRetentionPoliciesCreateOrUpdateFuture an abstraction for monitoring and +// retrieving the results of a long-running operation. +type ManagedInstanceLongTermRetentionPoliciesCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ManagedInstanceLongTermRetentionPoliciesClient) (ManagedInstanceLongTermRetentionPolicy, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ManagedInstanceLongTermRetentionPoliciesCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ManagedInstanceLongTermRetentionPoliciesCreateOrUpdateFuture.Result. +func (future *ManagedInstanceLongTermRetentionPoliciesCreateOrUpdateFuture) result(client ManagedInstanceLongTermRetentionPoliciesClient) (miltrp ManagedInstanceLongTermRetentionPolicy, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceLongTermRetentionPoliciesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + miltrp.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ManagedInstanceLongTermRetentionPoliciesCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if miltrp.Response.Response, err = future.GetResult(sender); err == nil && miltrp.Response.Response.StatusCode != http.StatusNoContent { + miltrp, err = client.CreateOrUpdateResponder(miltrp.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceLongTermRetentionPoliciesCreateOrUpdateFuture", "Result", miltrp.Response.Response, "Failure responding to request") + } + } + return +} + +// ManagedInstanceLongTermRetentionPolicy a long term retention policy. +type ManagedInstanceLongTermRetentionPolicy struct { + autorest.Response `json:"-"` + // BaseLongTermRetentionPolicyProperties - Resource properties. + *BaseLongTermRetentionPolicyProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstanceLongTermRetentionPolicy. +func (miltrp ManagedInstanceLongTermRetentionPolicy) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if miltrp.BaseLongTermRetentionPolicyProperties != nil { + objectMap["properties"] = miltrp.BaseLongTermRetentionPolicyProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ManagedInstanceLongTermRetentionPolicy struct. +func (miltrp *ManagedInstanceLongTermRetentionPolicy) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var baseLongTermRetentionPolicyProperties BaseLongTermRetentionPolicyProperties + err = json.Unmarshal(*v, &baseLongTermRetentionPolicyProperties) + if err != nil { + return err + } + miltrp.BaseLongTermRetentionPolicyProperties = &baseLongTermRetentionPolicyProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + miltrp.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + miltrp.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + miltrp.Type = &typeVar + } + } + } + + return nil +} + +// ManagedInstanceLongTermRetentionPolicyListResult a list of long term retention policies. +type ManagedInstanceLongTermRetentionPolicyListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]ManagedInstanceLongTermRetentionPolicy `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstanceLongTermRetentionPolicyListResult. +func (miltrplr ManagedInstanceLongTermRetentionPolicyListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ManagedInstanceLongTermRetentionPolicyListResultIterator provides access to a complete listing of +// ManagedInstanceLongTermRetentionPolicy values. +type ManagedInstanceLongTermRetentionPolicyListResultIterator struct { + i int + page ManagedInstanceLongTermRetentionPolicyListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *ManagedInstanceLongTermRetentionPolicyListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceLongTermRetentionPolicyListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ManagedInstanceLongTermRetentionPolicyListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ManagedInstanceLongTermRetentionPolicyListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter ManagedInstanceLongTermRetentionPolicyListResultIterator) Response() ManagedInstanceLongTermRetentionPolicyListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter ManagedInstanceLongTermRetentionPolicyListResultIterator) Value() ManagedInstanceLongTermRetentionPolicy { + if !iter.page.NotDone() { + return ManagedInstanceLongTermRetentionPolicy{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ManagedInstanceLongTermRetentionPolicyListResultIterator type. +func NewManagedInstanceLongTermRetentionPolicyListResultIterator(page ManagedInstanceLongTermRetentionPolicyListResultPage) ManagedInstanceLongTermRetentionPolicyListResultIterator { + return ManagedInstanceLongTermRetentionPolicyListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (miltrplr ManagedInstanceLongTermRetentionPolicyListResult) IsEmpty() bool { + return miltrplr.Value == nil || len(*miltrplr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (miltrplr ManagedInstanceLongTermRetentionPolicyListResult) hasNextLink() bool { + return miltrplr.NextLink != nil && len(*miltrplr.NextLink) != 0 +} + +// managedInstanceLongTermRetentionPolicyListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (miltrplr ManagedInstanceLongTermRetentionPolicyListResult) managedInstanceLongTermRetentionPolicyListResultPreparer(ctx context.Context) (*http.Request, error) { + if !miltrplr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(miltrplr.NextLink))) +} + +// ManagedInstanceLongTermRetentionPolicyListResultPage contains a page of +// ManagedInstanceLongTermRetentionPolicy values. +type ManagedInstanceLongTermRetentionPolicyListResultPage struct { + fn func(context.Context, ManagedInstanceLongTermRetentionPolicyListResult) (ManagedInstanceLongTermRetentionPolicyListResult, error) + miltrplr ManagedInstanceLongTermRetentionPolicyListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *ManagedInstanceLongTermRetentionPolicyListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceLongTermRetentionPolicyListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.miltrplr) + if err != nil { + return err + } + page.miltrplr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *ManagedInstanceLongTermRetentionPolicyListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ManagedInstanceLongTermRetentionPolicyListResultPage) NotDone() bool { + return !page.miltrplr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ManagedInstanceLongTermRetentionPolicyListResultPage) Response() ManagedInstanceLongTermRetentionPolicyListResult { + return page.miltrplr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ManagedInstanceLongTermRetentionPolicyListResultPage) Values() []ManagedInstanceLongTermRetentionPolicy { + if page.miltrplr.IsEmpty() { + return nil + } + return *page.miltrplr.Value +} + +// Creates a new instance of the ManagedInstanceLongTermRetentionPolicyListResultPage type. +func NewManagedInstanceLongTermRetentionPolicyListResultPage(cur ManagedInstanceLongTermRetentionPolicyListResult, getNextPage func(context.Context, ManagedInstanceLongTermRetentionPolicyListResult) (ManagedInstanceLongTermRetentionPolicyListResult, error)) ManagedInstanceLongTermRetentionPolicyListResultPage { + return ManagedInstanceLongTermRetentionPolicyListResultPage{ + fn: getNextPage, + miltrplr: cur, + } +} + +// ManagedInstanceMaintenanceConfigurationCapability the maintenance configuration capability +type ManagedInstanceMaintenanceConfigurationCapability struct { + // Name - READ-ONLY; Maintenance configuration name + Name *string `json:"name,omitempty"` + // Status - READ-ONLY; The status of the capability. Possible values include: 'CapabilityStatusVisible', 'CapabilityStatusAvailable', 'CapabilityStatusDefault', 'CapabilityStatusDisabled' + Status CapabilityStatus `json:"status,omitempty"` + // Reason - The reason for the capability not being available. + Reason *string `json:"reason,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstanceMaintenanceConfigurationCapability. +func (mimcc ManagedInstanceMaintenanceConfigurationCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mimcc.Reason != nil { + objectMap["reason"] = mimcc.Reason + } + return json.Marshal(objectMap) +} + +// ManagedInstanceOperation a managed instance operation. +type ManagedInstanceOperation struct { + autorest.Response `json:"-"` + // ManagedInstanceOperationProperties - Resource properties. + *ManagedInstanceOperationProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstanceOperation. +func (mio ManagedInstanceOperation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mio.ManagedInstanceOperationProperties != nil { + objectMap["properties"] = mio.ManagedInstanceOperationProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ManagedInstanceOperation struct. +func (mio *ManagedInstanceOperation) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var managedInstanceOperationProperties ManagedInstanceOperationProperties + err = json.Unmarshal(*v, &managedInstanceOperationProperties) + if err != nil { + return err + } + mio.ManagedInstanceOperationProperties = &managedInstanceOperationProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + mio.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + mio.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + mio.Type = &typeVar + } + } + } + + return nil +} + +// ManagedInstanceOperationListResult the response to a list managed instance operations request +type ManagedInstanceOperationListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]ManagedInstanceOperation `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstanceOperationListResult. +func (miolr ManagedInstanceOperationListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ManagedInstanceOperationListResultIterator provides access to a complete listing of +// ManagedInstanceOperation values. +type ManagedInstanceOperationListResultIterator struct { + i int + page ManagedInstanceOperationListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *ManagedInstanceOperationListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceOperationListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ManagedInstanceOperationListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ManagedInstanceOperationListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter ManagedInstanceOperationListResultIterator) Response() ManagedInstanceOperationListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter ManagedInstanceOperationListResultIterator) Value() ManagedInstanceOperation { + if !iter.page.NotDone() { + return ManagedInstanceOperation{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ManagedInstanceOperationListResultIterator type. +func NewManagedInstanceOperationListResultIterator(page ManagedInstanceOperationListResultPage) ManagedInstanceOperationListResultIterator { + return ManagedInstanceOperationListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (miolr ManagedInstanceOperationListResult) IsEmpty() bool { + return miolr.Value == nil || len(*miolr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (miolr ManagedInstanceOperationListResult) hasNextLink() bool { + return miolr.NextLink != nil && len(*miolr.NextLink) != 0 +} + +// managedInstanceOperationListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (miolr ManagedInstanceOperationListResult) managedInstanceOperationListResultPreparer(ctx context.Context) (*http.Request, error) { + if !miolr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(miolr.NextLink))) +} + +// ManagedInstanceOperationListResultPage contains a page of ManagedInstanceOperation values. +type ManagedInstanceOperationListResultPage struct { + fn func(context.Context, ManagedInstanceOperationListResult) (ManagedInstanceOperationListResult, error) + miolr ManagedInstanceOperationListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *ManagedInstanceOperationListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceOperationListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.miolr) + if err != nil { + return err + } + page.miolr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *ManagedInstanceOperationListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ManagedInstanceOperationListResultPage) NotDone() bool { + return !page.miolr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ManagedInstanceOperationListResultPage) Response() ManagedInstanceOperationListResult { + return page.miolr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ManagedInstanceOperationListResultPage) Values() []ManagedInstanceOperation { + if page.miolr.IsEmpty() { + return nil + } + return *page.miolr.Value +} + +// Creates a new instance of the ManagedInstanceOperationListResultPage type. +func NewManagedInstanceOperationListResultPage(cur ManagedInstanceOperationListResult, getNextPage func(context.Context, ManagedInstanceOperationListResult) (ManagedInstanceOperationListResult, error)) ManagedInstanceOperationListResultPage { + return ManagedInstanceOperationListResultPage{ + fn: getNextPage, + miolr: cur, + } +} + +// ManagedInstanceOperationParametersPair the parameters of a managed instance operation. +type ManagedInstanceOperationParametersPair struct { + // CurrentParameters - READ-ONLY; The current parameters. + CurrentParameters *UpsertManagedServerOperationParameters `json:"currentParameters,omitempty"` + // RequestedParameters - READ-ONLY; The requested parameters. + RequestedParameters *UpsertManagedServerOperationParameters `json:"requestedParameters,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstanceOperationParametersPair. +func (miopp ManagedInstanceOperationParametersPair) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ManagedInstanceOperationProperties the properties of a managed instance operation. +type ManagedInstanceOperationProperties struct { + // ManagedInstanceName - READ-ONLY; The name of the managed instance the operation is being performed on. + ManagedInstanceName *string `json:"managedInstanceName,omitempty"` + // Operation - READ-ONLY; The name of operation. + Operation *string `json:"operation,omitempty"` + // OperationFriendlyName - READ-ONLY; The friendly name of operation. + OperationFriendlyName *string `json:"operationFriendlyName,omitempty"` + // PercentComplete - READ-ONLY; The percentage of the operation completed. + PercentComplete *int32 `json:"percentComplete,omitempty"` + // StartTime - READ-ONLY; The operation start time. + StartTime *date.Time `json:"startTime,omitempty"` + // State - READ-ONLY; The operation state. Possible values include: 'ManagementOperationStatePending', 'ManagementOperationStateInProgress', 'ManagementOperationStateSucceeded', 'ManagementOperationStateFailed', 'ManagementOperationStateCancelInProgress', 'ManagementOperationStateCancelled' + State ManagementOperationState `json:"state,omitempty"` + // ErrorCode - READ-ONLY; The operation error code. + ErrorCode *int32 `json:"errorCode,omitempty"` + // ErrorDescription - READ-ONLY; The operation error description. + ErrorDescription *string `json:"errorDescription,omitempty"` + // ErrorSeverity - READ-ONLY; The operation error severity. + ErrorSeverity *int32 `json:"errorSeverity,omitempty"` + // IsUserError - READ-ONLY; Whether or not the error is a user error. + IsUserError *bool `json:"isUserError,omitempty"` + // EstimatedCompletionTime - READ-ONLY; The estimated completion time of the operation. + EstimatedCompletionTime *date.Time `json:"estimatedCompletionTime,omitempty"` + // Description - READ-ONLY; The operation description. + Description *string `json:"description,omitempty"` + // IsCancellable - READ-ONLY; Whether the operation can be cancelled. + IsCancellable *bool `json:"isCancellable,omitempty"` + // OperationParameters - READ-ONLY; The operation parameters. + OperationParameters *ManagedInstanceOperationParametersPair `json:"operationParameters,omitempty"` + // OperationSteps - READ-ONLY; The operation steps. + OperationSteps *ManagedInstanceOperationSteps `json:"operationSteps,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstanceOperationProperties. +func (miop ManagedInstanceOperationProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ManagedInstanceOperationSteps the steps of a managed instance operation. +type ManagedInstanceOperationSteps struct { + // TotalSteps - READ-ONLY; The total number of operation steps. + TotalSteps *string `json:"totalSteps,omitempty"` + // CurrentStep - READ-ONLY; The number of current operation steps. + CurrentStep *int32 `json:"currentStep,omitempty"` + // StepsList - READ-ONLY; The operation steps list. + StepsList *[]UpsertManagedServerOperationStep `json:"stepsList,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstanceOperationSteps. +func (mios ManagedInstanceOperationSteps) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ManagedInstancePairInfo pairs of Managed Instances in the failover group. +type ManagedInstancePairInfo struct { + // PrimaryManagedInstanceID - Id of Primary Managed Instance in pair. + PrimaryManagedInstanceID *string `json:"primaryManagedInstanceId,omitempty"` + // PartnerManagedInstanceID - Id of Partner Managed Instance in pair. + PartnerManagedInstanceID *string `json:"partnerManagedInstanceId,omitempty"` +} + +// ManagedInstancePecProperty a private endpoint connection under a managed instance +type ManagedInstancePecProperty struct { + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Properties - READ-ONLY; Private endpoint connection properties + Properties *ManagedInstancePrivateEndpointConnectionProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstancePecProperty. +func (mipp ManagedInstancePecProperty) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ManagedInstancePrivateEndpointConnection a private endpoint connection +type ManagedInstancePrivateEndpointConnection struct { + autorest.Response `json:"-"` + // ManagedInstancePrivateEndpointConnectionProperties - Resource properties. + *ManagedInstancePrivateEndpointConnectionProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstancePrivateEndpointConnection. +func (mipec ManagedInstancePrivateEndpointConnection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mipec.ManagedInstancePrivateEndpointConnectionProperties != nil { + objectMap["properties"] = mipec.ManagedInstancePrivateEndpointConnectionProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ManagedInstancePrivateEndpointConnection struct. +func (mipec *ManagedInstancePrivateEndpointConnection) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var managedInstancePrivateEndpointConnectionProperties ManagedInstancePrivateEndpointConnectionProperties + err = json.Unmarshal(*v, &managedInstancePrivateEndpointConnectionProperties) + if err != nil { + return err + } + mipec.ManagedInstancePrivateEndpointConnectionProperties = &managedInstancePrivateEndpointConnectionProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + mipec.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + mipec.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + mipec.Type = &typeVar + } + } + } + + return nil +} + +// ManagedInstancePrivateEndpointConnectionListResult a list of private endpoint connections. +type ManagedInstancePrivateEndpointConnectionListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]ManagedInstancePrivateEndpointConnection `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstancePrivateEndpointConnectionListResult. +func (mipeclr ManagedInstancePrivateEndpointConnectionListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ManagedInstancePrivateEndpointConnectionListResultIterator provides access to a complete listing of +// ManagedInstancePrivateEndpointConnection values. +type ManagedInstancePrivateEndpointConnectionListResultIterator struct { + i int + page ManagedInstancePrivateEndpointConnectionListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *ManagedInstancePrivateEndpointConnectionListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstancePrivateEndpointConnectionListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ManagedInstancePrivateEndpointConnectionListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ManagedInstancePrivateEndpointConnectionListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter ManagedInstancePrivateEndpointConnectionListResultIterator) Response() ManagedInstancePrivateEndpointConnectionListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter ManagedInstancePrivateEndpointConnectionListResultIterator) Value() ManagedInstancePrivateEndpointConnection { + if !iter.page.NotDone() { + return ManagedInstancePrivateEndpointConnection{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ManagedInstancePrivateEndpointConnectionListResultIterator type. +func NewManagedInstancePrivateEndpointConnectionListResultIterator(page ManagedInstancePrivateEndpointConnectionListResultPage) ManagedInstancePrivateEndpointConnectionListResultIterator { + return ManagedInstancePrivateEndpointConnectionListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (mipeclr ManagedInstancePrivateEndpointConnectionListResult) IsEmpty() bool { + return mipeclr.Value == nil || len(*mipeclr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (mipeclr ManagedInstancePrivateEndpointConnectionListResult) hasNextLink() bool { + return mipeclr.NextLink != nil && len(*mipeclr.NextLink) != 0 +} + +// managedInstancePrivateEndpointConnectionListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (mipeclr ManagedInstancePrivateEndpointConnectionListResult) managedInstancePrivateEndpointConnectionListResultPreparer(ctx context.Context) (*http.Request, error) { + if !mipeclr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(mipeclr.NextLink))) +} + +// ManagedInstancePrivateEndpointConnectionListResultPage contains a page of +// ManagedInstancePrivateEndpointConnection values. +type ManagedInstancePrivateEndpointConnectionListResultPage struct { + fn func(context.Context, ManagedInstancePrivateEndpointConnectionListResult) (ManagedInstancePrivateEndpointConnectionListResult, error) + mipeclr ManagedInstancePrivateEndpointConnectionListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *ManagedInstancePrivateEndpointConnectionListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstancePrivateEndpointConnectionListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.mipeclr) + if err != nil { + return err + } + page.mipeclr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *ManagedInstancePrivateEndpointConnectionListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ManagedInstancePrivateEndpointConnectionListResultPage) NotDone() bool { + return !page.mipeclr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ManagedInstancePrivateEndpointConnectionListResultPage) Response() ManagedInstancePrivateEndpointConnectionListResult { + return page.mipeclr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ManagedInstancePrivateEndpointConnectionListResultPage) Values() []ManagedInstancePrivateEndpointConnection { + if page.mipeclr.IsEmpty() { + return nil + } + return *page.mipeclr.Value +} + +// Creates a new instance of the ManagedInstancePrivateEndpointConnectionListResultPage type. +func NewManagedInstancePrivateEndpointConnectionListResultPage(cur ManagedInstancePrivateEndpointConnectionListResult, getNextPage func(context.Context, ManagedInstancePrivateEndpointConnectionListResult) (ManagedInstancePrivateEndpointConnectionListResult, error)) ManagedInstancePrivateEndpointConnectionListResultPage { + return ManagedInstancePrivateEndpointConnectionListResultPage{ + fn: getNextPage, + mipeclr: cur, + } +} + +// ManagedInstancePrivateEndpointConnectionProperties properties of a private endpoint connection. +type ManagedInstancePrivateEndpointConnectionProperties struct { + // PrivateEndpoint - Private endpoint which the connection belongs to. + PrivateEndpoint *ManagedInstancePrivateEndpointProperty `json:"privateEndpoint,omitempty"` + // PrivateLinkServiceConnectionState - Connection State of the Private Endpoint Connection. + PrivateLinkServiceConnectionState *ManagedInstancePrivateLinkServiceConnectionStateProperty `json:"privateLinkServiceConnectionState,omitempty"` + // ProvisioningState - READ-ONLY; State of the Private Endpoint Connection. + ProvisioningState *string `json:"provisioningState,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstancePrivateEndpointConnectionProperties. +func (mipecp ManagedInstancePrivateEndpointConnectionProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mipecp.PrivateEndpoint != nil { + objectMap["privateEndpoint"] = mipecp.PrivateEndpoint + } + if mipecp.PrivateLinkServiceConnectionState != nil { + objectMap["privateLinkServiceConnectionState"] = mipecp.PrivateLinkServiceConnectionState + } + return json.Marshal(objectMap) +} + +// ManagedInstancePrivateEndpointConnectionsCreateOrUpdateFuture an abstraction for monitoring and +// retrieving the results of a long-running operation. +type ManagedInstancePrivateEndpointConnectionsCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ManagedInstancePrivateEndpointConnectionsClient) (ManagedInstancePrivateEndpointConnection, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ManagedInstancePrivateEndpointConnectionsCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ManagedInstancePrivateEndpointConnectionsCreateOrUpdateFuture.Result. +func (future *ManagedInstancePrivateEndpointConnectionsCreateOrUpdateFuture) result(client ManagedInstancePrivateEndpointConnectionsClient) (mipec ManagedInstancePrivateEndpointConnection, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancePrivateEndpointConnectionsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + mipec.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ManagedInstancePrivateEndpointConnectionsCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if mipec.Response.Response, err = future.GetResult(sender); err == nil && mipec.Response.Response.StatusCode != http.StatusNoContent { + mipec, err = client.CreateOrUpdateResponder(mipec.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancePrivateEndpointConnectionsCreateOrUpdateFuture", "Result", mipec.Response.Response, "Failure responding to request") + } + } + return +} + +// ManagedInstancePrivateEndpointConnectionsDeleteFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type ManagedInstancePrivateEndpointConnectionsDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ManagedInstancePrivateEndpointConnectionsClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ManagedInstancePrivateEndpointConnectionsDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ManagedInstancePrivateEndpointConnectionsDeleteFuture.Result. +func (future *ManagedInstancePrivateEndpointConnectionsDeleteFuture) result(client ManagedInstancePrivateEndpointConnectionsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancePrivateEndpointConnectionsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ManagedInstancePrivateEndpointConnectionsDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// ManagedInstancePrivateEndpointProperty ... +type ManagedInstancePrivateEndpointProperty struct { + // ID - Resource id of the private endpoint. + ID *string `json:"id,omitempty"` +} + +// ManagedInstancePrivateLink a private link resource +type ManagedInstancePrivateLink struct { + autorest.Response `json:"-"` + // Properties - READ-ONLY; The private link resource group id. + Properties *ManagedInstancePrivateLinkProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstancePrivateLink. +func (mipl ManagedInstancePrivateLink) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ManagedInstancePrivateLinkListResult a list of private link resources +type ManagedInstancePrivateLinkListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]ManagedInstancePrivateLink `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstancePrivateLinkListResult. +func (mipllr ManagedInstancePrivateLinkListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ManagedInstancePrivateLinkListResultIterator provides access to a complete listing of +// ManagedInstancePrivateLink values. +type ManagedInstancePrivateLinkListResultIterator struct { + i int + page ManagedInstancePrivateLinkListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *ManagedInstancePrivateLinkListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstancePrivateLinkListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ManagedInstancePrivateLinkListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ManagedInstancePrivateLinkListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter ManagedInstancePrivateLinkListResultIterator) Response() ManagedInstancePrivateLinkListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter ManagedInstancePrivateLinkListResultIterator) Value() ManagedInstancePrivateLink { + if !iter.page.NotDone() { + return ManagedInstancePrivateLink{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ManagedInstancePrivateLinkListResultIterator type. +func NewManagedInstancePrivateLinkListResultIterator(page ManagedInstancePrivateLinkListResultPage) ManagedInstancePrivateLinkListResultIterator { + return ManagedInstancePrivateLinkListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (mipllr ManagedInstancePrivateLinkListResult) IsEmpty() bool { + return mipllr.Value == nil || len(*mipllr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (mipllr ManagedInstancePrivateLinkListResult) hasNextLink() bool { + return mipllr.NextLink != nil && len(*mipllr.NextLink) != 0 +} + +// managedInstancePrivateLinkListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (mipllr ManagedInstancePrivateLinkListResult) managedInstancePrivateLinkListResultPreparer(ctx context.Context) (*http.Request, error) { + if !mipllr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(mipllr.NextLink))) +} + +// ManagedInstancePrivateLinkListResultPage contains a page of ManagedInstancePrivateLink values. +type ManagedInstancePrivateLinkListResultPage struct { + fn func(context.Context, ManagedInstancePrivateLinkListResult) (ManagedInstancePrivateLinkListResult, error) + mipllr ManagedInstancePrivateLinkListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *ManagedInstancePrivateLinkListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstancePrivateLinkListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.mipllr) + if err != nil { + return err + } + page.mipllr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *ManagedInstancePrivateLinkListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ManagedInstancePrivateLinkListResultPage) NotDone() bool { + return !page.mipllr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ManagedInstancePrivateLinkListResultPage) Response() ManagedInstancePrivateLinkListResult { + return page.mipllr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ManagedInstancePrivateLinkListResultPage) Values() []ManagedInstancePrivateLink { + if page.mipllr.IsEmpty() { + return nil + } + return *page.mipllr.Value +} + +// Creates a new instance of the ManagedInstancePrivateLinkListResultPage type. +func NewManagedInstancePrivateLinkListResultPage(cur ManagedInstancePrivateLinkListResult, getNextPage func(context.Context, ManagedInstancePrivateLinkListResult) (ManagedInstancePrivateLinkListResult, error)) ManagedInstancePrivateLinkListResultPage { + return ManagedInstancePrivateLinkListResultPage{ + fn: getNextPage, + mipllr: cur, + } +} + +// ManagedInstancePrivateLinkProperties properties of a private link resource. +type ManagedInstancePrivateLinkProperties struct { + // GroupID - READ-ONLY; The private link resource group id. + GroupID *string `json:"groupId,omitempty"` + // RequiredMembers - READ-ONLY; The private link resource required member names. + RequiredMembers *[]string `json:"requiredMembers,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstancePrivateLinkProperties. +func (miplp ManagedInstancePrivateLinkProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ManagedInstancePrivateLinkServiceConnectionStateProperty ... +type ManagedInstancePrivateLinkServiceConnectionStateProperty struct { + // Status - The private link service connection status. + Status *string `json:"status,omitempty"` + // Description - The private link service connection description. + Description *string `json:"description,omitempty"` + // ActionsRequired - READ-ONLY; The private link service connection description. + ActionsRequired *string `json:"actionsRequired,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstancePrivateLinkServiceConnectionStateProperty. +func (miplscsp ManagedInstancePrivateLinkServiceConnectionStateProperty) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if miplscsp.Status != nil { + objectMap["status"] = miplscsp.Status + } + if miplscsp.Description != nil { + objectMap["description"] = miplscsp.Description + } + return json.Marshal(objectMap) +} + +// ManagedInstanceProperties the properties of a managed instance. +type ManagedInstanceProperties struct { + // ProvisioningState - READ-ONLY; Possible values include: 'ProvisioningState1Creating', 'ProvisioningState1Deleting', 'ProvisioningState1Updating', 'ProvisioningState1Unknown', 'ProvisioningState1Succeeded', 'ProvisioningState1Failed' + ProvisioningState ProvisioningState1 `json:"provisioningState,omitempty"` + // ManagedInstanceCreateMode - Specifies the mode of database creation. + // + // Default: Regular instance creation. + // + // Restore: Creates an instance by restoring a set of backups to specific point in time. RestorePointInTime and SourceManagedInstanceId must be specified. Possible values include: 'ManagedServerCreateModeDefault', 'ManagedServerCreateModePointInTimeRestore' + ManagedInstanceCreateMode ManagedServerCreateMode `json:"managedInstanceCreateMode,omitempty"` + // FullyQualifiedDomainName - READ-ONLY; The fully qualified domain name of the managed instance. + FullyQualifiedDomainName *string `json:"fullyQualifiedDomainName,omitempty"` + // AdministratorLogin - Administrator username for the managed instance. Can only be specified when the managed instance is being created (and is required for creation). + AdministratorLogin *string `json:"administratorLogin,omitempty"` + // AdministratorLoginPassword - The administrator login password (required for managed instance creation). + AdministratorLoginPassword *string `json:"administratorLoginPassword,omitempty"` + // SubnetID - Subnet resource ID for the managed instance. + SubnetID *string `json:"subnetId,omitempty"` + // State - READ-ONLY; The state of the managed instance. + State *string `json:"state,omitempty"` + // LicenseType - The license type. Possible values are 'LicenseIncluded' (regular price inclusive of a new SQL license) and 'BasePrice' (discounted AHB price for bringing your own SQL licenses). Possible values include: 'ManagedInstanceLicenseTypeLicenseIncluded', 'ManagedInstanceLicenseTypeBasePrice' + LicenseType ManagedInstanceLicenseType `json:"licenseType,omitempty"` + // VCores - The number of vCores. Allowed values: 8, 16, 24, 32, 40, 64, 80. + VCores *int32 `json:"vCores,omitempty"` + // StorageSizeInGB - Storage size in GB. Minimum value: 32. Maximum value: 8192. Increments of 32 GB allowed only. + StorageSizeInGB *int32 `json:"storageSizeInGB,omitempty"` + // Collation - Collation of the managed instance. + Collation *string `json:"collation,omitempty"` + // DNSZone - READ-ONLY; The Dns Zone that the managed instance is in. + DNSZone *string `json:"dnsZone,omitempty"` + // DNSZonePartner - The resource id of another managed instance whose DNS zone this managed instance will share after creation. + DNSZonePartner *string `json:"dnsZonePartner,omitempty"` + // PublicDataEndpointEnabled - Whether or not the public data endpoint is enabled. + PublicDataEndpointEnabled *bool `json:"publicDataEndpointEnabled,omitempty"` + // SourceManagedInstanceID - The resource identifier of the source managed instance associated with create operation of this instance. + SourceManagedInstanceID *string `json:"sourceManagedInstanceId,omitempty"` + // RestorePointInTime - Specifies the point in time (ISO8601 format) of the source database that will be restored to create the new database. + RestorePointInTime *date.Time `json:"restorePointInTime,omitempty"` + // ProxyOverride - Connection type used for connecting to the instance. Possible values include: 'ManagedInstanceProxyOverrideProxy', 'ManagedInstanceProxyOverrideRedirect', 'ManagedInstanceProxyOverrideDefault' + ProxyOverride ManagedInstanceProxyOverride `json:"proxyOverride,omitempty"` + // TimezoneID - Id of the timezone. Allowed values are timezones supported by Windows. + // Windows keeps details on supported timezones, including the id, in registry under + // KEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones. + // You can get those registry values via SQL Server by querying SELECT name AS timezone_id FROM sys.time_zone_info. + // List of Ids can also be obtained by executing [System.TimeZoneInfo]::GetSystemTimeZones() in PowerShell. + // An example of valid timezone id is "Pacific Standard Time" or "W. Europe Standard Time". + TimezoneID *string `json:"timezoneId,omitempty"` + // InstancePoolID - The Id of the instance pool this managed server belongs to. + InstancePoolID *string `json:"instancePoolId,omitempty"` + // MaintenanceConfigurationID - Specifies maintenance configuration id to apply to this managed instance. + MaintenanceConfigurationID *string `json:"maintenanceConfigurationId,omitempty"` + // PrivateEndpointConnections - READ-ONLY; List of private endpoint connections on a managed instance. + PrivateEndpointConnections *[]ManagedInstancePecProperty `json:"privateEndpointConnections,omitempty"` + // MinimalTLSVersion - Minimal TLS version. Allowed values: 'None', '1.0', '1.1', '1.2' + MinimalTLSVersion *string `json:"minimalTlsVersion,omitempty"` + // StorageAccountType - The storage account type used to store backups for this instance. The options are LRS (LocallyRedundantStorage), ZRS (ZoneRedundantStorage) and GRS (GeoRedundantStorage). Possible values include: 'StorageAccountTypeGRS', 'StorageAccountTypeLRS', 'StorageAccountTypeZRS' + StorageAccountType StorageAccountType `json:"storageAccountType,omitempty"` + // ZoneRedundant - Whether or not the multi-az is enabled. + ZoneRedundant *bool `json:"zoneRedundant,omitempty"` + // PrimaryUserAssignedIdentityID - The resource id of a user assigned identity to be used by default. + PrimaryUserAssignedIdentityID *string `json:"primaryUserAssignedIdentityId,omitempty"` + // KeyID - A CMK URI of the key to use for encryption. + KeyID *string `json:"keyId,omitempty"` + // Administrators - The Azure Active Directory administrator of the server. + Administrators *ManagedInstanceExternalAdministrator `json:"administrators,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstanceProperties. +func (mip ManagedInstanceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mip.ManagedInstanceCreateMode != "" { + objectMap["managedInstanceCreateMode"] = mip.ManagedInstanceCreateMode + } + if mip.AdministratorLogin != nil { + objectMap["administratorLogin"] = mip.AdministratorLogin + } + if mip.AdministratorLoginPassword != nil { + objectMap["administratorLoginPassword"] = mip.AdministratorLoginPassword + } + if mip.SubnetID != nil { + objectMap["subnetId"] = mip.SubnetID + } + if mip.LicenseType != "" { + objectMap["licenseType"] = mip.LicenseType + } + if mip.VCores != nil { + objectMap["vCores"] = mip.VCores + } + if mip.StorageSizeInGB != nil { + objectMap["storageSizeInGB"] = mip.StorageSizeInGB + } + if mip.Collation != nil { + objectMap["collation"] = mip.Collation + } + if mip.DNSZonePartner != nil { + objectMap["dnsZonePartner"] = mip.DNSZonePartner + } + if mip.PublicDataEndpointEnabled != nil { + objectMap["publicDataEndpointEnabled"] = mip.PublicDataEndpointEnabled + } + if mip.SourceManagedInstanceID != nil { + objectMap["sourceManagedInstanceId"] = mip.SourceManagedInstanceID + } + if mip.RestorePointInTime != nil { + objectMap["restorePointInTime"] = mip.RestorePointInTime + } + if mip.ProxyOverride != "" { + objectMap["proxyOverride"] = mip.ProxyOverride + } + if mip.TimezoneID != nil { + objectMap["timezoneId"] = mip.TimezoneID + } + if mip.InstancePoolID != nil { + objectMap["instancePoolId"] = mip.InstancePoolID + } + if mip.MaintenanceConfigurationID != nil { + objectMap["maintenanceConfigurationId"] = mip.MaintenanceConfigurationID + } + if mip.MinimalTLSVersion != nil { + objectMap["minimalTlsVersion"] = mip.MinimalTLSVersion + } + if mip.StorageAccountType != "" { + objectMap["storageAccountType"] = mip.StorageAccountType + } + if mip.ZoneRedundant != nil { + objectMap["zoneRedundant"] = mip.ZoneRedundant + } + if mip.PrimaryUserAssignedIdentityID != nil { + objectMap["primaryUserAssignedIdentityId"] = mip.PrimaryUserAssignedIdentityID + } + if mip.KeyID != nil { + objectMap["keyId"] = mip.KeyID + } + if mip.Administrators != nil { + objectMap["administrators"] = mip.Administrators + } + return json.Marshal(objectMap) +} + +// ManagedInstanceQuery database query. +type ManagedInstanceQuery struct { + autorest.Response `json:"-"` + // QueryProperties - Resource properties. + *QueryProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstanceQuery. +func (miq ManagedInstanceQuery) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if miq.QueryProperties != nil { + objectMap["properties"] = miq.QueryProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ManagedInstanceQuery struct. +func (miq *ManagedInstanceQuery) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var queryProperties QueryProperties + err = json.Unmarshal(*v, &queryProperties) + if err != nil { + return err + } + miq.QueryProperties = &queryProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + miq.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + miq.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + miq.Type = &typeVar + } + } + } + + return nil +} + +// ManagedInstanceQueryStatistics execution statistics for one particular query +type ManagedInstanceQueryStatistics struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]QueryStatistics `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstanceQueryStatistics. +func (miqs ManagedInstanceQueryStatistics) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ManagedInstanceQueryStatisticsIterator provides access to a complete listing of QueryStatistics values. +type ManagedInstanceQueryStatisticsIterator struct { + i int + page ManagedInstanceQueryStatisticsPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *ManagedInstanceQueryStatisticsIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceQueryStatisticsIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ManagedInstanceQueryStatisticsIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ManagedInstanceQueryStatisticsIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter ManagedInstanceQueryStatisticsIterator) Response() ManagedInstanceQueryStatistics { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter ManagedInstanceQueryStatisticsIterator) Value() QueryStatistics { + if !iter.page.NotDone() { + return QueryStatistics{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ManagedInstanceQueryStatisticsIterator type. +func NewManagedInstanceQueryStatisticsIterator(page ManagedInstanceQueryStatisticsPage) ManagedInstanceQueryStatisticsIterator { + return ManagedInstanceQueryStatisticsIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (miqs ManagedInstanceQueryStatistics) IsEmpty() bool { + return miqs.Value == nil || len(*miqs.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (miqs ManagedInstanceQueryStatistics) hasNextLink() bool { + return miqs.NextLink != nil && len(*miqs.NextLink) != 0 +} + +// managedInstanceQueryStatisticsPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (miqs ManagedInstanceQueryStatistics) managedInstanceQueryStatisticsPreparer(ctx context.Context) (*http.Request, error) { + if !miqs.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(miqs.NextLink))) +} + +// ManagedInstanceQueryStatisticsPage contains a page of QueryStatistics values. +type ManagedInstanceQueryStatisticsPage struct { + fn func(context.Context, ManagedInstanceQueryStatistics) (ManagedInstanceQueryStatistics, error) + miqs ManagedInstanceQueryStatistics +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *ManagedInstanceQueryStatisticsPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceQueryStatisticsPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.miqs) + if err != nil { + return err + } + page.miqs = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *ManagedInstanceQueryStatisticsPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ManagedInstanceQueryStatisticsPage) NotDone() bool { + return !page.miqs.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ManagedInstanceQueryStatisticsPage) Response() ManagedInstanceQueryStatistics { + return page.miqs +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ManagedInstanceQueryStatisticsPage) Values() []QueryStatistics { + if page.miqs.IsEmpty() { + return nil + } + return *page.miqs.Value +} + +// Creates a new instance of the ManagedInstanceQueryStatisticsPage type. +func NewManagedInstanceQueryStatisticsPage(cur ManagedInstanceQueryStatistics, getNextPage func(context.Context, ManagedInstanceQueryStatistics) (ManagedInstanceQueryStatistics, error)) ManagedInstanceQueryStatisticsPage { + return ManagedInstanceQueryStatisticsPage{ + fn: getNextPage, + miqs: cur, + } +} + +// ManagedInstancesCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type ManagedInstancesCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ManagedInstancesClient) (ManagedInstance, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ManagedInstancesCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ManagedInstancesCreateOrUpdateFuture.Result. +func (future *ManagedInstancesCreateOrUpdateFuture) result(client ManagedInstancesClient) (mi ManagedInstance, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + mi.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ManagedInstancesCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if mi.Response.Response, err = future.GetResult(sender); err == nil && mi.Response.Response.StatusCode != http.StatusNoContent { + mi, err = client.CreateOrUpdateResponder(mi.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesCreateOrUpdateFuture", "Result", mi.Response.Response, "Failure responding to request") + } + } + return +} + +// ManagedInstancesDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ManagedInstancesDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ManagedInstancesClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ManagedInstancesDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ManagedInstancesDeleteFuture.Result. +func (future *ManagedInstancesDeleteFuture) result(client ManagedInstancesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ManagedInstancesDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// ManagedInstancesFailoverFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type ManagedInstancesFailoverFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ManagedInstancesClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ManagedInstancesFailoverFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ManagedInstancesFailoverFuture.Result. +func (future *ManagedInstancesFailoverFuture) result(client ManagedInstancesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesFailoverFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ManagedInstancesFailoverFuture") + return + } + ar.Response = future.Response() + return +} + +// ManagedInstancesUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ManagedInstancesUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ManagedInstancesClient) (ManagedInstance, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ManagedInstancesUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ManagedInstancesUpdateFuture.Result. +func (future *ManagedInstancesUpdateFuture) result(client ManagedInstancesClient) (mi ManagedInstance, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + mi.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ManagedInstancesUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if mi.Response.Response, err = future.GetResult(sender); err == nil && mi.Response.Response.StatusCode != http.StatusNoContent { + mi, err = client.UpdateResponder(mi.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstancesUpdateFuture", "Result", mi.Response.Response, "Failure responding to request") + } + } + return +} + +// ManagedInstanceTdeCertificatesCreateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type ManagedInstanceTdeCertificatesCreateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ManagedInstanceTdeCertificatesClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ManagedInstanceTdeCertificatesCreateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ManagedInstanceTdeCertificatesCreateFuture.Result. +func (future *ManagedInstanceTdeCertificatesCreateFuture) result(client ManagedInstanceTdeCertificatesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedInstanceTdeCertificatesCreateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ManagedInstanceTdeCertificatesCreateFuture") + return + } + ar.Response = future.Response() + return +} + +// ManagedInstanceUpdate an update request for an Azure SQL Database managed instance. +type ManagedInstanceUpdate struct { + // Sku - Managed instance sku + Sku *Sku `json:"sku,omitempty"` + // Identity - Managed instance identity + Identity *ResourceIdentity `json:"identity,omitempty"` + // ManagedInstanceProperties - Resource properties. + *ManagedInstanceProperties `json:"properties,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for ManagedInstanceUpdate. +func (miu ManagedInstanceUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if miu.Sku != nil { + objectMap["sku"] = miu.Sku + } + if miu.Identity != nil { + objectMap["identity"] = miu.Identity + } + if miu.ManagedInstanceProperties != nil { + objectMap["properties"] = miu.ManagedInstanceProperties + } + if miu.Tags != nil { + objectMap["tags"] = miu.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ManagedInstanceUpdate struct. +func (miu *ManagedInstanceUpdate) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "sku": + if v != nil { + var sku Sku + err = json.Unmarshal(*v, &sku) + if err != nil { + return err + } + miu.Sku = &sku + } + case "identity": + if v != nil { + var identity ResourceIdentity + err = json.Unmarshal(*v, &identity) + if err != nil { + return err + } + miu.Identity = &identity + } + case "properties": + if v != nil { + var managedInstanceProperties ManagedInstanceProperties + err = json.Unmarshal(*v, &managedInstanceProperties) + if err != nil { + return err + } + miu.ManagedInstanceProperties = &managedInstanceProperties + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + miu.Tags = tags + } + } + } + + return nil +} + +// ManagedInstanceVcoresCapability the managed instance virtual cores capability. +type ManagedInstanceVcoresCapability struct { + // Name - READ-ONLY; The virtual cores identifier. + Name *string `json:"name,omitempty"` + // Value - READ-ONLY; The virtual cores value. + Value *int32 `json:"value,omitempty"` + // IncludedMaxSize - READ-ONLY; Included size. + IncludedMaxSize *MaxSizeCapability `json:"includedMaxSize,omitempty"` + // SupportedStorageSizes - READ-ONLY; Storage size ranges. + SupportedStorageSizes *[]MaxSizeRangeCapability `json:"supportedStorageSizes,omitempty"` + // InstancePoolSupported - READ-ONLY; True if this service objective is supported for managed instances in an instance pool. + InstancePoolSupported *bool `json:"instancePoolSupported,omitempty"` + // StandaloneSupported - READ-ONLY; True if this service objective is supported for standalone managed instances. + StandaloneSupported *bool `json:"standaloneSupported,omitempty"` + // SupportedMaintenanceConfigurations - READ-ONLY; List of supported maintenance configurations + SupportedMaintenanceConfigurations *[]ManagedInstanceMaintenanceConfigurationCapability `json:"supportedMaintenanceConfigurations,omitempty"` + // Status - READ-ONLY; The status of the capability. Possible values include: 'CapabilityStatusVisible', 'CapabilityStatusAvailable', 'CapabilityStatusDefault', 'CapabilityStatusDisabled' + Status CapabilityStatus `json:"status,omitempty"` + // Reason - The reason for the capability not being available. + Reason *string `json:"reason,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstanceVcoresCapability. +func (mivc ManagedInstanceVcoresCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mivc.Reason != nil { + objectMap["reason"] = mivc.Reason + } + return json.Marshal(objectMap) +} + +// ManagedInstanceVersionCapability the managed instance capability +type ManagedInstanceVersionCapability struct { + // Name - READ-ONLY; The server version name. + Name *string `json:"name,omitempty"` + // SupportedEditions - READ-ONLY; The list of supported managed instance editions. + SupportedEditions *[]ManagedInstanceEditionCapability `json:"supportedEditions,omitempty"` + // SupportedInstancePoolEditions - READ-ONLY; The list of supported instance pool editions. + SupportedInstancePoolEditions *[]InstancePoolEditionCapability `json:"supportedInstancePoolEditions,omitempty"` + // Status - READ-ONLY; The status of the capability. Possible values include: 'CapabilityStatusVisible', 'CapabilityStatusAvailable', 'CapabilityStatusDefault', 'CapabilityStatusDisabled' + Status CapabilityStatus `json:"status,omitempty"` + // Reason - The reason for the capability not being available. + Reason *string `json:"reason,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstanceVersionCapability. +func (mivc ManagedInstanceVersionCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mivc.Reason != nil { + objectMap["reason"] = mivc.Reason + } + return json.Marshal(objectMap) +} + +// ManagedInstanceVulnerabilityAssessment a managed instance vulnerability assessment. +type ManagedInstanceVulnerabilityAssessment struct { + autorest.Response `json:"-"` + // ManagedInstanceVulnerabilityAssessmentProperties - Resource properties. + *ManagedInstanceVulnerabilityAssessmentProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstanceVulnerabilityAssessment. +func (miva ManagedInstanceVulnerabilityAssessment) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if miva.ManagedInstanceVulnerabilityAssessmentProperties != nil { + objectMap["properties"] = miva.ManagedInstanceVulnerabilityAssessmentProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ManagedInstanceVulnerabilityAssessment struct. +func (miva *ManagedInstanceVulnerabilityAssessment) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var managedInstanceVulnerabilityAssessmentProperties ManagedInstanceVulnerabilityAssessmentProperties + err = json.Unmarshal(*v, &managedInstanceVulnerabilityAssessmentProperties) + if err != nil { + return err + } + miva.ManagedInstanceVulnerabilityAssessmentProperties = &managedInstanceVulnerabilityAssessmentProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + miva.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + miva.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + miva.Type = &typeVar + } + } + } + + return nil +} + +// ManagedInstanceVulnerabilityAssessmentListResult a list of the ManagedInstance's vulnerability +// assessments. +type ManagedInstanceVulnerabilityAssessmentListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]ManagedInstanceVulnerabilityAssessment `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedInstanceVulnerabilityAssessmentListResult. +func (mivalr ManagedInstanceVulnerabilityAssessmentListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ManagedInstanceVulnerabilityAssessmentListResultIterator provides access to a complete listing of +// ManagedInstanceVulnerabilityAssessment values. +type ManagedInstanceVulnerabilityAssessmentListResultIterator struct { + i int + page ManagedInstanceVulnerabilityAssessmentListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *ManagedInstanceVulnerabilityAssessmentListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceVulnerabilityAssessmentListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ManagedInstanceVulnerabilityAssessmentListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ManagedInstanceVulnerabilityAssessmentListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter ManagedInstanceVulnerabilityAssessmentListResultIterator) Response() ManagedInstanceVulnerabilityAssessmentListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter ManagedInstanceVulnerabilityAssessmentListResultIterator) Value() ManagedInstanceVulnerabilityAssessment { + if !iter.page.NotDone() { + return ManagedInstanceVulnerabilityAssessment{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ManagedInstanceVulnerabilityAssessmentListResultIterator type. +func NewManagedInstanceVulnerabilityAssessmentListResultIterator(page ManagedInstanceVulnerabilityAssessmentListResultPage) ManagedInstanceVulnerabilityAssessmentListResultIterator { + return ManagedInstanceVulnerabilityAssessmentListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (mivalr ManagedInstanceVulnerabilityAssessmentListResult) IsEmpty() bool { + return mivalr.Value == nil || len(*mivalr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (mivalr ManagedInstanceVulnerabilityAssessmentListResult) hasNextLink() bool { + return mivalr.NextLink != nil && len(*mivalr.NextLink) != 0 +} + +// managedInstanceVulnerabilityAssessmentListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (mivalr ManagedInstanceVulnerabilityAssessmentListResult) managedInstanceVulnerabilityAssessmentListResultPreparer(ctx context.Context) (*http.Request, error) { + if !mivalr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(mivalr.NextLink))) +} + +// ManagedInstanceVulnerabilityAssessmentListResultPage contains a page of +// ManagedInstanceVulnerabilityAssessment values. +type ManagedInstanceVulnerabilityAssessmentListResultPage struct { + fn func(context.Context, ManagedInstanceVulnerabilityAssessmentListResult) (ManagedInstanceVulnerabilityAssessmentListResult, error) + mivalr ManagedInstanceVulnerabilityAssessmentListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *ManagedInstanceVulnerabilityAssessmentListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedInstanceVulnerabilityAssessmentListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.mivalr) + if err != nil { + return err + } + page.mivalr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *ManagedInstanceVulnerabilityAssessmentListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ManagedInstanceVulnerabilityAssessmentListResultPage) NotDone() bool { + return !page.mivalr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ManagedInstanceVulnerabilityAssessmentListResultPage) Response() ManagedInstanceVulnerabilityAssessmentListResult { + return page.mivalr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ManagedInstanceVulnerabilityAssessmentListResultPage) Values() []ManagedInstanceVulnerabilityAssessment { + if page.mivalr.IsEmpty() { + return nil + } + return *page.mivalr.Value +} + +// Creates a new instance of the ManagedInstanceVulnerabilityAssessmentListResultPage type. +func NewManagedInstanceVulnerabilityAssessmentListResultPage(cur ManagedInstanceVulnerabilityAssessmentListResult, getNextPage func(context.Context, ManagedInstanceVulnerabilityAssessmentListResult) (ManagedInstanceVulnerabilityAssessmentListResult, error)) ManagedInstanceVulnerabilityAssessmentListResultPage { + return ManagedInstanceVulnerabilityAssessmentListResultPage{ + fn: getNextPage, + mivalr: cur, + } +} + +// ManagedInstanceVulnerabilityAssessmentProperties properties of a managed instance vulnerability +// assessment. +type ManagedInstanceVulnerabilityAssessmentProperties struct { + // StorageContainerPath - A blob storage container path to hold the scan results (e.g. https://myStorage.blob.core.windows.net/VaScans/). + StorageContainerPath *string `json:"storageContainerPath,omitempty"` + // StorageContainerSasKey - A shared access signature (SAS Key) that has write access to the blob container specified in 'storageContainerPath' parameter. If 'storageAccountAccessKey' isn't specified, StorageContainerSasKey is required. Applies only if the storage account is not behind a Vnet or a firewall + StorageContainerSasKey *string `json:"storageContainerSasKey,omitempty"` + // StorageAccountAccessKey - Specifies the identifier key of the storage account for vulnerability assessment scan results. If 'StorageContainerSasKey' isn't specified, storageAccountAccessKey is required. Applies only if the storage account is not behind a Vnet or a firewall + StorageAccountAccessKey *string `json:"storageAccountAccessKey,omitempty"` + // RecurringScans - The recurring scans settings + RecurringScans *VulnerabilityAssessmentRecurringScansProperties `json:"recurringScans,omitempty"` +} + +// ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesCreateOrUpdateFuture an abstraction for +// monitoring and retrieving the results of a long-running operation. +type ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient) (ManagedBackupShortTermRetentionPolicy, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesCreateOrUpdateFuture.Result. +func (future *ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesCreateOrUpdateFuture) result(client ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient) (mbstrp ManagedBackupShortTermRetentionPolicy, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + mbstrp.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if mbstrp.Response.Response, err = future.GetResult(sender); err == nil && mbstrp.Response.Response.StatusCode != http.StatusNoContent { + mbstrp, err = client.CreateOrUpdateResponder(mbstrp.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesCreateOrUpdateFuture", "Result", mbstrp.Response.Response, "Failure responding to request") + } + } + return +} + +// ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesUpdateFuture an abstraction for +// monitoring and retrieving the results of a long-running operation. +type ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient) (ManagedBackupShortTermRetentionPolicy, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesUpdateFuture.Result. +func (future *ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesUpdateFuture) result(client ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient) (mbstrp ManagedBackupShortTermRetentionPolicy, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + mbstrp.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if mbstrp.Response.Response, err = future.GetResult(sender); err == nil && mbstrp.Response.Response.StatusCode != http.StatusNoContent { + mbstrp, err = client.UpdateResponder(mbstrp.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesUpdateFuture", "Result", mbstrp.Response.Response, "Failure responding to request") + } + } + return +} + +// ManagedServerSecurityAlertPoliciesCreateOrUpdateFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type ManagedServerSecurityAlertPoliciesCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ManagedServerSecurityAlertPoliciesClient) (ManagedServerSecurityAlertPolicy, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ManagedServerSecurityAlertPoliciesCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ManagedServerSecurityAlertPoliciesCreateOrUpdateFuture.Result. +func (future *ManagedServerSecurityAlertPoliciesCreateOrUpdateFuture) result(client ManagedServerSecurityAlertPoliciesClient) (mssap ManagedServerSecurityAlertPolicy, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedServerSecurityAlertPoliciesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + mssap.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ManagedServerSecurityAlertPoliciesCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if mssap.Response.Response, err = future.GetResult(sender); err == nil && mssap.Response.Response.StatusCode != http.StatusNoContent { + mssap, err = client.CreateOrUpdateResponder(mssap.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ManagedServerSecurityAlertPoliciesCreateOrUpdateFuture", "Result", mssap.Response.Response, "Failure responding to request") + } + } + return +} + +// ManagedServerSecurityAlertPolicy a managed server security alert policy. +type ManagedServerSecurityAlertPolicy struct { + autorest.Response `json:"-"` + // SystemData - READ-ONLY; SystemData of SecurityAlertPolicyResource. + SystemData *SystemData `json:"systemData,omitempty"` + // SecurityAlertsPolicyProperties - Resource properties. + *SecurityAlertsPolicyProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedServerSecurityAlertPolicy. +func (mssap ManagedServerSecurityAlertPolicy) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mssap.SecurityAlertsPolicyProperties != nil { + objectMap["properties"] = mssap.SecurityAlertsPolicyProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ManagedServerSecurityAlertPolicy struct. +func (mssap *ManagedServerSecurityAlertPolicy) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "systemData": + if v != nil { + var systemData SystemData + err = json.Unmarshal(*v, &systemData) + if err != nil { + return err + } + mssap.SystemData = &systemData + } + case "properties": + if v != nil { + var securityAlertsPolicyProperties SecurityAlertsPolicyProperties + err = json.Unmarshal(*v, &securityAlertsPolicyProperties) + if err != nil { + return err + } + mssap.SecurityAlertsPolicyProperties = &securityAlertsPolicyProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + mssap.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + mssap.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + mssap.Type = &typeVar + } + } + } + + return nil +} + +// ManagedServerSecurityAlertPolicyListResult a list of the managed Server's security alert policies. +type ManagedServerSecurityAlertPolicyListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]ManagedServerSecurityAlertPolicy `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedServerSecurityAlertPolicyListResult. +func (mssaplr ManagedServerSecurityAlertPolicyListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ManagedServerSecurityAlertPolicyListResultIterator provides access to a complete listing of +// ManagedServerSecurityAlertPolicy values. +type ManagedServerSecurityAlertPolicyListResultIterator struct { + i int + page ManagedServerSecurityAlertPolicyListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *ManagedServerSecurityAlertPolicyListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedServerSecurityAlertPolicyListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ManagedServerSecurityAlertPolicyListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ManagedServerSecurityAlertPolicyListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter ManagedServerSecurityAlertPolicyListResultIterator) Response() ManagedServerSecurityAlertPolicyListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter ManagedServerSecurityAlertPolicyListResultIterator) Value() ManagedServerSecurityAlertPolicy { + if !iter.page.NotDone() { + return ManagedServerSecurityAlertPolicy{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ManagedServerSecurityAlertPolicyListResultIterator type. +func NewManagedServerSecurityAlertPolicyListResultIterator(page ManagedServerSecurityAlertPolicyListResultPage) ManagedServerSecurityAlertPolicyListResultIterator { + return ManagedServerSecurityAlertPolicyListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (mssaplr ManagedServerSecurityAlertPolicyListResult) IsEmpty() bool { + return mssaplr.Value == nil || len(*mssaplr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (mssaplr ManagedServerSecurityAlertPolicyListResult) hasNextLink() bool { + return mssaplr.NextLink != nil && len(*mssaplr.NextLink) != 0 +} + +// managedServerSecurityAlertPolicyListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (mssaplr ManagedServerSecurityAlertPolicyListResult) managedServerSecurityAlertPolicyListResultPreparer(ctx context.Context) (*http.Request, error) { + if !mssaplr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(mssaplr.NextLink))) +} + +// ManagedServerSecurityAlertPolicyListResultPage contains a page of ManagedServerSecurityAlertPolicy +// values. +type ManagedServerSecurityAlertPolicyListResultPage struct { + fn func(context.Context, ManagedServerSecurityAlertPolicyListResult) (ManagedServerSecurityAlertPolicyListResult, error) + mssaplr ManagedServerSecurityAlertPolicyListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *ManagedServerSecurityAlertPolicyListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedServerSecurityAlertPolicyListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.mssaplr) + if err != nil { + return err + } + page.mssaplr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *ManagedServerSecurityAlertPolicyListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ManagedServerSecurityAlertPolicyListResultPage) NotDone() bool { + return !page.mssaplr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ManagedServerSecurityAlertPolicyListResultPage) Response() ManagedServerSecurityAlertPolicyListResult { + return page.mssaplr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ManagedServerSecurityAlertPolicyListResultPage) Values() []ManagedServerSecurityAlertPolicy { + if page.mssaplr.IsEmpty() { + return nil + } + return *page.mssaplr.Value +} + +// Creates a new instance of the ManagedServerSecurityAlertPolicyListResultPage type. +func NewManagedServerSecurityAlertPolicyListResultPage(cur ManagedServerSecurityAlertPolicyListResult, getNextPage func(context.Context, ManagedServerSecurityAlertPolicyListResult) (ManagedServerSecurityAlertPolicyListResult, error)) ManagedServerSecurityAlertPolicyListResultPage { + return ManagedServerSecurityAlertPolicyListResultPage{ + fn: getNextPage, + mssaplr: cur, + } +} + +// ManagedTransparentDataEncryption a managed database transparent data encryption state. +type ManagedTransparentDataEncryption struct { + autorest.Response `json:"-"` + // ManagedTransparentDataEncryptionProperties - Resource properties. + *ManagedTransparentDataEncryptionProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedTransparentDataEncryption. +func (mtde ManagedTransparentDataEncryption) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mtde.ManagedTransparentDataEncryptionProperties != nil { + objectMap["properties"] = mtde.ManagedTransparentDataEncryptionProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ManagedTransparentDataEncryption struct. +func (mtde *ManagedTransparentDataEncryption) UnmarshalJSON(body []byte) error { + 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 managedTransparentDataEncryptionProperties ManagedTransparentDataEncryptionProperties + err = json.Unmarshal(*v, &managedTransparentDataEncryptionProperties) + if err != nil { + return err + } + mtde.ManagedTransparentDataEncryptionProperties = &managedTransparentDataEncryptionProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + mtde.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + mtde.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + mtde.Type = &typeVar + } + } + } + + return nil +} + +// ManagedTransparentDataEncryptionListResult a list of managed transparent data encryptions +type ManagedTransparentDataEncryptionListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]ManagedTransparentDataEncryption `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedTransparentDataEncryptionListResult. +func (mtdelr ManagedTransparentDataEncryptionListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ManagedTransparentDataEncryptionListResultIterator provides access to a complete listing of +// ManagedTransparentDataEncryption values. +type ManagedTransparentDataEncryptionListResultIterator struct { + i int + page ManagedTransparentDataEncryptionListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *ManagedTransparentDataEncryptionListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedTransparentDataEncryptionListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ManagedTransparentDataEncryptionListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ManagedTransparentDataEncryptionListResultIterator) 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 ManagedTransparentDataEncryptionListResultIterator) Response() ManagedTransparentDataEncryptionListResult { + 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 ManagedTransparentDataEncryptionListResultIterator) Value() ManagedTransparentDataEncryption { + if !iter.page.NotDone() { + return ManagedTransparentDataEncryption{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ManagedTransparentDataEncryptionListResultIterator type. +func NewManagedTransparentDataEncryptionListResultIterator(page ManagedTransparentDataEncryptionListResultPage) ManagedTransparentDataEncryptionListResultIterator { + return ManagedTransparentDataEncryptionListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (mtdelr ManagedTransparentDataEncryptionListResult) IsEmpty() bool { + return mtdelr.Value == nil || len(*mtdelr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (mtdelr ManagedTransparentDataEncryptionListResult) hasNextLink() bool { + return mtdelr.NextLink != nil && len(*mtdelr.NextLink) != 0 +} + +// managedTransparentDataEncryptionListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (mtdelr ManagedTransparentDataEncryptionListResult) managedTransparentDataEncryptionListResultPreparer(ctx context.Context) (*http.Request, error) { + if !mtdelr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(mtdelr.NextLink))) +} + +// ManagedTransparentDataEncryptionListResultPage contains a page of ManagedTransparentDataEncryption +// values. +type ManagedTransparentDataEncryptionListResultPage struct { + fn func(context.Context, ManagedTransparentDataEncryptionListResult) (ManagedTransparentDataEncryptionListResult, error) + mtdelr ManagedTransparentDataEncryptionListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *ManagedTransparentDataEncryptionListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedTransparentDataEncryptionListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.mtdelr) + if err != nil { + return err + } + page.mtdelr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *ManagedTransparentDataEncryptionListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ManagedTransparentDataEncryptionListResultPage) NotDone() bool { + return !page.mtdelr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ManagedTransparentDataEncryptionListResultPage) Response() ManagedTransparentDataEncryptionListResult { + return page.mtdelr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ManagedTransparentDataEncryptionListResultPage) Values() []ManagedTransparentDataEncryption { + if page.mtdelr.IsEmpty() { + return nil + } + return *page.mtdelr.Value +} + +// Creates a new instance of the ManagedTransparentDataEncryptionListResultPage type. +func NewManagedTransparentDataEncryptionListResultPage(cur ManagedTransparentDataEncryptionListResult, getNextPage func(context.Context, ManagedTransparentDataEncryptionListResult) (ManagedTransparentDataEncryptionListResult, error)) ManagedTransparentDataEncryptionListResultPage { + return ManagedTransparentDataEncryptionListResultPage{ + fn: getNextPage, + mtdelr: cur, + } +} + +// ManagedTransparentDataEncryptionProperties properties of a transparent data encryption. +type ManagedTransparentDataEncryptionProperties struct { + // State - Specifies the state of the transparent data encryption. Possible values include: 'TransparentDataEncryptionStateEnabled', 'TransparentDataEncryptionStateDisabled' + State TransparentDataEncryptionState `json:"state,omitempty"` +} + +// MaxSizeCapability the maximum size capability. +type MaxSizeCapability struct { + // Limit - READ-ONLY; The maximum size limit (see 'unit' for the units). + Limit *int32 `json:"limit,omitempty"` + // Unit - READ-ONLY; The units that the limit is expressed in. Possible values include: 'MaxSizeUnitMegabytes', 'MaxSizeUnitGigabytes', 'MaxSizeUnitTerabytes', 'MaxSizeUnitPetabytes' + Unit MaxSizeUnit `json:"unit,omitempty"` +} + +// MarshalJSON is the custom marshaler for MaxSizeCapability. +func (msc MaxSizeCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// MaxSizeRangeCapability the maximum size range capability. +type MaxSizeRangeCapability struct { + // MinValue - READ-ONLY; Minimum value. + MinValue *MaxSizeCapability `json:"minValue,omitempty"` + // MaxValue - READ-ONLY; Maximum value. + MaxValue *MaxSizeCapability `json:"maxValue,omitempty"` + // ScaleSize - READ-ONLY; Scale/step size for discrete values between the minimum value and the maximum value. + ScaleSize *MaxSizeCapability `json:"scaleSize,omitempty"` + // LogSize - READ-ONLY; Size of transaction log. + LogSize *LogSizeCapability `json:"logSize,omitempty"` + // Status - READ-ONLY; The status of the capability. Possible values include: 'CapabilityStatusVisible', 'CapabilityStatusAvailable', 'CapabilityStatusDefault', 'CapabilityStatusDisabled' + Status CapabilityStatus `json:"status,omitempty"` + // Reason - The reason for the capability not being available. + Reason *string `json:"reason,omitempty"` +} + +// MarshalJSON is the custom marshaler for MaxSizeRangeCapability. +func (msrc MaxSizeRangeCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if msrc.Reason != nil { + objectMap["reason"] = msrc.Reason + } + return json.Marshal(objectMap) +} + +// Metric database metrics. +type Metric struct { + // StartTime - READ-ONLY; The start time for the metric (ISO-8601 format). + StartTime *date.Time `json:"startTime,omitempty"` + // EndTime - READ-ONLY; The end time for the metric (ISO-8601 format). + EndTime *date.Time `json:"endTime,omitempty"` + // TimeGrain - READ-ONLY; The time step to be used to summarize the metric values. + TimeGrain *string `json:"timeGrain,omitempty"` + // Unit - READ-ONLY; The unit of the metric. Possible values include: 'UnitTypeCount', 'UnitTypeBytes', 'UnitTypeSeconds', 'UnitTypePercent', 'UnitTypeCountPerSecond', 'UnitTypeBytesPerSecond' + Unit UnitType `json:"unit,omitempty"` + // Name - READ-ONLY; The name information for the metric. + Name *MetricName `json:"name,omitempty"` + // MetricValues - READ-ONLY; The metric values for the specified time window and timestep. + MetricValues *[]MetricValue `json:"metricValues,omitempty"` +} + +// MarshalJSON is the custom marshaler for Metric. +func (mVar Metric) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// MetricAvailability a metric availability value. +type MetricAvailability struct { + // Retention - READ-ONLY; The length of retention for the database metric. + Retention *string `json:"retention,omitempty"` + // TimeGrain - READ-ONLY; The granularity of the database metric. + TimeGrain *string `json:"timeGrain,omitempty"` +} + +// MarshalJSON is the custom marshaler for MetricAvailability. +func (ma MetricAvailability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// MetricDefinition a database metric definition. +type MetricDefinition struct { + // Name - READ-ONLY; The name information for the metric. + Name *MetricName `json:"name,omitempty"` + // PrimaryAggregationType - READ-ONLY; The primary aggregation type defining how metric values are displayed. Possible values include: 'PrimaryAggregationTypeNone', 'PrimaryAggregationTypeAverage', 'PrimaryAggregationTypeCount', 'PrimaryAggregationTypeMinimum', 'PrimaryAggregationTypeMaximum', 'PrimaryAggregationTypeTotal' + PrimaryAggregationType PrimaryAggregationType `json:"primaryAggregationType,omitempty"` + // ResourceURI - READ-ONLY; The resource uri of the database. + ResourceURI *string `json:"resourceUri,omitempty"` + // Unit - READ-ONLY; The unit of the metric. Possible values include: 'UnitDefinitionTypeCount', 'UnitDefinitionTypeBytes', 'UnitDefinitionTypeSeconds', 'UnitDefinitionTypePercent', 'UnitDefinitionTypeCountPerSecond', 'UnitDefinitionTypeBytesPerSecond' + Unit UnitDefinitionType `json:"unit,omitempty"` + // MetricAvailabilities - READ-ONLY; The list of database metric availabilities for the metric. + MetricAvailabilities *[]MetricAvailability `json:"metricAvailabilities,omitempty"` +} + +// MarshalJSON is the custom marshaler for MetricDefinition. +func (md MetricDefinition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// MetricDefinitionListResult the response to a list database metric definitions request. +type MetricDefinitionListResult struct { + autorest.Response `json:"-"` + // Value - The list of metric definitions for the database. + Value *[]MetricDefinition `json:"value,omitempty"` +} + +// MetricListResult the response to a list database metrics request. +type MetricListResult struct { + autorest.Response `json:"-"` + // Value - The list of metrics for the database. + Value *[]Metric `json:"value,omitempty"` +} + +// MetricName a database metric name. +type MetricName struct { + // Value - READ-ONLY; The name of the database metric. + Value *string `json:"value,omitempty"` + // LocalizedValue - READ-ONLY; The friendly name of the database metric. + LocalizedValue *string `json:"localizedValue,omitempty"` +} + +// MarshalJSON is the custom marshaler for MetricName. +func (mn MetricName) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// MetricValue represents database metrics. +type MetricValue struct { + // Count - READ-ONLY; The number of values for the metric. + Count *float64 `json:"count,omitempty"` + // Average - READ-ONLY; The average value of the metric. + Average *float64 `json:"average,omitempty"` + // Maximum - READ-ONLY; The max value of the metric. + Maximum *float64 `json:"maximum,omitempty"` + // Minimum - READ-ONLY; The min value of the metric. + Minimum *float64 `json:"minimum,omitempty"` + // Timestamp - READ-ONLY; The metric timestamp (ISO-8601 format). + Timestamp *date.Time `json:"timestamp,omitempty"` + // Total - READ-ONLY; The total value of the metric. + Total *float64 `json:"total,omitempty"` +} + +// MarshalJSON is the custom marshaler for MetricValue. +func (mv MetricValue) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// MinCapacityCapability the min capacity capability +type MinCapacityCapability struct { + // Value - READ-ONLY; Min capacity value + Value *float64 `json:"value,omitempty"` + // Status - READ-ONLY; The status of the capability. Possible values include: 'CapabilityStatusVisible', 'CapabilityStatusAvailable', 'CapabilityStatusDefault', 'CapabilityStatusDisabled' + Status CapabilityStatus `json:"status,omitempty"` + // Reason - The reason for the capability not being available. + Reason *string `json:"reason,omitempty"` +} + +// MarshalJSON is the custom marshaler for MinCapacityCapability. +func (mcc MinCapacityCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mcc.Reason != nil { + objectMap["reason"] = mcc.Reason + } + return json.Marshal(objectMap) +} + +// Name ARM Usage Name +type Name struct { + // Value - Usage name value + Value *string `json:"value,omitempty"` + // LocalizedValue - Usage name localized value. + LocalizedValue *string `json:"localizedValue,omitempty"` +} + +// NetworkIsolationSettings contains the ARM resources for which to create private endpoint connection. +type NetworkIsolationSettings struct { + // StorageAccountResourceID - The resource id for the storage account used to store BACPAC file. If set, private endpoint connection will be created for the storage account. Must match storage account used for StorageUri parameter. + StorageAccountResourceID *string `json:"storageAccountResourceId,omitempty"` + // SQLServerResourceID - The resource id for the SQL server which is the target of this request. If set, private endpoint connection will be created for the SQL server. Must match server which is target of the operation. + SQLServerResourceID *string `json:"sqlServerResourceId,omitempty"` +} + +// Operation SQL REST API operation definition. +type Operation struct { + // Name - READ-ONLY; The name of the operation being performed on this particular object. + Name *string `json:"name,omitempty"` + // Display - READ-ONLY; The localized display information for this particular operation / action. + Display *OperationDisplay `json:"display,omitempty"` + // Origin - READ-ONLY; The intended executor of the operation. Possible values include: 'OperationOriginUser', 'OperationOriginSystem' + Origin OperationOrigin `json:"origin,omitempty"` + // Properties - READ-ONLY; Additional descriptions for the operation. + Properties map[string]interface{} `json:"properties"` +} + +// MarshalJSON is the custom marshaler for Operation. +func (o Operation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// OperationDisplay display metadata associated with the operation. +type OperationDisplay struct { + // Provider - READ-ONLY; The localized friendly form of the resource provider name. + Provider *string `json:"provider,omitempty"` + // Resource - READ-ONLY; The localized friendly form of the resource type related to this action/operation. + Resource *string `json:"resource,omitempty"` + // Operation - READ-ONLY; The localized friendly name for the operation. + Operation *string `json:"operation,omitempty"` + // Description - READ-ONLY; The localized friendly description for the operation. + Description *string `json:"description,omitempty"` +} + +// MarshalJSON is the custom marshaler for OperationDisplay. +func (od OperationDisplay) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// OperationImpact the impact of an operation, both in absolute and relative terms. +type OperationImpact struct { + // Name - READ-ONLY; The name of the impact dimension. + Name *string `json:"name,omitempty"` + // Unit - READ-ONLY; The unit in which estimated impact to dimension is measured. + Unit *string `json:"unit,omitempty"` + // ChangeValueAbsolute - READ-ONLY; The absolute impact to dimension. + ChangeValueAbsolute *float64 `json:"changeValueAbsolute,omitempty"` + // ChangeValueRelative - READ-ONLY; The relative impact to dimension (null if not applicable) + ChangeValueRelative *float64 `json:"changeValueRelative,omitempty"` +} + +// MarshalJSON is the custom marshaler for OperationImpact. +func (oi OperationImpact) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// OperationListResult result of the request to list SQL operations. +type OperationListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]Operation `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for OperationListResult. +func (olr OperationListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// OperationListResultIterator provides access to a complete listing of Operation values. +type OperationListResultIterator struct { + i int + page OperationListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *OperationListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *OperationListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter OperationListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter OperationListResultIterator) Response() OperationListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter OperationListResultIterator) Value() Operation { + if !iter.page.NotDone() { + return Operation{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the OperationListResultIterator type. +func NewOperationListResultIterator(page OperationListResultPage) OperationListResultIterator { + return OperationListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (olr OperationListResult) IsEmpty() bool { + return olr.Value == nil || len(*olr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (olr OperationListResult) hasNextLink() bool { + return olr.NextLink != nil && len(*olr.NextLink) != 0 +} + +// operationListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (olr OperationListResult) operationListResultPreparer(ctx context.Context) (*http.Request, error) { + if !olr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(olr.NextLink))) +} + +// OperationListResultPage contains a page of Operation values. +type OperationListResultPage struct { + fn func(context.Context, OperationListResult) (OperationListResult, error) + olr OperationListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *OperationListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.olr) + if err != nil { + return err + } + page.olr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *OperationListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page OperationListResultPage) NotDone() bool { + return !page.olr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page OperationListResultPage) Response() OperationListResult { + return page.olr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page OperationListResultPage) Values() []Operation { + if page.olr.IsEmpty() { + return nil + } + return *page.olr.Value +} + +// Creates a new instance of the OperationListResultPage type. +func NewOperationListResultPage(cur OperationListResult, getNextPage func(context.Context, OperationListResult) (OperationListResult, error)) OperationListResultPage { + return OperationListResultPage{ + fn: getNextPage, + olr: cur, + } +} + +// OperationsHealth operations health status in a location. +type OperationsHealth struct { + // OperationsHealthProperties - Resource properties. + *OperationsHealthProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for OperationsHealth. +func (oh OperationsHealth) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if oh.OperationsHealthProperties != nil { + objectMap["properties"] = oh.OperationsHealthProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for OperationsHealth struct. +func (oh *OperationsHealth) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var operationsHealthProperties OperationsHealthProperties + err = json.Unmarshal(*v, &operationsHealthProperties) + if err != nil { + return err + } + oh.OperationsHealthProperties = &operationsHealthProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + oh.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + oh.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + oh.Type = &typeVar + } + } + } + + return nil +} + +// OperationsHealthListResult a list of service health statuses in a location. +type OperationsHealthListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]OperationsHealth `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for OperationsHealthListResult. +func (ohlr OperationsHealthListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// OperationsHealthListResultIterator provides access to a complete listing of OperationsHealth values. +type OperationsHealthListResultIterator struct { + i int + page OperationsHealthListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *OperationsHealthListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationsHealthListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *OperationsHealthListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter OperationsHealthListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter OperationsHealthListResultIterator) Response() OperationsHealthListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter OperationsHealthListResultIterator) Value() OperationsHealth { + if !iter.page.NotDone() { + return OperationsHealth{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the OperationsHealthListResultIterator type. +func NewOperationsHealthListResultIterator(page OperationsHealthListResultPage) OperationsHealthListResultIterator { + return OperationsHealthListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (ohlr OperationsHealthListResult) IsEmpty() bool { + return ohlr.Value == nil || len(*ohlr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (ohlr OperationsHealthListResult) hasNextLink() bool { + return ohlr.NextLink != nil && len(*ohlr.NextLink) != 0 +} + +// operationsHealthListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (ohlr OperationsHealthListResult) operationsHealthListResultPreparer(ctx context.Context) (*http.Request, error) { + if !ohlr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(ohlr.NextLink))) +} + +// OperationsHealthListResultPage contains a page of OperationsHealth values. +type OperationsHealthListResultPage struct { + fn func(context.Context, OperationsHealthListResult) (OperationsHealthListResult, error) + ohlr OperationsHealthListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *OperationsHealthListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationsHealthListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.ohlr) + if err != nil { + return err + } + page.ohlr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *OperationsHealthListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page OperationsHealthListResultPage) NotDone() bool { + return !page.ohlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page OperationsHealthListResultPage) Response() OperationsHealthListResult { + return page.ohlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page OperationsHealthListResultPage) Values() []OperationsHealth { + if page.ohlr.IsEmpty() { + return nil + } + return *page.ohlr.Value +} + +// Creates a new instance of the OperationsHealthListResultPage type. +func NewOperationsHealthListResultPage(cur OperationsHealthListResult, getNextPage func(context.Context, OperationsHealthListResult) (OperationsHealthListResult, error)) OperationsHealthListResultPage { + return OperationsHealthListResultPage{ + fn: getNextPage, + ohlr: cur, + } +} + +// OperationsHealthProperties properties of an operation health. +type OperationsHealthProperties struct { + // Name - READ-ONLY; Operation name for the service + Name *string `json:"name,omitempty"` + // Health - READ-ONLY; Operation health status of the service. + Health *string `json:"health,omitempty"` + // Description - READ-ONLY; Health status description. + Description *string `json:"description,omitempty"` +} + +// MarshalJSON is the custom marshaler for OperationsHealthProperties. +func (ohp OperationsHealthProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// OutboundFirewallRule an Azure SQL DB Server Outbound Firewall Rule. +type OutboundFirewallRule struct { + autorest.Response `json:"-"` + // OutboundFirewallRuleProperties - Resource properties. + *OutboundFirewallRuleProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for OutboundFirewallRule. +func (ofr OutboundFirewallRule) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ofr.OutboundFirewallRuleProperties != nil { + objectMap["properties"] = ofr.OutboundFirewallRuleProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for OutboundFirewallRule struct. +func (ofr *OutboundFirewallRule) UnmarshalJSON(body []byte) error { + 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 outboundFirewallRuleProperties OutboundFirewallRuleProperties + err = json.Unmarshal(*v, &outboundFirewallRuleProperties) + if err != nil { + return err + } + ofr.OutboundFirewallRuleProperties = &outboundFirewallRuleProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + ofr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ofr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ofr.Type = &typeVar + } + } + } + + return nil +} + +// OutboundFirewallRuleListResult a list of outbound rules. +type OutboundFirewallRuleListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]OutboundFirewallRule `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for OutboundFirewallRuleListResult. +func (ofrlr OutboundFirewallRuleListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// OutboundFirewallRuleListResultIterator provides access to a complete listing of OutboundFirewallRule +// values. +type OutboundFirewallRuleListResultIterator struct { + i int + page OutboundFirewallRuleListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *OutboundFirewallRuleListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OutboundFirewallRuleListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *OutboundFirewallRuleListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter OutboundFirewallRuleListResultIterator) 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 OutboundFirewallRuleListResultIterator) Response() OutboundFirewallRuleListResult { + 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 OutboundFirewallRuleListResultIterator) Value() OutboundFirewallRule { + if !iter.page.NotDone() { + return OutboundFirewallRule{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the OutboundFirewallRuleListResultIterator type. +func NewOutboundFirewallRuleListResultIterator(page OutboundFirewallRuleListResultPage) OutboundFirewallRuleListResultIterator { + return OutboundFirewallRuleListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (ofrlr OutboundFirewallRuleListResult) IsEmpty() bool { + return ofrlr.Value == nil || len(*ofrlr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (ofrlr OutboundFirewallRuleListResult) hasNextLink() bool { + return ofrlr.NextLink != nil && len(*ofrlr.NextLink) != 0 +} + +// outboundFirewallRuleListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (ofrlr OutboundFirewallRuleListResult) outboundFirewallRuleListResultPreparer(ctx context.Context) (*http.Request, error) { + if !ofrlr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(ofrlr.NextLink))) +} + +// OutboundFirewallRuleListResultPage contains a page of OutboundFirewallRule values. +type OutboundFirewallRuleListResultPage struct { + fn func(context.Context, OutboundFirewallRuleListResult) (OutboundFirewallRuleListResult, error) + ofrlr OutboundFirewallRuleListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *OutboundFirewallRuleListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OutboundFirewallRuleListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.ofrlr) + if err != nil { + return err + } + page.ofrlr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *OutboundFirewallRuleListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page OutboundFirewallRuleListResultPage) NotDone() bool { + return !page.ofrlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page OutboundFirewallRuleListResultPage) Response() OutboundFirewallRuleListResult { + return page.ofrlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page OutboundFirewallRuleListResultPage) Values() []OutboundFirewallRule { + if page.ofrlr.IsEmpty() { + return nil + } + return *page.ofrlr.Value +} + +// Creates a new instance of the OutboundFirewallRuleListResultPage type. +func NewOutboundFirewallRuleListResultPage(cur OutboundFirewallRuleListResult, getNextPage func(context.Context, OutboundFirewallRuleListResult) (OutboundFirewallRuleListResult, error)) OutboundFirewallRuleListResultPage { + return OutboundFirewallRuleListResultPage{ + fn: getNextPage, + ofrlr: cur, + } +} + +// OutboundFirewallRuleProperties the properties of an outbound firewall rule. +type OutboundFirewallRuleProperties struct { + // ProvisioningState - READ-ONLY; The state of the outbound rule. + ProvisioningState *string `json:"provisioningState,omitempty"` +} + +// MarshalJSON is the custom marshaler for OutboundFirewallRuleProperties. +func (ofrp OutboundFirewallRuleProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// OutboundFirewallRulesCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type OutboundFirewallRulesCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(OutboundFirewallRulesClient) (OutboundFirewallRule, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *OutboundFirewallRulesCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for OutboundFirewallRulesCreateOrUpdateFuture.Result. +func (future *OutboundFirewallRulesCreateOrUpdateFuture) result(client OutboundFirewallRulesClient) (ofr OutboundFirewallRule, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.OutboundFirewallRulesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ofr.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.OutboundFirewallRulesCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if ofr.Response.Response, err = future.GetResult(sender); err == nil && ofr.Response.Response.StatusCode != http.StatusNoContent { + ofr, err = client.CreateOrUpdateResponder(ofr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.OutboundFirewallRulesCreateOrUpdateFuture", "Result", ofr.Response.Response, "Failure responding to request") + } + } + return +} + +// OutboundFirewallRulesDeleteFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type OutboundFirewallRulesDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(OutboundFirewallRulesClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *OutboundFirewallRulesDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for OutboundFirewallRulesDeleteFuture.Result. +func (future *OutboundFirewallRulesDeleteFuture) result(client OutboundFirewallRulesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.OutboundFirewallRulesDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.OutboundFirewallRulesDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// PartnerInfo partner server information for the failover group. +type PartnerInfo struct { + // ID - Resource identifier of the partner server. + ID *string `json:"id,omitempty"` + // Location - READ-ONLY; Geo location of the partner server. + Location *string `json:"location,omitempty"` + // ReplicationRole - READ-ONLY; Replication role of the partner server. Possible values include: 'FailoverGroupReplicationRolePrimary', 'FailoverGroupReplicationRoleSecondary' + ReplicationRole FailoverGroupReplicationRole `json:"replicationRole,omitempty"` +} + +// MarshalJSON is the custom marshaler for PartnerInfo. +func (pi PartnerInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if pi.ID != nil { + objectMap["id"] = pi.ID + } + return json.Marshal(objectMap) +} + +// PartnerRegionInfo partner region information for the failover group. +type PartnerRegionInfo struct { + // Location - Geo location of the partner managed instances. + Location *string `json:"location,omitempty"` + // ReplicationRole - READ-ONLY; Replication role of the partner managed instances. Possible values include: 'InstanceFailoverGroupReplicationRolePrimary', 'InstanceFailoverGroupReplicationRoleSecondary' + ReplicationRole InstanceFailoverGroupReplicationRole `json:"replicationRole,omitempty"` +} + +// MarshalJSON is the custom marshaler for PartnerRegionInfo. +func (pri PartnerRegionInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if pri.Location != nil { + objectMap["location"] = pri.Location + } + return json.Marshal(objectMap) +} + +// PerformanceLevelCapability the performance level capability. +type PerformanceLevelCapability struct { + // Value - READ-ONLY; Performance level value. + Value *float64 `json:"value,omitempty"` + // Unit - READ-ONLY; Unit type used to measure performance level. Possible values include: 'PerformanceLevelUnitDTU', 'PerformanceLevelUnitVCores' + Unit PerformanceLevelUnit `json:"unit,omitempty"` +} + +// MarshalJSON is the custom marshaler for PerformanceLevelCapability. +func (plc PerformanceLevelCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// PrivateEndpointConnection a private endpoint connection +type PrivateEndpointConnection struct { + autorest.Response `json:"-"` + // PrivateEndpointConnectionProperties - Resource properties. + *PrivateEndpointConnectionProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for PrivateEndpointConnection. +func (pec PrivateEndpointConnection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if pec.PrivateEndpointConnectionProperties != nil { + objectMap["properties"] = pec.PrivateEndpointConnectionProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for PrivateEndpointConnection struct. +func (pec *PrivateEndpointConnection) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var privateEndpointConnectionProperties PrivateEndpointConnectionProperties + err = json.Unmarshal(*v, &privateEndpointConnectionProperties) + if err != nil { + return err + } + pec.PrivateEndpointConnectionProperties = &privateEndpointConnectionProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + pec.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + pec.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + pec.Type = &typeVar + } + } + } + + return nil +} + +// PrivateEndpointConnectionListResult a list of private endpoint connections. +type PrivateEndpointConnectionListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]PrivateEndpointConnection `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for PrivateEndpointConnectionListResult. +func (peclr PrivateEndpointConnectionListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// PrivateEndpointConnectionListResultIterator provides access to a complete listing of +// PrivateEndpointConnection values. +type PrivateEndpointConnectionListResultIterator struct { + i int + page PrivateEndpointConnectionListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *PrivateEndpointConnectionListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *PrivateEndpointConnectionListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter PrivateEndpointConnectionListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter PrivateEndpointConnectionListResultIterator) Response() PrivateEndpointConnectionListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter PrivateEndpointConnectionListResultIterator) Value() PrivateEndpointConnection { + if !iter.page.NotDone() { + return PrivateEndpointConnection{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the PrivateEndpointConnectionListResultIterator type. +func NewPrivateEndpointConnectionListResultIterator(page PrivateEndpointConnectionListResultPage) PrivateEndpointConnectionListResultIterator { + return PrivateEndpointConnectionListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (peclr PrivateEndpointConnectionListResult) IsEmpty() bool { + return peclr.Value == nil || len(*peclr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (peclr PrivateEndpointConnectionListResult) hasNextLink() bool { + return peclr.NextLink != nil && len(*peclr.NextLink) != 0 +} + +// privateEndpointConnectionListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (peclr PrivateEndpointConnectionListResult) privateEndpointConnectionListResultPreparer(ctx context.Context) (*http.Request, error) { + if !peclr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(peclr.NextLink))) +} + +// PrivateEndpointConnectionListResultPage contains a page of PrivateEndpointConnection values. +type PrivateEndpointConnectionListResultPage struct { + fn func(context.Context, PrivateEndpointConnectionListResult) (PrivateEndpointConnectionListResult, error) + peclr PrivateEndpointConnectionListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *PrivateEndpointConnectionListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.peclr) + if err != nil { + return err + } + page.peclr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *PrivateEndpointConnectionListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page PrivateEndpointConnectionListResultPage) NotDone() bool { + return !page.peclr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page PrivateEndpointConnectionListResultPage) Response() PrivateEndpointConnectionListResult { + return page.peclr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page PrivateEndpointConnectionListResultPage) Values() []PrivateEndpointConnection { + if page.peclr.IsEmpty() { + return nil + } + return *page.peclr.Value +} + +// Creates a new instance of the PrivateEndpointConnectionListResultPage type. +func NewPrivateEndpointConnectionListResultPage(cur PrivateEndpointConnectionListResult, getNextPage func(context.Context, PrivateEndpointConnectionListResult) (PrivateEndpointConnectionListResult, error)) PrivateEndpointConnectionListResultPage { + return PrivateEndpointConnectionListResultPage{ + fn: getNextPage, + peclr: cur, + } +} + +// PrivateEndpointConnectionProperties properties of a private endpoint connection. +type PrivateEndpointConnectionProperties struct { + // PrivateEndpoint - Private endpoint which the connection belongs to. + PrivateEndpoint *PrivateEndpointProperty `json:"privateEndpoint,omitempty"` + // PrivateLinkServiceConnectionState - Connection state of the private endpoint connection. + PrivateLinkServiceConnectionState *PrivateLinkServiceConnectionStateProperty `json:"privateLinkServiceConnectionState,omitempty"` + // ProvisioningState - READ-ONLY; State of the private endpoint connection. Possible values include: 'PrivateEndpointProvisioningStateApproving', 'PrivateEndpointProvisioningStateReady', 'PrivateEndpointProvisioningStateDropping', 'PrivateEndpointProvisioningStateFailed', 'PrivateEndpointProvisioningStateRejecting' + ProvisioningState PrivateEndpointProvisioningState `json:"provisioningState,omitempty"` +} + +// MarshalJSON is the custom marshaler for PrivateEndpointConnectionProperties. +func (pecp PrivateEndpointConnectionProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if pecp.PrivateEndpoint != nil { + objectMap["privateEndpoint"] = pecp.PrivateEndpoint + } + if pecp.PrivateLinkServiceConnectionState != nil { + objectMap["privateLinkServiceConnectionState"] = pecp.PrivateLinkServiceConnectionState + } + return json.Marshal(objectMap) +} + +// PrivateEndpointConnectionRequestStatus contains the private endpoint connection requests status. +type PrivateEndpointConnectionRequestStatus struct { + // PrivateLinkServiceID - READ-ONLY; Resource id for which the private endpoint is created. + PrivateLinkServiceID *string `json:"privateLinkServiceId,omitempty"` + // PrivateEndpointConnectionName - READ-ONLY; The connection name for the private endpoint. + PrivateEndpointConnectionName *string `json:"privateEndpointConnectionName,omitempty"` + // Status - READ-ONLY; Status of this private endpoint connection. + Status *string `json:"status,omitempty"` +} + +// MarshalJSON is the custom marshaler for PrivateEndpointConnectionRequestStatus. +func (pecrs PrivateEndpointConnectionRequestStatus) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// PrivateEndpointConnectionsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results +// of a long-running operation. +type PrivateEndpointConnectionsCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(PrivateEndpointConnectionsClient) (PrivateEndpointConnection, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *PrivateEndpointConnectionsCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for PrivateEndpointConnectionsCreateOrUpdateFuture.Result. +func (future *PrivateEndpointConnectionsCreateOrUpdateFuture) result(client PrivateEndpointConnectionsClient) (pec PrivateEndpointConnection, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.PrivateEndpointConnectionsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + pec.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.PrivateEndpointConnectionsCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if pec.Response.Response, err = future.GetResult(sender); err == nil && pec.Response.Response.StatusCode != http.StatusNoContent { + pec, err = client.CreateOrUpdateResponder(pec.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.PrivateEndpointConnectionsCreateOrUpdateFuture", "Result", pec.Response.Response, "Failure responding to request") + } + } + return +} + +// PrivateEndpointConnectionsDeleteFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type PrivateEndpointConnectionsDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(PrivateEndpointConnectionsClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *PrivateEndpointConnectionsDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for PrivateEndpointConnectionsDeleteFuture.Result. +func (future *PrivateEndpointConnectionsDeleteFuture) result(client PrivateEndpointConnectionsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.PrivateEndpointConnectionsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.PrivateEndpointConnectionsDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// PrivateEndpointProperty ... +type PrivateEndpointProperty struct { + // ID - Resource id of the private endpoint. + ID *string `json:"id,omitempty"` +} + +// PrivateLinkResource a private link resource +type PrivateLinkResource struct { + autorest.Response `json:"-"` + // Properties - READ-ONLY; The private link resource group id. + Properties *PrivateLinkResourceProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for PrivateLinkResource. +func (plr PrivateLinkResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// PrivateLinkResourceListResult a list of private link resources +type PrivateLinkResourceListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]PrivateLinkResource `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for PrivateLinkResourceListResult. +func (plrlr PrivateLinkResourceListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// PrivateLinkResourceListResultIterator provides access to a complete listing of PrivateLinkResource +// values. +type PrivateLinkResourceListResultIterator struct { + i int + page PrivateLinkResourceListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *PrivateLinkResourceListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkResourceListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *PrivateLinkResourceListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter PrivateLinkResourceListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter PrivateLinkResourceListResultIterator) Response() PrivateLinkResourceListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter PrivateLinkResourceListResultIterator) Value() PrivateLinkResource { + if !iter.page.NotDone() { + return PrivateLinkResource{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the PrivateLinkResourceListResultIterator type. +func NewPrivateLinkResourceListResultIterator(page PrivateLinkResourceListResultPage) PrivateLinkResourceListResultIterator { + return PrivateLinkResourceListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (plrlr PrivateLinkResourceListResult) IsEmpty() bool { + return plrlr.Value == nil || len(*plrlr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (plrlr PrivateLinkResourceListResult) hasNextLink() bool { + return plrlr.NextLink != nil && len(*plrlr.NextLink) != 0 +} + +// privateLinkResourceListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (plrlr PrivateLinkResourceListResult) privateLinkResourceListResultPreparer(ctx context.Context) (*http.Request, error) { + if !plrlr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(plrlr.NextLink))) +} + +// PrivateLinkResourceListResultPage contains a page of PrivateLinkResource values. +type PrivateLinkResourceListResultPage struct { + fn func(context.Context, PrivateLinkResourceListResult) (PrivateLinkResourceListResult, error) + plrlr PrivateLinkResourceListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *PrivateLinkResourceListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkResourceListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.plrlr) + if err != nil { + return err + } + page.plrlr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *PrivateLinkResourceListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page PrivateLinkResourceListResultPage) NotDone() bool { + return !page.plrlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page PrivateLinkResourceListResultPage) Response() PrivateLinkResourceListResult { + return page.plrlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page PrivateLinkResourceListResultPage) Values() []PrivateLinkResource { + if page.plrlr.IsEmpty() { + return nil + } + return *page.plrlr.Value +} + +// Creates a new instance of the PrivateLinkResourceListResultPage type. +func NewPrivateLinkResourceListResultPage(cur PrivateLinkResourceListResult, getNextPage func(context.Context, PrivateLinkResourceListResult) (PrivateLinkResourceListResult, error)) PrivateLinkResourceListResultPage { + return PrivateLinkResourceListResultPage{ + fn: getNextPage, + plrlr: cur, + } +} + +// PrivateLinkResourceProperties properties of a private link resource. +type PrivateLinkResourceProperties struct { + // GroupID - READ-ONLY; The private link resource group id. + GroupID *string `json:"groupId,omitempty"` + // RequiredMembers - READ-ONLY; The private link resource required member names. + RequiredMembers *[]string `json:"requiredMembers,omitempty"` + // RequiredZoneNames - READ-ONLY; The private link resource required zone names. + RequiredZoneNames *[]string `json:"requiredZoneNames,omitempty"` +} + +// MarshalJSON is the custom marshaler for PrivateLinkResourceProperties. +func (plrp PrivateLinkResourceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// PrivateLinkServiceConnectionStateProperty ... +type PrivateLinkServiceConnectionStateProperty struct { + // Status - The private link service connection status. Possible values include: 'PrivateLinkServiceConnectionStateStatusApproved', 'PrivateLinkServiceConnectionStateStatusPending', 'PrivateLinkServiceConnectionStateStatusRejected', 'PrivateLinkServiceConnectionStateStatusDisconnected' + Status PrivateLinkServiceConnectionStateStatus `json:"status,omitempty"` + // Description - The private link service connection description. + Description *string `json:"description,omitempty"` + // ActionsRequired - READ-ONLY; The actions required for private link service connection. Possible values include: 'PrivateLinkServiceConnectionStateActionsRequireNone' + ActionsRequired PrivateLinkServiceConnectionStateActionsRequire `json:"actionsRequired,omitempty"` +} + +// MarshalJSON is the custom marshaler for PrivateLinkServiceConnectionStateProperty. +func (plscsp PrivateLinkServiceConnectionStateProperty) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if plscsp.Status != "" { + objectMap["status"] = plscsp.Status + } + if plscsp.Description != nil { + objectMap["description"] = plscsp.Description + } + return json.Marshal(objectMap) +} + +// ProxyResource ARM proxy resource. +type ProxyResource struct { + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ProxyResource. +func (pr ProxyResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ProxyResourceWithWritableName ARM proxy resource. +type ProxyResourceWithWritableName struct { + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ProxyResourceWithWritableName. +func (prwwn ProxyResourceWithWritableName) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if prwwn.Name != nil { + objectMap["name"] = prwwn.Name + } + return json.Marshal(objectMap) +} + +// QueryMetricInterval properties of a query metrics interval. +type QueryMetricInterval struct { + // IntervalStartTime - READ-ONLY; The start time for the metric interval (ISO-8601 format). + IntervalStartTime *string `json:"intervalStartTime,omitempty"` + // IntervalType - READ-ONLY; Interval type (length). Possible values include: 'QueryTimeGrainTypePT1H', 'QueryTimeGrainTypeP1D' + IntervalType QueryTimeGrainType `json:"intervalType,omitempty"` + // ExecutionCount - READ-ONLY; Execution count of a query in this interval. + ExecutionCount *int64 `json:"executionCount,omitempty"` + // Metrics - List of metric objects for this interval + Metrics *[]QueryMetricProperties `json:"metrics,omitempty"` +} + +// MarshalJSON is the custom marshaler for QueryMetricInterval. +func (qmi QueryMetricInterval) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if qmi.Metrics != nil { + objectMap["metrics"] = qmi.Metrics + } + return json.Marshal(objectMap) +} + +// QueryMetricProperties properties of a topquery metric in one interval. +type QueryMetricProperties struct { + // Name - READ-ONLY; The name information for the metric. + Name *string `json:"name,omitempty"` + // DisplayName - READ-ONLY; The UI appropriate name for the metric. + DisplayName *string `json:"displayName,omitempty"` + // Unit - READ-ONLY; The unit of the metric. Possible values include: 'QueryMetricUnitTypePercentage', 'QueryMetricUnitTypeKB', 'QueryMetricUnitTypeMicroseconds', 'QueryMetricUnitTypeCount' + Unit QueryMetricUnitType `json:"unit,omitempty"` + // Value - READ-ONLY; The value of the metric. + Value *float64 `json:"value,omitempty"` + // Min - READ-ONLY; Metric value when min() aggregate function is used over the interval. + Min *float64 `json:"min,omitempty"` + // Max - READ-ONLY; Metric value when max() aggregate function is used over the interval. + Max *float64 `json:"max,omitempty"` + // Avg - READ-ONLY; Metric value when avg() aggregate function is used over the interval. + Avg *float64 `json:"avg,omitempty"` + // Sum - READ-ONLY; Metric value when sum() aggregate function is used over the interval. + Sum *float64 `json:"sum,omitempty"` + // Stdev - READ-ONLY; Metric value when stdev aggregate function is used over the interval. + Stdev *float64 `json:"stdev,omitempty"` +} + +// MarshalJSON is the custom marshaler for QueryMetricProperties. +func (qmp QueryMetricProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// QueryProperties properties of a database query. +type QueryProperties struct { + // QueryText - Query text. + QueryText *string `json:"queryText,omitempty"` +} + +// QueryStatistics ... +type QueryStatistics struct { + // QueryStatisticsProperties - Resource properties. + *QueryStatisticsProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for QueryStatistics. +func (qs QueryStatistics) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if qs.QueryStatisticsProperties != nil { + objectMap["properties"] = qs.QueryStatisticsProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for QueryStatistics struct. +func (qs *QueryStatistics) UnmarshalJSON(body []byte) error { + 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 queryStatisticsProperties QueryStatisticsProperties + err = json.Unmarshal(*v, &queryStatisticsProperties) + if err != nil { + return err + } + qs.QueryStatisticsProperties = &queryStatisticsProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + qs.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + qs.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + qs.Type = &typeVar + } + } + } + + return nil +} + +// QueryStatisticsProperties properties of a query execution statistics. +type QueryStatisticsProperties struct { + // DatabaseName - READ-ONLY; Database name of the database in which this query was executed. + DatabaseName *string `json:"databaseName,omitempty"` + // QueryID - READ-ONLY; Unique query id (unique within one database). + QueryID *string `json:"queryId,omitempty"` + // StartTime - READ-ONLY; The start time for the metric (ISO-8601 format). + StartTime *string `json:"startTime,omitempty"` + // EndTime - READ-ONLY; The end time for the metric (ISO-8601 format). + EndTime *string `json:"endTime,omitempty"` + // Intervals - List of intervals with appropriate metric data + Intervals *[]QueryMetricInterval `json:"intervals,omitempty"` +} + +// MarshalJSON is the custom marshaler for QueryStatisticsProperties. +func (qsp QueryStatisticsProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if qsp.Intervals != nil { + objectMap["intervals"] = qsp.Intervals + } + return json.Marshal(objectMap) +} + +// ReadScaleCapability the read scale capability. +type ReadScaleCapability struct { + // MaxNumberOfReplicas - READ-ONLY; The maximum number of read scale replicas. + MaxNumberOfReplicas *int32 `json:"maxNumberOfReplicas,omitempty"` + // Status - READ-ONLY; The status of the capability. Possible values include: 'CapabilityStatusVisible', 'CapabilityStatusAvailable', 'CapabilityStatusDefault', 'CapabilityStatusDisabled' + Status CapabilityStatus `json:"status,omitempty"` + // Reason - The reason for the capability not being available. + Reason *string `json:"reason,omitempty"` +} + +// MarshalJSON is the custom marshaler for ReadScaleCapability. +func (rsc ReadScaleCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rsc.Reason != nil { + objectMap["reason"] = rsc.Reason + } + return json.Marshal(objectMap) +} + +// RecommendedAction database, Server or Elastic Pool Recommended Action. +type RecommendedAction struct { + autorest.Response `json:"-"` + // Kind - READ-ONLY; Resource kind. + Kind *string `json:"kind,omitempty"` + // Location - READ-ONLY; Resource location. + Location *string `json:"location,omitempty"` + // RecommendedActionProperties - Resource properties. + *RecommendedActionProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for RecommendedAction. +func (ra RecommendedAction) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ra.RecommendedActionProperties != nil { + objectMap["properties"] = ra.RecommendedActionProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for RecommendedAction struct. +func (ra *RecommendedAction) UnmarshalJSON(body []byte) error { + 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 + } + ra.Kind = &kind + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + ra.Location = &location + } + case "properties": + if v != nil { + var recommendedActionProperties RecommendedActionProperties + err = json.Unmarshal(*v, &recommendedActionProperties) + if err != nil { + return err + } + ra.RecommendedActionProperties = &recommendedActionProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + ra.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ra.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ra.Type = &typeVar + } + } + } + + return nil +} + +// RecommendedActionErrorInfo contains error information for an Azure SQL Database, Server or Elastic Pool +// Recommended Action. +type RecommendedActionErrorInfo struct { + // ErrorCode - READ-ONLY; Gets the reason why the recommended action was put to error state. e.g., DatabaseHasQdsOff, IndexAlreadyExists + ErrorCode *string `json:"errorCode,omitempty"` + // IsRetryable - READ-ONLY; Gets whether the error could be ignored and recommended action could be retried. Possible values are: Yes/No. Possible values include: 'IsRetryableYes', 'IsRetryableNo' + IsRetryable IsRetryable `json:"isRetryable,omitempty"` +} + +// MarshalJSON is the custom marshaler for RecommendedActionErrorInfo. +func (raei RecommendedActionErrorInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// RecommendedActionImpactRecord contains information of estimated or observed impact on various metrics +// for an Azure SQL Database, Server or Elastic Pool Recommended Action. +type RecommendedActionImpactRecord struct { + // DimensionName - READ-ONLY; Gets the name of the impact dimension. e.g., CPUChange, DiskSpaceChange, NumberOfQueriesAffected. + DimensionName *string `json:"dimensionName,omitempty"` + // Unit - READ-ONLY; Gets the name of the impact dimension. e.g., CPUChange, DiskSpaceChange, NumberOfQueriesAffected. + Unit *string `json:"unit,omitempty"` + // AbsoluteValue - READ-ONLY; Gets the absolute value of this dimension if applicable. e.g., Number of Queries affected + AbsoluteValue *float64 `json:"absoluteValue,omitempty"` + // ChangeValueAbsolute - READ-ONLY; Gets the absolute change in the value of this dimension. e.g., Absolute Disk space change in Megabytes + ChangeValueAbsolute *float64 `json:"changeValueAbsolute,omitempty"` + // ChangeValueRelative - READ-ONLY; Gets the relative change in the value of this dimension. e.g., Relative Disk space change in Percentage + ChangeValueRelative *float64 `json:"changeValueRelative,omitempty"` +} + +// MarshalJSON is the custom marshaler for RecommendedActionImpactRecord. +func (rair RecommendedActionImpactRecord) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// RecommendedActionImplementationInfo contains information for manual implementation for an Azure SQL +// Database, Server or Elastic Pool Recommended Action. +type RecommendedActionImplementationInfo struct { + // Method - READ-ONLY; Gets the method in which this recommended action can be manually implemented. e.g., TSql, AzurePowerShell. Possible values include: 'ImplementationMethodTSQL', 'ImplementationMethodAzurePowerShell' + Method ImplementationMethod `json:"method,omitempty"` + // Script - READ-ONLY; Gets the manual implementation script. e.g., T-SQL script that could be executed on the database. + Script *string `json:"script,omitempty"` +} + +// MarshalJSON is the custom marshaler for RecommendedActionImplementationInfo. +func (raii RecommendedActionImplementationInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// RecommendedActionMetricInfo contains time series of various impacted metrics for an Azure SQL Database, +// Server or Elastic Pool Recommended Action. +type RecommendedActionMetricInfo struct { + // MetricName - READ-ONLY; Gets the name of the metric. e.g., CPU, Number of Queries. + MetricName *string `json:"metricName,omitempty"` + // Unit - READ-ONLY; Gets the unit in which metric is measured. e.g., DTU, Frequency + Unit *string `json:"unit,omitempty"` + // TimeGrain - READ-ONLY; Gets the duration of time interval for the value given by this MetricInfo. e.g., PT1H (1 hour) + TimeGrain *string `json:"timeGrain,omitempty"` + // StartTime - READ-ONLY; Gets the start time of time interval given by this MetricInfo. + StartTime *date.Time `json:"startTime,omitempty"` + // Value - READ-ONLY; Gets the value of the metric in the time interval given by this MetricInfo. + Value *float64 `json:"value,omitempty"` +} + +// MarshalJSON is the custom marshaler for RecommendedActionMetricInfo. +func (rami RecommendedActionMetricInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// RecommendedActionProperties properties for a Database, Server or Elastic Pool Recommended Action. +type RecommendedActionProperties struct { + // RecommendationReason - READ-ONLY; Gets the reason for recommending this action. e.g., DuplicateIndex + RecommendationReason *string `json:"recommendationReason,omitempty"` + // ValidSince - READ-ONLY; Gets the time since when this recommended action is valid. + ValidSince *date.Time `json:"validSince,omitempty"` + // LastRefresh - READ-ONLY; Gets time when this recommended action was last refreshed. + LastRefresh *date.Time `json:"lastRefresh,omitempty"` + // State - Gets the info of the current state the recommended action is in. + State *RecommendedActionStateInfo `json:"state,omitempty"` + // IsExecutableAction - READ-ONLY; Gets if this recommended action is actionable by user + IsExecutableAction *bool `json:"isExecutableAction,omitempty"` + // IsRevertableAction - READ-ONLY; Gets if changes applied by this recommended action can be reverted by user + IsRevertableAction *bool `json:"isRevertableAction,omitempty"` + // IsArchivedAction - READ-ONLY; Gets if this recommended action was suggested some time ago but user chose to ignore this and system added a new recommended action again. + IsArchivedAction *bool `json:"isArchivedAction,omitempty"` + // ExecuteActionStartTime - READ-ONLY; Gets the time when system started applying this recommended action on the user resource. e.g., index creation start time + ExecuteActionStartTime *date.Time `json:"executeActionStartTime,omitempty"` + // ExecuteActionDuration - READ-ONLY; Gets the time taken for applying this recommended action on user resource. e.g., time taken for index creation + ExecuteActionDuration *string `json:"executeActionDuration,omitempty"` + // RevertActionStartTime - READ-ONLY; Gets the time when system started reverting changes of this recommended action on user resource. e.g., time when index drop is executed. + RevertActionStartTime *date.Time `json:"revertActionStartTime,omitempty"` + // RevertActionDuration - READ-ONLY; Gets the time taken for reverting changes of this recommended action on user resource. e.g., time taken for dropping the created index. + RevertActionDuration *string `json:"revertActionDuration,omitempty"` + // ExecuteActionInitiatedBy - READ-ONLY; Gets if approval for applying this recommended action was given by user/system. Possible values include: 'RecommendedActionInitiatedByUser', 'RecommendedActionInitiatedBySystem' + ExecuteActionInitiatedBy RecommendedActionInitiatedBy `json:"executeActionInitiatedBy,omitempty"` + // ExecuteActionInitiatedTime - READ-ONLY; Gets the time when this recommended action was approved for execution. + ExecuteActionInitiatedTime *date.Time `json:"executeActionInitiatedTime,omitempty"` + // RevertActionInitiatedBy - READ-ONLY; Gets if approval for reverting this recommended action was given by user/system. Possible values include: 'RecommendedActionInitiatedByUser', 'RecommendedActionInitiatedBySystem' + RevertActionInitiatedBy RecommendedActionInitiatedBy `json:"revertActionInitiatedBy,omitempty"` + // RevertActionInitiatedTime - READ-ONLY; Gets the time when this recommended action was approved for revert. + RevertActionInitiatedTime *date.Time `json:"revertActionInitiatedTime,omitempty"` + // Score - READ-ONLY; Gets the impact of this recommended action. Possible values are 1 - Low impact, 2 - Medium Impact and 3 - High Impact + Score *int32 `json:"score,omitempty"` + // ImplementationDetails - READ-ONLY; Gets the implementation details of this recommended action for user to apply it manually. + ImplementationDetails *RecommendedActionImplementationInfo `json:"implementationDetails,omitempty"` + // ErrorDetails - READ-ONLY; Gets the error details if and why this recommended action is put to error state. + ErrorDetails *RecommendedActionErrorInfo `json:"errorDetails,omitempty"` + // EstimatedImpact - READ-ONLY; Gets the estimated impact info for this recommended action e.g., Estimated CPU gain, Estimated Disk Space change + EstimatedImpact *[]RecommendedActionImpactRecord `json:"estimatedImpact,omitempty"` + // ObservedImpact - READ-ONLY; Gets the observed/actual impact info for this recommended action e.g., Actual CPU gain, Actual Disk Space change + ObservedImpact *[]RecommendedActionImpactRecord `json:"observedImpact,omitempty"` + // TimeSeries - READ-ONLY; Gets the time series info of metrics for this recommended action e.g., CPU consumption time series + TimeSeries *[]RecommendedActionMetricInfo `json:"timeSeries,omitempty"` + // LinkedObjects - READ-ONLY; Gets the linked objects, if any. + LinkedObjects *[]string `json:"linkedObjects,omitempty"` + // Details - READ-ONLY; Gets additional details specific to this recommended action. + Details map[string]interface{} `json:"details"` +} + +// MarshalJSON is the custom marshaler for RecommendedActionProperties. +func (rap RecommendedActionProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rap.State != nil { + objectMap["state"] = rap.State + } + return json.Marshal(objectMap) +} + +// RecommendedActionStateInfo contains information of current state for an Azure SQL Database, Server or +// Elastic Pool Recommended Action. +type RecommendedActionStateInfo struct { + // CurrentValue - Current state the recommended action is in. Some commonly used states are: Active -> recommended action is active and no action has been taken yet. Pending -> recommended action is approved for and is awaiting execution. Executing -> recommended action is being applied on the user database. Verifying -> recommended action was applied and is being verified of its usefulness by the system. Success -> recommended action was applied and improvement found during verification. Pending Revert -> verification found little or no improvement so recommended action is queued for revert or user has manually reverted. Reverting -> changes made while applying recommended action are being reverted on the user database. Reverted -> successfully reverted the changes made by recommended action on user database. Ignored -> user explicitly ignored/discarded the recommended action. Possible values include: 'RecommendedActionCurrentStateActive', 'RecommendedActionCurrentStatePending', 'RecommendedActionCurrentStateExecuting', 'RecommendedActionCurrentStateVerifying', 'RecommendedActionCurrentStatePendingRevert', 'RecommendedActionCurrentStateRevertCancelled', 'RecommendedActionCurrentStateReverting', 'RecommendedActionCurrentStateReverted', 'RecommendedActionCurrentStateIgnored', 'RecommendedActionCurrentStateExpired', 'RecommendedActionCurrentStateMonitoring', 'RecommendedActionCurrentStateResolved', 'RecommendedActionCurrentStateSuccess', 'RecommendedActionCurrentStateError' + CurrentValue RecommendedActionCurrentState `json:"currentValue,omitempty"` + // ActionInitiatedBy - READ-ONLY; Gets who initiated the execution of this recommended action. Possible Value are: User -> When user explicity notified system to apply the recommended action. System -> When auto-execute status of this advisor was set to 'Enabled', in which case the system applied it. Possible values include: 'RecommendedActionInitiatedByUser', 'RecommendedActionInitiatedBySystem' + ActionInitiatedBy RecommendedActionInitiatedBy `json:"actionInitiatedBy,omitempty"` + // LastModified - READ-ONLY; Gets the time when the state was last modified + LastModified *date.Time `json:"lastModified,omitempty"` +} + +// MarshalJSON is the custom marshaler for RecommendedActionStateInfo. +func (rasi RecommendedActionStateInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rasi.CurrentValue != "" { + objectMap["currentValue"] = rasi.CurrentValue + } + return json.Marshal(objectMap) +} + +// RecommendedSensitivityLabelUpdate a recommended sensitivity label update operation. +type RecommendedSensitivityLabelUpdate struct { + // RecommendedSensitivityLabelUpdateProperties - Resource properties. + *RecommendedSensitivityLabelUpdateProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for RecommendedSensitivityLabelUpdate. +func (rslu RecommendedSensitivityLabelUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rslu.RecommendedSensitivityLabelUpdateProperties != nil { + objectMap["properties"] = rslu.RecommendedSensitivityLabelUpdateProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for RecommendedSensitivityLabelUpdate struct. +func (rslu *RecommendedSensitivityLabelUpdate) UnmarshalJSON(body []byte) error { + 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 recommendedSensitivityLabelUpdateProperties RecommendedSensitivityLabelUpdateProperties + err = json.Unmarshal(*v, &recommendedSensitivityLabelUpdateProperties) + if err != nil { + return err + } + rslu.RecommendedSensitivityLabelUpdateProperties = &recommendedSensitivityLabelUpdateProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + rslu.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + rslu.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + rslu.Type = &typeVar + } + } + } + + return nil +} + +// RecommendedSensitivityLabelUpdateList a list of recommended sensitivity label update operations. +type RecommendedSensitivityLabelUpdateList struct { + Operations *[]RecommendedSensitivityLabelUpdate `json:"operations,omitempty"` +} + +// RecommendedSensitivityLabelUpdateProperties properties of an operation executed on a recommended +// sensitivity label. +type RecommendedSensitivityLabelUpdateProperties struct { + // Op - Possible values include: 'RecommendedSensitivityLabelUpdateKindEnable', 'RecommendedSensitivityLabelUpdateKindDisable' + Op RecommendedSensitivityLabelUpdateKind `json:"op,omitempty"` + // Schema - Schema name of the column to update. + Schema *string `json:"schema,omitempty"` + // Table - Table name of the column to update. + Table *string `json:"table,omitempty"` + // Column - Column name to update. + Column *string `json:"column,omitempty"` +} + +// RecoverableDatabase a recoverable database +type RecoverableDatabase struct { + autorest.Response `json:"-"` + // RecoverableDatabaseProperties - The properties of a recoverable database + *RecoverableDatabaseProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for RecoverableDatabase. +func (rd RecoverableDatabase) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rd.RecoverableDatabaseProperties != nil { + objectMap["properties"] = rd.RecoverableDatabaseProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for RecoverableDatabase struct. +func (rd *RecoverableDatabase) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var recoverableDatabaseProperties RecoverableDatabaseProperties + err = json.Unmarshal(*v, &recoverableDatabaseProperties) + if err != nil { + return err + } + rd.RecoverableDatabaseProperties = &recoverableDatabaseProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + rd.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + rd.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + rd.Type = &typeVar + } + } + } + + return nil +} + +// RecoverableDatabaseListResult the response to a list recoverable databases request +type RecoverableDatabaseListResult struct { + autorest.Response `json:"-"` + // Value - A list of recoverable databases + Value *[]RecoverableDatabase `json:"value,omitempty"` +} + +// RecoverableDatabaseProperties the properties of a recoverable database +type RecoverableDatabaseProperties struct { + // Edition - READ-ONLY; The edition of the database + Edition *string `json:"edition,omitempty"` + // ServiceLevelObjective - READ-ONLY; The service level objective name of the database + ServiceLevelObjective *string `json:"serviceLevelObjective,omitempty"` + // ElasticPoolName - READ-ONLY; The elastic pool name of the database + ElasticPoolName *string `json:"elasticPoolName,omitempty"` + // LastAvailableBackupDate - READ-ONLY; The last available backup date of the database (ISO8601 format) + LastAvailableBackupDate *date.Time `json:"lastAvailableBackupDate,omitempty"` +} + +// MarshalJSON is the custom marshaler for RecoverableDatabaseProperties. +func (rdp RecoverableDatabaseProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// RecoverableManagedDatabase a recoverable managed database resource. +type RecoverableManagedDatabase struct { + autorest.Response `json:"-"` + // RecoverableManagedDatabaseProperties - Resource properties. + *RecoverableManagedDatabaseProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for RecoverableManagedDatabase. +func (rmd RecoverableManagedDatabase) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rmd.RecoverableManagedDatabaseProperties != nil { + objectMap["properties"] = rmd.RecoverableManagedDatabaseProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for RecoverableManagedDatabase struct. +func (rmd *RecoverableManagedDatabase) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var recoverableManagedDatabaseProperties RecoverableManagedDatabaseProperties + err = json.Unmarshal(*v, &recoverableManagedDatabaseProperties) + if err != nil { + return err + } + rmd.RecoverableManagedDatabaseProperties = &recoverableManagedDatabaseProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + rmd.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + rmd.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + rmd.Type = &typeVar + } + } + } + + return nil +} + +// RecoverableManagedDatabaseListResult a list of recoverable managed databases. +type RecoverableManagedDatabaseListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]RecoverableManagedDatabase `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for RecoverableManagedDatabaseListResult. +func (rmdlr RecoverableManagedDatabaseListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// RecoverableManagedDatabaseListResultIterator provides access to a complete listing of +// RecoverableManagedDatabase values. +type RecoverableManagedDatabaseListResultIterator struct { + i int + page RecoverableManagedDatabaseListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *RecoverableManagedDatabaseListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RecoverableManagedDatabaseListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *RecoverableManagedDatabaseListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter RecoverableManagedDatabaseListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter RecoverableManagedDatabaseListResultIterator) Response() RecoverableManagedDatabaseListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter RecoverableManagedDatabaseListResultIterator) Value() RecoverableManagedDatabase { + if !iter.page.NotDone() { + return RecoverableManagedDatabase{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the RecoverableManagedDatabaseListResultIterator type. +func NewRecoverableManagedDatabaseListResultIterator(page RecoverableManagedDatabaseListResultPage) RecoverableManagedDatabaseListResultIterator { + return RecoverableManagedDatabaseListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (rmdlr RecoverableManagedDatabaseListResult) IsEmpty() bool { + return rmdlr.Value == nil || len(*rmdlr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (rmdlr RecoverableManagedDatabaseListResult) hasNextLink() bool { + return rmdlr.NextLink != nil && len(*rmdlr.NextLink) != 0 +} + +// recoverableManagedDatabaseListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (rmdlr RecoverableManagedDatabaseListResult) recoverableManagedDatabaseListResultPreparer(ctx context.Context) (*http.Request, error) { + if !rmdlr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(rmdlr.NextLink))) +} + +// RecoverableManagedDatabaseListResultPage contains a page of RecoverableManagedDatabase values. +type RecoverableManagedDatabaseListResultPage struct { + fn func(context.Context, RecoverableManagedDatabaseListResult) (RecoverableManagedDatabaseListResult, error) + rmdlr RecoverableManagedDatabaseListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *RecoverableManagedDatabaseListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RecoverableManagedDatabaseListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.rmdlr) + if err != nil { + return err + } + page.rmdlr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *RecoverableManagedDatabaseListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page RecoverableManagedDatabaseListResultPage) NotDone() bool { + return !page.rmdlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page RecoverableManagedDatabaseListResultPage) Response() RecoverableManagedDatabaseListResult { + return page.rmdlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page RecoverableManagedDatabaseListResultPage) Values() []RecoverableManagedDatabase { + if page.rmdlr.IsEmpty() { + return nil + } + return *page.rmdlr.Value +} + +// Creates a new instance of the RecoverableManagedDatabaseListResultPage type. +func NewRecoverableManagedDatabaseListResultPage(cur RecoverableManagedDatabaseListResult, getNextPage func(context.Context, RecoverableManagedDatabaseListResult) (RecoverableManagedDatabaseListResult, error)) RecoverableManagedDatabaseListResultPage { + return RecoverableManagedDatabaseListResultPage{ + fn: getNextPage, + rmdlr: cur, + } +} + +// RecoverableManagedDatabaseProperties the recoverable managed database's properties. +type RecoverableManagedDatabaseProperties struct { + // LastAvailableBackupDate - READ-ONLY; The last available backup date. + LastAvailableBackupDate *string `json:"lastAvailableBackupDate,omitempty"` +} + +// MarshalJSON is the custom marshaler for RecoverableManagedDatabaseProperties. +func (rmdp RecoverableManagedDatabaseProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ReplicationLink a replication link. +type ReplicationLink struct { + autorest.Response `json:"-"` + // ReplicationLinkProperties - Resource properties. + *ReplicationLinkProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ReplicationLink. +func (rl ReplicationLink) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rl.ReplicationLinkProperties != nil { + objectMap["properties"] = rl.ReplicationLinkProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ReplicationLink struct. +func (rl *ReplicationLink) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "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 a list of replication links. +type ReplicationLinkListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]ReplicationLink `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for ReplicationLinkListResult. +func (rllr ReplicationLinkListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ReplicationLinkListResultIterator provides access to a complete listing of ReplicationLink values. +type ReplicationLinkListResultIterator struct { + i int + page ReplicationLinkListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *ReplicationLinkListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationLinkListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ReplicationLinkListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ReplicationLinkListResultIterator) 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 ReplicationLinkListResultIterator) Response() ReplicationLinkListResult { + 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 ReplicationLinkListResultIterator) Value() ReplicationLink { + if !iter.page.NotDone() { + return ReplicationLink{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ReplicationLinkListResultIterator type. +func NewReplicationLinkListResultIterator(page ReplicationLinkListResultPage) ReplicationLinkListResultIterator { + return ReplicationLinkListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (rllr ReplicationLinkListResult) IsEmpty() bool { + return rllr.Value == nil || len(*rllr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (rllr ReplicationLinkListResult) hasNextLink() bool { + return rllr.NextLink != nil && len(*rllr.NextLink) != 0 +} + +// replicationLinkListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (rllr ReplicationLinkListResult) replicationLinkListResultPreparer(ctx context.Context) (*http.Request, error) { + if !rllr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(rllr.NextLink))) +} + +// ReplicationLinkListResultPage contains a page of ReplicationLink values. +type ReplicationLinkListResultPage struct { + fn func(context.Context, ReplicationLinkListResult) (ReplicationLinkListResult, error) + rllr ReplicationLinkListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *ReplicationLinkListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationLinkListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.rllr) + if err != nil { + return err + } + page.rllr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *ReplicationLinkListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ReplicationLinkListResultPage) NotDone() bool { + return !page.rllr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ReplicationLinkListResultPage) Response() ReplicationLinkListResult { + return page.rllr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ReplicationLinkListResultPage) Values() []ReplicationLink { + if page.rllr.IsEmpty() { + return nil + } + return *page.rllr.Value +} + +// Creates a new instance of the ReplicationLinkListResultPage type. +func NewReplicationLinkListResultPage(cur ReplicationLinkListResult, getNextPage func(context.Context, ReplicationLinkListResult) (ReplicationLinkListResult, error)) ReplicationLinkListResultPage { + return ReplicationLinkListResultPage{ + fn: getNextPage, + rllr: cur, + } +} + +// ReplicationLinkProperties properties of a replication link. +type ReplicationLinkProperties struct { + // PartnerServer - READ-ONLY; Resource partner server. + PartnerServer *string `json:"partnerServer,omitempty"` + // PartnerDatabase - READ-ONLY; Resource partner database. + PartnerDatabase *string `json:"partnerDatabase,omitempty"` + // PartnerLocation - READ-ONLY; Resource partner location. + PartnerLocation *string `json:"partnerLocation,omitempty"` + // Role - READ-ONLY; Local replication role. Possible values include: 'ReplicationRolePrimary', 'ReplicationRoleSecondary', 'ReplicationRoleNonReadableSecondary', 'ReplicationRoleSource', 'ReplicationRoleCopy' + Role ReplicationRole `json:"role,omitempty"` + // PartnerRole - READ-ONLY; Partner replication role. Possible values include: 'ReplicationRolePrimary', 'ReplicationRoleSecondary', 'ReplicationRoleNonReadableSecondary', 'ReplicationRoleSource', 'ReplicationRoleCopy' + PartnerRole ReplicationRole `json:"partnerRole,omitempty"` + // ReplicationMode - READ-ONLY; Replication mode. + ReplicationMode *string `json:"replicationMode,omitempty"` + // StartTime - READ-ONLY; Time at which the link was created. + StartTime *date.Time `json:"startTime,omitempty"` + // PercentComplete - READ-ONLY; Seeding completion percentage for the link. + PercentComplete *int32 `json:"percentComplete,omitempty"` + // ReplicationState - READ-ONLY; Replication state (PENDING, SEEDING, CATCHUP, SUSPENDED). Possible values include: 'ReplicationStatePENDING', 'ReplicationStateSEEDING', 'ReplicationStateCATCHUP', 'ReplicationStateSUSPENDED' + ReplicationState ReplicationState `json:"replicationState,omitempty"` + // IsTerminationAllowed - READ-ONLY; Whether the user is currently allowed to terminate the link. + IsTerminationAllowed *bool `json:"isTerminationAllowed,omitempty"` + // LinkType - READ-ONLY; Link type (GEO, NAMED). Possible values include: 'ReplicationLinkTypeGEO', 'ReplicationLinkTypeNAMED' + LinkType ReplicationLinkType `json:"linkType,omitempty"` +} + +// MarshalJSON is the custom marshaler for ReplicationLinkProperties. +func (rlp ReplicationLinkProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ReplicationLinksFailoverAllowDataLossFuture an abstraction for monitoring and retrieving the results of +// a long-running operation. +type ReplicationLinksFailoverAllowDataLossFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ReplicationLinksClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ReplicationLinksFailoverAllowDataLossFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ReplicationLinksFailoverAllowDataLossFuture.Result. +func (future *ReplicationLinksFailoverAllowDataLossFuture) result(client ReplicationLinksClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ReplicationLinksFailoverAllowDataLossFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ReplicationLinksFailoverAllowDataLossFuture") + return + } + ar.Response = future.Response() + return +} + +// ReplicationLinksFailoverFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type ReplicationLinksFailoverFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ReplicationLinksClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ReplicationLinksFailoverFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ReplicationLinksFailoverFuture.Result. +func (future *ReplicationLinksFailoverFuture) result(client ReplicationLinksClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ReplicationLinksFailoverFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ReplicationLinksFailoverFuture") + return + } + ar.Response = future.Response() + return +} + +// ReplicationLinksUnlinkFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ReplicationLinksUnlinkFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ReplicationLinksClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ReplicationLinksUnlinkFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ReplicationLinksUnlinkFuture.Result. +func (future *ReplicationLinksUnlinkFuture) result(client ReplicationLinksClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ReplicationLinksUnlinkFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ReplicationLinksUnlinkFuture") + return + } + ar.Response = future.Response() + return +} + +// Resource ARM resource. +type Resource struct { + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Resource. +func (r Resource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ResourceIdentity azure Active Directory identity configuration for a resource. +type ResourceIdentity struct { + // UserAssignedIdentities - The resource ids of the user assigned identities to use + UserAssignedIdentities map[string]*UserIdentity `json:"userAssignedIdentities"` + // PrincipalID - READ-ONLY; The Azure Active Directory principal id. + PrincipalID *uuid.UUID `json:"principalId,omitempty"` + // Type - The identity type. Set this to 'SystemAssigned' in order to automatically create and assign an Azure Active Directory principal for the resource. Possible values include: 'IdentityTypeNone', 'IdentityTypeSystemAssigned', 'IdentityTypeUserAssigned' + Type IdentityType `json:"type,omitempty"` + // TenantID - READ-ONLY; The Azure Active Directory tenant id. + TenantID *uuid.UUID `json:"tenantId,omitempty"` +} + +// MarshalJSON is the custom marshaler for ResourceIdentity. +func (ri ResourceIdentity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ri.UserAssignedIdentities != nil { + objectMap["userAssignedIdentities"] = ri.UserAssignedIdentities + } + if ri.Type != "" { + objectMap["type"] = ri.Type + } + return json.Marshal(objectMap) +} + +// ResourceIdentityWithUserAssignedIdentities azure Active Directory identity configuration for a resource. +type ResourceIdentityWithUserAssignedIdentities struct { + // UserAssignedIdentities - The resource ids of the user assigned identities to use + UserAssignedIdentities map[string]*UserIdentity `json:"userAssignedIdentities"` + // PrincipalID - READ-ONLY; The Azure Active Directory principal id. + PrincipalID *uuid.UUID `json:"principalId,omitempty"` + // Type - The identity type. Set this to 'SystemAssigned' in order to automatically create and assign an Azure Active Directory principal for the resource. Possible values include: 'IdentityTypeNone', 'IdentityTypeSystemAssigned', 'IdentityTypeUserAssigned' + Type IdentityType `json:"type,omitempty"` + // TenantID - READ-ONLY; The Azure Active Directory tenant id. + TenantID *uuid.UUID `json:"tenantId,omitempty"` +} + +// MarshalJSON is the custom marshaler for ResourceIdentityWithUserAssignedIdentities. +func (riwuai ResourceIdentityWithUserAssignedIdentities) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if riwuai.UserAssignedIdentities != nil { + objectMap["userAssignedIdentities"] = riwuai.UserAssignedIdentities + } + if riwuai.Type != "" { + objectMap["type"] = riwuai.Type + } + return json.Marshal(objectMap) +} + +// ResourceMoveDefinition contains the information necessary to perform a resource move (rename). +type ResourceMoveDefinition struct { + // ID - The target ID for the resource + ID *string `json:"id,omitempty"` +} + +// ResourceWithWritableName ARM resource. +type ResourceWithWritableName struct { + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ResourceWithWritableName. +func (rwwn ResourceWithWritableName) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rwwn.Name != nil { + objectMap["name"] = rwwn.Name + } + return json.Marshal(objectMap) +} + +// RestorableDroppedDatabase a restorable dropped database resource. +type RestorableDroppedDatabase struct { + autorest.Response `json:"-"` + // Sku - The name and tier of the SKU. + Sku *Sku `json:"sku,omitempty"` + // Location - Resource location. + Location *string `json:"location,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // RestorableDroppedDatabaseProperties - Resource properties. + *RestorableDroppedDatabaseProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for RestorableDroppedDatabase. +func (rdd RestorableDroppedDatabase) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rdd.Sku != nil { + objectMap["sku"] = rdd.Sku + } + if rdd.Location != nil { + objectMap["location"] = rdd.Location + } + if rdd.Tags != nil { + objectMap["tags"] = rdd.Tags + } + if rdd.RestorableDroppedDatabaseProperties != nil { + objectMap["properties"] = rdd.RestorableDroppedDatabaseProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for RestorableDroppedDatabase struct. +func (rdd *RestorableDroppedDatabase) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "sku": + if v != nil { + var sku Sku + err = json.Unmarshal(*v, &sku) + if err != nil { + return err + } + rdd.Sku = &sku + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + rdd.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + rdd.Tags = tags + } + 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 a list of restorable dropped databases. +type RestorableDroppedDatabaseListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]RestorableDroppedDatabase `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for RestorableDroppedDatabaseListResult. +func (rddlr RestorableDroppedDatabaseListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// RestorableDroppedDatabaseListResultIterator provides access to a complete listing of +// RestorableDroppedDatabase values. +type RestorableDroppedDatabaseListResultIterator struct { + i int + page RestorableDroppedDatabaseListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *RestorableDroppedDatabaseListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RestorableDroppedDatabaseListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *RestorableDroppedDatabaseListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter RestorableDroppedDatabaseListResultIterator) 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 RestorableDroppedDatabaseListResultIterator) Response() RestorableDroppedDatabaseListResult { + 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 RestorableDroppedDatabaseListResultIterator) Value() RestorableDroppedDatabase { + if !iter.page.NotDone() { + return RestorableDroppedDatabase{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the RestorableDroppedDatabaseListResultIterator type. +func NewRestorableDroppedDatabaseListResultIterator(page RestorableDroppedDatabaseListResultPage) RestorableDroppedDatabaseListResultIterator { + return RestorableDroppedDatabaseListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (rddlr RestorableDroppedDatabaseListResult) IsEmpty() bool { + return rddlr.Value == nil || len(*rddlr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (rddlr RestorableDroppedDatabaseListResult) hasNextLink() bool { + return rddlr.NextLink != nil && len(*rddlr.NextLink) != 0 +} + +// restorableDroppedDatabaseListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (rddlr RestorableDroppedDatabaseListResult) restorableDroppedDatabaseListResultPreparer(ctx context.Context) (*http.Request, error) { + if !rddlr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(rddlr.NextLink))) +} + +// RestorableDroppedDatabaseListResultPage contains a page of RestorableDroppedDatabase values. +type RestorableDroppedDatabaseListResultPage struct { + fn func(context.Context, RestorableDroppedDatabaseListResult) (RestorableDroppedDatabaseListResult, error) + rddlr RestorableDroppedDatabaseListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *RestorableDroppedDatabaseListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RestorableDroppedDatabaseListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.rddlr) + if err != nil { + return err + } + page.rddlr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *RestorableDroppedDatabaseListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page RestorableDroppedDatabaseListResultPage) NotDone() bool { + return !page.rddlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page RestorableDroppedDatabaseListResultPage) Response() RestorableDroppedDatabaseListResult { + return page.rddlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page RestorableDroppedDatabaseListResultPage) Values() []RestorableDroppedDatabase { + if page.rddlr.IsEmpty() { + return nil + } + return *page.rddlr.Value +} + +// Creates a new instance of the RestorableDroppedDatabaseListResultPage type. +func NewRestorableDroppedDatabaseListResultPage(cur RestorableDroppedDatabaseListResult, getNextPage func(context.Context, RestorableDroppedDatabaseListResult) (RestorableDroppedDatabaseListResult, error)) RestorableDroppedDatabaseListResultPage { + return RestorableDroppedDatabaseListResultPage{ + fn: getNextPage, + rddlr: cur, + } +} + +// RestorableDroppedDatabaseProperties the restorable dropped database's properties. +type RestorableDroppedDatabaseProperties struct { + // DatabaseName - READ-ONLY; The name of the database. + DatabaseName *string `json:"databaseName,omitempty"` + // MaxSizeBytes - READ-ONLY; The max size of the database expressed in bytes. + MaxSizeBytes *int64 `json:"maxSizeBytes,omitempty"` + // ElasticPoolID - READ-ONLY; DEPRECATED: The resource name of the elastic pool containing this database. This property is deprecated and the value will always be null. + ElasticPoolID *string `json:"elasticPoolId,omitempty"` + // CreationDate - READ-ONLY; The creation date of the database (ISO8601 format). + CreationDate *date.Time `json:"creationDate,omitempty"` + // DeletionDate - READ-ONLY; The deletion date of the database (ISO8601 format). + DeletionDate *date.Time `json:"deletionDate,omitempty"` + // EarliestRestoreDate - READ-ONLY; The earliest restore date of the database (ISO8601 format). + EarliestRestoreDate *date.Time `json:"earliestRestoreDate,omitempty"` + // BackupStorageRedundancy - READ-ONLY; The storage account type used to store backups for this database. Possible values include: 'BackupStorageRedundancy1Geo', 'BackupStorageRedundancy1Local', 'BackupStorageRedundancy1Zone' + BackupStorageRedundancy BackupStorageRedundancy1 `json:"backupStorageRedundancy,omitempty"` +} + +// MarshalJSON is the custom marshaler for RestorableDroppedDatabaseProperties. +func (rddp RestorableDroppedDatabaseProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// RestorableDroppedManagedDatabase a restorable dropped managed database resource. +type RestorableDroppedManagedDatabase struct { + autorest.Response `json:"-"` + // RestorableDroppedManagedDatabaseProperties - Resource properties. + *RestorableDroppedManagedDatabaseProperties `json:"properties,omitempty"` + // Location - Resource location. + Location *string `json:"location,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for RestorableDroppedManagedDatabase. +func (rdmd RestorableDroppedManagedDatabase) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rdmd.RestorableDroppedManagedDatabaseProperties != nil { + objectMap["properties"] = rdmd.RestorableDroppedManagedDatabaseProperties + } + if rdmd.Location != nil { + objectMap["location"] = rdmd.Location + } + if rdmd.Tags != nil { + objectMap["tags"] = rdmd.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for RestorableDroppedManagedDatabase struct. +func (rdmd *RestorableDroppedManagedDatabase) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var restorableDroppedManagedDatabaseProperties RestorableDroppedManagedDatabaseProperties + err = json.Unmarshal(*v, &restorableDroppedManagedDatabaseProperties) + if err != nil { + return err + } + rdmd.RestorableDroppedManagedDatabaseProperties = &restorableDroppedManagedDatabaseProperties + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + rdmd.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + rdmd.Tags = tags + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + rdmd.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + rdmd.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + rdmd.Type = &typeVar + } + } + } + + return nil +} + +// RestorableDroppedManagedDatabaseListResult a list of restorable dropped managed databases. +type RestorableDroppedManagedDatabaseListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]RestorableDroppedManagedDatabase `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for RestorableDroppedManagedDatabaseListResult. +func (rdmdlr RestorableDroppedManagedDatabaseListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// RestorableDroppedManagedDatabaseListResultIterator provides access to a complete listing of +// RestorableDroppedManagedDatabase values. +type RestorableDroppedManagedDatabaseListResultIterator struct { + i int + page RestorableDroppedManagedDatabaseListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *RestorableDroppedManagedDatabaseListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RestorableDroppedManagedDatabaseListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *RestorableDroppedManagedDatabaseListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter RestorableDroppedManagedDatabaseListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter RestorableDroppedManagedDatabaseListResultIterator) Response() RestorableDroppedManagedDatabaseListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter RestorableDroppedManagedDatabaseListResultIterator) Value() RestorableDroppedManagedDatabase { + if !iter.page.NotDone() { + return RestorableDroppedManagedDatabase{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the RestorableDroppedManagedDatabaseListResultIterator type. +func NewRestorableDroppedManagedDatabaseListResultIterator(page RestorableDroppedManagedDatabaseListResultPage) RestorableDroppedManagedDatabaseListResultIterator { + return RestorableDroppedManagedDatabaseListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (rdmdlr RestorableDroppedManagedDatabaseListResult) IsEmpty() bool { + return rdmdlr.Value == nil || len(*rdmdlr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (rdmdlr RestorableDroppedManagedDatabaseListResult) hasNextLink() bool { + return rdmdlr.NextLink != nil && len(*rdmdlr.NextLink) != 0 +} + +// restorableDroppedManagedDatabaseListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (rdmdlr RestorableDroppedManagedDatabaseListResult) restorableDroppedManagedDatabaseListResultPreparer(ctx context.Context) (*http.Request, error) { + if !rdmdlr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(rdmdlr.NextLink))) +} + +// RestorableDroppedManagedDatabaseListResultPage contains a page of RestorableDroppedManagedDatabase +// values. +type RestorableDroppedManagedDatabaseListResultPage struct { + fn func(context.Context, RestorableDroppedManagedDatabaseListResult) (RestorableDroppedManagedDatabaseListResult, error) + rdmdlr RestorableDroppedManagedDatabaseListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *RestorableDroppedManagedDatabaseListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RestorableDroppedManagedDatabaseListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.rdmdlr) + if err != nil { + return err + } + page.rdmdlr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *RestorableDroppedManagedDatabaseListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page RestorableDroppedManagedDatabaseListResultPage) NotDone() bool { + return !page.rdmdlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page RestorableDroppedManagedDatabaseListResultPage) Response() RestorableDroppedManagedDatabaseListResult { + return page.rdmdlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page RestorableDroppedManagedDatabaseListResultPage) Values() []RestorableDroppedManagedDatabase { + if page.rdmdlr.IsEmpty() { + return nil + } + return *page.rdmdlr.Value +} + +// Creates a new instance of the RestorableDroppedManagedDatabaseListResultPage type. +func NewRestorableDroppedManagedDatabaseListResultPage(cur RestorableDroppedManagedDatabaseListResult, getNextPage func(context.Context, RestorableDroppedManagedDatabaseListResult) (RestorableDroppedManagedDatabaseListResult, error)) RestorableDroppedManagedDatabaseListResultPage { + return RestorableDroppedManagedDatabaseListResultPage{ + fn: getNextPage, + rdmdlr: cur, + } +} + +// RestorableDroppedManagedDatabaseProperties the restorable dropped managed database's properties. +type RestorableDroppedManagedDatabaseProperties struct { + // DatabaseName - READ-ONLY; The name of the database. + DatabaseName *string `json:"databaseName,omitempty"` + // CreationDate - READ-ONLY; The creation date of the database (ISO8601 format). + CreationDate *date.Time `json:"creationDate,omitempty"` + // DeletionDate - READ-ONLY; The deletion date of the database (ISO8601 format). + DeletionDate *date.Time `json:"deletionDate,omitempty"` + // EarliestRestoreDate - READ-ONLY; The earliest restore date of the database (ISO8601 format). + EarliestRestoreDate *date.Time `json:"earliestRestoreDate,omitempty"` +} + +// MarshalJSON is the custom marshaler for RestorableDroppedManagedDatabaseProperties. +func (rdmdp RestorableDroppedManagedDatabaseProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// RestorePoint database restore points. +type RestorePoint struct { + autorest.Response `json:"-"` + // Location - READ-ONLY; Resource location. + Location *string `json:"location,omitempty"` + // RestorePointProperties - Resource properties. + *RestorePointProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for RestorePoint. +func (rp RestorePoint) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rp.RestorePointProperties != nil { + objectMap["properties"] = rp.RestorePointProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for RestorePoint struct. +func (rp *RestorePoint) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + rp.Location = &location + } + case "properties": + if v != nil { + var restorePointProperties RestorePointProperties + err = json.Unmarshal(*v, &restorePointProperties) + if err != nil { + return err + } + rp.RestorePointProperties = &restorePointProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + rp.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + rp.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + rp.Type = &typeVar + } + } + } + + return nil +} + +// RestorePointListResult a list of long term retention backups. +type RestorePointListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]RestorePoint `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for RestorePointListResult. +func (rplr RestorePointListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// RestorePointListResultIterator provides access to a complete listing of RestorePoint values. +type RestorePointListResultIterator struct { + i int + page RestorePointListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *RestorePointListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RestorePointListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *RestorePointListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter RestorePointListResultIterator) 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 RestorePointListResultIterator) Response() RestorePointListResult { + 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 RestorePointListResultIterator) Value() RestorePoint { + if !iter.page.NotDone() { + return RestorePoint{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the RestorePointListResultIterator type. +func NewRestorePointListResultIterator(page RestorePointListResultPage) RestorePointListResultIterator { + return RestorePointListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (rplr RestorePointListResult) IsEmpty() bool { + return rplr.Value == nil || len(*rplr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (rplr RestorePointListResult) hasNextLink() bool { + return rplr.NextLink != nil && len(*rplr.NextLink) != 0 +} + +// restorePointListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (rplr RestorePointListResult) restorePointListResultPreparer(ctx context.Context) (*http.Request, error) { + if !rplr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(rplr.NextLink))) +} + +// RestorePointListResultPage contains a page of RestorePoint values. +type RestorePointListResultPage struct { + fn func(context.Context, RestorePointListResult) (RestorePointListResult, error) + rplr RestorePointListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *RestorePointListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RestorePointListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.rplr) + if err != nil { + return err + } + page.rplr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *RestorePointListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page RestorePointListResultPage) NotDone() bool { + return !page.rplr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page RestorePointListResultPage) Response() RestorePointListResult { + return page.rplr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page RestorePointListResultPage) Values() []RestorePoint { + if page.rplr.IsEmpty() { + return nil + } + return *page.rplr.Value +} + +// Creates a new instance of the RestorePointListResultPage type. +func NewRestorePointListResultPage(cur RestorePointListResult, getNextPage func(context.Context, RestorePointListResult) (RestorePointListResult, error)) RestorePointListResultPage { + return RestorePointListResultPage{ + fn: getNextPage, + rplr: cur, + } +} + +// RestorePointProperties properties of a database restore point +type RestorePointProperties struct { + // RestorePointType - READ-ONLY; The type of restore point. Possible values include: 'RestorePointTypeCONTINUOUS', 'RestorePointTypeDISCRETE' + RestorePointType RestorePointType `json:"restorePointType,omitempty"` + // EarliestRestoreDate - READ-ONLY; The earliest time to which this database can be restored + EarliestRestoreDate *date.Time `json:"earliestRestoreDate,omitempty"` + // RestorePointCreationDate - READ-ONLY; The time the backup was taken + RestorePointCreationDate *date.Time `json:"restorePointCreationDate,omitempty"` + // RestorePointLabel - READ-ONLY; The label of restore point for backup request by user + RestorePointLabel *string `json:"restorePointLabel,omitempty"` +} + +// MarshalJSON is the custom marshaler for RestorePointProperties. +func (rpp RestorePointProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// RestorePointsCreateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type RestorePointsCreateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(RestorePointsClient) (RestorePoint, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *RestorePointsCreateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for RestorePointsCreateFuture.Result. +func (future *RestorePointsCreateFuture) result(client RestorePointsClient) (rp RestorePoint, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.RestorePointsCreateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + rp.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.RestorePointsCreateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if rp.Response.Response, err = future.GetResult(sender); err == nil && rp.Response.Response.StatusCode != http.StatusNoContent { + rp, err = client.CreateResponder(rp.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.RestorePointsCreateFuture", "Result", rp.Response.Response, "Failure responding to request") + } + } + return +} + +// SecurityAlertPolicyProperties properties of a security alert policy. +type SecurityAlertPolicyProperties struct { + // State - Specifies the state of the policy, whether it is enabled or disabled or a policy has not been applied yet on the specific database. Possible values include: 'SecurityAlertPolicyStateNew', 'SecurityAlertPolicyStateEnabled', 'SecurityAlertPolicyStateDisabled' + State SecurityAlertPolicyState `json:"state,omitempty"` + // DisabledAlerts - Specifies an array of alerts that are disabled. Allowed values are: Sql_Injection, Sql_Injection_Vulnerability, Access_Anomaly, Data_Exfiltration, Unsafe_Action, Brute_Force + DisabledAlerts *[]string `json:"disabledAlerts,omitempty"` + // EmailAddresses - Specifies an array of e-mail addresses to which the alert is sent. + EmailAddresses *[]string `json:"emailAddresses,omitempty"` + // EmailAccountAdmins - Specifies that the alert is sent to the account administrators. + EmailAccountAdmins *bool `json:"emailAccountAdmins,omitempty"` + // StorageEndpoint - Specifies the blob storage endpoint (e.g. https://MyAccount.blob.core.windows.net). This blob storage will hold all Threat Detection audit logs. + StorageEndpoint *string `json:"storageEndpoint,omitempty"` + // StorageAccountAccessKey - Specifies the identifier key of the Threat Detection audit storage account. + StorageAccountAccessKey *string `json:"storageAccountAccessKey,omitempty"` + // RetentionDays - Specifies the number of days to keep in the Threat Detection audit logs. + RetentionDays *int32 `json:"retentionDays,omitempty"` + // CreationTime - READ-ONLY; Specifies the UTC creation time of the policy. + CreationTime *date.Time `json:"creationTime,omitempty"` +} + +// MarshalJSON is the custom marshaler for SecurityAlertPolicyProperties. +func (sapp SecurityAlertPolicyProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sapp.State != "" { + objectMap["state"] = sapp.State + } + if sapp.DisabledAlerts != nil { + objectMap["disabledAlerts"] = sapp.DisabledAlerts + } + if sapp.EmailAddresses != nil { + objectMap["emailAddresses"] = sapp.EmailAddresses + } + if sapp.EmailAccountAdmins != nil { + objectMap["emailAccountAdmins"] = sapp.EmailAccountAdmins + } + if sapp.StorageEndpoint != nil { + objectMap["storageEndpoint"] = sapp.StorageEndpoint + } + if sapp.StorageAccountAccessKey != nil { + objectMap["storageAccountAccessKey"] = sapp.StorageAccountAccessKey + } + if sapp.RetentionDays != nil { + objectMap["retentionDays"] = sapp.RetentionDays + } + return json.Marshal(objectMap) +} + +// SecurityAlertsPolicyProperties properties of a security alert policy. +type SecurityAlertsPolicyProperties struct { + // State - Specifies the state of the policy, whether it is enabled or disabled or a policy has not been applied yet on the specific database. Possible values include: 'SecurityAlertsPolicyStateEnabled', 'SecurityAlertsPolicyStateDisabled' + State SecurityAlertsPolicyState `json:"state,omitempty"` + // DisabledAlerts - Specifies an array of alerts that are disabled. Allowed values are: Sql_Injection, Sql_Injection_Vulnerability, Access_Anomaly, Data_Exfiltration, Unsafe_Action, Brute_Force + DisabledAlerts *[]string `json:"disabledAlerts,omitempty"` + // EmailAddresses - Specifies an array of e-mail addresses to which the alert is sent. + EmailAddresses *[]string `json:"emailAddresses,omitempty"` + // EmailAccountAdmins - Specifies that the alert is sent to the account administrators. + EmailAccountAdmins *bool `json:"emailAccountAdmins,omitempty"` + // StorageEndpoint - Specifies the blob storage endpoint (e.g. https://MyAccount.blob.core.windows.net). This blob storage will hold all Threat Detection audit logs. + StorageEndpoint *string `json:"storageEndpoint,omitempty"` + // StorageAccountAccessKey - Specifies the identifier key of the Threat Detection audit storage account. + StorageAccountAccessKey *string `json:"storageAccountAccessKey,omitempty"` + // RetentionDays - Specifies the number of days to keep in the Threat Detection audit logs. + RetentionDays *int32 `json:"retentionDays,omitempty"` + // CreationTime - READ-ONLY; Specifies the UTC creation time of the policy. + CreationTime *date.Time `json:"creationTime,omitempty"` +} + +// MarshalJSON is the custom marshaler for SecurityAlertsPolicyProperties. +func (sapp SecurityAlertsPolicyProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sapp.State != "" { + objectMap["state"] = sapp.State + } + if sapp.DisabledAlerts != nil { + objectMap["disabledAlerts"] = sapp.DisabledAlerts + } + if sapp.EmailAddresses != nil { + objectMap["emailAddresses"] = sapp.EmailAddresses + } + if sapp.EmailAccountAdmins != nil { + objectMap["emailAccountAdmins"] = sapp.EmailAccountAdmins + } + if sapp.StorageEndpoint != nil { + objectMap["storageEndpoint"] = sapp.StorageEndpoint + } + if sapp.StorageAccountAccessKey != nil { + objectMap["storageAccountAccessKey"] = sapp.StorageAccountAccessKey + } + if sapp.RetentionDays != nil { + objectMap["retentionDays"] = sapp.RetentionDays + } + return json.Marshal(objectMap) +} + +// SecurityEvent a security event. +type SecurityEvent struct { + // SecurityEventProperties - Resource properties. + *SecurityEventProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for SecurityEvent. +func (se SecurityEvent) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if se.SecurityEventProperties != nil { + objectMap["properties"] = se.SecurityEventProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for SecurityEvent struct. +func (se *SecurityEvent) UnmarshalJSON(body []byte) error { + 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 securityEventProperties SecurityEventProperties + err = json.Unmarshal(*v, &securityEventProperties) + if err != nil { + return err + } + se.SecurityEventProperties = &securityEventProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + se.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + se.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + se.Type = &typeVar + } + } + } + + return nil +} + +// SecurityEventCollection a list of security events. +type SecurityEventCollection struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]SecurityEvent `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for SecurityEventCollection. +func (sec SecurityEventCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// SecurityEventCollectionIterator provides access to a complete listing of SecurityEvent values. +type SecurityEventCollectionIterator struct { + i int + page SecurityEventCollectionPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *SecurityEventCollectionIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SecurityEventCollectionIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *SecurityEventCollectionIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter SecurityEventCollectionIterator) 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 SecurityEventCollectionIterator) Response() SecurityEventCollection { + 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 SecurityEventCollectionIterator) Value() SecurityEvent { + if !iter.page.NotDone() { + return SecurityEvent{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the SecurityEventCollectionIterator type. +func NewSecurityEventCollectionIterator(page SecurityEventCollectionPage) SecurityEventCollectionIterator { + return SecurityEventCollectionIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (sec SecurityEventCollection) IsEmpty() bool { + return sec.Value == nil || len(*sec.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (sec SecurityEventCollection) hasNextLink() bool { + return sec.NextLink != nil && len(*sec.NextLink) != 0 +} + +// securityEventCollectionPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (sec SecurityEventCollection) securityEventCollectionPreparer(ctx context.Context) (*http.Request, error) { + if !sec.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(sec.NextLink))) +} + +// SecurityEventCollectionPage contains a page of SecurityEvent values. +type SecurityEventCollectionPage struct { + fn func(context.Context, SecurityEventCollection) (SecurityEventCollection, error) + sec SecurityEventCollection +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *SecurityEventCollectionPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SecurityEventCollectionPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.sec) + if err != nil { + return err + } + page.sec = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *SecurityEventCollectionPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page SecurityEventCollectionPage) NotDone() bool { + return !page.sec.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page SecurityEventCollectionPage) Response() SecurityEventCollection { + return page.sec +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page SecurityEventCollectionPage) Values() []SecurityEvent { + if page.sec.IsEmpty() { + return nil + } + return *page.sec.Value +} + +// Creates a new instance of the SecurityEventCollectionPage type. +func NewSecurityEventCollectionPage(cur SecurityEventCollection, getNextPage func(context.Context, SecurityEventCollection) (SecurityEventCollection, error)) SecurityEventCollectionPage { + return SecurityEventCollectionPage{ + fn: getNextPage, + sec: cur, + } +} + +// SecurityEventProperties the properties of a security event. +type SecurityEventProperties struct { + // EventTime - READ-ONLY; The time when the security event occurred. + EventTime *date.Time `json:"eventTime,omitempty"` + // SecurityEventType - READ-ONLY; The type of the security event. Possible values include: 'SecurityEventTypeUndefined', 'SecurityEventTypeSQLInjectionVulnerability', 'SecurityEventTypeSQLInjectionExploit' + SecurityEventType SecurityEventType `json:"securityEventType,omitempty"` + // Subscription - READ-ONLY; The subscription name + Subscription *string `json:"subscription,omitempty"` + // Server - READ-ONLY; The server name + Server *string `json:"server,omitempty"` + // Database - READ-ONLY; The database name + Database *string `json:"database,omitempty"` + // ClientIP - READ-ONLY; The IP address of the client who executed the statement. + ClientIP *string `json:"clientIp,omitempty"` + // ApplicationName - READ-ONLY; The application used to execute the statement. + ApplicationName *string `json:"applicationName,omitempty"` + // PrincipalName - READ-ONLY; The principal user who executed the statement + PrincipalName *string `json:"principalName,omitempty"` + // SecurityEventSQLInjectionAdditionalProperties - READ-ONLY; The sql injection additional properties, populated only if the type of the security event is sql injection. + SecurityEventSQLInjectionAdditionalProperties *SecurityEventSQLInjectionAdditionalProperties `json:"securityEventSqlInjectionAdditionalProperties,omitempty"` +} + +// MarshalJSON is the custom marshaler for SecurityEventProperties. +func (sep SecurityEventProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// SecurityEventsFilterParameters the properties that are supported in the $filter operation. +type SecurityEventsFilterParameters struct { + // EventTime - Filter on the event time. + EventTime *date.Time `json:"eventTime,omitempty"` + // ShowServerRecords - Whether to show server records or not. + ShowServerRecords *bool `json:"showServerRecords,omitempty"` +} + +// SecurityEventSQLInjectionAdditionalProperties the properties of a security event sql injection +// additional properties. +type SecurityEventSQLInjectionAdditionalProperties struct { + // ThreatID - READ-ONLY; The threat ID. + ThreatID *string `json:"threatId,omitempty"` + // Statement - READ-ONLY; The statement + Statement *string `json:"statement,omitempty"` + // StatementHighlightOffset - READ-ONLY; The statement highlight offset + StatementHighlightOffset *int32 `json:"statementHighlightOffset,omitempty"` + // StatementHighlightLength - READ-ONLY; The statement highlight length + StatementHighlightLength *int32 `json:"statementHighlightLength,omitempty"` + // ErrorCode - READ-ONLY; The sql error code + ErrorCode *int32 `json:"errorCode,omitempty"` + // ErrorSeverity - READ-ONLY; The sql error severity + ErrorSeverity *int32 `json:"errorSeverity,omitempty"` + // ErrorMessage - READ-ONLY; The sql error message + ErrorMessage *string `json:"errorMessage,omitempty"` +} + +// MarshalJSON is the custom marshaler for SecurityEventSQLInjectionAdditionalProperties. +func (sesiap SecurityEventSQLInjectionAdditionalProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// SensitivityLabel a sensitivity label. +type SensitivityLabel struct { + autorest.Response `json:"-"` + // ManagedBy - READ-ONLY; Resource that manages the sensitivity label. + ManagedBy *string `json:"managedBy,omitempty"` + // SensitivityLabelProperties - Resource properties. + *SensitivityLabelProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for SensitivityLabel. +func (sl SensitivityLabel) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sl.SensitivityLabelProperties != nil { + objectMap["properties"] = sl.SensitivityLabelProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for SensitivityLabel struct. +func (sl *SensitivityLabel) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "managedBy": + if v != nil { + var managedBy string + err = json.Unmarshal(*v, &managedBy) + if err != nil { + return err + } + sl.ManagedBy = &managedBy + } + case "properties": + if v != nil { + var sensitivityLabelProperties SensitivityLabelProperties + err = json.Unmarshal(*v, &sensitivityLabelProperties) + if err != nil { + return err + } + sl.SensitivityLabelProperties = &sensitivityLabelProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + sl.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + sl.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + sl.Type = &typeVar + } + } + } + + return nil +} + +// SensitivityLabelListResult a list of sensitivity labels. +type SensitivityLabelListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]SensitivityLabel `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for SensitivityLabelListResult. +func (sllr SensitivityLabelListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// SensitivityLabelListResultIterator provides access to a complete listing of SensitivityLabel values. +type SensitivityLabelListResultIterator struct { + i int + page SensitivityLabelListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *SensitivityLabelListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SensitivityLabelListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *SensitivityLabelListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter SensitivityLabelListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter SensitivityLabelListResultIterator) Response() SensitivityLabelListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter SensitivityLabelListResultIterator) Value() SensitivityLabel { + if !iter.page.NotDone() { + return SensitivityLabel{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the SensitivityLabelListResultIterator type. +func NewSensitivityLabelListResultIterator(page SensitivityLabelListResultPage) SensitivityLabelListResultIterator { + return SensitivityLabelListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (sllr SensitivityLabelListResult) IsEmpty() bool { + return sllr.Value == nil || len(*sllr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (sllr SensitivityLabelListResult) hasNextLink() bool { + return sllr.NextLink != nil && len(*sllr.NextLink) != 0 +} + +// sensitivityLabelListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (sllr SensitivityLabelListResult) sensitivityLabelListResultPreparer(ctx context.Context) (*http.Request, error) { + if !sllr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(sllr.NextLink))) +} + +// SensitivityLabelListResultPage contains a page of SensitivityLabel values. +type SensitivityLabelListResultPage struct { + fn func(context.Context, SensitivityLabelListResult) (SensitivityLabelListResult, error) + sllr SensitivityLabelListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *SensitivityLabelListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SensitivityLabelListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.sllr) + if err != nil { + return err + } + page.sllr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *SensitivityLabelListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page SensitivityLabelListResultPage) NotDone() bool { + return !page.sllr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page SensitivityLabelListResultPage) Response() SensitivityLabelListResult { + return page.sllr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page SensitivityLabelListResultPage) Values() []SensitivityLabel { + if page.sllr.IsEmpty() { + return nil + } + return *page.sllr.Value +} + +// Creates a new instance of the SensitivityLabelListResultPage type. +func NewSensitivityLabelListResultPage(cur SensitivityLabelListResult, getNextPage func(context.Context, SensitivityLabelListResult) (SensitivityLabelListResult, error)) SensitivityLabelListResultPage { + return SensitivityLabelListResultPage{ + fn: getNextPage, + sllr: cur, + } +} + +// SensitivityLabelProperties properties of a sensitivity label. +type SensitivityLabelProperties struct { + // SchemaName - READ-ONLY; The schema name. + SchemaName *string `json:"schemaName,omitempty"` + // TableName - READ-ONLY; The table name. + TableName *string `json:"tableName,omitempty"` + // ColumnName - READ-ONLY; The column name. + ColumnName *string `json:"columnName,omitempty"` + // LabelName - The label name. + LabelName *string `json:"labelName,omitempty"` + // LabelID - The label ID. + LabelID *string `json:"labelId,omitempty"` + // InformationType - The information type. + InformationType *string `json:"informationType,omitempty"` + // InformationTypeID - The information type ID. + InformationTypeID *string `json:"informationTypeId,omitempty"` + // IsDisabled - READ-ONLY; Is sensitivity recommendation disabled. Applicable for recommended sensitivity label only. Specifies whether the sensitivity recommendation on this column is disabled (dismissed) or not. + IsDisabled *bool `json:"isDisabled,omitempty"` + // Rank - Possible values include: 'SensitivityLabelRankNone', 'SensitivityLabelRankLow', 'SensitivityLabelRankMedium', 'SensitivityLabelRankHigh', 'SensitivityLabelRankCritical' + Rank SensitivityLabelRank `json:"rank,omitempty"` +} + +// MarshalJSON is the custom marshaler for SensitivityLabelProperties. +func (slp SensitivityLabelProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if slp.LabelName != nil { + objectMap["labelName"] = slp.LabelName + } + if slp.LabelID != nil { + objectMap["labelId"] = slp.LabelID + } + if slp.InformationType != nil { + objectMap["informationType"] = slp.InformationType + } + if slp.InformationTypeID != nil { + objectMap["informationTypeId"] = slp.InformationTypeID + } + if slp.Rank != "" { + objectMap["rank"] = slp.Rank + } + return json.Marshal(objectMap) +} + +// SensitivityLabelUpdate a sensitivity label update operation. +type SensitivityLabelUpdate struct { + // SensitivityLabelUpdateProperties - Resource properties. + *SensitivityLabelUpdateProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for SensitivityLabelUpdate. +func (slu SensitivityLabelUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if slu.SensitivityLabelUpdateProperties != nil { + objectMap["properties"] = slu.SensitivityLabelUpdateProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for SensitivityLabelUpdate struct. +func (slu *SensitivityLabelUpdate) UnmarshalJSON(body []byte) error { + 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 sensitivityLabelUpdateProperties SensitivityLabelUpdateProperties + err = json.Unmarshal(*v, &sensitivityLabelUpdateProperties) + if err != nil { + return err + } + slu.SensitivityLabelUpdateProperties = &sensitivityLabelUpdateProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + slu.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + slu.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + slu.Type = &typeVar + } + } + } + + return nil +} + +// SensitivityLabelUpdateList a list of sensitivity label update operations. +type SensitivityLabelUpdateList struct { + Operations *[]SensitivityLabelUpdate `json:"operations,omitempty"` +} + +// SensitivityLabelUpdateProperties properties of an operation executed on a sensitivity label. +type SensitivityLabelUpdateProperties struct { + // Op - Possible values include: 'SensitivityLabelUpdateKindSet', 'SensitivityLabelUpdateKindRemove' + Op SensitivityLabelUpdateKind `json:"op,omitempty"` + // Schema - Schema name of the column to update. + Schema *string `json:"schema,omitempty"` + // Table - Table name of the column to update. + Table *string `json:"table,omitempty"` + // Column - Column name to update. + Column *string `json:"column,omitempty"` + // SensitivityLabel - The sensitivity label information to apply on a column. + SensitivityLabel *SensitivityLabel `json:"sensitivityLabel,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 - READ-ONLY; Kind of sql server. This is metadata used for the Azure portal experience. + Kind *string `json:"kind,omitempty"` + // ServerProperties - Resource properties. + *ServerProperties `json:"properties,omitempty"` + // Location - Resource location. + Location *string `json:"location,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Server. +func (s Server) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if s.Identity != nil { + objectMap["identity"] = s.Identity + } + if s.ServerProperties != nil { + objectMap["properties"] = s.ServerProperties + } + if s.Location != nil { + objectMap["location"] = s.Location + } + if s.Tags != nil { + objectMap["tags"] = s.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Server struct. +func (s *Server) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "identity": + if v != nil { + var identity ResourceIdentity + err = json.Unmarshal(*v, &identity) + if err != nil { + return err + } + s.Identity = &identity + } + case "kind": + if v != nil { + var kind string + err = json.Unmarshal(*v, &kind) + if err != nil { + return err + } + s.Kind = &kind + } + case "properties": + if v != nil { + var serverProperties ServerProperties + err = json.Unmarshal(*v, &serverProperties) + if err != nil { + return err + } + s.ServerProperties = &serverProperties + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + s.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + s.Tags = tags + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + s.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + s.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + s.Type = &typeVar + } + } + } + + return nil +} + +// ServerAutomaticTuning server-level Automatic Tuning. +type ServerAutomaticTuning struct { + autorest.Response `json:"-"` + // AutomaticTuningServerProperties - Resource properties. + *AutomaticTuningServerProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServerAutomaticTuning. +func (sat ServerAutomaticTuning) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sat.AutomaticTuningServerProperties != nil { + objectMap["properties"] = sat.AutomaticTuningServerProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ServerAutomaticTuning struct. +func (sat *ServerAutomaticTuning) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var automaticTuningServerProperties AutomaticTuningServerProperties + err = json.Unmarshal(*v, &automaticTuningServerProperties) + if err != nil { + return err + } + sat.AutomaticTuningServerProperties = &automaticTuningServerProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + sat.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + sat.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + sat.Type = &typeVar + } + } + } + + return nil +} + +// ServerAzureADAdministrator azure Active Directory administrator. +type ServerAzureADAdministrator struct { + autorest.Response `json:"-"` + // AdministratorProperties - Resource properties. + *AdministratorProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServerAzureADAdministrator. +func (saaa ServerAzureADAdministrator) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if saaa.AdministratorProperties != nil { + objectMap["properties"] = saaa.AdministratorProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ServerAzureADAdministrator struct. +func (saaa *ServerAzureADAdministrator) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var administratorProperties AdministratorProperties + err = json.Unmarshal(*v, &administratorProperties) + if err != nil { + return err + } + saaa.AdministratorProperties = &administratorProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + saaa.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + saaa.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + saaa.Type = &typeVar + } + } + } + + return nil +} + +// ServerAzureADAdministratorsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results +// of a long-running operation. +type ServerAzureADAdministratorsCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ServerAzureADAdministratorsClient) (ServerAzureADAdministrator, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ServerAzureADAdministratorsCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ServerAzureADAdministratorsCreateOrUpdateFuture.Result. +func (future *ServerAzureADAdministratorsCreateOrUpdateFuture) result(client ServerAzureADAdministratorsClient) (saaa ServerAzureADAdministrator, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAzureADAdministratorsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + saaa.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ServerAzureADAdministratorsCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if saaa.Response.Response, err = future.GetResult(sender); err == nil && saaa.Response.Response.StatusCode != http.StatusNoContent { + saaa, err = client.CreateOrUpdateResponder(saaa.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAzureADAdministratorsCreateOrUpdateFuture", "Result", saaa.Response.Response, "Failure responding to request") + } + } + return +} + +// ServerAzureADAdministratorsDeleteFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type ServerAzureADAdministratorsDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ServerAzureADAdministratorsClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ServerAzureADAdministratorsDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ServerAzureADAdministratorsDeleteFuture.Result. +func (future *ServerAzureADAdministratorsDeleteFuture) result(client ServerAzureADAdministratorsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAzureADAdministratorsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ServerAzureADAdministratorsDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// ServerAzureADOnlyAuthentication azure Active Directory only authentication. +type ServerAzureADOnlyAuthentication struct { + autorest.Response `json:"-"` + // AzureADOnlyAuthProperties - Resource properties. + *AzureADOnlyAuthProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServerAzureADOnlyAuthentication. +func (saaoa ServerAzureADOnlyAuthentication) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if saaoa.AzureADOnlyAuthProperties != nil { + objectMap["properties"] = saaoa.AzureADOnlyAuthProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ServerAzureADOnlyAuthentication struct. +func (saaoa *ServerAzureADOnlyAuthentication) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var azureADOnlyAuthProperties AzureADOnlyAuthProperties + err = json.Unmarshal(*v, &azureADOnlyAuthProperties) + if err != nil { + return err + } + saaoa.AzureADOnlyAuthProperties = &azureADOnlyAuthProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + saaoa.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + saaoa.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + saaoa.Type = &typeVar + } + } + } + + return nil +} + +// ServerAzureADOnlyAuthenticationsCreateOrUpdateFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type ServerAzureADOnlyAuthenticationsCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ServerAzureADOnlyAuthenticationsClient) (ServerAzureADOnlyAuthentication, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ServerAzureADOnlyAuthenticationsCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ServerAzureADOnlyAuthenticationsCreateOrUpdateFuture.Result. +func (future *ServerAzureADOnlyAuthenticationsCreateOrUpdateFuture) result(client ServerAzureADOnlyAuthenticationsClient) (saaoa ServerAzureADOnlyAuthentication, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAzureADOnlyAuthenticationsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + saaoa.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ServerAzureADOnlyAuthenticationsCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if saaoa.Response.Response, err = future.GetResult(sender); err == nil && saaoa.Response.Response.StatusCode != http.StatusNoContent { + saaoa, err = client.CreateOrUpdateResponder(saaoa.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAzureADOnlyAuthenticationsCreateOrUpdateFuture", "Result", saaoa.Response.Response, "Failure responding to request") + } + } + return +} + +// ServerAzureADOnlyAuthenticationsDeleteFuture an abstraction for monitoring and retrieving the results of +// a long-running operation. +type ServerAzureADOnlyAuthenticationsDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ServerAzureADOnlyAuthenticationsClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ServerAzureADOnlyAuthenticationsDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ServerAzureADOnlyAuthenticationsDeleteFuture.Result. +func (future *ServerAzureADOnlyAuthenticationsDeleteFuture) result(client ServerAzureADOnlyAuthenticationsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAzureADOnlyAuthenticationsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ServerAzureADOnlyAuthenticationsDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// ServerBlobAuditingPoliciesCreateOrUpdateFuture an abstraction for monitoring and retrieving the results +// of a long-running operation. +type ServerBlobAuditingPoliciesCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ServerBlobAuditingPoliciesClient) (ServerBlobAuditingPolicy, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ServerBlobAuditingPoliciesCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ServerBlobAuditingPoliciesCreateOrUpdateFuture.Result. +func (future *ServerBlobAuditingPoliciesCreateOrUpdateFuture) result(client ServerBlobAuditingPoliciesClient) (sbap ServerBlobAuditingPolicy, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerBlobAuditingPoliciesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + sbap.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ServerBlobAuditingPoliciesCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if sbap.Response.Response, err = future.GetResult(sender); err == nil && sbap.Response.Response.StatusCode != http.StatusNoContent { + sbap, err = client.CreateOrUpdateResponder(sbap.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerBlobAuditingPoliciesCreateOrUpdateFuture", "Result", sbap.Response.Response, "Failure responding to request") + } + } + return +} + +// ServerBlobAuditingPolicy a server blob auditing policy. +type ServerBlobAuditingPolicy struct { + autorest.Response `json:"-"` + // ServerBlobAuditingPolicyProperties - Resource properties. + *ServerBlobAuditingPolicyProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServerBlobAuditingPolicy. +func (sbap ServerBlobAuditingPolicy) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sbap.ServerBlobAuditingPolicyProperties != nil { + objectMap["properties"] = sbap.ServerBlobAuditingPolicyProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ServerBlobAuditingPolicy struct. +func (sbap *ServerBlobAuditingPolicy) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var serverBlobAuditingPolicyProperties ServerBlobAuditingPolicyProperties + err = json.Unmarshal(*v, &serverBlobAuditingPolicyProperties) + if err != nil { + return err + } + sbap.ServerBlobAuditingPolicyProperties = &serverBlobAuditingPolicyProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + sbap.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + sbap.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + sbap.Type = &typeVar + } + } + } + + return nil +} + +// ServerBlobAuditingPolicyListResult a list of server auditing settings. +type ServerBlobAuditingPolicyListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]ServerBlobAuditingPolicy `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServerBlobAuditingPolicyListResult. +func (sbaplr ServerBlobAuditingPolicyListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ServerBlobAuditingPolicyListResultIterator provides access to a complete listing of +// ServerBlobAuditingPolicy values. +type ServerBlobAuditingPolicyListResultIterator struct { + i int + page ServerBlobAuditingPolicyListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *ServerBlobAuditingPolicyListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerBlobAuditingPolicyListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ServerBlobAuditingPolicyListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ServerBlobAuditingPolicyListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter ServerBlobAuditingPolicyListResultIterator) Response() ServerBlobAuditingPolicyListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter ServerBlobAuditingPolicyListResultIterator) Value() ServerBlobAuditingPolicy { + if !iter.page.NotDone() { + return ServerBlobAuditingPolicy{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ServerBlobAuditingPolicyListResultIterator type. +func NewServerBlobAuditingPolicyListResultIterator(page ServerBlobAuditingPolicyListResultPage) ServerBlobAuditingPolicyListResultIterator { + return ServerBlobAuditingPolicyListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (sbaplr ServerBlobAuditingPolicyListResult) IsEmpty() bool { + return sbaplr.Value == nil || len(*sbaplr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (sbaplr ServerBlobAuditingPolicyListResult) hasNextLink() bool { + return sbaplr.NextLink != nil && len(*sbaplr.NextLink) != 0 +} + +// serverBlobAuditingPolicyListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (sbaplr ServerBlobAuditingPolicyListResult) serverBlobAuditingPolicyListResultPreparer(ctx context.Context) (*http.Request, error) { + if !sbaplr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(sbaplr.NextLink))) +} + +// ServerBlobAuditingPolicyListResultPage contains a page of ServerBlobAuditingPolicy values. +type ServerBlobAuditingPolicyListResultPage struct { + fn func(context.Context, ServerBlobAuditingPolicyListResult) (ServerBlobAuditingPolicyListResult, error) + sbaplr ServerBlobAuditingPolicyListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *ServerBlobAuditingPolicyListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerBlobAuditingPolicyListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.sbaplr) + if err != nil { + return err + } + page.sbaplr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *ServerBlobAuditingPolicyListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ServerBlobAuditingPolicyListResultPage) NotDone() bool { + return !page.sbaplr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ServerBlobAuditingPolicyListResultPage) Response() ServerBlobAuditingPolicyListResult { + return page.sbaplr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ServerBlobAuditingPolicyListResultPage) Values() []ServerBlobAuditingPolicy { + if page.sbaplr.IsEmpty() { + return nil + } + return *page.sbaplr.Value +} + +// Creates a new instance of the ServerBlobAuditingPolicyListResultPage type. +func NewServerBlobAuditingPolicyListResultPage(cur ServerBlobAuditingPolicyListResult, getNextPage func(context.Context, ServerBlobAuditingPolicyListResult) (ServerBlobAuditingPolicyListResult, error)) ServerBlobAuditingPolicyListResultPage { + return ServerBlobAuditingPolicyListResultPage{ + fn: getNextPage, + sbaplr: cur, + } +} + +// ServerBlobAuditingPolicyProperties properties of a server blob auditing policy. +type ServerBlobAuditingPolicyProperties struct { + // IsDevopsAuditEnabled - Specifies the state of devops audit. If state is Enabled, devops logs will be sent to Azure Monitor. + // In order to send the events to Azure Monitor, specify 'State' as 'Enabled', 'IsAzureMonitorTargetEnabled' as true and 'IsDevopsAuditEnabled' as true + // + // When using REST API to configure auditing, Diagnostic Settings with 'DevOpsOperationsAudit' diagnostic logs category on the master database should also be created. + // + // Diagnostic Settings URI format: + // PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Sql/servers/{serverName}/databases/master/providers/microsoft.insights/diagnosticSettings/{settingsName}?api-version=2017-05-01-preview + // + // For more information, see [Diagnostic Settings REST API](https://go.microsoft.com/fwlink/?linkid=2033207) + // or [Diagnostic Settings PowerShell](https://go.microsoft.com/fwlink/?linkid=2033043) + IsDevopsAuditEnabled *bool `json:"isDevopsAuditEnabled,omitempty"` + // RetentionDays - Specifies the number of days to keep in the audit logs in the storage account. + RetentionDays *int32 `json:"retentionDays,omitempty"` + // AuditActionsAndGroups - Specifies the Actions-Groups and Actions to audit. + // + // The recommended set of action groups to use is the following combination - this will audit all the queries and stored procedures executed against the database, as well as successful and failed logins: + // + // BATCH_COMPLETED_GROUP, + // SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP, + // FAILED_DATABASE_AUTHENTICATION_GROUP. + // + // This above combination is also the set that is configured by default when enabling auditing from the Azure portal. + // + // The supported action groups to audit are (note: choose only specific groups that cover your auditing needs. Using unnecessary groups could lead to very large quantities of audit records): + // + // APPLICATION_ROLE_CHANGE_PASSWORD_GROUP + // BACKUP_RESTORE_GROUP + // DATABASE_LOGOUT_GROUP + // DATABASE_OBJECT_CHANGE_GROUP + // DATABASE_OBJECT_OWNERSHIP_CHANGE_GROUP + // DATABASE_OBJECT_PERMISSION_CHANGE_GROUP + // DATABASE_OPERATION_GROUP + // DATABASE_PERMISSION_CHANGE_GROUP + // DATABASE_PRINCIPAL_CHANGE_GROUP + // DATABASE_PRINCIPAL_IMPERSONATION_GROUP + // DATABASE_ROLE_MEMBER_CHANGE_GROUP + // FAILED_DATABASE_AUTHENTICATION_GROUP + // SCHEMA_OBJECT_ACCESS_GROUP + // SCHEMA_OBJECT_CHANGE_GROUP + // SCHEMA_OBJECT_OWNERSHIP_CHANGE_GROUP + // SCHEMA_OBJECT_PERMISSION_CHANGE_GROUP + // SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP + // USER_CHANGE_PASSWORD_GROUP + // BATCH_STARTED_GROUP + // BATCH_COMPLETED_GROUP + // + // These are groups that cover all sql statements and stored procedures executed against the database, and should not be used in combination with other groups as this will result in duplicate audit logs. + // + // For more information, see [Database-Level Audit Action Groups](https://docs.microsoft.com/en-us/sql/relational-databases/security/auditing/sql-server-audit-action-groups-and-actions#database-level-audit-action-groups). + // + // For Database auditing policy, specific Actions can also be specified (note that Actions cannot be specified for Server auditing policy). The supported actions to audit are: + // SELECT + // UPDATE + // INSERT + // DELETE + // EXECUTE + // RECEIVE + // REFERENCES + // + // The general form for defining an action to be audited is: + // {action} ON {object} BY {principal} + // + // Note that in the above format can refer to an object like a table, view, or stored procedure, or an entire database or schema. For the latter cases, the forms DATABASE::{db_name} and SCHEMA::{schema_name} are used, respectively. + // + // For example: + // SELECT on dbo.myTable by public + // SELECT on DATABASE::myDatabase by public + // SELECT on SCHEMA::mySchema by public + // + // For more information, see [Database-Level Audit Actions](https://docs.microsoft.com/en-us/sql/relational-databases/security/auditing/sql-server-audit-action-groups-and-actions#database-level-audit-actions) + AuditActionsAndGroups *[]string `json:"auditActionsAndGroups,omitempty"` + // IsStorageSecondaryKeyInUse - Specifies whether storageAccountAccessKey value is the storage's secondary key. + IsStorageSecondaryKeyInUse *bool `json:"isStorageSecondaryKeyInUse,omitempty"` + // IsAzureMonitorTargetEnabled - Specifies whether audit events are sent to Azure Monitor. + // In order to send the events to Azure Monitor, specify 'State' as 'Enabled' and 'IsAzureMonitorTargetEnabled' as true. + // + // When using REST API to configure auditing, Diagnostic Settings with 'SQLSecurityAuditEvents' diagnostic logs category on the database should be also created. + // Note that for server level audit you should use the 'master' database as {databaseName}. + // + // Diagnostic Settings URI format: + // PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/providers/microsoft.insights/diagnosticSettings/{settingsName}?api-version=2017-05-01-preview + // + // For more information, see [Diagnostic Settings REST API](https://go.microsoft.com/fwlink/?linkid=2033207) + // or [Diagnostic Settings PowerShell](https://go.microsoft.com/fwlink/?linkid=2033043) + IsAzureMonitorTargetEnabled *bool `json:"isAzureMonitorTargetEnabled,omitempty"` + // QueueDelayMs - Specifies the amount of time in milliseconds that can elapse before audit actions are forced to be processed. + // The default minimum value is 1000 (1 second). The maximum is 2,147,483,647. + QueueDelayMs *int32 `json:"queueDelayMs,omitempty"` + // State - Specifies the state of the audit. If state is Enabled, storageEndpoint or isAzureMonitorTargetEnabled are required. Possible values include: 'BlobAuditingPolicyStateEnabled', 'BlobAuditingPolicyStateDisabled' + State BlobAuditingPolicyState `json:"state,omitempty"` + // StorageEndpoint - Specifies the blob storage endpoint (e.g. https://MyAccount.blob.core.windows.net). If state is Enabled, storageEndpoint or isAzureMonitorTargetEnabled is required. + StorageEndpoint *string `json:"storageEndpoint,omitempty"` + // StorageAccountAccessKey - Specifies the identifier key of the auditing storage account. + // If state is Enabled and storageEndpoint is specified, not specifying the storageAccountAccessKey will use SQL server system-assigned managed identity to access the storage. + // Prerequisites for using managed identity authentication: + // 1. Assign SQL Server a system-assigned managed identity in Azure Active Directory (AAD). + // 2. Grant SQL Server identity access to the storage account by adding 'Storage Blob Data Contributor' RBAC role to the server identity. + // For more information, see [Auditing to storage using Managed Identity authentication](https://go.microsoft.com/fwlink/?linkid=2114355) + StorageAccountAccessKey *string `json:"storageAccountAccessKey,omitempty"` + // StorageAccountSubscriptionID - Specifies the blob storage subscription Id. + StorageAccountSubscriptionID *uuid.UUID `json:"storageAccountSubscriptionId,omitempty"` +} + +// ServerCommunicationLink server communication link. +type ServerCommunicationLink struct { + autorest.Response `json:"-"` + // ServerCommunicationLinkProperties - The properties of resource. + *ServerCommunicationLinkProperties `json:"properties,omitempty"` + // Location - READ-ONLY; Communication link location. + Location *string `json:"location,omitempty"` + // Kind - READ-ONLY; Communication link kind. This property is used for Azure Portal metadata. + Kind *string `json:"kind,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServerCommunicationLink. +func (scl ServerCommunicationLink) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if scl.ServerCommunicationLinkProperties != nil { + objectMap["properties"] = scl.ServerCommunicationLinkProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ServerCommunicationLink struct. +func (scl *ServerCommunicationLink) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var serverCommunicationLinkProperties ServerCommunicationLinkProperties + err = json.Unmarshal(*v, &serverCommunicationLinkProperties) + if err != nil { + return err + } + scl.ServerCommunicationLinkProperties = &serverCommunicationLinkProperties + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + scl.Location = &location + } + case "kind": + if v != nil { + var kind string + err = json.Unmarshal(*v, &kind) + if err != nil { + return err + } + scl.Kind = &kind + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + scl.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + scl.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + scl.Type = &typeVar + } + } + } + + return nil +} + +// ServerCommunicationLinkListResult a list of server communication links. +type ServerCommunicationLinkListResult struct { + autorest.Response `json:"-"` + // Value - The list of server communication links. + Value *[]ServerCommunicationLink `json:"value,omitempty"` +} + +// ServerCommunicationLinkProperties the properties of a server communication link. +type ServerCommunicationLinkProperties struct { + // State - READ-ONLY; The state. + State *string `json:"state,omitempty"` + // PartnerServer - The name of the partner server. + PartnerServer *string `json:"partnerServer,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServerCommunicationLinkProperties. +func (sclp ServerCommunicationLinkProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sclp.PartnerServer != nil { + objectMap["partnerServer"] = sclp.PartnerServer + } + return json.Marshal(objectMap) +} + +// ServerCommunicationLinksCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of +// a long-running operation. +type ServerCommunicationLinksCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ServerCommunicationLinksClient) (ServerCommunicationLink, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ServerCommunicationLinksCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ServerCommunicationLinksCreateOrUpdateFuture.Result. +func (future *ServerCommunicationLinksCreateOrUpdateFuture) result(client ServerCommunicationLinksClient) (scl ServerCommunicationLink, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerCommunicationLinksCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + scl.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ServerCommunicationLinksCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if scl.Response.Response, err = future.GetResult(sender); err == nil && scl.Response.Response.StatusCode != http.StatusNoContent { + scl, err = client.CreateOrUpdateResponder(scl.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerCommunicationLinksCreateOrUpdateFuture", "Result", scl.Response.Response, "Failure responding to request") + } + } + return +} + +// ServerConnectionPolicy a server secure connection policy. +type ServerConnectionPolicy struct { + autorest.Response `json:"-"` + // Kind - READ-ONLY; Metadata used for the Azure portal experience. + Kind *string `json:"kind,omitempty"` + // Location - READ-ONLY; Resource location. + Location *string `json:"location,omitempty"` + // ServerConnectionPolicyProperties - The properties of the server secure connection policy. + *ServerConnectionPolicyProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServerConnectionPolicy. +func (scp ServerConnectionPolicy) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if scp.ServerConnectionPolicyProperties != nil { + objectMap["properties"] = scp.ServerConnectionPolicyProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ServerConnectionPolicy struct. +func (scp *ServerConnectionPolicy) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "kind": + if v != nil { + var kind string + err = json.Unmarshal(*v, &kind) + if err != nil { + return err + } + scp.Kind = &kind + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + scp.Location = &location + } + case "properties": + if v != nil { + var serverConnectionPolicyProperties ServerConnectionPolicyProperties + err = json.Unmarshal(*v, &serverConnectionPolicyProperties) + if err != nil { + return err + } + scp.ServerConnectionPolicyProperties = &serverConnectionPolicyProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + scp.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + scp.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + scp.Type = &typeVar + } + } + } + + return nil +} + +// ServerConnectionPolicyProperties the properties of a server secure connection policy. +type ServerConnectionPolicyProperties struct { + // ConnectionType - The server connection type. Possible values include: 'ServerConnectionTypeDefault', 'ServerConnectionTypeProxy', 'ServerConnectionTypeRedirect' + ConnectionType ServerConnectionType `json:"connectionType,omitempty"` +} + +// ServerDevOpsAuditingSettings a server DevOps auditing settings. +type ServerDevOpsAuditingSettings struct { + autorest.Response `json:"-"` + // SystemData - READ-ONLY; SystemData of ServerDevOpsAuditSettingsResource. + SystemData *SystemData `json:"systemData,omitempty"` + // ServerDevOpsAuditSettingsProperties - Resource properties. + *ServerDevOpsAuditSettingsProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServerDevOpsAuditingSettings. +func (sdoas ServerDevOpsAuditingSettings) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sdoas.ServerDevOpsAuditSettingsProperties != nil { + objectMap["properties"] = sdoas.ServerDevOpsAuditSettingsProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ServerDevOpsAuditingSettings struct. +func (sdoas *ServerDevOpsAuditingSettings) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "systemData": + if v != nil { + var systemData SystemData + err = json.Unmarshal(*v, &systemData) + if err != nil { + return err + } + sdoas.SystemData = &systemData + } + case "properties": + if v != nil { + var serverDevOpsAuditSettingsProperties ServerDevOpsAuditSettingsProperties + err = json.Unmarshal(*v, &serverDevOpsAuditSettingsProperties) + if err != nil { + return err + } + sdoas.ServerDevOpsAuditSettingsProperties = &serverDevOpsAuditSettingsProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + sdoas.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + sdoas.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + sdoas.Type = &typeVar + } + } + } + + return nil +} + +// ServerDevOpsAuditSettingsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results +// of a long-running operation. +type ServerDevOpsAuditSettingsCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ServerDevOpsAuditSettingsClient) (ServerDevOpsAuditingSettings, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ServerDevOpsAuditSettingsCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ServerDevOpsAuditSettingsCreateOrUpdateFuture.Result. +func (future *ServerDevOpsAuditSettingsCreateOrUpdateFuture) result(client ServerDevOpsAuditSettingsClient) (sdoas ServerDevOpsAuditingSettings, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerDevOpsAuditSettingsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + sdoas.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ServerDevOpsAuditSettingsCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if sdoas.Response.Response, err = future.GetResult(sender); err == nil && sdoas.Response.Response.StatusCode != http.StatusNoContent { + sdoas, err = client.CreateOrUpdateResponder(sdoas.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerDevOpsAuditSettingsCreateOrUpdateFuture", "Result", sdoas.Response.Response, "Failure responding to request") + } + } + return +} + +// ServerDevOpsAuditSettingsListResult a list of server DevOps audit settings. +type ServerDevOpsAuditSettingsListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]ServerDevOpsAuditingSettings `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServerDevOpsAuditSettingsListResult. +func (sdoaslr ServerDevOpsAuditSettingsListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ServerDevOpsAuditSettingsListResultIterator provides access to a complete listing of +// ServerDevOpsAuditingSettings values. +type ServerDevOpsAuditSettingsListResultIterator struct { + i int + page ServerDevOpsAuditSettingsListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *ServerDevOpsAuditSettingsListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerDevOpsAuditSettingsListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ServerDevOpsAuditSettingsListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ServerDevOpsAuditSettingsListResultIterator) 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 ServerDevOpsAuditSettingsListResultIterator) Response() ServerDevOpsAuditSettingsListResult { + 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 ServerDevOpsAuditSettingsListResultIterator) Value() ServerDevOpsAuditingSettings { + if !iter.page.NotDone() { + return ServerDevOpsAuditingSettings{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ServerDevOpsAuditSettingsListResultIterator type. +func NewServerDevOpsAuditSettingsListResultIterator(page ServerDevOpsAuditSettingsListResultPage) ServerDevOpsAuditSettingsListResultIterator { + return ServerDevOpsAuditSettingsListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (sdoaslr ServerDevOpsAuditSettingsListResult) IsEmpty() bool { + return sdoaslr.Value == nil || len(*sdoaslr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (sdoaslr ServerDevOpsAuditSettingsListResult) hasNextLink() bool { + return sdoaslr.NextLink != nil && len(*sdoaslr.NextLink) != 0 +} + +// serverDevOpsAuditSettingsListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (sdoaslr ServerDevOpsAuditSettingsListResult) serverDevOpsAuditSettingsListResultPreparer(ctx context.Context) (*http.Request, error) { + if !sdoaslr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(sdoaslr.NextLink))) +} + +// ServerDevOpsAuditSettingsListResultPage contains a page of ServerDevOpsAuditingSettings values. +type ServerDevOpsAuditSettingsListResultPage struct { + fn func(context.Context, ServerDevOpsAuditSettingsListResult) (ServerDevOpsAuditSettingsListResult, error) + sdoaslr ServerDevOpsAuditSettingsListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *ServerDevOpsAuditSettingsListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerDevOpsAuditSettingsListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.sdoaslr) + if err != nil { + return err + } + page.sdoaslr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *ServerDevOpsAuditSettingsListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ServerDevOpsAuditSettingsListResultPage) NotDone() bool { + return !page.sdoaslr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ServerDevOpsAuditSettingsListResultPage) Response() ServerDevOpsAuditSettingsListResult { + return page.sdoaslr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ServerDevOpsAuditSettingsListResultPage) Values() []ServerDevOpsAuditingSettings { + if page.sdoaslr.IsEmpty() { + return nil + } + return *page.sdoaslr.Value +} + +// Creates a new instance of the ServerDevOpsAuditSettingsListResultPage type. +func NewServerDevOpsAuditSettingsListResultPage(cur ServerDevOpsAuditSettingsListResult, getNextPage func(context.Context, ServerDevOpsAuditSettingsListResult) (ServerDevOpsAuditSettingsListResult, error)) ServerDevOpsAuditSettingsListResultPage { + return ServerDevOpsAuditSettingsListResultPage{ + fn: getNextPage, + sdoaslr: cur, + } +} + +// ServerDevOpsAuditSettingsProperties properties of a server DevOps audit settings. +type ServerDevOpsAuditSettingsProperties struct { + // IsAzureMonitorTargetEnabled - Specifies whether DevOps audit events are sent to Azure Monitor. + // In order to send the events to Azure Monitor, specify 'State' as 'Enabled' and 'IsAzureMonitorTargetEnabled' as true. + // + // When using REST API to configure DevOps audit, Diagnostic Settings with 'DevOpsOperationsAudit' diagnostic logs category on the master database should be also created. + // + // Diagnostic Settings URI format: + // PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Sql/servers/{serverName}/databases/master/providers/microsoft.insights/diagnosticSettings/{settingsName}?api-version=2017-05-01-preview + // + // For more information, see [Diagnostic Settings REST API](https://go.microsoft.com/fwlink/?linkid=2033207) + // or [Diagnostic Settings PowerShell](https://go.microsoft.com/fwlink/?linkid=2033043) + IsAzureMonitorTargetEnabled *bool `json:"isAzureMonitorTargetEnabled,omitempty"` + // State - Specifies the state of the audit. If state is Enabled, storageEndpoint or isAzureMonitorTargetEnabled are required. Possible values include: 'BlobAuditingPolicyStateEnabled', 'BlobAuditingPolicyStateDisabled' + State BlobAuditingPolicyState `json:"state,omitempty"` + // StorageEndpoint - Specifies the blob storage endpoint (e.g. https://MyAccount.blob.core.windows.net). If state is Enabled, storageEndpoint or isAzureMonitorTargetEnabled is required. + StorageEndpoint *string `json:"storageEndpoint,omitempty"` + // StorageAccountAccessKey - Specifies the identifier key of the auditing storage account. + // If state is Enabled and storageEndpoint is specified, not specifying the storageAccountAccessKey will use SQL server system-assigned managed identity to access the storage. + // Prerequisites for using managed identity authentication: + // 1. Assign SQL Server a system-assigned managed identity in Azure Active Directory (AAD). + // 2. Grant SQL Server identity access to the storage account by adding 'Storage Blob Data Contributor' RBAC role to the server identity. + // For more information, see [Auditing to storage using Managed Identity authentication](https://go.microsoft.com/fwlink/?linkid=2114355) + StorageAccountAccessKey *string `json:"storageAccountAccessKey,omitempty"` + // StorageAccountSubscriptionID - Specifies the blob storage subscription Id. + StorageAccountSubscriptionID *uuid.UUID `json:"storageAccountSubscriptionId,omitempty"` +} + +// ServerDNSAlias a server DNS alias. +type ServerDNSAlias struct { + autorest.Response `json:"-"` + // ServerDNSAliasProperties - Resource properties. + *ServerDNSAliasProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServerDNSAlias. +func (sda ServerDNSAlias) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sda.ServerDNSAliasProperties != nil { + objectMap["properties"] = sda.ServerDNSAliasProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ServerDNSAlias struct. +func (sda *ServerDNSAlias) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var serverDNSAliasProperties ServerDNSAliasProperties + err = json.Unmarshal(*v, &serverDNSAliasProperties) + if err != nil { + return err + } + sda.ServerDNSAliasProperties = &serverDNSAliasProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + sda.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + sda.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + sda.Type = &typeVar + } + } + } + + return nil +} + +// ServerDNSAliasAcquisition a server dns alias acquisition request. +type ServerDNSAliasAcquisition struct { + // OldServerDNSAliasID - The id of the server alias that will be acquired to point to this server instead. + OldServerDNSAliasID *string `json:"oldServerDnsAliasId,omitempty"` +} + +// ServerDNSAliasesAcquireFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ServerDNSAliasesAcquireFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ServerDNSAliasesClient) (ServerDNSAlias, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ServerDNSAliasesAcquireFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ServerDNSAliasesAcquireFuture.Result. +func (future *ServerDNSAliasesAcquireFuture) result(client ServerDNSAliasesClient) (sda ServerDNSAlias, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerDNSAliasesAcquireFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + sda.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ServerDNSAliasesAcquireFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if sda.Response.Response, err = future.GetResult(sender); err == nil && sda.Response.Response.StatusCode != http.StatusNoContent { + sda, err = client.AcquireResponder(sda.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerDNSAliasesAcquireFuture", "Result", sda.Response.Response, "Failure responding to request") + } + } + return +} + +// ServerDNSAliasesCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type ServerDNSAliasesCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ServerDNSAliasesClient) (ServerDNSAlias, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ServerDNSAliasesCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ServerDNSAliasesCreateOrUpdateFuture.Result. +func (future *ServerDNSAliasesCreateOrUpdateFuture) result(client ServerDNSAliasesClient) (sda ServerDNSAlias, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerDNSAliasesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + sda.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ServerDNSAliasesCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if sda.Response.Response, err = future.GetResult(sender); err == nil && sda.Response.Response.StatusCode != http.StatusNoContent { + sda, err = client.CreateOrUpdateResponder(sda.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerDNSAliasesCreateOrUpdateFuture", "Result", sda.Response.Response, "Failure responding to request") + } + } + return +} + +// ServerDNSAliasesDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ServerDNSAliasesDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ServerDNSAliasesClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ServerDNSAliasesDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ServerDNSAliasesDeleteFuture.Result. +func (future *ServerDNSAliasesDeleteFuture) result(client ServerDNSAliasesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerDNSAliasesDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ServerDNSAliasesDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// ServerDNSAliasListResult a list of server DNS aliases. +type ServerDNSAliasListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]ServerDNSAlias `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServerDNSAliasListResult. +func (sdalr ServerDNSAliasListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ServerDNSAliasListResultIterator provides access to a complete listing of ServerDNSAlias values. +type ServerDNSAliasListResultIterator struct { + i int + page ServerDNSAliasListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *ServerDNSAliasListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerDNSAliasListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ServerDNSAliasListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ServerDNSAliasListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter ServerDNSAliasListResultIterator) Response() ServerDNSAliasListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter ServerDNSAliasListResultIterator) Value() ServerDNSAlias { + if !iter.page.NotDone() { + return ServerDNSAlias{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ServerDNSAliasListResultIterator type. +func NewServerDNSAliasListResultIterator(page ServerDNSAliasListResultPage) ServerDNSAliasListResultIterator { + return ServerDNSAliasListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (sdalr ServerDNSAliasListResult) IsEmpty() bool { + return sdalr.Value == nil || len(*sdalr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (sdalr ServerDNSAliasListResult) hasNextLink() bool { + return sdalr.NextLink != nil && len(*sdalr.NextLink) != 0 +} + +// serverDNSAliasListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (sdalr ServerDNSAliasListResult) serverDNSAliasListResultPreparer(ctx context.Context) (*http.Request, error) { + if !sdalr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(sdalr.NextLink))) +} + +// ServerDNSAliasListResultPage contains a page of ServerDNSAlias values. +type ServerDNSAliasListResultPage struct { + fn func(context.Context, ServerDNSAliasListResult) (ServerDNSAliasListResult, error) + sdalr ServerDNSAliasListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *ServerDNSAliasListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerDNSAliasListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.sdalr) + if err != nil { + return err + } + page.sdalr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *ServerDNSAliasListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ServerDNSAliasListResultPage) NotDone() bool { + return !page.sdalr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ServerDNSAliasListResultPage) Response() ServerDNSAliasListResult { + return page.sdalr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ServerDNSAliasListResultPage) Values() []ServerDNSAlias { + if page.sdalr.IsEmpty() { + return nil + } + return *page.sdalr.Value +} + +// Creates a new instance of the ServerDNSAliasListResultPage type. +func NewServerDNSAliasListResultPage(cur ServerDNSAliasListResult, getNextPage func(context.Context, ServerDNSAliasListResult) (ServerDNSAliasListResult, error)) ServerDNSAliasListResultPage { + return ServerDNSAliasListResultPage{ + fn: getNextPage, + sdalr: cur, + } +} + +// ServerDNSAliasProperties properties of a server DNS alias. +type ServerDNSAliasProperties struct { + // AzureDNSRecord - READ-ONLY; The fully qualified DNS record for alias + AzureDNSRecord *string `json:"azureDnsRecord,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServerDNSAliasProperties. +func (sdap ServerDNSAliasProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ServerExternalAdministrator properties of a active directory administrator. +type ServerExternalAdministrator struct { + // AdministratorType - Type of the sever administrator. Possible values include: 'AdministratorTypeActiveDirectory' + AdministratorType AdministratorType `json:"administratorType,omitempty"` + // PrincipalType - Principal Type of the sever administrator. Possible values include: 'PrincipalTypeUser', 'PrincipalTypeGroup', 'PrincipalTypeApplication' + PrincipalType PrincipalType `json:"principalType,omitempty"` + // Login - Login name of the server administrator. + Login *string `json:"login,omitempty"` + // Sid - SID (object ID) of the server administrator. + Sid *uuid.UUID `json:"sid,omitempty"` + // TenantID - Tenant ID of the administrator. + TenantID *uuid.UUID `json:"tenantId,omitempty"` + // AzureADOnlyAuthentication - Azure Active Directory only Authentication enabled. + AzureADOnlyAuthentication *bool `json:"azureADOnlyAuthentication,omitempty"` +} + +// ServerFirewallRuleProperties the properties of a server firewall rule. +type ServerFirewallRuleProperties struct { + // StartIPAddress - The start IP address of the firewall rule. Must be IPv4 format. Use value '0.0.0.0' for 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' for all Azure-internal IP addresses. + EndIPAddress *string `json:"endIpAddress,omitempty"` +} + +// ServerInfo server info for the server trust group. +type ServerInfo struct { + // ServerID - Server Id. + ServerID *string `json:"serverId,omitempty"` +} + +// ServerKey a server key. +type ServerKey struct { + autorest.Response `json:"-"` + // Kind - READ-ONLY; Kind of encryption protector. This is metadata used for the Azure portal experience. + Kind *string `json:"kind,omitempty"` + // Location - READ-ONLY; Resource location. + Location *string `json:"location,omitempty"` + // ServerKeyProperties - Resource properties. + *ServerKeyProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServerKey. +func (sk ServerKey) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sk.ServerKeyProperties != nil { + objectMap["properties"] = sk.ServerKeyProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ServerKey struct. +func (sk *ServerKey) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "kind": + if v != nil { + var kind string + err = json.Unmarshal(*v, &kind) + if err != nil { + return err + } + sk.Kind = &kind + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + sk.Location = &location + } + case "properties": + if v != nil { + var serverKeyProperties ServerKeyProperties + err = json.Unmarshal(*v, &serverKeyProperties) + if err != nil { + return err + } + sk.ServerKeyProperties = &serverKeyProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + sk.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + sk.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + sk.Type = &typeVar + } + } + } + + return nil +} + +// ServerKeyListResult a list of server keys. +type ServerKeyListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]ServerKey `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServerKeyListResult. +func (sklr ServerKeyListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ServerKeyListResultIterator provides access to a complete listing of ServerKey values. +type ServerKeyListResultIterator struct { + i int + page ServerKeyListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *ServerKeyListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerKeyListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ServerKeyListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ServerKeyListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter ServerKeyListResultIterator) Response() ServerKeyListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter ServerKeyListResultIterator) Value() ServerKey { + if !iter.page.NotDone() { + return ServerKey{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ServerKeyListResultIterator type. +func NewServerKeyListResultIterator(page ServerKeyListResultPage) ServerKeyListResultIterator { + return ServerKeyListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (sklr ServerKeyListResult) IsEmpty() bool { + return sklr.Value == nil || len(*sklr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (sklr ServerKeyListResult) hasNextLink() bool { + return sklr.NextLink != nil && len(*sklr.NextLink) != 0 +} + +// serverKeyListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (sklr ServerKeyListResult) serverKeyListResultPreparer(ctx context.Context) (*http.Request, error) { + if !sklr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(sklr.NextLink))) +} + +// ServerKeyListResultPage contains a page of ServerKey values. +type ServerKeyListResultPage struct { + fn func(context.Context, ServerKeyListResult) (ServerKeyListResult, error) + sklr ServerKeyListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *ServerKeyListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerKeyListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.sklr) + if err != nil { + return err + } + page.sklr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *ServerKeyListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ServerKeyListResultPage) NotDone() bool { + return !page.sklr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ServerKeyListResultPage) Response() ServerKeyListResult { + return page.sklr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ServerKeyListResultPage) Values() []ServerKey { + if page.sklr.IsEmpty() { + return nil + } + return *page.sklr.Value +} + +// Creates a new instance of the ServerKeyListResultPage type. +func NewServerKeyListResultPage(cur ServerKeyListResult, getNextPage func(context.Context, ServerKeyListResult) (ServerKeyListResult, error)) ServerKeyListResultPage { + return ServerKeyListResultPage{ + fn: getNextPage, + sklr: cur, + } +} + +// ServerKeyProperties properties for a server key execution. +type ServerKeyProperties struct { + // Subregion - READ-ONLY; Subregion of the server key. + Subregion *string `json:"subregion,omitempty"` + // ServerKeyType - The server key type like 'ServiceManaged', 'AzureKeyVault'. Possible values include: 'ServerKeyTypeServiceManaged', 'ServerKeyTypeAzureKeyVault' + ServerKeyType ServerKeyType `json:"serverKeyType,omitempty"` + // URI - The URI of the server key. If the ServerKeyType is AzureKeyVault, then the URI is required. + URI *string `json:"uri,omitempty"` + // Thumbprint - READ-ONLY; Thumbprint of the server key. + Thumbprint *string `json:"thumbprint,omitempty"` + // CreationDate - READ-ONLY; The server key creation date. + CreationDate *date.Time `json:"creationDate,omitempty"` + // AutoRotationEnabled - READ-ONLY; Key auto rotation opt-in flag. Either true or false. + AutoRotationEnabled *bool `json:"autoRotationEnabled,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServerKeyProperties. +func (skp ServerKeyProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if skp.ServerKeyType != "" { + objectMap["serverKeyType"] = skp.ServerKeyType + } + if skp.URI != nil { + objectMap["uri"] = skp.URI + } + return json.Marshal(objectMap) +} + +// ServerKeysCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type ServerKeysCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ServerKeysClient) (ServerKey, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ServerKeysCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ServerKeysCreateOrUpdateFuture.Result. +func (future *ServerKeysCreateOrUpdateFuture) result(client ServerKeysClient) (sk ServerKey, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerKeysCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + sk.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ServerKeysCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if sk.Response.Response, err = future.GetResult(sender); err == nil && sk.Response.Response.StatusCode != http.StatusNoContent { + sk, err = client.CreateOrUpdateResponder(sk.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerKeysCreateOrUpdateFuture", "Result", sk.Response.Response, "Failure responding to request") + } + } + return +} + +// ServerKeysDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ServerKeysDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ServerKeysClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ServerKeysDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ServerKeysDeleteFuture.Result. +func (future *ServerKeysDeleteFuture) result(client ServerKeysClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerKeysDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ServerKeysDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// ServerListResult a list of servers. +type ServerListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]Server `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServerListResult. +func (slr ServerListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ServerListResultIterator provides access to a complete listing of Server values. +type ServerListResultIterator struct { + i int + page ServerListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *ServerListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ServerListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ServerListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter ServerListResultIterator) Response() ServerListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter ServerListResultIterator) Value() Server { + if !iter.page.NotDone() { + return Server{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ServerListResultIterator type. +func NewServerListResultIterator(page ServerListResultPage) ServerListResultIterator { + return ServerListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (slr ServerListResult) IsEmpty() bool { + return slr.Value == nil || len(*slr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (slr ServerListResult) hasNextLink() bool { + return slr.NextLink != nil && len(*slr.NextLink) != 0 +} + +// serverListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (slr ServerListResult) serverListResultPreparer(ctx context.Context) (*http.Request, error) { + if !slr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(slr.NextLink))) +} + +// ServerListResultPage contains a page of Server values. +type ServerListResultPage struct { + fn func(context.Context, ServerListResult) (ServerListResult, error) + slr ServerListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *ServerListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.slr) + if err != nil { + return err + } + page.slr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *ServerListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ServerListResultPage) NotDone() bool { + return !page.slr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ServerListResultPage) Response() ServerListResult { + return page.slr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ServerListResultPage) Values() []Server { + if page.slr.IsEmpty() { + return nil + } + return *page.slr.Value +} + +// Creates a new instance of the ServerListResultPage type. +func NewServerListResultPage(cur ServerListResult, getNextPage func(context.Context, ServerListResult) (ServerListResult, error)) ServerListResultPage { + return ServerListResultPage{ + fn: getNextPage, + slr: cur, + } +} + +// ServerOperation a server operation. +type ServerOperation struct { + // ServerOperationProperties - Resource properties. + *ServerOperationProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServerOperation. +func (so ServerOperation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if so.ServerOperationProperties != nil { + objectMap["properties"] = so.ServerOperationProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ServerOperation struct. +func (so *ServerOperation) UnmarshalJSON(body []byte) error { + 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 serverOperationProperties ServerOperationProperties + err = json.Unmarshal(*v, &serverOperationProperties) + if err != nil { + return err + } + so.ServerOperationProperties = &serverOperationProperties + } + 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 +} + +// ServerOperationListResult the response to a list server operations request +type ServerOperationListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]ServerOperation `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServerOperationListResult. +func (solr ServerOperationListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ServerOperationListResultIterator provides access to a complete listing of ServerOperation values. +type ServerOperationListResultIterator struct { + i int + page ServerOperationListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *ServerOperationListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerOperationListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ServerOperationListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ServerOperationListResultIterator) 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 ServerOperationListResultIterator) Response() ServerOperationListResult { + 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 ServerOperationListResultIterator) Value() ServerOperation { + if !iter.page.NotDone() { + return ServerOperation{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ServerOperationListResultIterator type. +func NewServerOperationListResultIterator(page ServerOperationListResultPage) ServerOperationListResultIterator { + return ServerOperationListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (solr ServerOperationListResult) IsEmpty() bool { + return solr.Value == nil || len(*solr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (solr ServerOperationListResult) hasNextLink() bool { + return solr.NextLink != nil && len(*solr.NextLink) != 0 +} + +// serverOperationListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (solr ServerOperationListResult) serverOperationListResultPreparer(ctx context.Context) (*http.Request, error) { + if !solr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(solr.NextLink))) +} + +// ServerOperationListResultPage contains a page of ServerOperation values. +type ServerOperationListResultPage struct { + fn func(context.Context, ServerOperationListResult) (ServerOperationListResult, error) + solr ServerOperationListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *ServerOperationListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerOperationListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.solr) + if err != nil { + return err + } + page.solr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *ServerOperationListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ServerOperationListResultPage) NotDone() bool { + return !page.solr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ServerOperationListResultPage) Response() ServerOperationListResult { + return page.solr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ServerOperationListResultPage) Values() []ServerOperation { + if page.solr.IsEmpty() { + return nil + } + return *page.solr.Value +} + +// Creates a new instance of the ServerOperationListResultPage type. +func NewServerOperationListResultPage(cur ServerOperationListResult, getNextPage func(context.Context, ServerOperationListResult) (ServerOperationListResult, error)) ServerOperationListResultPage { + return ServerOperationListResultPage{ + fn: getNextPage, + solr: cur, + } +} + +// ServerOperationProperties the properties of a server operation. +type ServerOperationProperties struct { + // Operation - READ-ONLY; The name of operation. + Operation *string `json:"operation,omitempty"` + // OperationFriendlyName - READ-ONLY; The friendly name of operation. + OperationFriendlyName *string `json:"operationFriendlyName,omitempty"` + // PercentComplete - READ-ONLY; The percentage of the operation completed. + PercentComplete *int32 `json:"percentComplete,omitempty"` + // ServerName - READ-ONLY; The name of the server. + ServerName *string `json:"serverName,omitempty"` + // StartTime - READ-ONLY; The operation start time. + StartTime *date.Time `json:"startTime,omitempty"` + // State - READ-ONLY; The operation state. Possible values include: 'ManagementOperationStatePending', 'ManagementOperationStateInProgress', 'ManagementOperationStateSucceeded', 'ManagementOperationStateFailed', 'ManagementOperationStateCancelInProgress', 'ManagementOperationStateCancelled' + State ManagementOperationState `json:"state,omitempty"` + // ErrorCode - READ-ONLY; The operation error code. + ErrorCode *int32 `json:"errorCode,omitempty"` + // ErrorDescription - READ-ONLY; The operation error description. + ErrorDescription *string `json:"errorDescription,omitempty"` + // ErrorSeverity - READ-ONLY; The operation error severity. + ErrorSeverity *int32 `json:"errorSeverity,omitempty"` + // IsUserError - READ-ONLY; Whether or not the error is a user error. + IsUserError *bool `json:"isUserError,omitempty"` + // EstimatedCompletionTime - READ-ONLY; The estimated completion time of the operation. + EstimatedCompletionTime *date.Time `json:"estimatedCompletionTime,omitempty"` + // Description - READ-ONLY; The operation description. + Description *string `json:"description,omitempty"` + // IsCancellable - READ-ONLY; Whether the operation can be cancelled. + IsCancellable *bool `json:"isCancellable,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServerOperationProperties. +func (sop ServerOperationProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ServerPrivateEndpointConnection a private endpoint connection under a server +type ServerPrivateEndpointConnection struct { + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Properties - READ-ONLY; Private endpoint connection properties + Properties *PrivateEndpointConnectionProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServerPrivateEndpointConnection. +func (spec ServerPrivateEndpointConnection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ServerProperties the properties of a server. +type ServerProperties struct { + // AdministratorLogin - Administrator username for the server. Once created it cannot be changed. + AdministratorLogin *string `json:"administratorLogin,omitempty"` + // AdministratorLoginPassword - The administrator login password (required for server creation). + AdministratorLoginPassword *string `json:"administratorLoginPassword,omitempty"` + // Version - The version of the server. + Version *string `json:"version,omitempty"` + // State - READ-ONLY; The state of the server. + State *string `json:"state,omitempty"` + // FullyQualifiedDomainName - READ-ONLY; The fully qualified domain name of the server. + FullyQualifiedDomainName *string `json:"fullyQualifiedDomainName,omitempty"` + // PrivateEndpointConnections - READ-ONLY; List of private endpoint connections on a server + PrivateEndpointConnections *[]ServerPrivateEndpointConnection `json:"privateEndpointConnections,omitempty"` + // MinimalTLSVersion - Minimal TLS version. Allowed values: '1.0', '1.1', '1.2' + MinimalTLSVersion *string `json:"minimalTlsVersion,omitempty"` + // PublicNetworkAccess - Whether or not public endpoint access is allowed for this server. Value is optional but if passed in, must be 'Enabled' or 'Disabled'. Possible values include: 'ServerNetworkAccessFlagEnabled', 'ServerNetworkAccessFlagDisabled' + PublicNetworkAccess ServerNetworkAccessFlag `json:"publicNetworkAccess,omitempty"` + // WorkspaceFeature - READ-ONLY; Whether or not existing server has a workspace created and if it allows connection from workspace. Possible values include: 'ServerWorkspaceFeatureConnected', 'ServerWorkspaceFeatureDisconnected' + WorkspaceFeature ServerWorkspaceFeature `json:"workspaceFeature,omitempty"` + // PrimaryUserAssignedIdentityID - The resource id of a user assigned identity to be used by default. + PrimaryUserAssignedIdentityID *string `json:"primaryUserAssignedIdentityId,omitempty"` + // FederatedClientID - The Client id used for cross tenant CMK scenario + FederatedClientID *uuid.UUID `json:"federatedClientId,omitempty"` + // KeyID - A CMK URI of the key to use for encryption. + KeyID *string `json:"keyId,omitempty"` + // Administrators - The Azure Active Directory identity of the server. + Administrators *ServerExternalAdministrator `json:"administrators,omitempty"` + // RestrictOutboundNetworkAccess - Whether or not to restrict outbound network access for this server. Value is optional but if passed in, must be 'Enabled' or 'Disabled'. Possible values include: 'ServerNetworkAccessFlagEnabled', 'ServerNetworkAccessFlagDisabled' + RestrictOutboundNetworkAccess ServerNetworkAccessFlag `json:"restrictOutboundNetworkAccess,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServerProperties. +func (sp ServerProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sp.AdministratorLogin != nil { + objectMap["administratorLogin"] = sp.AdministratorLogin + } + if sp.AdministratorLoginPassword != nil { + objectMap["administratorLoginPassword"] = sp.AdministratorLoginPassword + } + if sp.Version != nil { + objectMap["version"] = sp.Version + } + if sp.MinimalTLSVersion != nil { + objectMap["minimalTlsVersion"] = sp.MinimalTLSVersion + } + if sp.PublicNetworkAccess != "" { + objectMap["publicNetworkAccess"] = sp.PublicNetworkAccess + } + if sp.PrimaryUserAssignedIdentityID != nil { + objectMap["primaryUserAssignedIdentityId"] = sp.PrimaryUserAssignedIdentityID + } + if sp.FederatedClientID != nil { + objectMap["federatedClientId"] = sp.FederatedClientID + } + if sp.KeyID != nil { + objectMap["keyId"] = sp.KeyID + } + if sp.Administrators != nil { + objectMap["administrators"] = sp.Administrators + } + if sp.RestrictOutboundNetworkAccess != "" { + objectMap["restrictOutboundNetworkAccess"] = sp.RestrictOutboundNetworkAccess + } + return json.Marshal(objectMap) +} + +// ServersCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ServersCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ServersClient) (Server, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ServersCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ServersCreateOrUpdateFuture.Result. +func (future *ServersCreateOrUpdateFuture) result(client ServersClient) (s Server, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + s.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ServersCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if s.Response.Response, err = future.GetResult(sender); err == nil && s.Response.Response.StatusCode != http.StatusNoContent { + s, err = client.CreateOrUpdateResponder(s.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersCreateOrUpdateFuture", "Result", s.Response.Response, "Failure responding to request") + } + } + return +} + +// ServersDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ServersDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ServersClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ServersDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ServersDeleteFuture.Result. +func (future *ServersDeleteFuture) result(client ServersClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ServersDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// ServerSecurityAlertPoliciesCreateOrUpdateFuture an abstraction for monitoring and retrieving the results +// of a long-running operation. +type ServerSecurityAlertPoliciesCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ServerSecurityAlertPoliciesClient) (ServerSecurityAlertPolicy, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ServerSecurityAlertPoliciesCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ServerSecurityAlertPoliciesCreateOrUpdateFuture.Result. +func (future *ServerSecurityAlertPoliciesCreateOrUpdateFuture) result(client ServerSecurityAlertPoliciesClient) (ssap ServerSecurityAlertPolicy, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerSecurityAlertPoliciesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ssap.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ServerSecurityAlertPoliciesCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if ssap.Response.Response, err = future.GetResult(sender); err == nil && ssap.Response.Response.StatusCode != http.StatusNoContent { + ssap, err = client.CreateOrUpdateResponder(ssap.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerSecurityAlertPoliciesCreateOrUpdateFuture", "Result", ssap.Response.Response, "Failure responding to request") + } + } + return +} + +// ServerSecurityAlertPolicy a server security alert policy. +type ServerSecurityAlertPolicy struct { + autorest.Response `json:"-"` + // SystemData - READ-ONLY; SystemData of SecurityAlertPolicyResource. + SystemData *SystemData `json:"systemData,omitempty"` + // SecurityAlertsPolicyProperties - Resource properties. + *SecurityAlertsPolicyProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServerSecurityAlertPolicy. +func (ssap ServerSecurityAlertPolicy) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ssap.SecurityAlertsPolicyProperties != nil { + objectMap["properties"] = ssap.SecurityAlertsPolicyProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ServerSecurityAlertPolicy struct. +func (ssap *ServerSecurityAlertPolicy) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "systemData": + if v != nil { + var systemData SystemData + err = json.Unmarshal(*v, &systemData) + if err != nil { + return err + } + ssap.SystemData = &systemData + } + case "properties": + if v != nil { + var securityAlertsPolicyProperties SecurityAlertsPolicyProperties + err = json.Unmarshal(*v, &securityAlertsPolicyProperties) + if err != nil { + return err + } + ssap.SecurityAlertsPolicyProperties = &securityAlertsPolicyProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + ssap.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ssap.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ssap.Type = &typeVar + } + } + } + + return nil +} + +// ServersImportDatabaseFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ServersImportDatabaseFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ServersClient) (ImportExportOperationResult, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ServersImportDatabaseFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ServersImportDatabaseFuture.Result. +func (future *ServersImportDatabaseFuture) result(client ServersClient) (ieor ImportExportOperationResult, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersImportDatabaseFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ieor.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ServersImportDatabaseFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if ieor.Response.Response, err = future.GetResult(sender); err == nil && ieor.Response.Response.StatusCode != http.StatusNoContent { + ieor, err = client.ImportDatabaseResponder(ieor.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersImportDatabaseFuture", "Result", ieor.Response.Response, "Failure responding to request") + } + } + return +} + +// ServersUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ServersUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ServersClient) (Server, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ServersUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ServersUpdateFuture.Result. +func (future *ServersUpdateFuture) result(client ServersClient) (s Server, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + s.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ServersUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if s.Response.Response, err = future.GetResult(sender); err == nil && s.Response.Response.StatusCode != http.StatusNoContent { + s, err = client.UpdateResponder(s.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersUpdateFuture", "Result", s.Response.Response, "Failure responding to request") + } + } + return +} + +// ServerTrustGroup a server trust group. +type ServerTrustGroup struct { + autorest.Response `json:"-"` + // ServerTrustGroupProperties - Resource properties. + *ServerTrustGroupProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServerTrustGroup. +func (stg ServerTrustGroup) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if stg.ServerTrustGroupProperties != nil { + objectMap["properties"] = stg.ServerTrustGroupProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ServerTrustGroup struct. +func (stg *ServerTrustGroup) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var serverTrustGroupProperties ServerTrustGroupProperties + err = json.Unmarshal(*v, &serverTrustGroupProperties) + if err != nil { + return err + } + stg.ServerTrustGroupProperties = &serverTrustGroupProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + stg.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + stg.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + stg.Type = &typeVar + } + } + } + + return nil +} + +// ServerTrustGroupListResult a list of server trust groups. +type ServerTrustGroupListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]ServerTrustGroup `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServerTrustGroupListResult. +func (stglr ServerTrustGroupListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ServerTrustGroupListResultIterator provides access to a complete listing of ServerTrustGroup values. +type ServerTrustGroupListResultIterator struct { + i int + page ServerTrustGroupListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *ServerTrustGroupListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerTrustGroupListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ServerTrustGroupListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ServerTrustGroupListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter ServerTrustGroupListResultIterator) Response() ServerTrustGroupListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter ServerTrustGroupListResultIterator) Value() ServerTrustGroup { + if !iter.page.NotDone() { + return ServerTrustGroup{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ServerTrustGroupListResultIterator type. +func NewServerTrustGroupListResultIterator(page ServerTrustGroupListResultPage) ServerTrustGroupListResultIterator { + return ServerTrustGroupListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (stglr ServerTrustGroupListResult) IsEmpty() bool { + return stglr.Value == nil || len(*stglr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (stglr ServerTrustGroupListResult) hasNextLink() bool { + return stglr.NextLink != nil && len(*stglr.NextLink) != 0 +} + +// serverTrustGroupListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (stglr ServerTrustGroupListResult) serverTrustGroupListResultPreparer(ctx context.Context) (*http.Request, error) { + if !stglr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(stglr.NextLink))) +} + +// ServerTrustGroupListResultPage contains a page of ServerTrustGroup values. +type ServerTrustGroupListResultPage struct { + fn func(context.Context, ServerTrustGroupListResult) (ServerTrustGroupListResult, error) + stglr ServerTrustGroupListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *ServerTrustGroupListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerTrustGroupListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.stglr) + if err != nil { + return err + } + page.stglr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *ServerTrustGroupListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ServerTrustGroupListResultPage) NotDone() bool { + return !page.stglr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ServerTrustGroupListResultPage) Response() ServerTrustGroupListResult { + return page.stglr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ServerTrustGroupListResultPage) Values() []ServerTrustGroup { + if page.stglr.IsEmpty() { + return nil + } + return *page.stglr.Value +} + +// Creates a new instance of the ServerTrustGroupListResultPage type. +func NewServerTrustGroupListResultPage(cur ServerTrustGroupListResult, getNextPage func(context.Context, ServerTrustGroupListResult) (ServerTrustGroupListResult, error)) ServerTrustGroupListResultPage { + return ServerTrustGroupListResultPage{ + fn: getNextPage, + stglr: cur, + } +} + +// ServerTrustGroupProperties properties of a server trust group. +type ServerTrustGroupProperties struct { + // GroupMembers - Group members information for the server trust group. + GroupMembers *[]ServerInfo `json:"groupMembers,omitempty"` + // TrustScopes - Trust scope of the server trust group. + TrustScopes *[]string `json:"trustScopes,omitempty"` +} + +// ServerTrustGroupsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type ServerTrustGroupsCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ServerTrustGroupsClient) (ServerTrustGroup, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ServerTrustGroupsCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ServerTrustGroupsCreateOrUpdateFuture.Result. +func (future *ServerTrustGroupsCreateOrUpdateFuture) result(client ServerTrustGroupsClient) (stg ServerTrustGroup, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerTrustGroupsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + stg.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ServerTrustGroupsCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if stg.Response.Response, err = future.GetResult(sender); err == nil && stg.Response.Response.StatusCode != http.StatusNoContent { + stg, err = client.CreateOrUpdateResponder(stg.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerTrustGroupsCreateOrUpdateFuture", "Result", stg.Response.Response, "Failure responding to request") + } + } + return +} + +// ServerTrustGroupsDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ServerTrustGroupsDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ServerTrustGroupsClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ServerTrustGroupsDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ServerTrustGroupsDeleteFuture.Result. +func (future *ServerTrustGroupsDeleteFuture) result(client ServerTrustGroupsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerTrustGroupsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.ServerTrustGroupsDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// ServerUpdate an update request for an Azure SQL Database server. +type ServerUpdate struct { + // Identity - Server identity + Identity *ResourceIdentity `json:"identity,omitempty"` + // 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.Identity != nil { + objectMap["identity"] = su.Identity + } + 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 "identity": + if v != nil { + var identity ResourceIdentity + err = json.Unmarshal(*v, &identity) + if err != nil { + return err + } + su.Identity = &identity + } + case "properties": + if v != nil { + var serverProperties ServerProperties + err = json.Unmarshal(*v, &serverProperties) + if err != nil { + return err + } + su.ServerProperties = &serverProperties + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + su.Tags = tags + } + } + } + + return nil +} + +// ServerUsage represents server metrics. +type ServerUsage struct { + // Name - READ-ONLY; Name of the server usage metric. + Name *string `json:"name,omitempty"` + // ResourceName - READ-ONLY; The name of the resource. + ResourceName *string `json:"resourceName,omitempty"` + // DisplayName - READ-ONLY; The metric display name. + DisplayName *string `json:"displayName,omitempty"` + // CurrentValue - READ-ONLY; The current value of the metric. + CurrentValue *float64 `json:"currentValue,omitempty"` + // Limit - READ-ONLY; The current limit of the metric. + Limit *float64 `json:"limit,omitempty"` + // Unit - READ-ONLY; The units of the metric. + Unit *string `json:"unit,omitempty"` + // NextResetTime - READ-ONLY; The next reset time for the metric (ISO8601 format). + NextResetTime *date.Time `json:"nextResetTime,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServerUsage. +func (su ServerUsage) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ServerUsageListResult represents the response to a list server metrics request. +type ServerUsageListResult struct { + autorest.Response `json:"-"` + // Value - The list of server metrics for the server. + Value *[]ServerUsage `json:"value,omitempty"` +} + +// ServerVersionCapability the server capability +type ServerVersionCapability struct { + // Name - READ-ONLY; The server version name. + Name *string `json:"name,omitempty"` + // SupportedEditions - READ-ONLY; The list of supported database editions. + SupportedEditions *[]EditionCapability `json:"supportedEditions,omitempty"` + // SupportedElasticPoolEditions - READ-ONLY; The list of supported elastic pool editions. + SupportedElasticPoolEditions *[]ElasticPoolEditionCapability `json:"supportedElasticPoolEditions,omitempty"` + // Status - READ-ONLY; The status of the capability. Possible values include: 'CapabilityStatusVisible', 'CapabilityStatusAvailable', 'CapabilityStatusDefault', 'CapabilityStatusDisabled' + Status CapabilityStatus `json:"status,omitempty"` + // Reason - The reason for the capability not being available. + Reason *string `json:"reason,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServerVersionCapability. +func (svc ServerVersionCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if svc.Reason != nil { + objectMap["reason"] = svc.Reason + } + return json.Marshal(objectMap) +} + +// ServerVulnerabilityAssessment a server vulnerability assessment. +type ServerVulnerabilityAssessment struct { + autorest.Response `json:"-"` + // ServerVulnerabilityAssessmentProperties - Resource properties. + *ServerVulnerabilityAssessmentProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServerVulnerabilityAssessment. +func (sva ServerVulnerabilityAssessment) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sva.ServerVulnerabilityAssessmentProperties != nil { + objectMap["properties"] = sva.ServerVulnerabilityAssessmentProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ServerVulnerabilityAssessment struct. +func (sva *ServerVulnerabilityAssessment) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var serverVulnerabilityAssessmentProperties ServerVulnerabilityAssessmentProperties + err = json.Unmarshal(*v, &serverVulnerabilityAssessmentProperties) + if err != nil { + return err + } + sva.ServerVulnerabilityAssessmentProperties = &serverVulnerabilityAssessmentProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + sva.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + sva.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + sva.Type = &typeVar + } + } + } + + return nil +} + +// ServerVulnerabilityAssessmentListResult a list of the server's vulnerability assessments. +type ServerVulnerabilityAssessmentListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]ServerVulnerabilityAssessment `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServerVulnerabilityAssessmentListResult. +func (svalr ServerVulnerabilityAssessmentListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ServerVulnerabilityAssessmentListResultIterator provides access to a complete listing of +// ServerVulnerabilityAssessment values. +type ServerVulnerabilityAssessmentListResultIterator struct { + i int + page ServerVulnerabilityAssessmentListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *ServerVulnerabilityAssessmentListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerVulnerabilityAssessmentListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ServerVulnerabilityAssessmentListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ServerVulnerabilityAssessmentListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter ServerVulnerabilityAssessmentListResultIterator) Response() ServerVulnerabilityAssessmentListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter ServerVulnerabilityAssessmentListResultIterator) Value() ServerVulnerabilityAssessment { + if !iter.page.NotDone() { + return ServerVulnerabilityAssessment{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ServerVulnerabilityAssessmentListResultIterator type. +func NewServerVulnerabilityAssessmentListResultIterator(page ServerVulnerabilityAssessmentListResultPage) ServerVulnerabilityAssessmentListResultIterator { + return ServerVulnerabilityAssessmentListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (svalr ServerVulnerabilityAssessmentListResult) IsEmpty() bool { + return svalr.Value == nil || len(*svalr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (svalr ServerVulnerabilityAssessmentListResult) hasNextLink() bool { + return svalr.NextLink != nil && len(*svalr.NextLink) != 0 +} + +// serverVulnerabilityAssessmentListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (svalr ServerVulnerabilityAssessmentListResult) serverVulnerabilityAssessmentListResultPreparer(ctx context.Context) (*http.Request, error) { + if !svalr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(svalr.NextLink))) +} + +// ServerVulnerabilityAssessmentListResultPage contains a page of ServerVulnerabilityAssessment values. +type ServerVulnerabilityAssessmentListResultPage struct { + fn func(context.Context, ServerVulnerabilityAssessmentListResult) (ServerVulnerabilityAssessmentListResult, error) + svalr ServerVulnerabilityAssessmentListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *ServerVulnerabilityAssessmentListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerVulnerabilityAssessmentListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.svalr) + if err != nil { + return err + } + page.svalr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *ServerVulnerabilityAssessmentListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ServerVulnerabilityAssessmentListResultPage) NotDone() bool { + return !page.svalr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ServerVulnerabilityAssessmentListResultPage) Response() ServerVulnerabilityAssessmentListResult { + return page.svalr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ServerVulnerabilityAssessmentListResultPage) Values() []ServerVulnerabilityAssessment { + if page.svalr.IsEmpty() { + return nil + } + return *page.svalr.Value +} + +// Creates a new instance of the ServerVulnerabilityAssessmentListResultPage type. +func NewServerVulnerabilityAssessmentListResultPage(cur ServerVulnerabilityAssessmentListResult, getNextPage func(context.Context, ServerVulnerabilityAssessmentListResult) (ServerVulnerabilityAssessmentListResult, error)) ServerVulnerabilityAssessmentListResultPage { + return ServerVulnerabilityAssessmentListResultPage{ + fn: getNextPage, + svalr: cur, + } +} + +// ServerVulnerabilityAssessmentProperties properties of a server Vulnerability Assessment. +type ServerVulnerabilityAssessmentProperties struct { + // StorageContainerPath - A blob storage container path to hold the scan results (e.g. https://myStorage.blob.core.windows.net/VaScans/). + StorageContainerPath *string `json:"storageContainerPath,omitempty"` + // StorageContainerSasKey - A shared access signature (SAS Key) that has write access to the blob container specified in 'storageContainerPath' parameter. If 'storageAccountAccessKey' isn't specified, StorageContainerSasKey is required. Applies only if the storage account is not behind a Vnet or a firewall + StorageContainerSasKey *string `json:"storageContainerSasKey,omitempty"` + // StorageAccountAccessKey - Specifies the identifier key of the storage account for vulnerability assessment scan results. If 'StorageContainerSasKey' isn't specified, storageAccountAccessKey is required. Applies only if the storage account is not behind a Vnet or a firewall + StorageAccountAccessKey *string `json:"storageAccountAccessKey,omitempty"` + // RecurringScans - The recurring scans settings + RecurringScans *VulnerabilityAssessmentRecurringScansProperties `json:"recurringScans,omitempty"` +} + +// ServiceObjective represents a database service objective. +type ServiceObjective struct { + autorest.Response `json:"-"` + // ServiceObjectiveProperties - Represents the properties of the resource. + *ServiceObjectiveProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServiceObjective. +func (so ServiceObjective) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if so.ServiceObjectiveProperties != nil { + objectMap["properties"] = so.ServiceObjectiveProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ServiceObjective struct. +func (so *ServiceObjective) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var serviceObjectiveProperties ServiceObjectiveProperties + err = json.Unmarshal(*v, &serviceObjectiveProperties) + if err != nil { + return err + } + so.ServiceObjectiveProperties = &serviceObjectiveProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + so.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + so.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + so.Type = &typeVar + } + } + } + + return nil +} + +// ServiceObjectiveCapability the service objectives capability. +type ServiceObjectiveCapability struct { + // ID - READ-ONLY; The unique ID of the service objective. + ID *uuid.UUID `json:"id,omitempty"` + // Name - READ-ONLY; The service objective name. + Name *string `json:"name,omitempty"` + // SupportedMaxSizes - READ-ONLY; The list of supported maximum database sizes. + SupportedMaxSizes *[]MaxSizeRangeCapability `json:"supportedMaxSizes,omitempty"` + // PerformanceLevel - READ-ONLY; The performance level. + PerformanceLevel *PerformanceLevelCapability `json:"performanceLevel,omitempty"` + // Sku - READ-ONLY; The sku. + Sku *Sku `json:"sku,omitempty"` + // SupportedLicenseTypes - READ-ONLY; List of supported license types. + SupportedLicenseTypes *[]LicenseTypeCapability `json:"supportedLicenseTypes,omitempty"` + // IncludedMaxSize - READ-ONLY; The included (free) max size. + IncludedMaxSize *MaxSizeCapability `json:"includedMaxSize,omitempty"` + // ZoneRedundant - READ-ONLY; Whether or not zone redundancy is supported for the service objective. + ZoneRedundant *bool `json:"zoneRedundant,omitempty"` + // SupportedAutoPauseDelay - READ-ONLY; Supported time range for auto pause delay + SupportedAutoPauseDelay *AutoPauseDelayTimeRange `json:"supportedAutoPauseDelay,omitempty"` + // SupportedMinCapacities - READ-ONLY; List of supported min capacities + SupportedMinCapacities *[]MinCapacityCapability `json:"supportedMinCapacities,omitempty"` + // ComputeModel - READ-ONLY; The compute model + ComputeModel *string `json:"computeModel,omitempty"` + // SupportedMaintenanceConfigurations - READ-ONLY; List of supported maintenance configurations + SupportedMaintenanceConfigurations *[]MaintenanceConfigurationCapability `json:"supportedMaintenanceConfigurations,omitempty"` + // Status - READ-ONLY; The status of the capability. Possible values include: 'CapabilityStatusVisible', 'CapabilityStatusAvailable', 'CapabilityStatusDefault', 'CapabilityStatusDisabled' + Status CapabilityStatus `json:"status,omitempty"` + // Reason - The reason for the capability not being available. + Reason *string `json:"reason,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServiceObjectiveCapability. +func (soc ServiceObjectiveCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if soc.Reason != nil { + objectMap["reason"] = soc.Reason + } + return json.Marshal(objectMap) +} + +// ServiceObjectiveListResult represents the response to a get database service objectives request. +type ServiceObjectiveListResult struct { + autorest.Response `json:"-"` + // Value - The list of database service objectives. + Value *[]ServiceObjective `json:"value,omitempty"` +} + +// ServiceObjectiveProperties represents the properties of a database service objective. +type ServiceObjectiveProperties struct { + // ServiceObjectiveName - READ-ONLY; The name for the service objective. + ServiceObjectiveName *string `json:"serviceObjectiveName,omitempty"` + // IsDefault - READ-ONLY; Gets whether the service level objective is the default service objective. + IsDefault *bool `json:"isDefault,omitempty"` + // IsSystem - READ-ONLY; Gets whether the service level objective is a system service objective. + IsSystem *bool `json:"isSystem,omitempty"` + // Description - READ-ONLY; The description for the service level objective. + Description *string `json:"description,omitempty"` + // Enabled - READ-ONLY; Gets whether the service level objective is enabled. + Enabled *bool `json:"enabled,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServiceObjectiveProperties. +func (sop ServiceObjectiveProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// Sku an ARM Resource SKU. +type Sku struct { + // Name - The name of the SKU, typically, a letter + Number code, e.g. P3. + Name *string `json:"name,omitempty"` + // Tier - The tier or edition of the particular SKU, e.g. Basic, Premium. + Tier *string `json:"tier,omitempty"` + // Size - Size of the particular SKU + Size *string `json:"size,omitempty"` + // Family - If the service has different generations of hardware, for the same SKU, then that can be captured here. + Family *string `json:"family,omitempty"` + // Capacity - Capacity of the particular SKU. + Capacity *int32 `json:"capacity,omitempty"` +} + +// SloUsageMetric a Slo Usage Metric. +type SloUsageMetric struct { + // ServiceLevelObjective - READ-ONLY; The serviceLevelObjective for SLO usage metric. Possible values include: 'ServiceObjectiveNameSystem', 'ServiceObjectiveNameSystem0', 'ServiceObjectiveNameSystem1', 'ServiceObjectiveNameSystem2', 'ServiceObjectiveNameSystem3', 'ServiceObjectiveNameSystem4', 'ServiceObjectiveNameSystem2L', 'ServiceObjectiveNameSystem3L', 'ServiceObjectiveNameSystem4L', 'ServiceObjectiveNameFree', 'ServiceObjectiveNameBasic', 'ServiceObjectiveNameS0', 'ServiceObjectiveNameS1', 'ServiceObjectiveNameS2', 'ServiceObjectiveNameS3', 'ServiceObjectiveNameS4', 'ServiceObjectiveNameS6', 'ServiceObjectiveNameS7', 'ServiceObjectiveNameS9', 'ServiceObjectiveNameS12', 'ServiceObjectiveNameP1', 'ServiceObjectiveNameP2', 'ServiceObjectiveNameP3', 'ServiceObjectiveNameP4', 'ServiceObjectiveNameP6', 'ServiceObjectiveNameP11', 'ServiceObjectiveNameP15', 'ServiceObjectiveNamePRS1', 'ServiceObjectiveNamePRS2', 'ServiceObjectiveNamePRS4', 'ServiceObjectiveNamePRS6', 'ServiceObjectiveNameDW100', 'ServiceObjectiveNameDW200', 'ServiceObjectiveNameDW300', 'ServiceObjectiveNameDW400', 'ServiceObjectiveNameDW500', 'ServiceObjectiveNameDW600', 'ServiceObjectiveNameDW1000', 'ServiceObjectiveNameDW1200', 'ServiceObjectiveNameDW1000c', 'ServiceObjectiveNameDW1500', 'ServiceObjectiveNameDW1500c', 'ServiceObjectiveNameDW2000', 'ServiceObjectiveNameDW2000c', 'ServiceObjectiveNameDW3000', 'ServiceObjectiveNameDW2500c', 'ServiceObjectiveNameDW3000c', 'ServiceObjectiveNameDW6000', 'ServiceObjectiveNameDW5000c', 'ServiceObjectiveNameDW6000c', 'ServiceObjectiveNameDW7500c', 'ServiceObjectiveNameDW10000c', 'ServiceObjectiveNameDW15000c', 'ServiceObjectiveNameDW30000c', 'ServiceObjectiveNameDS100', 'ServiceObjectiveNameDS200', 'ServiceObjectiveNameDS300', 'ServiceObjectiveNameDS400', 'ServiceObjectiveNameDS500', 'ServiceObjectiveNameDS600', 'ServiceObjectiveNameDS1000', 'ServiceObjectiveNameDS1200', 'ServiceObjectiveNameDS1500', 'ServiceObjectiveNameDS2000', 'ServiceObjectiveNameElasticPool' + ServiceLevelObjective ServiceObjectiveName `json:"serviceLevelObjective,omitempty"` + // ServiceLevelObjectiveID - READ-ONLY; The serviceLevelObjectiveId for SLO usage metric. + ServiceLevelObjectiveID *uuid.UUID `json:"serviceLevelObjectiveId,omitempty"` + // InRangeTimeRatio - READ-ONLY; Gets or sets inRangeTimeRatio for SLO usage metric. + InRangeTimeRatio *float64 `json:"inRangeTimeRatio,omitempty"` +} + +// MarshalJSON is the custom marshaler for SloUsageMetric. +func (sum SloUsageMetric) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// StorageCapability the storage account type capability. +type StorageCapability struct { + // StorageAccountType - READ-ONLY; The storage account type for the database's backups. Possible values include: 'StorageAccountType1GRS', 'StorageAccountType1LRS', 'StorageAccountType1ZRS' + StorageAccountType StorageAccountType1 `json:"storageAccountType,omitempty"` + // Status - READ-ONLY; The status of the capability. Possible values include: 'CapabilityStatusVisible', 'CapabilityStatusAvailable', 'CapabilityStatusDefault', 'CapabilityStatusDisabled' + Status CapabilityStatus `json:"status,omitempty"` + // Reason - The reason for the capability not being available. + Reason *string `json:"reason,omitempty"` +} + +// MarshalJSON is the custom marshaler for StorageCapability. +func (sc StorageCapability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sc.Reason != nil { + objectMap["reason"] = sc.Reason + } + return json.Marshal(objectMap) +} + +// SubscriptionUsage usage Metric of a Subscription in a Location. +type SubscriptionUsage struct { + autorest.Response `json:"-"` + // SubscriptionUsageProperties - Resource properties. + *SubscriptionUsageProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for SubscriptionUsage. +func (su SubscriptionUsage) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if su.SubscriptionUsageProperties != nil { + objectMap["properties"] = su.SubscriptionUsageProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for SubscriptionUsage struct. +func (su *SubscriptionUsage) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var subscriptionUsageProperties SubscriptionUsageProperties + err = json.Unmarshal(*v, &subscriptionUsageProperties) + if err != nil { + return err + } + su.SubscriptionUsageProperties = &subscriptionUsageProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + su.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + su.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + su.Type = &typeVar + } + } + } + + return nil +} + +// SubscriptionUsageListResult a list of subscription usage metrics in a location. +type SubscriptionUsageListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]SubscriptionUsage `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for SubscriptionUsageListResult. +func (sulr SubscriptionUsageListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// SubscriptionUsageListResultIterator provides access to a complete listing of SubscriptionUsage values. +type SubscriptionUsageListResultIterator struct { + i int + page SubscriptionUsageListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *SubscriptionUsageListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SubscriptionUsageListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *SubscriptionUsageListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter SubscriptionUsageListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter SubscriptionUsageListResultIterator) Response() SubscriptionUsageListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter SubscriptionUsageListResultIterator) Value() SubscriptionUsage { + if !iter.page.NotDone() { + return SubscriptionUsage{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the SubscriptionUsageListResultIterator type. +func NewSubscriptionUsageListResultIterator(page SubscriptionUsageListResultPage) SubscriptionUsageListResultIterator { + return SubscriptionUsageListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (sulr SubscriptionUsageListResult) IsEmpty() bool { + return sulr.Value == nil || len(*sulr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (sulr SubscriptionUsageListResult) hasNextLink() bool { + return sulr.NextLink != nil && len(*sulr.NextLink) != 0 +} + +// subscriptionUsageListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (sulr SubscriptionUsageListResult) subscriptionUsageListResultPreparer(ctx context.Context) (*http.Request, error) { + if !sulr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(sulr.NextLink))) +} + +// SubscriptionUsageListResultPage contains a page of SubscriptionUsage values. +type SubscriptionUsageListResultPage struct { + fn func(context.Context, SubscriptionUsageListResult) (SubscriptionUsageListResult, error) + sulr SubscriptionUsageListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *SubscriptionUsageListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SubscriptionUsageListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.sulr) + if err != nil { + return err + } + page.sulr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *SubscriptionUsageListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page SubscriptionUsageListResultPage) NotDone() bool { + return !page.sulr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page SubscriptionUsageListResultPage) Response() SubscriptionUsageListResult { + return page.sulr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page SubscriptionUsageListResultPage) Values() []SubscriptionUsage { + if page.sulr.IsEmpty() { + return nil + } + return *page.sulr.Value +} + +// Creates a new instance of the SubscriptionUsageListResultPage type. +func NewSubscriptionUsageListResultPage(cur SubscriptionUsageListResult, getNextPage func(context.Context, SubscriptionUsageListResult) (SubscriptionUsageListResult, error)) SubscriptionUsageListResultPage { + return SubscriptionUsageListResultPage{ + fn: getNextPage, + sulr: cur, + } +} + +// SubscriptionUsageProperties properties of a subscription usage. +type SubscriptionUsageProperties struct { + // DisplayName - READ-ONLY; User-readable name of the metric. + DisplayName *string `json:"displayName,omitempty"` + // CurrentValue - READ-ONLY; Current value of the metric. + CurrentValue *float64 `json:"currentValue,omitempty"` + // Limit - READ-ONLY; Boundary value of the metric. + Limit *float64 `json:"limit,omitempty"` + // Unit - READ-ONLY; Unit of the metric. + Unit *string `json:"unit,omitempty"` +} + +// MarshalJSON is the custom marshaler for SubscriptionUsageProperties. +func (sup SubscriptionUsageProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// SyncAgent an Azure SQL Database sync agent. +type SyncAgent struct { + autorest.Response `json:"-"` + // SyncAgentProperties - Resource properties. + *SyncAgentProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for SyncAgent. +func (sa SyncAgent) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sa.SyncAgentProperties != nil { + objectMap["properties"] = sa.SyncAgentProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for SyncAgent struct. +func (sa *SyncAgent) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var syncAgentProperties SyncAgentProperties + err = json.Unmarshal(*v, &syncAgentProperties) + if err != nil { + return err + } + sa.SyncAgentProperties = &syncAgentProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + sa.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + sa.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + sa.Type = &typeVar + } + } + } + + return nil +} + +// SyncAgentKeyProperties properties of an Azure SQL Database sync agent key. +type SyncAgentKeyProperties struct { + autorest.Response `json:"-"` + // SyncAgentKey - READ-ONLY; Key of sync agent. + SyncAgentKey *string `json:"syncAgentKey,omitempty"` +} + +// MarshalJSON is the custom marshaler for SyncAgentKeyProperties. +func (sakp SyncAgentKeyProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// SyncAgentLinkedDatabase an Azure SQL Database sync agent linked database. +type SyncAgentLinkedDatabase struct { + // SyncAgentLinkedDatabaseProperties - Resource properties. + *SyncAgentLinkedDatabaseProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for SyncAgentLinkedDatabase. +func (sald SyncAgentLinkedDatabase) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sald.SyncAgentLinkedDatabaseProperties != nil { + objectMap["properties"] = sald.SyncAgentLinkedDatabaseProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for SyncAgentLinkedDatabase struct. +func (sald *SyncAgentLinkedDatabase) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var syncAgentLinkedDatabaseProperties SyncAgentLinkedDatabaseProperties + err = json.Unmarshal(*v, &syncAgentLinkedDatabaseProperties) + if err != nil { + return err + } + sald.SyncAgentLinkedDatabaseProperties = &syncAgentLinkedDatabaseProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + sald.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + sald.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + sald.Type = &typeVar + } + } + } + + return nil +} + +// SyncAgentLinkedDatabaseListResult a list of sync agent linked databases. +type SyncAgentLinkedDatabaseListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]SyncAgentLinkedDatabase `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for SyncAgentLinkedDatabaseListResult. +func (saldlr SyncAgentLinkedDatabaseListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// SyncAgentLinkedDatabaseListResultIterator provides access to a complete listing of +// SyncAgentLinkedDatabase values. +type SyncAgentLinkedDatabaseListResultIterator struct { + i int + page SyncAgentLinkedDatabaseListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *SyncAgentLinkedDatabaseListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncAgentLinkedDatabaseListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *SyncAgentLinkedDatabaseListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter SyncAgentLinkedDatabaseListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter SyncAgentLinkedDatabaseListResultIterator) Response() SyncAgentLinkedDatabaseListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter SyncAgentLinkedDatabaseListResultIterator) Value() SyncAgentLinkedDatabase { + if !iter.page.NotDone() { + return SyncAgentLinkedDatabase{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the SyncAgentLinkedDatabaseListResultIterator type. +func NewSyncAgentLinkedDatabaseListResultIterator(page SyncAgentLinkedDatabaseListResultPage) SyncAgentLinkedDatabaseListResultIterator { + return SyncAgentLinkedDatabaseListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (saldlr SyncAgentLinkedDatabaseListResult) IsEmpty() bool { + return saldlr.Value == nil || len(*saldlr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (saldlr SyncAgentLinkedDatabaseListResult) hasNextLink() bool { + return saldlr.NextLink != nil && len(*saldlr.NextLink) != 0 +} + +// syncAgentLinkedDatabaseListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (saldlr SyncAgentLinkedDatabaseListResult) syncAgentLinkedDatabaseListResultPreparer(ctx context.Context) (*http.Request, error) { + if !saldlr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(saldlr.NextLink))) +} + +// SyncAgentLinkedDatabaseListResultPage contains a page of SyncAgentLinkedDatabase values. +type SyncAgentLinkedDatabaseListResultPage struct { + fn func(context.Context, SyncAgentLinkedDatabaseListResult) (SyncAgentLinkedDatabaseListResult, error) + saldlr SyncAgentLinkedDatabaseListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *SyncAgentLinkedDatabaseListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncAgentLinkedDatabaseListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.saldlr) + if err != nil { + return err + } + page.saldlr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *SyncAgentLinkedDatabaseListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page SyncAgentLinkedDatabaseListResultPage) NotDone() bool { + return !page.saldlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page SyncAgentLinkedDatabaseListResultPage) Response() SyncAgentLinkedDatabaseListResult { + return page.saldlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page SyncAgentLinkedDatabaseListResultPage) Values() []SyncAgentLinkedDatabase { + if page.saldlr.IsEmpty() { + return nil + } + return *page.saldlr.Value +} + +// Creates a new instance of the SyncAgentLinkedDatabaseListResultPage type. +func NewSyncAgentLinkedDatabaseListResultPage(cur SyncAgentLinkedDatabaseListResult, getNextPage func(context.Context, SyncAgentLinkedDatabaseListResult) (SyncAgentLinkedDatabaseListResult, error)) SyncAgentLinkedDatabaseListResultPage { + return SyncAgentLinkedDatabaseListResultPage{ + fn: getNextPage, + saldlr: cur, + } +} + +// SyncAgentLinkedDatabaseProperties properties of an Azure SQL Database sync agent linked database. +type SyncAgentLinkedDatabaseProperties struct { + // DatabaseType - READ-ONLY; Type of the sync agent linked database. Possible values include: 'SyncMemberDbTypeAzureSQLDatabase', 'SyncMemberDbTypeSQLServerDatabase' + DatabaseType SyncMemberDbType `json:"databaseType,omitempty"` + // DatabaseID - READ-ONLY; Id of the sync agent linked database. + DatabaseID *string `json:"databaseId,omitempty"` + // Description - READ-ONLY; Description of the sync agent linked database. + Description *string `json:"description,omitempty"` + // ServerName - READ-ONLY; Server name of the sync agent linked database. + ServerName *string `json:"serverName,omitempty"` + // DatabaseName - READ-ONLY; Database name of the sync agent linked database. + DatabaseName *string `json:"databaseName,omitempty"` + // UserName - READ-ONLY; User name of the sync agent linked database. + UserName *string `json:"userName,omitempty"` +} + +// MarshalJSON is the custom marshaler for SyncAgentLinkedDatabaseProperties. +func (saldp SyncAgentLinkedDatabaseProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// SyncAgentListResult a list of sync agents. +type SyncAgentListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]SyncAgent `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for SyncAgentListResult. +func (salr SyncAgentListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// SyncAgentListResultIterator provides access to a complete listing of SyncAgent values. +type SyncAgentListResultIterator struct { + i int + page SyncAgentListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *SyncAgentListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncAgentListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *SyncAgentListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter SyncAgentListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter SyncAgentListResultIterator) Response() SyncAgentListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter SyncAgentListResultIterator) Value() SyncAgent { + if !iter.page.NotDone() { + return SyncAgent{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the SyncAgentListResultIterator type. +func NewSyncAgentListResultIterator(page SyncAgentListResultPage) SyncAgentListResultIterator { + return SyncAgentListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (salr SyncAgentListResult) IsEmpty() bool { + return salr.Value == nil || len(*salr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (salr SyncAgentListResult) hasNextLink() bool { + return salr.NextLink != nil && len(*salr.NextLink) != 0 +} + +// syncAgentListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (salr SyncAgentListResult) syncAgentListResultPreparer(ctx context.Context) (*http.Request, error) { + if !salr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(salr.NextLink))) +} + +// SyncAgentListResultPage contains a page of SyncAgent values. +type SyncAgentListResultPage struct { + fn func(context.Context, SyncAgentListResult) (SyncAgentListResult, error) + salr SyncAgentListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *SyncAgentListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncAgentListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.salr) + if err != nil { + return err + } + page.salr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *SyncAgentListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page SyncAgentListResultPage) NotDone() bool { + return !page.salr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page SyncAgentListResultPage) Response() SyncAgentListResult { + return page.salr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page SyncAgentListResultPage) Values() []SyncAgent { + if page.salr.IsEmpty() { + return nil + } + return *page.salr.Value +} + +// Creates a new instance of the SyncAgentListResultPage type. +func NewSyncAgentListResultPage(cur SyncAgentListResult, getNextPage func(context.Context, SyncAgentListResult) (SyncAgentListResult, error)) SyncAgentListResultPage { + return SyncAgentListResultPage{ + fn: getNextPage, + salr: cur, + } +} + +// SyncAgentProperties properties of an Azure SQL Database sync agent. +type SyncAgentProperties struct { + // Name - READ-ONLY; Name of the sync agent. + Name *string `json:"name,omitempty"` + // SyncDatabaseID - ARM resource id of the sync database in the sync agent. + SyncDatabaseID *string `json:"syncDatabaseId,omitempty"` + // LastAliveTime - READ-ONLY; Last alive time of the sync agent. + LastAliveTime *date.Time `json:"lastAliveTime,omitempty"` + // State - READ-ONLY; State of the sync agent. Possible values include: 'SyncAgentStateOnline', 'SyncAgentStateOffline', 'SyncAgentStateNeverConnected' + State SyncAgentState `json:"state,omitempty"` + // IsUpToDate - READ-ONLY; If the sync agent version is up to date. + IsUpToDate *bool `json:"isUpToDate,omitempty"` + // ExpiryTime - READ-ONLY; Expiration time of the sync agent version. + ExpiryTime *date.Time `json:"expiryTime,omitempty"` + // Version - READ-ONLY; Version of the sync agent. + Version *string `json:"version,omitempty"` +} + +// MarshalJSON is the custom marshaler for SyncAgentProperties. +func (sap SyncAgentProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sap.SyncDatabaseID != nil { + objectMap["syncDatabaseId"] = sap.SyncDatabaseID + } + return json.Marshal(objectMap) +} + +// SyncAgentsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type SyncAgentsCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(SyncAgentsClient) (SyncAgent, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *SyncAgentsCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for SyncAgentsCreateOrUpdateFuture.Result. +func (future *SyncAgentsCreateOrUpdateFuture) result(client SyncAgentsClient) (sa SyncAgent, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncAgentsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + sa.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.SyncAgentsCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if sa.Response.Response, err = future.GetResult(sender); err == nil && sa.Response.Response.StatusCode != http.StatusNoContent { + sa, err = client.CreateOrUpdateResponder(sa.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncAgentsCreateOrUpdateFuture", "Result", sa.Response.Response, "Failure responding to request") + } + } + return +} + +// SyncAgentsDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type SyncAgentsDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(SyncAgentsClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *SyncAgentsDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for SyncAgentsDeleteFuture.Result. +func (future *SyncAgentsDeleteFuture) result(client SyncAgentsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncAgentsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.SyncAgentsDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// SyncDatabaseIDListResult a list of sync database ID properties. +type SyncDatabaseIDListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]SyncDatabaseIDProperties `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for SyncDatabaseIDListResult. +func (sdilr SyncDatabaseIDListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// SyncDatabaseIDListResultIterator provides access to a complete listing of SyncDatabaseIDProperties +// values. +type SyncDatabaseIDListResultIterator struct { + i int + page SyncDatabaseIDListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *SyncDatabaseIDListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncDatabaseIDListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *SyncDatabaseIDListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter SyncDatabaseIDListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter SyncDatabaseIDListResultIterator) Response() SyncDatabaseIDListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter SyncDatabaseIDListResultIterator) Value() SyncDatabaseIDProperties { + if !iter.page.NotDone() { + return SyncDatabaseIDProperties{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the SyncDatabaseIDListResultIterator type. +func NewSyncDatabaseIDListResultIterator(page SyncDatabaseIDListResultPage) SyncDatabaseIDListResultIterator { + return SyncDatabaseIDListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (sdilr SyncDatabaseIDListResult) IsEmpty() bool { + return sdilr.Value == nil || len(*sdilr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (sdilr SyncDatabaseIDListResult) hasNextLink() bool { + return sdilr.NextLink != nil && len(*sdilr.NextLink) != 0 +} + +// syncDatabaseIDListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (sdilr SyncDatabaseIDListResult) syncDatabaseIDListResultPreparer(ctx context.Context) (*http.Request, error) { + if !sdilr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(sdilr.NextLink))) +} + +// SyncDatabaseIDListResultPage contains a page of SyncDatabaseIDProperties values. +type SyncDatabaseIDListResultPage struct { + fn func(context.Context, SyncDatabaseIDListResult) (SyncDatabaseIDListResult, error) + sdilr SyncDatabaseIDListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *SyncDatabaseIDListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncDatabaseIDListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.sdilr) + if err != nil { + return err + } + page.sdilr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *SyncDatabaseIDListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page SyncDatabaseIDListResultPage) NotDone() bool { + return !page.sdilr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page SyncDatabaseIDListResultPage) Response() SyncDatabaseIDListResult { + return page.sdilr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page SyncDatabaseIDListResultPage) Values() []SyncDatabaseIDProperties { + if page.sdilr.IsEmpty() { + return nil + } + return *page.sdilr.Value +} + +// Creates a new instance of the SyncDatabaseIDListResultPage type. +func NewSyncDatabaseIDListResultPage(cur SyncDatabaseIDListResult, getNextPage func(context.Context, SyncDatabaseIDListResult) (SyncDatabaseIDListResult, error)) SyncDatabaseIDListResultPage { + return SyncDatabaseIDListResultPage{ + fn: getNextPage, + sdilr: cur, + } +} + +// SyncDatabaseIDProperties properties of the sync database id. +type SyncDatabaseIDProperties struct { + // ID - READ-ONLY; ARM resource id of sync database. + ID *string `json:"id,omitempty"` +} + +// MarshalJSON is the custom marshaler for SyncDatabaseIDProperties. +func (sdip SyncDatabaseIDProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// SyncFullSchemaProperties properties of the database full schema. +type SyncFullSchemaProperties struct { + // Tables - READ-ONLY; List of tables in the database full schema. + Tables *[]SyncFullSchemaTable `json:"tables,omitempty"` + // LastUpdateTime - READ-ONLY; Last update time of the database schema. + LastUpdateTime *date.Time `json:"lastUpdateTime,omitempty"` +} + +// MarshalJSON is the custom marshaler for SyncFullSchemaProperties. +func (sfsp SyncFullSchemaProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// SyncFullSchemaPropertiesListResult a list of sync schema properties. +type SyncFullSchemaPropertiesListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]SyncFullSchemaProperties `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for SyncFullSchemaPropertiesListResult. +func (sfsplr SyncFullSchemaPropertiesListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// SyncFullSchemaPropertiesListResultIterator provides access to a complete listing of +// SyncFullSchemaProperties values. +type SyncFullSchemaPropertiesListResultIterator struct { + i int + page SyncFullSchemaPropertiesListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *SyncFullSchemaPropertiesListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncFullSchemaPropertiesListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *SyncFullSchemaPropertiesListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter SyncFullSchemaPropertiesListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter SyncFullSchemaPropertiesListResultIterator) Response() SyncFullSchemaPropertiesListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter SyncFullSchemaPropertiesListResultIterator) Value() SyncFullSchemaProperties { + if !iter.page.NotDone() { + return SyncFullSchemaProperties{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the SyncFullSchemaPropertiesListResultIterator type. +func NewSyncFullSchemaPropertiesListResultIterator(page SyncFullSchemaPropertiesListResultPage) SyncFullSchemaPropertiesListResultIterator { + return SyncFullSchemaPropertiesListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (sfsplr SyncFullSchemaPropertiesListResult) IsEmpty() bool { + return sfsplr.Value == nil || len(*sfsplr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (sfsplr SyncFullSchemaPropertiesListResult) hasNextLink() bool { + return sfsplr.NextLink != nil && len(*sfsplr.NextLink) != 0 +} + +// syncFullSchemaPropertiesListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (sfsplr SyncFullSchemaPropertiesListResult) syncFullSchemaPropertiesListResultPreparer(ctx context.Context) (*http.Request, error) { + if !sfsplr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(sfsplr.NextLink))) +} + +// SyncFullSchemaPropertiesListResultPage contains a page of SyncFullSchemaProperties values. +type SyncFullSchemaPropertiesListResultPage struct { + fn func(context.Context, SyncFullSchemaPropertiesListResult) (SyncFullSchemaPropertiesListResult, error) + sfsplr SyncFullSchemaPropertiesListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *SyncFullSchemaPropertiesListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncFullSchemaPropertiesListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.sfsplr) + if err != nil { + return err + } + page.sfsplr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *SyncFullSchemaPropertiesListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page SyncFullSchemaPropertiesListResultPage) NotDone() bool { + return !page.sfsplr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page SyncFullSchemaPropertiesListResultPage) Response() SyncFullSchemaPropertiesListResult { + return page.sfsplr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page SyncFullSchemaPropertiesListResultPage) Values() []SyncFullSchemaProperties { + if page.sfsplr.IsEmpty() { + return nil + } + return *page.sfsplr.Value +} + +// Creates a new instance of the SyncFullSchemaPropertiesListResultPage type. +func NewSyncFullSchemaPropertiesListResultPage(cur SyncFullSchemaPropertiesListResult, getNextPage func(context.Context, SyncFullSchemaPropertiesListResult) (SyncFullSchemaPropertiesListResult, error)) SyncFullSchemaPropertiesListResultPage { + return SyncFullSchemaPropertiesListResultPage{ + fn: getNextPage, + sfsplr: cur, + } +} + +// SyncFullSchemaTable properties of the table in the database full schema. +type SyncFullSchemaTable struct { + // Columns - READ-ONLY; List of columns in the table of database full schema. + Columns *[]SyncFullSchemaTableColumn `json:"columns,omitempty"` + // ErrorID - READ-ONLY; Error id of the table. + ErrorID *string `json:"errorId,omitempty"` + // HasError - READ-ONLY; If there is error in the table. + HasError *bool `json:"hasError,omitempty"` + // Name - READ-ONLY; Name of the table. + Name *string `json:"name,omitempty"` + // QuotedName - READ-ONLY; Quoted name of the table. + QuotedName *string `json:"quotedName,omitempty"` +} + +// MarshalJSON is the custom marshaler for SyncFullSchemaTable. +func (sfst SyncFullSchemaTable) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// SyncFullSchemaTableColumn properties of the column in the table of database full schema. +type SyncFullSchemaTableColumn struct { + // DataSize - READ-ONLY; Data size of the column. + DataSize *string `json:"dataSize,omitempty"` + // DataType - READ-ONLY; Data type of the column. + DataType *string `json:"dataType,omitempty"` + // ErrorID - READ-ONLY; Error id of the column. + ErrorID *string `json:"errorId,omitempty"` + // HasError - READ-ONLY; If there is error in the table. + HasError *bool `json:"hasError,omitempty"` + // IsPrimaryKey - READ-ONLY; If it is the primary key of the table. + IsPrimaryKey *bool `json:"isPrimaryKey,omitempty"` + // Name - READ-ONLY; Name of the column. + Name *string `json:"name,omitempty"` + // QuotedName - READ-ONLY; Quoted name of the column. + QuotedName *string `json:"quotedName,omitempty"` +} + +// MarshalJSON is the custom marshaler for SyncFullSchemaTableColumn. +func (sfstc SyncFullSchemaTableColumn) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// SyncGroup an Azure SQL Database sync group. +type SyncGroup struct { + autorest.Response `json:"-"` + // Sku - The name and capacity of the SKU. + Sku *Sku `json:"sku,omitempty"` + // SyncGroupProperties - Resource properties. + *SyncGroupProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for SyncGroup. +func (sg SyncGroup) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sg.Sku != nil { + objectMap["sku"] = sg.Sku + } + if sg.SyncGroupProperties != nil { + objectMap["properties"] = sg.SyncGroupProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for SyncGroup struct. +func (sg *SyncGroup) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "sku": + if v != nil { + var sku Sku + err = json.Unmarshal(*v, &sku) + if err != nil { + return err + } + sg.Sku = &sku + } + case "properties": + if v != nil { + var syncGroupProperties SyncGroupProperties + err = json.Unmarshal(*v, &syncGroupProperties) + if err != nil { + return err + } + sg.SyncGroupProperties = &syncGroupProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + sg.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + sg.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + sg.Type = &typeVar + } + } + } + + return nil +} + +// SyncGroupListResult a list of sync groups. +type SyncGroupListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]SyncGroup `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for SyncGroupListResult. +func (sglr SyncGroupListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// SyncGroupListResultIterator provides access to a complete listing of SyncGroup values. +type SyncGroupListResultIterator struct { + i int + page SyncGroupListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *SyncGroupListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncGroupListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *SyncGroupListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter SyncGroupListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter SyncGroupListResultIterator) Response() SyncGroupListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter SyncGroupListResultIterator) Value() SyncGroup { + if !iter.page.NotDone() { + return SyncGroup{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the SyncGroupListResultIterator type. +func NewSyncGroupListResultIterator(page SyncGroupListResultPage) SyncGroupListResultIterator { + return SyncGroupListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (sglr SyncGroupListResult) IsEmpty() bool { + return sglr.Value == nil || len(*sglr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (sglr SyncGroupListResult) hasNextLink() bool { + return sglr.NextLink != nil && len(*sglr.NextLink) != 0 +} + +// syncGroupListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (sglr SyncGroupListResult) syncGroupListResultPreparer(ctx context.Context) (*http.Request, error) { + if !sglr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(sglr.NextLink))) +} + +// SyncGroupListResultPage contains a page of SyncGroup values. +type SyncGroupListResultPage struct { + fn func(context.Context, SyncGroupListResult) (SyncGroupListResult, error) + sglr SyncGroupListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *SyncGroupListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncGroupListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.sglr) + if err != nil { + return err + } + page.sglr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *SyncGroupListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page SyncGroupListResultPage) NotDone() bool { + return !page.sglr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page SyncGroupListResultPage) Response() SyncGroupListResult { + return page.sglr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page SyncGroupListResultPage) Values() []SyncGroup { + if page.sglr.IsEmpty() { + return nil + } + return *page.sglr.Value +} + +// Creates a new instance of the SyncGroupListResultPage type. +func NewSyncGroupListResultPage(cur SyncGroupListResult, getNextPage func(context.Context, SyncGroupListResult) (SyncGroupListResult, error)) SyncGroupListResultPage { + return SyncGroupListResultPage{ + fn: getNextPage, + sglr: cur, + } +} + +// SyncGroupLogListResult a list of sync group log properties. +type SyncGroupLogListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]SyncGroupLogProperties `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for SyncGroupLogListResult. +func (sgllr SyncGroupLogListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// SyncGroupLogListResultIterator provides access to a complete listing of SyncGroupLogProperties values. +type SyncGroupLogListResultIterator struct { + i int + page SyncGroupLogListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *SyncGroupLogListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncGroupLogListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *SyncGroupLogListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter SyncGroupLogListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter SyncGroupLogListResultIterator) Response() SyncGroupLogListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter SyncGroupLogListResultIterator) Value() SyncGroupLogProperties { + if !iter.page.NotDone() { + return SyncGroupLogProperties{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the SyncGroupLogListResultIterator type. +func NewSyncGroupLogListResultIterator(page SyncGroupLogListResultPage) SyncGroupLogListResultIterator { + return SyncGroupLogListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (sgllr SyncGroupLogListResult) IsEmpty() bool { + return sgllr.Value == nil || len(*sgllr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (sgllr SyncGroupLogListResult) hasNextLink() bool { + return sgllr.NextLink != nil && len(*sgllr.NextLink) != 0 +} + +// syncGroupLogListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (sgllr SyncGroupLogListResult) syncGroupLogListResultPreparer(ctx context.Context) (*http.Request, error) { + if !sgllr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(sgllr.NextLink))) +} + +// SyncGroupLogListResultPage contains a page of SyncGroupLogProperties values. +type SyncGroupLogListResultPage struct { + fn func(context.Context, SyncGroupLogListResult) (SyncGroupLogListResult, error) + sgllr SyncGroupLogListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *SyncGroupLogListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncGroupLogListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.sgllr) + if err != nil { + return err + } + page.sgllr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *SyncGroupLogListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page SyncGroupLogListResultPage) NotDone() bool { + return !page.sgllr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page SyncGroupLogListResultPage) Response() SyncGroupLogListResult { + return page.sgllr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page SyncGroupLogListResultPage) Values() []SyncGroupLogProperties { + if page.sgllr.IsEmpty() { + return nil + } + return *page.sgllr.Value +} + +// Creates a new instance of the SyncGroupLogListResultPage type. +func NewSyncGroupLogListResultPage(cur SyncGroupLogListResult, getNextPage func(context.Context, SyncGroupLogListResult) (SyncGroupLogListResult, error)) SyncGroupLogListResultPage { + return SyncGroupLogListResultPage{ + fn: getNextPage, + sgllr: cur, + } +} + +// SyncGroupLogProperties properties of an Azure SQL Database sync group log. +type SyncGroupLogProperties struct { + // Timestamp - READ-ONLY; Timestamp of the sync group log. + Timestamp *date.Time `json:"timestamp,omitempty"` + // Type - READ-ONLY; Type of the sync group log. Possible values include: 'SyncGroupLogTypeAll', 'SyncGroupLogTypeError', 'SyncGroupLogTypeWarning', 'SyncGroupLogTypeSuccess' + Type SyncGroupLogType `json:"type,omitempty"` + // Source - READ-ONLY; Source of the sync group log. + Source *string `json:"source,omitempty"` + // Details - READ-ONLY; Details of the sync group log. + Details *string `json:"details,omitempty"` + // TracingID - READ-ONLY; TracingId of the sync group log. + TracingID *uuid.UUID `json:"tracingId,omitempty"` + // OperationStatus - READ-ONLY; OperationStatus of the sync group log. + OperationStatus *string `json:"operationStatus,omitempty"` +} + +// MarshalJSON is the custom marshaler for SyncGroupLogProperties. +func (sglp SyncGroupLogProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// SyncGroupProperties properties of a sync group. +type SyncGroupProperties struct { + // Interval - Sync interval of the sync group. + Interval *int32 `json:"interval,omitempty"` + // LastSyncTime - READ-ONLY; Last sync time of the sync group. + LastSyncTime *date.Time `json:"lastSyncTime,omitempty"` + // ConflictResolutionPolicy - Conflict resolution policy of the sync group. Possible values include: 'SyncConflictResolutionPolicyHubWin', 'SyncConflictResolutionPolicyMemberWin' + ConflictResolutionPolicy SyncConflictResolutionPolicy `json:"conflictResolutionPolicy,omitempty"` + // SyncDatabaseID - ARM resource id of the sync database in the sync group. + SyncDatabaseID *string `json:"syncDatabaseId,omitempty"` + // HubDatabaseUserName - User name for the sync group hub database credential. + HubDatabaseUserName *string `json:"hubDatabaseUserName,omitempty"` + // HubDatabasePassword - Password for the sync group hub database credential. + HubDatabasePassword *string `json:"hubDatabasePassword,omitempty"` + // SyncState - READ-ONLY; Sync state of the sync group. Possible values include: 'SyncGroupStateNotReady', 'SyncGroupStateError', 'SyncGroupStateWarning', 'SyncGroupStateProgressing', 'SyncGroupStateGood' + SyncState SyncGroupState `json:"syncState,omitempty"` + // Schema - Sync schema of the sync group. + Schema *SyncGroupSchema `json:"schema,omitempty"` + // EnableConflictLogging - If conflict logging is enabled. + EnableConflictLogging *bool `json:"enableConflictLogging,omitempty"` + // ConflictLoggingRetentionInDays - Conflict logging retention period. + ConflictLoggingRetentionInDays *int32 `json:"conflictLoggingRetentionInDays,omitempty"` + // UsePrivateLinkConnection - If use private link connection is enabled. + UsePrivateLinkConnection *bool `json:"usePrivateLinkConnection,omitempty"` + // PrivateEndpointName - READ-ONLY; Private endpoint name of the sync group if use private link connection is enabled. + PrivateEndpointName *string `json:"privateEndpointName,omitempty"` +} + +// MarshalJSON is the custom marshaler for SyncGroupProperties. +func (sgp SyncGroupProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sgp.Interval != nil { + objectMap["interval"] = sgp.Interval + } + if sgp.ConflictResolutionPolicy != "" { + objectMap["conflictResolutionPolicy"] = sgp.ConflictResolutionPolicy + } + if sgp.SyncDatabaseID != nil { + objectMap["syncDatabaseId"] = sgp.SyncDatabaseID + } + if sgp.HubDatabaseUserName != nil { + objectMap["hubDatabaseUserName"] = sgp.HubDatabaseUserName + } + if sgp.HubDatabasePassword != nil { + objectMap["hubDatabasePassword"] = sgp.HubDatabasePassword + } + if sgp.Schema != nil { + objectMap["schema"] = sgp.Schema + } + if sgp.EnableConflictLogging != nil { + objectMap["enableConflictLogging"] = sgp.EnableConflictLogging + } + if sgp.ConflictLoggingRetentionInDays != nil { + objectMap["conflictLoggingRetentionInDays"] = sgp.ConflictLoggingRetentionInDays + } + if sgp.UsePrivateLinkConnection != nil { + objectMap["usePrivateLinkConnection"] = sgp.UsePrivateLinkConnection + } + return json.Marshal(objectMap) +} + +// SyncGroupSchema properties of sync group schema. +type SyncGroupSchema struct { + // Tables - List of tables in sync group schema. + Tables *[]SyncGroupSchemaTable `json:"tables,omitempty"` + // MasterSyncMemberName - Name of master sync member where the schema is from. + MasterSyncMemberName *string `json:"masterSyncMemberName,omitempty"` +} + +// SyncGroupSchemaTable properties of table in sync group schema. +type SyncGroupSchemaTable struct { + // Columns - List of columns in sync group schema. + Columns *[]SyncGroupSchemaTableColumn `json:"columns,omitempty"` + // QuotedName - Quoted name of sync group schema table. + QuotedName *string `json:"quotedName,omitempty"` +} + +// SyncGroupSchemaTableColumn properties of column in sync group table. +type SyncGroupSchemaTableColumn struct { + // QuotedName - Quoted name of sync group table column. + QuotedName *string `json:"quotedName,omitempty"` + // DataSize - Data size of the column. + DataSize *string `json:"dataSize,omitempty"` + // DataType - Data type of the column. + DataType *string `json:"dataType,omitempty"` +} + +// SyncGroupsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type SyncGroupsCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(SyncGroupsClient) (SyncGroup, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *SyncGroupsCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for SyncGroupsCreateOrUpdateFuture.Result. +func (future *SyncGroupsCreateOrUpdateFuture) result(client SyncGroupsClient) (sg SyncGroup, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + sg.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.SyncGroupsCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if sg.Response.Response, err = future.GetResult(sender); err == nil && sg.Response.Response.StatusCode != http.StatusNoContent { + sg, err = client.CreateOrUpdateResponder(sg.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsCreateOrUpdateFuture", "Result", sg.Response.Response, "Failure responding to request") + } + } + return +} + +// SyncGroupsDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type SyncGroupsDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(SyncGroupsClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *SyncGroupsDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for SyncGroupsDeleteFuture.Result. +func (future *SyncGroupsDeleteFuture) result(client SyncGroupsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.SyncGroupsDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// SyncGroupsRefreshHubSchemaFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type SyncGroupsRefreshHubSchemaFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(SyncGroupsClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *SyncGroupsRefreshHubSchemaFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for SyncGroupsRefreshHubSchemaFuture.Result. +func (future *SyncGroupsRefreshHubSchemaFuture) result(client SyncGroupsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsRefreshHubSchemaFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.SyncGroupsRefreshHubSchemaFuture") + return + } + ar.Response = future.Response() + return +} + +// SyncGroupsUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type SyncGroupsUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(SyncGroupsClient) (SyncGroup, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *SyncGroupsUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for SyncGroupsUpdateFuture.Result. +func (future *SyncGroupsUpdateFuture) result(client SyncGroupsClient) (sg SyncGroup, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + sg.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.SyncGroupsUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if sg.Response.Response, err = future.GetResult(sender); err == nil && sg.Response.Response.StatusCode != http.StatusNoContent { + sg, err = client.UpdateResponder(sg.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsUpdateFuture", "Result", sg.Response.Response, "Failure responding to request") + } + } + return +} + +// SyncMember an Azure SQL Database sync member. +type SyncMember struct { + autorest.Response `json:"-"` + // SyncMemberProperties - Resource properties. + *SyncMemberProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for SyncMember. +func (sm SyncMember) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sm.SyncMemberProperties != nil { + objectMap["properties"] = sm.SyncMemberProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for SyncMember struct. +func (sm *SyncMember) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var syncMemberProperties SyncMemberProperties + err = json.Unmarshal(*v, &syncMemberProperties) + if err != nil { + return err + } + sm.SyncMemberProperties = &syncMemberProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + sm.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + sm.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + sm.Type = &typeVar + } + } + } + + return nil +} + +// SyncMemberListResult a list of Azure SQL Database sync members. +type SyncMemberListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]SyncMember `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for SyncMemberListResult. +func (smlr SyncMemberListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// SyncMemberListResultIterator provides access to a complete listing of SyncMember values. +type SyncMemberListResultIterator struct { + i int + page SyncMemberListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *SyncMemberListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncMemberListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *SyncMemberListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter SyncMemberListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter SyncMemberListResultIterator) Response() SyncMemberListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter SyncMemberListResultIterator) Value() SyncMember { + if !iter.page.NotDone() { + return SyncMember{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the SyncMemberListResultIterator type. +func NewSyncMemberListResultIterator(page SyncMemberListResultPage) SyncMemberListResultIterator { + return SyncMemberListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (smlr SyncMemberListResult) IsEmpty() bool { + return smlr.Value == nil || len(*smlr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (smlr SyncMemberListResult) hasNextLink() bool { + return smlr.NextLink != nil && len(*smlr.NextLink) != 0 +} + +// syncMemberListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (smlr SyncMemberListResult) syncMemberListResultPreparer(ctx context.Context) (*http.Request, error) { + if !smlr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(smlr.NextLink))) +} + +// SyncMemberListResultPage contains a page of SyncMember values. +type SyncMemberListResultPage struct { + fn func(context.Context, SyncMemberListResult) (SyncMemberListResult, error) + smlr SyncMemberListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *SyncMemberListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncMemberListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.smlr) + if err != nil { + return err + } + page.smlr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *SyncMemberListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page SyncMemberListResultPage) NotDone() bool { + return !page.smlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page SyncMemberListResultPage) Response() SyncMemberListResult { + return page.smlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page SyncMemberListResultPage) Values() []SyncMember { + if page.smlr.IsEmpty() { + return nil + } + return *page.smlr.Value +} + +// Creates a new instance of the SyncMemberListResultPage type. +func NewSyncMemberListResultPage(cur SyncMemberListResult, getNextPage func(context.Context, SyncMemberListResult) (SyncMemberListResult, error)) SyncMemberListResultPage { + return SyncMemberListResultPage{ + fn: getNextPage, + smlr: cur, + } +} + +// SyncMemberProperties properties of a sync member. +type SyncMemberProperties struct { + // DatabaseType - Database type of the sync member. Possible values include: 'SyncMemberDbTypeAzureSQLDatabase', 'SyncMemberDbTypeSQLServerDatabase' + DatabaseType SyncMemberDbType `json:"databaseType,omitempty"` + // SyncAgentID - ARM resource id of the sync agent in the sync member. + SyncAgentID *string `json:"syncAgentId,omitempty"` + // SQLServerDatabaseID - SQL Server database id of the sync member. + SQLServerDatabaseID *uuid.UUID `json:"sqlServerDatabaseId,omitempty"` + // SyncMemberAzureDatabaseResourceID - ARM resource id of the sync member logical database, for sync members in Azure. + SyncMemberAzureDatabaseResourceID *string `json:"syncMemberAzureDatabaseResourceId,omitempty"` + // UsePrivateLinkConnection - Whether to use private link connection. + UsePrivateLinkConnection *bool `json:"usePrivateLinkConnection,omitempty"` + // PrivateEndpointName - READ-ONLY; Private endpoint name of the sync member if use private link connection is enabled, for sync members in Azure. + PrivateEndpointName *string `json:"privateEndpointName,omitempty"` + // ServerName - Server name of the member database in the sync member + ServerName *string `json:"serverName,omitempty"` + // DatabaseName - Database name of the member database in the sync member. + DatabaseName *string `json:"databaseName,omitempty"` + // UserName - User name of the member database in the sync member. + UserName *string `json:"userName,omitempty"` + // Password - Password of the member database in the sync member. + Password *string `json:"password,omitempty"` + // SyncDirection - Sync direction of the sync member. Possible values include: 'SyncDirectionBidirectional', 'SyncDirectionOneWayMemberToHub', 'SyncDirectionOneWayHubToMember' + SyncDirection SyncDirection `json:"syncDirection,omitempty"` + // SyncState - READ-ONLY; Sync state of the sync member. Possible values include: 'SyncMemberStateSyncInProgress', 'SyncMemberStateSyncSucceeded', 'SyncMemberStateSyncFailed', 'SyncMemberStateDisabledTombstoneCleanup', 'SyncMemberStateDisabledBackupRestore', 'SyncMemberStateSyncSucceededWithWarnings', 'SyncMemberStateSyncCancelling', 'SyncMemberStateSyncCancelled', 'SyncMemberStateUnProvisioned', 'SyncMemberStateProvisioning', 'SyncMemberStateProvisioned', 'SyncMemberStateProvisionFailed', 'SyncMemberStateDeProvisioning', 'SyncMemberStateDeProvisioned', 'SyncMemberStateDeProvisionFailed', 'SyncMemberStateReprovisioning', 'SyncMemberStateReprovisionFailed', 'SyncMemberStateUnReprovisioned' + SyncState SyncMemberState `json:"syncState,omitempty"` +} + +// MarshalJSON is the custom marshaler for SyncMemberProperties. +func (smp SyncMemberProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if smp.DatabaseType != "" { + objectMap["databaseType"] = smp.DatabaseType + } + if smp.SyncAgentID != nil { + objectMap["syncAgentId"] = smp.SyncAgentID + } + if smp.SQLServerDatabaseID != nil { + objectMap["sqlServerDatabaseId"] = smp.SQLServerDatabaseID + } + if smp.SyncMemberAzureDatabaseResourceID != nil { + objectMap["syncMemberAzureDatabaseResourceId"] = smp.SyncMemberAzureDatabaseResourceID + } + if smp.UsePrivateLinkConnection != nil { + objectMap["usePrivateLinkConnection"] = smp.UsePrivateLinkConnection + } + if smp.ServerName != nil { + objectMap["serverName"] = smp.ServerName + } + if smp.DatabaseName != nil { + objectMap["databaseName"] = smp.DatabaseName + } + if smp.UserName != nil { + objectMap["userName"] = smp.UserName + } + if smp.Password != nil { + objectMap["password"] = smp.Password + } + if smp.SyncDirection != "" { + objectMap["syncDirection"] = smp.SyncDirection + } + return json.Marshal(objectMap) +} + +// SyncMembersCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type SyncMembersCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(SyncMembersClient) (SyncMember, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *SyncMembersCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for SyncMembersCreateOrUpdateFuture.Result. +func (future *SyncMembersCreateOrUpdateFuture) result(client SyncMembersClient) (sm SyncMember, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + sm.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.SyncMembersCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if sm.Response.Response, err = future.GetResult(sender); err == nil && sm.Response.Response.StatusCode != http.StatusNoContent { + sm, err = client.CreateOrUpdateResponder(sm.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersCreateOrUpdateFuture", "Result", sm.Response.Response, "Failure responding to request") + } + } + return +} + +// SyncMembersDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type SyncMembersDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(SyncMembersClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *SyncMembersDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for SyncMembersDeleteFuture.Result. +func (future *SyncMembersDeleteFuture) result(client SyncMembersClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.SyncMembersDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// SyncMembersRefreshMemberSchemaFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type SyncMembersRefreshMemberSchemaFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(SyncMembersClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *SyncMembersRefreshMemberSchemaFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for SyncMembersRefreshMemberSchemaFuture.Result. +func (future *SyncMembersRefreshMemberSchemaFuture) result(client SyncMembersClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersRefreshMemberSchemaFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.SyncMembersRefreshMemberSchemaFuture") + return + } + ar.Response = future.Response() + return +} + +// SyncMembersUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type SyncMembersUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(SyncMembersClient) (SyncMember, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *SyncMembersUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for SyncMembersUpdateFuture.Result. +func (future *SyncMembersUpdateFuture) result(client SyncMembersClient) (sm SyncMember, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + sm.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.SyncMembersUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if sm.Response.Response, err = future.GetResult(sender); err == nil && sm.Response.Response.StatusCode != http.StatusNoContent { + sm, err = client.UpdateResponder(sm.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersUpdateFuture", "Result", sm.Response.Response, "Failure responding to request") + } + } + return +} + +// SystemData metadata pertaining to creation and last modification of the resource. +type SystemData struct { + // CreatedBy - The identity that created the resource. + CreatedBy *string `json:"createdBy,omitempty"` + // CreatedByType - The type of identity that created the resource. Possible values include: 'CreatedByTypeUser', 'CreatedByTypeApplication', 'CreatedByTypeManagedIdentity', 'CreatedByTypeKey' + CreatedByType CreatedByType `json:"createdByType,omitempty"` + // CreatedAt - The timestamp of resource creation (UTC). + CreatedAt *date.Time `json:"createdAt,omitempty"` + // LastModifiedBy - The identity that last modified the resource. + LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + // LastModifiedByType - The type of identity that last modified the resource. Possible values include: 'CreatedByTypeUser', 'CreatedByTypeApplication', 'CreatedByTypeManagedIdentity', 'CreatedByTypeKey' + LastModifiedByType CreatedByType `json:"lastModifiedByType,omitempty"` + // LastModifiedAt - The timestamp of resource last modification (UTC) + LastModifiedAt *date.Time `json:"lastModifiedAt,omitempty"` +} + +// TdeCertificate a TDE certificate that can be uploaded into a server. +type TdeCertificate struct { + // TdeCertificateProperties - Resource properties. + *TdeCertificateProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for TdeCertificate. +func (tc TdeCertificate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if tc.TdeCertificateProperties != nil { + objectMap["properties"] = tc.TdeCertificateProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for TdeCertificate struct. +func (tc *TdeCertificate) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var tdeCertificateProperties TdeCertificateProperties + err = json.Unmarshal(*v, &tdeCertificateProperties) + if err != nil { + return err + } + tc.TdeCertificateProperties = &tdeCertificateProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + tc.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + tc.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + tc.Type = &typeVar + } + } + } + + return nil +} + +// TdeCertificateProperties properties of a TDE certificate. +type TdeCertificateProperties struct { + // PrivateBlob - The base64 encoded certificate private blob. + PrivateBlob *string `json:"privateBlob,omitempty"` + // CertPassword - The certificate password. + CertPassword *string `json:"certPassword,omitempty"` +} + +// TdeCertificatesCreateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type TdeCertificatesCreateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(TdeCertificatesClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *TdeCertificatesCreateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for TdeCertificatesCreateFuture.Result. +func (future *TdeCertificatesCreateFuture) result(client TdeCertificatesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.TdeCertificatesCreateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.TdeCertificatesCreateFuture") + return + } + ar.Response = future.Response() + return +} + +// TimeZone time Zone. +type TimeZone struct { + autorest.Response `json:"-"` + // TimeZoneProperties - Resource properties. + *TimeZoneProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for TimeZone. +func (tz TimeZone) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if tz.TimeZoneProperties != nil { + objectMap["properties"] = tz.TimeZoneProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for TimeZone struct. +func (tz *TimeZone) UnmarshalJSON(body []byte) error { + 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 timeZoneProperties TimeZoneProperties + err = json.Unmarshal(*v, &timeZoneProperties) + if err != nil { + return err + } + tz.TimeZoneProperties = &timeZoneProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + tz.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + tz.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + tz.Type = &typeVar + } + } + } + + return nil +} + +// TimeZoneListResult a list of time zones. +type TimeZoneListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]TimeZone `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for TimeZoneListResult. +func (tzlr TimeZoneListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// TimeZoneListResultIterator provides access to a complete listing of TimeZone values. +type TimeZoneListResultIterator struct { + i int + page TimeZoneListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *TimeZoneListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TimeZoneListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *TimeZoneListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter TimeZoneListResultIterator) 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 TimeZoneListResultIterator) Response() TimeZoneListResult { + 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 TimeZoneListResultIterator) Value() TimeZone { + if !iter.page.NotDone() { + return TimeZone{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the TimeZoneListResultIterator type. +func NewTimeZoneListResultIterator(page TimeZoneListResultPage) TimeZoneListResultIterator { + return TimeZoneListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (tzlr TimeZoneListResult) IsEmpty() bool { + return tzlr.Value == nil || len(*tzlr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (tzlr TimeZoneListResult) hasNextLink() bool { + return tzlr.NextLink != nil && len(*tzlr.NextLink) != 0 +} + +// timeZoneListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (tzlr TimeZoneListResult) timeZoneListResultPreparer(ctx context.Context) (*http.Request, error) { + if !tzlr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(tzlr.NextLink))) +} + +// TimeZoneListResultPage contains a page of TimeZone values. +type TimeZoneListResultPage struct { + fn func(context.Context, TimeZoneListResult) (TimeZoneListResult, error) + tzlr TimeZoneListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *TimeZoneListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TimeZoneListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.tzlr) + if err != nil { + return err + } + page.tzlr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *TimeZoneListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page TimeZoneListResultPage) NotDone() bool { + return !page.tzlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page TimeZoneListResultPage) Response() TimeZoneListResult { + return page.tzlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page TimeZoneListResultPage) Values() []TimeZone { + if page.tzlr.IsEmpty() { + return nil + } + return *page.tzlr.Value +} + +// Creates a new instance of the TimeZoneListResultPage type. +func NewTimeZoneListResultPage(cur TimeZoneListResult, getNextPage func(context.Context, TimeZoneListResult) (TimeZoneListResult, error)) TimeZoneListResultPage { + return TimeZoneListResultPage{ + fn: getNextPage, + tzlr: cur, + } +} + +// TimeZoneProperties the properties of a time zone. +type TimeZoneProperties struct { + // TimeZoneID - READ-ONLY; The time zone id + TimeZoneID *string `json:"timeZoneId,omitempty"` + // DisplayName - READ-ONLY; The time zone display name + DisplayName *string `json:"displayName,omitempty"` +} + +// MarshalJSON is the custom marshaler for TimeZoneProperties. +func (tzp TimeZoneProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// TopQueries ... +type TopQueries struct { + // NumberOfQueries - READ-ONLY; Requested number of top queries. + NumberOfQueries *int32 `json:"numberOfQueries,omitempty"` + // AggregationFunction - READ-ONLY; Aggregation function used to calculate query metrics. + AggregationFunction *string `json:"aggregationFunction,omitempty"` + // ObservationMetric - READ-ONLY; Metric used to rank queries. + ObservationMetric *string `json:"observationMetric,omitempty"` + // IntervalType - READ-ONLY; Interval type (length). Possible values include: 'QueryTimeGrainTypePT1H', 'QueryTimeGrainTypeP1D' + IntervalType QueryTimeGrainType `json:"intervalType,omitempty"` + // StartTime - READ-ONLY; The start time for the metric (ISO-8601 format). + StartTime *string `json:"startTime,omitempty"` + // EndTime - READ-ONLY; The end time for the metric (ISO-8601 format). + EndTime *string `json:"endTime,omitempty"` + // Queries - List of top resource consuming queries with appropriate metric data + Queries *[]QueryStatisticsProperties `json:"queries,omitempty"` +} + +// MarshalJSON is the custom marshaler for TopQueries. +func (tq TopQueries) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if tq.Queries != nil { + objectMap["queries"] = tq.Queries + } + return json.Marshal(objectMap) +} + +// TopQueriesListResult a list of top resource consuming queries on managed instance +type TopQueriesListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]TopQueries `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for TopQueriesListResult. +func (tqlr TopQueriesListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// TopQueriesListResultIterator provides access to a complete listing of TopQueries values. +type TopQueriesListResultIterator struct { + i int + page TopQueriesListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *TopQueriesListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TopQueriesListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *TopQueriesListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter TopQueriesListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter TopQueriesListResultIterator) Response() TopQueriesListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter TopQueriesListResultIterator) Value() TopQueries { + if !iter.page.NotDone() { + return TopQueries{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the TopQueriesListResultIterator type. +func NewTopQueriesListResultIterator(page TopQueriesListResultPage) TopQueriesListResultIterator { + return TopQueriesListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (tqlr TopQueriesListResult) IsEmpty() bool { + return tqlr.Value == nil || len(*tqlr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (tqlr TopQueriesListResult) hasNextLink() bool { + return tqlr.NextLink != nil && len(*tqlr.NextLink) != 0 +} + +// topQueriesListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (tqlr TopQueriesListResult) topQueriesListResultPreparer(ctx context.Context) (*http.Request, error) { + if !tqlr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(tqlr.NextLink))) +} + +// TopQueriesListResultPage contains a page of TopQueries values. +type TopQueriesListResultPage struct { + fn func(context.Context, TopQueriesListResult) (TopQueriesListResult, error) + tqlr TopQueriesListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *TopQueriesListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TopQueriesListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.tqlr) + if err != nil { + return err + } + page.tqlr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *TopQueriesListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page TopQueriesListResultPage) NotDone() bool { + return !page.tqlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page TopQueriesListResultPage) Response() TopQueriesListResult { + return page.tqlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page TopQueriesListResultPage) Values() []TopQueries { + if page.tqlr.IsEmpty() { + return nil + } + return *page.tqlr.Value +} + +// Creates a new instance of the TopQueriesListResultPage type. +func NewTopQueriesListResultPage(cur TopQueriesListResult, getNextPage func(context.Context, TopQueriesListResult) (TopQueriesListResult, error)) TopQueriesListResultPage { + return TopQueriesListResultPage{ + fn: getNextPage, + tqlr: cur, + } +} + +// TrackedResource ARM tracked top level resource. +type TrackedResource struct { + // Location - Resource location. + Location *string `json:"location,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for TrackedResource. +func (tr TrackedResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if tr.Location != nil { + objectMap["location"] = tr.Location + } + if tr.Tags != nil { + objectMap["tags"] = tr.Tags + } + return json.Marshal(objectMap) +} + +// TransparentDataEncryption represents a database transparent data encryption configuration. +type TransparentDataEncryption struct { + autorest.Response `json:"-"` + // Location - READ-ONLY; Resource location. + Location *string `json:"location,omitempty"` + // TransparentDataEncryptionProperties - Represents the properties of the resource. + *TransparentDataEncryptionProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for TransparentDataEncryption. +func (tde TransparentDataEncryption) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if tde.TransparentDataEncryptionProperties != nil { + objectMap["properties"] = tde.TransparentDataEncryptionProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for TransparentDataEncryption struct. +func (tde *TransparentDataEncryption) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + tde.Location = &location + } + case "properties": + if v != nil { + var transparentDataEncryptionProperties TransparentDataEncryptionProperties + err = json.Unmarshal(*v, &transparentDataEncryptionProperties) + if err != nil { + return err + } + tde.TransparentDataEncryptionProperties = &transparentDataEncryptionProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + tde.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + tde.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + tde.Type = &typeVar + } + } + } + + return nil +} + +// TransparentDataEncryptionActivity represents a database transparent data encryption Scan. +type TransparentDataEncryptionActivity struct { + // Location - READ-ONLY; Resource location. + Location *string `json:"location,omitempty"` + // TransparentDataEncryptionActivityProperties - Represents the properties of the resource. + *TransparentDataEncryptionActivityProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for TransparentDataEncryptionActivity. +func (tdea TransparentDataEncryptionActivity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if tdea.TransparentDataEncryptionActivityProperties != nil { + objectMap["properties"] = tdea.TransparentDataEncryptionActivityProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for TransparentDataEncryptionActivity struct. +func (tdea *TransparentDataEncryptionActivity) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + tdea.Location = &location + } + case "properties": + if v != nil { + var transparentDataEncryptionActivityProperties TransparentDataEncryptionActivityProperties + err = json.Unmarshal(*v, &transparentDataEncryptionActivityProperties) + if err != nil { + return err + } + tdea.TransparentDataEncryptionActivityProperties = &transparentDataEncryptionActivityProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + tdea.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + tdea.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + tdea.Type = &typeVar + } + } + } + + return nil +} + +// TransparentDataEncryptionActivityListResult represents the response to a list database transparent data +// encryption activity request. +type TransparentDataEncryptionActivityListResult struct { + autorest.Response `json:"-"` + // Value - The list of database transparent data encryption activities. + Value *[]TransparentDataEncryptionActivity `json:"value,omitempty"` +} + +// TransparentDataEncryptionActivityProperties represents the properties of a database transparent data +// encryption Scan. +type TransparentDataEncryptionActivityProperties struct { + // Status - READ-ONLY; The status of the database. Possible values include: 'TransparentDataEncryptionActivityStatusEncrypting', 'TransparentDataEncryptionActivityStatusDecrypting' + Status TransparentDataEncryptionActivityStatus `json:"status,omitempty"` + // PercentComplete - READ-ONLY; The percent complete of the transparent data encryption scan for a database. + PercentComplete *float64 `json:"percentComplete,omitempty"` +} + +// MarshalJSON is the custom marshaler for TransparentDataEncryptionActivityProperties. +func (tdeap TransparentDataEncryptionActivityProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// TransparentDataEncryptionProperties represents the properties of a database transparent data encryption. +type TransparentDataEncryptionProperties struct { + // Status - The status of the database transparent data encryption. Possible values include: 'TransparentDataEncryptionStatusEnabled', 'TransparentDataEncryptionStatusDisabled' + Status TransparentDataEncryptionStatus `json:"status,omitempty"` +} + +// UnlinkParameters represents the parameters for Unlink Replication Link request. +type UnlinkParameters struct { + // ForcedTermination - Determines whether link will be terminated in a forced or a friendly way. + ForcedTermination *bool `json:"forcedTermination,omitempty"` +} + +// UpdateLongTermRetentionBackupParameters contains the information necessary to perform long term +// retention backup update operation. +type UpdateLongTermRetentionBackupParameters struct { + // UpdateLongTermRetentionBackupParametersProperties - Resource properties. + *UpdateLongTermRetentionBackupParametersProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for UpdateLongTermRetentionBackupParameters. +func (ultrbp UpdateLongTermRetentionBackupParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ultrbp.UpdateLongTermRetentionBackupParametersProperties != nil { + objectMap["properties"] = ultrbp.UpdateLongTermRetentionBackupParametersProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for UpdateLongTermRetentionBackupParameters struct. +func (ultrbp *UpdateLongTermRetentionBackupParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var updateLongTermRetentionBackupParametersProperties UpdateLongTermRetentionBackupParametersProperties + err = json.Unmarshal(*v, &updateLongTermRetentionBackupParametersProperties) + if err != nil { + return err + } + ultrbp.UpdateLongTermRetentionBackupParametersProperties = &updateLongTermRetentionBackupParametersProperties + } + } + } + + return nil +} + +// UpdateLongTermRetentionBackupParametersProperties contains the properties to perform long term retention +// backup copy operation. +type UpdateLongTermRetentionBackupParametersProperties struct { + // RequestedBackupStorageRedundancy - The storage redundancy type of the copied backup. Possible values include: 'RequestedBackupStorageRedundancyGeo', 'RequestedBackupStorageRedundancyLocal', 'RequestedBackupStorageRedundancyZone' + RequestedBackupStorageRedundancy RequestedBackupStorageRedundancy `json:"requestedBackupStorageRedundancy,omitempty"` +} + +// UpdateManagedInstanceDNSServersOperation a recoverable managed database resource. +type UpdateManagedInstanceDNSServersOperation struct { + autorest.Response `json:"-"` + // DNSRefreshConfigurationProperties - Resource properties. + *DNSRefreshConfigurationProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for UpdateManagedInstanceDNSServersOperation. +func (umidso UpdateManagedInstanceDNSServersOperation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if umidso.DNSRefreshConfigurationProperties != nil { + objectMap["properties"] = umidso.DNSRefreshConfigurationProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for UpdateManagedInstanceDNSServersOperation struct. +func (umidso *UpdateManagedInstanceDNSServersOperation) UnmarshalJSON(body []byte) error { + 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 DNSRefreshConfigurationProperties DNSRefreshConfigurationProperties + err = json.Unmarshal(*v, &DNSRefreshConfigurationProperties) + if err != nil { + return err + } + umidso.DNSRefreshConfigurationProperties = &DNSRefreshConfigurationProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + umidso.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + umidso.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + umidso.Type = &typeVar + } + } + } + + return nil +} + +// UpsertManagedServerOperationParameters ... +type UpsertManagedServerOperationParameters struct { + Family *string `json:"family,omitempty"` + Tier *string `json:"tier,omitempty"` + VCores *int32 `json:"vCores,omitempty"` + StorageSizeInGB *int32 `json:"storageSizeInGB,omitempty"` +} + +// UpsertManagedServerOperationStep ... +type UpsertManagedServerOperationStep struct { + Order *int32 `json:"order,omitempty"` + Name *string `json:"name,omitempty"` + // Status - Possible values include: 'StatusNotStarted', 'StatusInProgress', 'StatusSlowedDown', 'StatusCompleted', 'StatusFailed', 'StatusCanceled' + Status Status `json:"status,omitempty"` +} + +// Usage ARM usage. +type Usage struct { + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *Name `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` + // Unit - READ-ONLY; Usage unit. + Unit *string `json:"unit,omitempty"` + // CurrentValue - READ-ONLY; Usage current value. + CurrentValue *int32 `json:"currentValue,omitempty"` + // Limit - READ-ONLY; Usage limit. + Limit *int32 `json:"limit,omitempty"` + // RequestedLimit - READ-ONLY; Usage requested limit. + RequestedLimit *int32 `json:"requestedLimit,omitempty"` +} + +// MarshalJSON is the custom marshaler for Usage. +func (u Usage) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// UsageListResult a list of usages. +type UsageListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]Usage `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for UsageListResult. +func (ulr UsageListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// UsageListResultIterator provides access to a complete listing of Usage values. +type UsageListResultIterator struct { + i int + page UsageListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *UsageListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/UsageListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *UsageListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter UsageListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter UsageListResultIterator) Response() UsageListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter UsageListResultIterator) Value() Usage { + if !iter.page.NotDone() { + return Usage{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the UsageListResultIterator type. +func NewUsageListResultIterator(page UsageListResultPage) UsageListResultIterator { + return UsageListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (ulr UsageListResult) IsEmpty() bool { + return ulr.Value == nil || len(*ulr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (ulr UsageListResult) hasNextLink() bool { + return ulr.NextLink != nil && len(*ulr.NextLink) != 0 +} + +// usageListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (ulr UsageListResult) usageListResultPreparer(ctx context.Context) (*http.Request, error) { + if !ulr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(ulr.NextLink))) +} + +// UsageListResultPage contains a page of Usage values. +type UsageListResultPage struct { + fn func(context.Context, UsageListResult) (UsageListResult, error) + ulr UsageListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *UsageListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/UsageListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.ulr) + if err != nil { + return err + } + page.ulr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *UsageListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page UsageListResultPage) NotDone() bool { + return !page.ulr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page UsageListResultPage) Response() UsageListResult { + return page.ulr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page UsageListResultPage) Values() []Usage { + if page.ulr.IsEmpty() { + return nil + } + return *page.ulr.Value +} + +// Creates a new instance of the UsageListResultPage type. +func NewUsageListResultPage(cur UsageListResult, getNextPage func(context.Context, UsageListResult) (UsageListResult, error)) UsageListResultPage { + return UsageListResultPage{ + fn: getNextPage, + ulr: cur, + } +} + +// UserIdentity azure Active Directory identity configuration for a resource. +type UserIdentity struct { + // PrincipalID - READ-ONLY; The Azure Active Directory principal id. + PrincipalID *uuid.UUID `json:"principalId,omitempty"` + // ClientID - READ-ONLY; The Azure Active Directory client id. + ClientID *uuid.UUID `json:"clientId,omitempty"` +} + +// MarshalJSON is the custom marshaler for UserIdentity. +func (UI UserIdentity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// VirtualCluster an Azure SQL virtual cluster. +type VirtualCluster struct { + autorest.Response `json:"-"` + // VirtualClusterProperties - Resource properties. + *VirtualClusterProperties `json:"properties,omitempty"` + // Location - Resource location. + Location *string `json:"location,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for VirtualCluster. +func (vc VirtualCluster) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if vc.VirtualClusterProperties != nil { + objectMap["properties"] = vc.VirtualClusterProperties + } + if vc.Location != nil { + objectMap["location"] = vc.Location + } + if vc.Tags != nil { + objectMap["tags"] = vc.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for VirtualCluster struct. +func (vc *VirtualCluster) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var virtualClusterProperties VirtualClusterProperties + err = json.Unmarshal(*v, &virtualClusterProperties) + if err != nil { + return err + } + vc.VirtualClusterProperties = &virtualClusterProperties + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + vc.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + vc.Tags = tags + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + vc.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + vc.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + vc.Type = &typeVar + } + } + } + + return nil +} + +// VirtualClusterListResult a list of virtual clusters. +type VirtualClusterListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]VirtualCluster `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for VirtualClusterListResult. +func (vclr VirtualClusterListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// VirtualClusterListResultIterator provides access to a complete listing of VirtualCluster values. +type VirtualClusterListResultIterator struct { + i int + page VirtualClusterListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *VirtualClusterListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/VirtualClusterListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *VirtualClusterListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter VirtualClusterListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter VirtualClusterListResultIterator) Response() VirtualClusterListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter VirtualClusterListResultIterator) Value() VirtualCluster { + if !iter.page.NotDone() { + return VirtualCluster{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the VirtualClusterListResultIterator type. +func NewVirtualClusterListResultIterator(page VirtualClusterListResultPage) VirtualClusterListResultIterator { + return VirtualClusterListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (vclr VirtualClusterListResult) IsEmpty() bool { + return vclr.Value == nil || len(*vclr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (vclr VirtualClusterListResult) hasNextLink() bool { + return vclr.NextLink != nil && len(*vclr.NextLink) != 0 +} + +// virtualClusterListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (vclr VirtualClusterListResult) virtualClusterListResultPreparer(ctx context.Context) (*http.Request, error) { + if !vclr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(vclr.NextLink))) +} + +// VirtualClusterListResultPage contains a page of VirtualCluster values. +type VirtualClusterListResultPage struct { + fn func(context.Context, VirtualClusterListResult) (VirtualClusterListResult, error) + vclr VirtualClusterListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *VirtualClusterListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/VirtualClusterListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.vclr) + if err != nil { + return err + } + page.vclr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *VirtualClusterListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page VirtualClusterListResultPage) NotDone() bool { + return !page.vclr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page VirtualClusterListResultPage) Response() VirtualClusterListResult { + return page.vclr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page VirtualClusterListResultPage) Values() []VirtualCluster { + if page.vclr.IsEmpty() { + return nil + } + return *page.vclr.Value +} + +// Creates a new instance of the VirtualClusterListResultPage type. +func NewVirtualClusterListResultPage(cur VirtualClusterListResult, getNextPage func(context.Context, VirtualClusterListResult) (VirtualClusterListResult, error)) VirtualClusterListResultPage { + return VirtualClusterListResultPage{ + fn: getNextPage, + vclr: cur, + } +} + +// VirtualClusterProperties the properties of a virtual cluster. +type VirtualClusterProperties struct { + // SubnetID - READ-ONLY; Subnet resource ID for the virtual cluster. + SubnetID *string `json:"subnetId,omitempty"` + // Family - If the service has different generations of hardware, for the same SKU, then that can be captured here. + Family *string `json:"family,omitempty"` + // ChildResources - READ-ONLY; List of resources in this virtual cluster. + ChildResources *[]string `json:"childResources,omitempty"` + // MaintenanceConfigurationID - Specifies maintenance configuration id to apply to this virtual cluster. + MaintenanceConfigurationID *string `json:"maintenanceConfigurationId,omitempty"` +} + +// MarshalJSON is the custom marshaler for VirtualClusterProperties. +func (vcp VirtualClusterProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if vcp.Family != nil { + objectMap["family"] = vcp.Family + } + if vcp.MaintenanceConfigurationID != nil { + objectMap["maintenanceConfigurationId"] = vcp.MaintenanceConfigurationID + } + return json.Marshal(objectMap) +} + +// VirtualClustersDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type VirtualClustersDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(VirtualClustersClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *VirtualClustersDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for VirtualClustersDeleteFuture.Result. +func (future *VirtualClustersDeleteFuture) result(client VirtualClustersClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualClustersDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.VirtualClustersDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// VirtualClustersUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type VirtualClustersUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(VirtualClustersClient) (VirtualCluster, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *VirtualClustersUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for VirtualClustersUpdateFuture.Result. +func (future *VirtualClustersUpdateFuture) result(client VirtualClustersClient) (vc VirtualCluster, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualClustersUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + vc.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.VirtualClustersUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if vc.Response.Response, err = future.GetResult(sender); err == nil && vc.Response.Response.StatusCode != http.StatusNoContent { + vc, err = client.UpdateResponder(vc.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualClustersUpdateFuture", "Result", vc.Response.Response, "Failure responding to request") + } + } + return +} + +// VirtualClusterUpdate an update request for an Azure SQL Database virtual cluster. +type VirtualClusterUpdate struct { + // VirtualClusterProperties - Resource properties. + *VirtualClusterProperties `json:"properties,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for VirtualClusterUpdate. +func (vcu VirtualClusterUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if vcu.VirtualClusterProperties != nil { + objectMap["properties"] = vcu.VirtualClusterProperties + } + if vcu.Tags != nil { + objectMap["tags"] = vcu.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for VirtualClusterUpdate struct. +func (vcu *VirtualClusterUpdate) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var virtualClusterProperties VirtualClusterProperties + err = json.Unmarshal(*v, &virtualClusterProperties) + if err != nil { + return err + } + vcu.VirtualClusterProperties = &virtualClusterProperties + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + vcu.Tags = tags + } + } + } + + return nil +} + +// VirtualNetworkRule a virtual network rule. +type VirtualNetworkRule struct { + autorest.Response `json:"-"` + // VirtualNetworkRuleProperties - Resource properties. + *VirtualNetworkRuleProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for VirtualNetworkRule. +func (vnr VirtualNetworkRule) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if vnr.VirtualNetworkRuleProperties != nil { + objectMap["properties"] = vnr.VirtualNetworkRuleProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for VirtualNetworkRule struct. +func (vnr *VirtualNetworkRule) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var virtualNetworkRuleProperties VirtualNetworkRuleProperties + err = json.Unmarshal(*v, &virtualNetworkRuleProperties) + if err != nil { + return err + } + vnr.VirtualNetworkRuleProperties = &virtualNetworkRuleProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + vnr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + vnr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + vnr.Type = &typeVar + } + } + } + + return nil +} + +// VirtualNetworkRuleListResult a list of virtual network rules. +type VirtualNetworkRuleListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]VirtualNetworkRule `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for VirtualNetworkRuleListResult. +func (vnrlr VirtualNetworkRuleListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// VirtualNetworkRuleListResultIterator provides access to a complete listing of VirtualNetworkRule values. +type VirtualNetworkRuleListResultIterator struct { + i int + page VirtualNetworkRuleListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *VirtualNetworkRuleListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/VirtualNetworkRuleListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *VirtualNetworkRuleListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter VirtualNetworkRuleListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter VirtualNetworkRuleListResultIterator) Response() VirtualNetworkRuleListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter VirtualNetworkRuleListResultIterator) Value() VirtualNetworkRule { + if !iter.page.NotDone() { + return VirtualNetworkRule{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the VirtualNetworkRuleListResultIterator type. +func NewVirtualNetworkRuleListResultIterator(page VirtualNetworkRuleListResultPage) VirtualNetworkRuleListResultIterator { + return VirtualNetworkRuleListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (vnrlr VirtualNetworkRuleListResult) IsEmpty() bool { + return vnrlr.Value == nil || len(*vnrlr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (vnrlr VirtualNetworkRuleListResult) hasNextLink() bool { + return vnrlr.NextLink != nil && len(*vnrlr.NextLink) != 0 +} + +// virtualNetworkRuleListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (vnrlr VirtualNetworkRuleListResult) virtualNetworkRuleListResultPreparer(ctx context.Context) (*http.Request, error) { + if !vnrlr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(vnrlr.NextLink))) +} + +// VirtualNetworkRuleListResultPage contains a page of VirtualNetworkRule values. +type VirtualNetworkRuleListResultPage struct { + fn func(context.Context, VirtualNetworkRuleListResult) (VirtualNetworkRuleListResult, error) + vnrlr VirtualNetworkRuleListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *VirtualNetworkRuleListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/VirtualNetworkRuleListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.vnrlr) + if err != nil { + return err + } + page.vnrlr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *VirtualNetworkRuleListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page VirtualNetworkRuleListResultPage) NotDone() bool { + return !page.vnrlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page VirtualNetworkRuleListResultPage) Response() VirtualNetworkRuleListResult { + return page.vnrlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page VirtualNetworkRuleListResultPage) Values() []VirtualNetworkRule { + if page.vnrlr.IsEmpty() { + return nil + } + return *page.vnrlr.Value +} + +// Creates a new instance of the VirtualNetworkRuleListResultPage type. +func NewVirtualNetworkRuleListResultPage(cur VirtualNetworkRuleListResult, getNextPage func(context.Context, VirtualNetworkRuleListResult) (VirtualNetworkRuleListResult, error)) VirtualNetworkRuleListResultPage { + return VirtualNetworkRuleListResultPage{ + fn: getNextPage, + vnrlr: cur, + } +} + +// VirtualNetworkRuleProperties properties of a virtual network rule. +type VirtualNetworkRuleProperties struct { + // VirtualNetworkSubnetID - The ARM resource id of the virtual network subnet. + VirtualNetworkSubnetID *string `json:"virtualNetworkSubnetId,omitempty"` + // IgnoreMissingVnetServiceEndpoint - Create firewall rule before the virtual network has vnet service endpoint enabled. + IgnoreMissingVnetServiceEndpoint *bool `json:"ignoreMissingVnetServiceEndpoint,omitempty"` + // State - READ-ONLY; Virtual Network Rule State. Possible values include: 'VirtualNetworkRuleStateInitializing', 'VirtualNetworkRuleStateInProgress', 'VirtualNetworkRuleStateReady', 'VirtualNetworkRuleStateFailed', 'VirtualNetworkRuleStateDeleting', 'VirtualNetworkRuleStateUnknown' + State VirtualNetworkRuleState `json:"state,omitempty"` +} + +// MarshalJSON is the custom marshaler for VirtualNetworkRuleProperties. +func (vnrp VirtualNetworkRuleProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if vnrp.VirtualNetworkSubnetID != nil { + objectMap["virtualNetworkSubnetId"] = vnrp.VirtualNetworkSubnetID + } + if vnrp.IgnoreMissingVnetServiceEndpoint != nil { + objectMap["ignoreMissingVnetServiceEndpoint"] = vnrp.IgnoreMissingVnetServiceEndpoint + } + return json.Marshal(objectMap) +} + +// VirtualNetworkRulesCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type VirtualNetworkRulesCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(VirtualNetworkRulesClient) (VirtualNetworkRule, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *VirtualNetworkRulesCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for VirtualNetworkRulesCreateOrUpdateFuture.Result. +func (future *VirtualNetworkRulesCreateOrUpdateFuture) result(client VirtualNetworkRulesClient) (vnr VirtualNetworkRule, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualNetworkRulesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + vnr.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.VirtualNetworkRulesCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if vnr.Response.Response, err = future.GetResult(sender); err == nil && vnr.Response.Response.StatusCode != http.StatusNoContent { + vnr, err = client.CreateOrUpdateResponder(vnr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualNetworkRulesCreateOrUpdateFuture", "Result", vnr.Response.Response, "Failure responding to request") + } + } + return +} + +// VirtualNetworkRulesDeleteFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type VirtualNetworkRulesDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(VirtualNetworkRulesClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *VirtualNetworkRulesDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for VirtualNetworkRulesDeleteFuture.Result. +func (future *VirtualNetworkRulesDeleteFuture) result(client VirtualNetworkRulesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualNetworkRulesDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.VirtualNetworkRulesDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// VulnerabilityAssessmentRecurringScansProperties properties of a Vulnerability Assessment recurring +// scans. +type VulnerabilityAssessmentRecurringScansProperties struct { + // IsEnabled - Recurring scans state. + IsEnabled *bool `json:"isEnabled,omitempty"` + // EmailSubscriptionAdmins - Specifies that the schedule scan notification will be is sent to the subscription administrators. + EmailSubscriptionAdmins *bool `json:"emailSubscriptionAdmins,omitempty"` + // Emails - Specifies an array of e-mail addresses to which the scan notification is sent. + Emails *[]string `json:"emails,omitempty"` +} + +// VulnerabilityAssessmentScanError properties of a vulnerability assessment scan error. +type VulnerabilityAssessmentScanError struct { + // Code - READ-ONLY; The error code. + Code *string `json:"code,omitempty"` + // Message - READ-ONLY; The error message. + Message *string `json:"message,omitempty"` +} + +// MarshalJSON is the custom marshaler for VulnerabilityAssessmentScanError. +func (vase VulnerabilityAssessmentScanError) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// VulnerabilityAssessmentScanRecord a vulnerability assessment scan record. +type VulnerabilityAssessmentScanRecord struct { + autorest.Response `json:"-"` + // VulnerabilityAssessmentScanRecordProperties - Resource properties. + *VulnerabilityAssessmentScanRecordProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for VulnerabilityAssessmentScanRecord. +func (vasr VulnerabilityAssessmentScanRecord) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if vasr.VulnerabilityAssessmentScanRecordProperties != nil { + objectMap["properties"] = vasr.VulnerabilityAssessmentScanRecordProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for VulnerabilityAssessmentScanRecord struct. +func (vasr *VulnerabilityAssessmentScanRecord) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var vulnerabilityAssessmentScanRecordProperties VulnerabilityAssessmentScanRecordProperties + err = json.Unmarshal(*v, &vulnerabilityAssessmentScanRecordProperties) + if err != nil { + return err + } + vasr.VulnerabilityAssessmentScanRecordProperties = &vulnerabilityAssessmentScanRecordProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + vasr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + vasr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + vasr.Type = &typeVar + } + } + } + + return nil +} + +// VulnerabilityAssessmentScanRecordListResult a list of vulnerability assessment scan records. +type VulnerabilityAssessmentScanRecordListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]VulnerabilityAssessmentScanRecord `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for VulnerabilityAssessmentScanRecordListResult. +func (vasrlr VulnerabilityAssessmentScanRecordListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// VulnerabilityAssessmentScanRecordListResultIterator provides access to a complete listing of +// VulnerabilityAssessmentScanRecord values. +type VulnerabilityAssessmentScanRecordListResultIterator struct { + i int + page VulnerabilityAssessmentScanRecordListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *VulnerabilityAssessmentScanRecordListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/VulnerabilityAssessmentScanRecordListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *VulnerabilityAssessmentScanRecordListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter VulnerabilityAssessmentScanRecordListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter VulnerabilityAssessmentScanRecordListResultIterator) Response() VulnerabilityAssessmentScanRecordListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter VulnerabilityAssessmentScanRecordListResultIterator) Value() VulnerabilityAssessmentScanRecord { + if !iter.page.NotDone() { + return VulnerabilityAssessmentScanRecord{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the VulnerabilityAssessmentScanRecordListResultIterator type. +func NewVulnerabilityAssessmentScanRecordListResultIterator(page VulnerabilityAssessmentScanRecordListResultPage) VulnerabilityAssessmentScanRecordListResultIterator { + return VulnerabilityAssessmentScanRecordListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (vasrlr VulnerabilityAssessmentScanRecordListResult) IsEmpty() bool { + return vasrlr.Value == nil || len(*vasrlr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (vasrlr VulnerabilityAssessmentScanRecordListResult) hasNextLink() bool { + return vasrlr.NextLink != nil && len(*vasrlr.NextLink) != 0 +} + +// vulnerabilityAssessmentScanRecordListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (vasrlr VulnerabilityAssessmentScanRecordListResult) vulnerabilityAssessmentScanRecordListResultPreparer(ctx context.Context) (*http.Request, error) { + if !vasrlr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(vasrlr.NextLink))) +} + +// VulnerabilityAssessmentScanRecordListResultPage contains a page of VulnerabilityAssessmentScanRecord +// values. +type VulnerabilityAssessmentScanRecordListResultPage struct { + fn func(context.Context, VulnerabilityAssessmentScanRecordListResult) (VulnerabilityAssessmentScanRecordListResult, error) + vasrlr VulnerabilityAssessmentScanRecordListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *VulnerabilityAssessmentScanRecordListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/VulnerabilityAssessmentScanRecordListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.vasrlr) + if err != nil { + return err + } + page.vasrlr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *VulnerabilityAssessmentScanRecordListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page VulnerabilityAssessmentScanRecordListResultPage) NotDone() bool { + return !page.vasrlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page VulnerabilityAssessmentScanRecordListResultPage) Response() VulnerabilityAssessmentScanRecordListResult { + return page.vasrlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page VulnerabilityAssessmentScanRecordListResultPage) Values() []VulnerabilityAssessmentScanRecord { + if page.vasrlr.IsEmpty() { + return nil + } + return *page.vasrlr.Value +} + +// Creates a new instance of the VulnerabilityAssessmentScanRecordListResultPage type. +func NewVulnerabilityAssessmentScanRecordListResultPage(cur VulnerabilityAssessmentScanRecordListResult, getNextPage func(context.Context, VulnerabilityAssessmentScanRecordListResult) (VulnerabilityAssessmentScanRecordListResult, error)) VulnerabilityAssessmentScanRecordListResultPage { + return VulnerabilityAssessmentScanRecordListResultPage{ + fn: getNextPage, + vasrlr: cur, + } +} + +// VulnerabilityAssessmentScanRecordProperties properties of a vulnerability assessment scan record. +type VulnerabilityAssessmentScanRecordProperties struct { + // ScanID - READ-ONLY; The scan ID. + ScanID *string `json:"scanId,omitempty"` + // TriggerType - READ-ONLY; The scan trigger type. Possible values include: 'VulnerabilityAssessmentScanTriggerTypeOnDemand', 'VulnerabilityAssessmentScanTriggerTypeRecurring' + TriggerType VulnerabilityAssessmentScanTriggerType `json:"triggerType,omitempty"` + // State - READ-ONLY; The scan status. Possible values include: 'VulnerabilityAssessmentScanStatePassed', 'VulnerabilityAssessmentScanStateFailed', 'VulnerabilityAssessmentScanStateFailedToRun', 'VulnerabilityAssessmentScanStateInProgress' + State VulnerabilityAssessmentScanState `json:"state,omitempty"` + // StartTime - READ-ONLY; The scan start time (UTC). + StartTime *date.Time `json:"startTime,omitempty"` + // EndTime - READ-ONLY; The scan end time (UTC). + EndTime *date.Time `json:"endTime,omitempty"` + // Errors - READ-ONLY; The scan errors. + Errors *[]VulnerabilityAssessmentScanError `json:"errors,omitempty"` + // StorageContainerPath - READ-ONLY; The scan results storage container path. + StorageContainerPath *string `json:"storageContainerPath,omitempty"` + // NumberOfFailedSecurityChecks - READ-ONLY; The number of failed security checks. + NumberOfFailedSecurityChecks *int32 `json:"numberOfFailedSecurityChecks,omitempty"` +} + +// MarshalJSON is the custom marshaler for VulnerabilityAssessmentScanRecordProperties. +func (vasrp VulnerabilityAssessmentScanRecordProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// WorkloadClassifier workload classifier operations for a data warehouse +type WorkloadClassifier struct { + autorest.Response `json:"-"` + // WorkloadClassifierProperties - Resource properties. + *WorkloadClassifierProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for WorkloadClassifier. +func (wc WorkloadClassifier) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if wc.WorkloadClassifierProperties != nil { + objectMap["properties"] = wc.WorkloadClassifierProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for WorkloadClassifier struct. +func (wc *WorkloadClassifier) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var workloadClassifierProperties WorkloadClassifierProperties + err = json.Unmarshal(*v, &workloadClassifierProperties) + if err != nil { + return err + } + wc.WorkloadClassifierProperties = &workloadClassifierProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + wc.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + wc.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + wc.Type = &typeVar + } + } + } + + return nil +} + +// WorkloadClassifierListResult a list of workload classifiers for a workload group. +type WorkloadClassifierListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]WorkloadClassifier `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for WorkloadClassifierListResult. +func (wclr WorkloadClassifierListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// WorkloadClassifierListResultIterator provides access to a complete listing of WorkloadClassifier values. +type WorkloadClassifierListResultIterator struct { + i int + page WorkloadClassifierListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *WorkloadClassifierListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkloadClassifierListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *WorkloadClassifierListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter WorkloadClassifierListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter WorkloadClassifierListResultIterator) Response() WorkloadClassifierListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter WorkloadClassifierListResultIterator) Value() WorkloadClassifier { + if !iter.page.NotDone() { + return WorkloadClassifier{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the WorkloadClassifierListResultIterator type. +func NewWorkloadClassifierListResultIterator(page WorkloadClassifierListResultPage) WorkloadClassifierListResultIterator { + return WorkloadClassifierListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (wclr WorkloadClassifierListResult) IsEmpty() bool { + return wclr.Value == nil || len(*wclr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (wclr WorkloadClassifierListResult) hasNextLink() bool { + return wclr.NextLink != nil && len(*wclr.NextLink) != 0 +} + +// workloadClassifierListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (wclr WorkloadClassifierListResult) workloadClassifierListResultPreparer(ctx context.Context) (*http.Request, error) { + if !wclr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(wclr.NextLink))) +} + +// WorkloadClassifierListResultPage contains a page of WorkloadClassifier values. +type WorkloadClassifierListResultPage struct { + fn func(context.Context, WorkloadClassifierListResult) (WorkloadClassifierListResult, error) + wclr WorkloadClassifierListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *WorkloadClassifierListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkloadClassifierListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.wclr) + if err != nil { + return err + } + page.wclr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *WorkloadClassifierListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page WorkloadClassifierListResultPage) NotDone() bool { + return !page.wclr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page WorkloadClassifierListResultPage) Response() WorkloadClassifierListResult { + return page.wclr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page WorkloadClassifierListResultPage) Values() []WorkloadClassifier { + if page.wclr.IsEmpty() { + return nil + } + return *page.wclr.Value +} + +// Creates a new instance of the WorkloadClassifierListResultPage type. +func NewWorkloadClassifierListResultPage(cur WorkloadClassifierListResult, getNextPage func(context.Context, WorkloadClassifierListResult) (WorkloadClassifierListResult, error)) WorkloadClassifierListResultPage { + return WorkloadClassifierListResultPage{ + fn: getNextPage, + wclr: cur, + } +} + +// WorkloadClassifierProperties workload classifier definition. For more information look at +// sys.workload_management_workload_classifiers (DMV). +type WorkloadClassifierProperties struct { + // MemberName - The workload classifier member name. + MemberName *string `json:"memberName,omitempty"` + // Label - The workload classifier label. + Label *string `json:"label,omitempty"` + // Context - The workload classifier context. + Context *string `json:"context,omitempty"` + // StartTime - The workload classifier start time for classification. + StartTime *string `json:"startTime,omitempty"` + // EndTime - The workload classifier end time for classification. + EndTime *string `json:"endTime,omitempty"` + // Importance - The workload classifier importance. + Importance *string `json:"importance,omitempty"` +} + +// WorkloadClassifiersCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type WorkloadClassifiersCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(WorkloadClassifiersClient) (WorkloadClassifier, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *WorkloadClassifiersCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for WorkloadClassifiersCreateOrUpdateFuture.Result. +func (future *WorkloadClassifiersCreateOrUpdateFuture) result(client WorkloadClassifiersClient) (wc WorkloadClassifier, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.WorkloadClassifiersCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + wc.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.WorkloadClassifiersCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if wc.Response.Response, err = future.GetResult(sender); err == nil && wc.Response.Response.StatusCode != http.StatusNoContent { + wc, err = client.CreateOrUpdateResponder(wc.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.WorkloadClassifiersCreateOrUpdateFuture", "Result", wc.Response.Response, "Failure responding to request") + } + } + return +} + +// WorkloadClassifiersDeleteFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type WorkloadClassifiersDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(WorkloadClassifiersClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *WorkloadClassifiersDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for WorkloadClassifiersDeleteFuture.Result. +func (future *WorkloadClassifiersDeleteFuture) result(client WorkloadClassifiersClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.WorkloadClassifiersDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.WorkloadClassifiersDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// WorkloadGroup workload group operations for a data warehouse +type WorkloadGroup struct { + autorest.Response `json:"-"` + // WorkloadGroupProperties - Resource properties. + *WorkloadGroupProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for WorkloadGroup. +func (wg WorkloadGroup) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if wg.WorkloadGroupProperties != nil { + objectMap["properties"] = wg.WorkloadGroupProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for WorkloadGroup struct. +func (wg *WorkloadGroup) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var workloadGroupProperties WorkloadGroupProperties + err = json.Unmarshal(*v, &workloadGroupProperties) + if err != nil { + return err + } + wg.WorkloadGroupProperties = &workloadGroupProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + wg.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + wg.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + wg.Type = &typeVar + } + } + } + + return nil +} + +// WorkloadGroupListResult a list of workload groups. +type WorkloadGroupListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Array of results. + Value *[]WorkloadGroup `json:"value,omitempty"` + // NextLink - READ-ONLY; Link to retrieve next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for WorkloadGroupListResult. +func (wglr WorkloadGroupListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// WorkloadGroupListResultIterator provides access to a complete listing of WorkloadGroup values. +type WorkloadGroupListResultIterator struct { + i int + page WorkloadGroupListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *WorkloadGroupListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkloadGroupListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *WorkloadGroupListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter WorkloadGroupListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter WorkloadGroupListResultIterator) Response() WorkloadGroupListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter WorkloadGroupListResultIterator) Value() WorkloadGroup { + if !iter.page.NotDone() { + return WorkloadGroup{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the WorkloadGroupListResultIterator type. +func NewWorkloadGroupListResultIterator(page WorkloadGroupListResultPage) WorkloadGroupListResultIterator { + return WorkloadGroupListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (wglr WorkloadGroupListResult) IsEmpty() bool { + return wglr.Value == nil || len(*wglr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (wglr WorkloadGroupListResult) hasNextLink() bool { + return wglr.NextLink != nil && len(*wglr.NextLink) != 0 +} + +// workloadGroupListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (wglr WorkloadGroupListResult) workloadGroupListResultPreparer(ctx context.Context) (*http.Request, error) { + if !wglr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(wglr.NextLink))) +} + +// WorkloadGroupListResultPage contains a page of WorkloadGroup values. +type WorkloadGroupListResultPage struct { + fn func(context.Context, WorkloadGroupListResult) (WorkloadGroupListResult, error) + wglr WorkloadGroupListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *WorkloadGroupListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkloadGroupListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.wglr) + if err != nil { + return err + } + page.wglr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *WorkloadGroupListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page WorkloadGroupListResultPage) NotDone() bool { + return !page.wglr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page WorkloadGroupListResultPage) Response() WorkloadGroupListResult { + return page.wglr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page WorkloadGroupListResultPage) Values() []WorkloadGroup { + if page.wglr.IsEmpty() { + return nil + } + return *page.wglr.Value +} + +// Creates a new instance of the WorkloadGroupListResultPage type. +func NewWorkloadGroupListResultPage(cur WorkloadGroupListResult, getNextPage func(context.Context, WorkloadGroupListResult) (WorkloadGroupListResult, error)) WorkloadGroupListResultPage { + return WorkloadGroupListResultPage{ + fn: getNextPage, + wglr: cur, + } +} + +// WorkloadGroupProperties workload group definition. For more information look at +// sys.workload_management_workload_groups (DMV). +type WorkloadGroupProperties struct { + // MinResourcePercent - The workload group minimum percentage resource. + MinResourcePercent *int32 `json:"minResourcePercent,omitempty"` + // MaxResourcePercent - The workload group cap percentage resource. + MaxResourcePercent *int32 `json:"maxResourcePercent,omitempty"` + // MinResourcePercentPerRequest - The workload group request minimum grant percentage. + MinResourcePercentPerRequest *float64 `json:"minResourcePercentPerRequest,omitempty"` + // MaxResourcePercentPerRequest - The workload group request maximum grant percentage. + MaxResourcePercentPerRequest *float64 `json:"maxResourcePercentPerRequest,omitempty"` + // Importance - The workload group importance level. + Importance *string `json:"importance,omitempty"` + // QueryExecutionTimeout - The workload group query execution timeout. + QueryExecutionTimeout *int32 `json:"queryExecutionTimeout,omitempty"` +} + +// WorkloadGroupsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type WorkloadGroupsCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(WorkloadGroupsClient) (WorkloadGroup, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *WorkloadGroupsCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for WorkloadGroupsCreateOrUpdateFuture.Result. +func (future *WorkloadGroupsCreateOrUpdateFuture) result(client WorkloadGroupsClient) (wg WorkloadGroup, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.WorkloadGroupsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + wg.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.WorkloadGroupsCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if wg.Response.Response, err = future.GetResult(sender); err == nil && wg.Response.Response.StatusCode != http.StatusNoContent { + wg, err = client.CreateOrUpdateResponder(wg.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.WorkloadGroupsCreateOrUpdateFuture", "Result", wg.Response.Response, "Failure responding to request") + } + } + return +} + +// WorkloadGroupsDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type WorkloadGroupsDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(WorkloadGroupsClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *WorkloadGroupsDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for WorkloadGroupsDeleteFuture.Result. +func (future *WorkloadGroupsDeleteFuture) result(client WorkloadGroupsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.WorkloadGroupsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("sql.WorkloadGroupsDeleteFuture") + return + } + ar.Response = future.Response() + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/operations.go b/services/preview/sql/mgmt/v5.0/sql/operations.go new file mode 100644 index 000000000000..38fa701b900d --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/operations.go @@ -0,0 +1,142 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// OperationsClient is the the Azure SQL Database management API provides a RESTful set of web services that interact +// with Azure SQL Database services to manage your databases. The API enables you to create, retrieve, update, and +// delete databases. +type OperationsClient struct { + BaseClient +} + +// NewOperationsClient creates an instance of the OperationsClient client. +func NewOperationsClient(subscriptionID string) OperationsClient { + return NewOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewOperationsClientWithBaseURI creates an instance of the OperationsClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient { + return OperationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List lists all of the available SQL Rest API operations. +func (client OperationsClient) List(ctx context.Context) (result OperationListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List") + defer func() { + sc := -1 + if result.olr.Response.Response != nil { + sc = result.olr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.OperationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.olr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.OperationsClient", "List", resp, "Failure sending request") + return + } + + result.olr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.OperationsClient", "List", resp, "Failure responding to request") + return + } + if result.olr.hasNextLink() && result.olr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client OperationsClient) ListPreparer(ctx context.Context) (*http.Request, error) { + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.Sql/operations"), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client OperationsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client OperationsClient) ListResponder(resp *http.Response) (result OperationListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client OperationsClient) listNextResults(ctx context.Context, lastResults OperationListResult) (result OperationListResult, err error) { + req, err := lastResults.operationListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.OperationsClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.OperationsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.OperationsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client OperationsClient) ListComplete(ctx context.Context) (result OperationListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx) + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/operationshealth.go b/services/preview/sql/mgmt/v5.0/sql/operationshealth.go new file mode 100644 index 000000000000..336375cc7e29 --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/operationshealth.go @@ -0,0 +1,150 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// OperationsHealthClient is the the Azure SQL Database management API provides a RESTful set of web services that +// interact with Azure SQL Database services to manage your databases. The API enables you to create, retrieve, update, +// and delete databases. +type OperationsHealthClient struct { + BaseClient +} + +// NewOperationsHealthClient creates an instance of the OperationsHealthClient client. +func NewOperationsHealthClient(subscriptionID string) OperationsHealthClient { + return NewOperationsHealthClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewOperationsHealthClientWithBaseURI creates an instance of the OperationsHealthClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewOperationsHealthClientWithBaseURI(baseURI string, subscriptionID string) OperationsHealthClient { + return OperationsHealthClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListByLocation gets a service operation health status. +// Parameters: +// locationName - the name of the region where the resource is located. +func (client OperationsHealthClient) ListByLocation(ctx context.Context, locationName string) (result OperationsHealthListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationsHealthClient.ListByLocation") + defer func() { + sc := -1 + if result.ohlr.Response.Response != nil { + sc = result.ohlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByLocationNextResults + req, err := client.ListByLocationPreparer(ctx, locationName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.OperationsHealthClient", "ListByLocation", nil, "Failure preparing request") + return + } + + resp, err := client.ListByLocationSender(req) + if err != nil { + result.ohlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.OperationsHealthClient", "ListByLocation", resp, "Failure sending request") + return + } + + result.ohlr, err = client.ListByLocationResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.OperationsHealthClient", "ListByLocation", resp, "Failure responding to request") + return + } + if result.ohlr.hasNextLink() && result.ohlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByLocationPreparer prepares the ListByLocation request. +func (client OperationsHealthClient) ListByLocationPreparer(ctx context.Context, locationName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "locationName": autorest.Encode("path", locationName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/operationsHealth", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByLocationSender sends the ListByLocation request. The method will close the +// http.Response Body if it receives an error. +func (client OperationsHealthClient) ListByLocationSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByLocationResponder handles the response to the ListByLocation request. The method always +// closes the http.Response Body. +func (client OperationsHealthClient) ListByLocationResponder(resp *http.Response) (result OperationsHealthListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByLocationNextResults retrieves the next set of results, if any. +func (client OperationsHealthClient) listByLocationNextResults(ctx context.Context, lastResults OperationsHealthListResult) (result OperationsHealthListResult, err error) { + req, err := lastResults.operationsHealthListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.OperationsHealthClient", "listByLocationNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByLocationSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.OperationsHealthClient", "listByLocationNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByLocationResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.OperationsHealthClient", "listByLocationNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByLocationComplete enumerates all values, automatically crossing page boundaries as required. +func (client OperationsHealthClient) ListByLocationComplete(ctx context.Context, locationName string) (result OperationsHealthListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationsHealthClient.ListByLocation") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByLocation(ctx, locationName) + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/outboundfirewallrules.go b/services/preview/sql/mgmt/v5.0/sql/outboundfirewallrules.go new file mode 100644 index 000000000000..40e9e5317bdd --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/outboundfirewallrules.go @@ -0,0 +1,392 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// OutboundFirewallRulesClient 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 OutboundFirewallRulesClient struct { + BaseClient +} + +// NewOutboundFirewallRulesClient creates an instance of the OutboundFirewallRulesClient client. +func NewOutboundFirewallRulesClient(subscriptionID string) OutboundFirewallRulesClient { + return NewOutboundFirewallRulesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewOutboundFirewallRulesClientWithBaseURI creates an instance of the OutboundFirewallRulesClient client using a +// custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, +// Azure stack). +func NewOutboundFirewallRulesClientWithBaseURI(baseURI string, subscriptionID string) OutboundFirewallRulesClient { + return OutboundFirewallRulesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate create a outbound firewall rule with a given name. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +func (client OutboundFirewallRulesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, outboundRuleFqdn string, parameters OutboundFirewallRule) (result OutboundFirewallRulesCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OutboundFirewallRulesClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, outboundRuleFqdn, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.OutboundFirewallRulesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.OutboundFirewallRulesClient", "CreateOrUpdate", nil, "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client OutboundFirewallRulesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, outboundRuleFqdn string, parameters OutboundFirewallRule) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "outboundRuleFqdn": autorest.Encode("path", outboundRuleFqdn), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-02-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/outboundFirewallRules/{outboundRuleFqdn}", 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 OutboundFirewallRulesClient) CreateOrUpdateSender(req *http.Request) (future OutboundFirewallRulesCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client OutboundFirewallRulesClient) CreateOrUpdateResponder(resp *http.Response) (result OutboundFirewallRule, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a outbound firewall rule with a given name. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +func (client OutboundFirewallRulesClient) Delete(ctx context.Context, resourceGroupName string, serverName string, outboundRuleFqdn string) (result OutboundFirewallRulesDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OutboundFirewallRulesClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, serverName, outboundRuleFqdn) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.OutboundFirewallRulesClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.OutboundFirewallRulesClient", "Delete", nil, "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client OutboundFirewallRulesClient) DeletePreparer(ctx context.Context, resourceGroupName string, serverName string, outboundRuleFqdn string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "outboundRuleFqdn": autorest.Encode("path", outboundRuleFqdn), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-02-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/outboundFirewallRules/{outboundRuleFqdn}", 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 OutboundFirewallRulesClient) DeleteSender(req *http.Request) (future OutboundFirewallRulesDeleteFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client OutboundFirewallRulesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets an outbound firewall rule. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +func (client OutboundFirewallRulesClient) Get(ctx context.Context, resourceGroupName string, serverName string, outboundRuleFqdn string) (result OutboundFirewallRule, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OutboundFirewallRulesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, outboundRuleFqdn) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.OutboundFirewallRulesClient", "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.OutboundFirewallRulesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.OutboundFirewallRulesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client OutboundFirewallRulesClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, outboundRuleFqdn string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "outboundRuleFqdn": autorest.Encode("path", outboundRuleFqdn), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-02-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/outboundFirewallRules/{outboundRuleFqdn}", 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 OutboundFirewallRulesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client OutboundFirewallRulesClient) GetResponder(resp *http.Response) (result OutboundFirewallRule, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer gets all outbound firewall rules on a server. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +func (client OutboundFirewallRulesClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result OutboundFirewallRuleListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OutboundFirewallRulesClient.ListByServer") + defer func() { + sc := -1 + if result.ofrlr.Response.Response != nil { + sc = result.ofrlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByServerNextResults + req, err := client.ListByServerPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.OutboundFirewallRulesClient", "ListByServer", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServerSender(req) + if err != nil { + result.ofrlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.OutboundFirewallRulesClient", "ListByServer", resp, "Failure sending request") + return + } + + result.ofrlr, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.OutboundFirewallRulesClient", "ListByServer", resp, "Failure responding to request") + return + } + if result.ofrlr.hasNextLink() && result.ofrlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServerPreparer prepares the ListByServer request. +func (client OutboundFirewallRulesClient) ListByServerPreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-02-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/outboundFirewallRules", 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 OutboundFirewallRulesClient) ListByServerSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client OutboundFirewallRulesClient) ListByServerResponder(resp *http.Response) (result OutboundFirewallRuleListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByServerNextResults retrieves the next set of results, if any. +func (client OutboundFirewallRulesClient) listByServerNextResults(ctx context.Context, lastResults OutboundFirewallRuleListResult) (result OutboundFirewallRuleListResult, err error) { + req, err := lastResults.outboundFirewallRuleListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.OutboundFirewallRulesClient", "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.OutboundFirewallRulesClient", "listByServerNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.OutboundFirewallRulesClient", "listByServerNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServerComplete enumerates all values, automatically crossing page boundaries as required. +func (client OutboundFirewallRulesClient) ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result OutboundFirewallRuleListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OutboundFirewallRulesClient.ListByServer") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByServer(ctx, resourceGroupName, serverName) + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/privateendpointconnections.go b/services/preview/sql/mgmt/v5.0/sql/privateendpointconnections.go new file mode 100644 index 000000000000..a090ca0ff760 --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/privateendpointconnections.go @@ -0,0 +1,403 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// PrivateEndpointConnectionsClient is the the Azure SQL Database management API provides a RESTful set of web services +// that interact with Azure SQL Database services to manage your databases. The API enables you to create, retrieve, +// update, and delete databases. +type PrivateEndpointConnectionsClient struct { + BaseClient +} + +// NewPrivateEndpointConnectionsClient creates an instance of the PrivateEndpointConnectionsClient client. +func NewPrivateEndpointConnectionsClient(subscriptionID string) PrivateEndpointConnectionsClient { + return NewPrivateEndpointConnectionsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewPrivateEndpointConnectionsClientWithBaseURI creates an instance of the PrivateEndpointConnectionsClient client +// using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign +// clouds, Azure stack). +func NewPrivateEndpointConnectionsClientWithBaseURI(baseURI string, subscriptionID string) PrivateEndpointConnectionsClient { + return PrivateEndpointConnectionsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate approve or reject a private endpoint connection with a given name. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +func (client PrivateEndpointConnectionsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, privateEndpointConnectionName string, parameters PrivateEndpointConnection) (result PrivateEndpointConnectionsCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.PrivateEndpointConnectionProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.PrivateEndpointConnectionProperties.PrivateLinkServiceConnectionState", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.PrivateEndpointConnectionProperties.PrivateLinkServiceConnectionState.Description", Name: validation.Null, Rule: true, Chain: nil}}}, + }}}}}); err != nil { + return result, validation.NewError("sql.PrivateEndpointConnectionsClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, privateEndpointConnectionName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.PrivateEndpointConnectionsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.PrivateEndpointConnectionsClient", "CreateOrUpdate", nil, "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client PrivateEndpointConnectionsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, privateEndpointConnectionName string, parameters PrivateEndpointConnection) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateEndpointConnectionName": autorest.Encode("path", privateEndpointConnectionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/privateEndpointConnections/{privateEndpointConnectionName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateEndpointConnectionsClient) CreateOrUpdateSender(req *http.Request) (future PrivateEndpointConnectionsCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client PrivateEndpointConnectionsClient) CreateOrUpdateResponder(resp *http.Response) (result PrivateEndpointConnection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a private endpoint connection with a given name. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +func (client PrivateEndpointConnectionsClient) Delete(ctx context.Context, resourceGroupName string, serverName string, privateEndpointConnectionName string) (result PrivateEndpointConnectionsDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, serverName, privateEndpointConnectionName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.PrivateEndpointConnectionsClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.PrivateEndpointConnectionsClient", "Delete", nil, "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client PrivateEndpointConnectionsClient) DeletePreparer(ctx context.Context, resourceGroupName string, serverName string, privateEndpointConnectionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateEndpointConnectionName": autorest.Encode("path", privateEndpointConnectionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/privateEndpointConnections/{privateEndpointConnectionName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateEndpointConnectionsClient) DeleteSender(req *http.Request) (future PrivateEndpointConnectionsDeleteFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client PrivateEndpointConnectionsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a private endpoint connection. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// privateEndpointConnectionName - the name of the private endpoint connection. +func (client PrivateEndpointConnectionsClient) Get(ctx context.Context, resourceGroupName string, serverName string, privateEndpointConnectionName string) (result PrivateEndpointConnection, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, privateEndpointConnectionName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.PrivateEndpointConnectionsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.PrivateEndpointConnectionsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.PrivateEndpointConnectionsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client PrivateEndpointConnectionsClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, privateEndpointConnectionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateEndpointConnectionName": autorest.Encode("path", privateEndpointConnectionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/privateEndpointConnections/{privateEndpointConnectionName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateEndpointConnectionsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client PrivateEndpointConnectionsClient) GetResponder(resp *http.Response) (result PrivateEndpointConnection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer gets all private endpoint connections on a server. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +func (client PrivateEndpointConnectionsClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result PrivateEndpointConnectionListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsClient.ListByServer") + defer func() { + sc := -1 + if result.peclr.Response.Response != nil { + sc = result.peclr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByServerNextResults + req, err := client.ListByServerPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.PrivateEndpointConnectionsClient", "ListByServer", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServerSender(req) + if err != nil { + result.peclr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.PrivateEndpointConnectionsClient", "ListByServer", resp, "Failure sending request") + return + } + + result.peclr, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.PrivateEndpointConnectionsClient", "ListByServer", resp, "Failure responding to request") + return + } + if result.peclr.hasNextLink() && result.peclr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServerPreparer prepares the ListByServer request. +func (client PrivateEndpointConnectionsClient) ListByServerPreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/privateEndpointConnections", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByServerSender sends the ListByServer request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateEndpointConnectionsClient) ListByServerSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client PrivateEndpointConnectionsClient) ListByServerResponder(resp *http.Response) (result PrivateEndpointConnectionListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByServerNextResults retrieves the next set of results, if any. +func (client PrivateEndpointConnectionsClient) listByServerNextResults(ctx context.Context, lastResults PrivateEndpointConnectionListResult) (result PrivateEndpointConnectionListResult, err error) { + req, err := lastResults.privateEndpointConnectionListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.PrivateEndpointConnectionsClient", "listByServerNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByServerSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.PrivateEndpointConnectionsClient", "listByServerNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.PrivateEndpointConnectionsClient", "listByServerNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServerComplete enumerates all values, automatically crossing page boundaries as required. +func (client PrivateEndpointConnectionsClient) ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result PrivateEndpointConnectionListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsClient.ListByServer") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByServer(ctx, resourceGroupName, serverName) + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/privatelinkresources.go b/services/preview/sql/mgmt/v5.0/sql/privatelinkresources.go new file mode 100644 index 000000000000..13d62618ce58 --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/privatelinkresources.go @@ -0,0 +1,232 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// PrivateLinkResourcesClient is the the Azure SQL Database management API provides a RESTful set of web services that +// interact with Azure SQL Database services to manage your databases. The API enables you to create, retrieve, update, +// and delete databases. +type PrivateLinkResourcesClient struct { + BaseClient +} + +// NewPrivateLinkResourcesClient creates an instance of the PrivateLinkResourcesClient client. +func NewPrivateLinkResourcesClient(subscriptionID string) PrivateLinkResourcesClient { + return NewPrivateLinkResourcesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewPrivateLinkResourcesClientWithBaseURI creates an instance of the PrivateLinkResourcesClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewPrivateLinkResourcesClientWithBaseURI(baseURI string, subscriptionID string) PrivateLinkResourcesClient { + return PrivateLinkResourcesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get gets a private link resource for SQL server. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// groupName - the name of the private link resource. +func (client PrivateLinkResourcesClient) Get(ctx context.Context, resourceGroupName string, serverName string, groupName string) (result PrivateLinkResource, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkResourcesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, groupName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.PrivateLinkResourcesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.PrivateLinkResourcesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.PrivateLinkResourcesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client PrivateLinkResourcesClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, groupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "groupName": autorest.Encode("path", groupName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/privateLinkResources/{groupName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateLinkResourcesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client PrivateLinkResourcesClient) GetResponder(resp *http.Response) (result PrivateLinkResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer gets the private link resources for SQL server. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +func (client PrivateLinkResourcesClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result PrivateLinkResourceListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkResourcesClient.ListByServer") + defer func() { + sc := -1 + if result.plrlr.Response.Response != nil { + sc = result.plrlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByServerNextResults + req, err := client.ListByServerPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.PrivateLinkResourcesClient", "ListByServer", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServerSender(req) + if err != nil { + result.plrlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.PrivateLinkResourcesClient", "ListByServer", resp, "Failure sending request") + return + } + + result.plrlr, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.PrivateLinkResourcesClient", "ListByServer", resp, "Failure responding to request") + return + } + if result.plrlr.hasNextLink() && result.plrlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServerPreparer prepares the ListByServer request. +func (client PrivateLinkResourcesClient) ListByServerPreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/privateLinkResources", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByServerSender sends the ListByServer request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateLinkResourcesClient) ListByServerSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client PrivateLinkResourcesClient) ListByServerResponder(resp *http.Response) (result PrivateLinkResourceListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByServerNextResults retrieves the next set of results, if any. +func (client PrivateLinkResourcesClient) listByServerNextResults(ctx context.Context, lastResults PrivateLinkResourceListResult) (result PrivateLinkResourceListResult, err error) { + req, err := lastResults.privateLinkResourceListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.PrivateLinkResourcesClient", "listByServerNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByServerSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.PrivateLinkResourcesClient", "listByServerNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.PrivateLinkResourcesClient", "listByServerNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServerComplete enumerates all values, automatically crossing page boundaries as required. +func (client PrivateLinkResourcesClient) ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result PrivateLinkResourceListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkResourcesClient.ListByServer") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByServer(ctx, resourceGroupName, serverName) + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/recommendedsensitivitylabels.go b/services/preview/sql/mgmt/v5.0/sql/recommendedsensitivitylabels.go new file mode 100644 index 000000000000..8a9311a7939e --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/recommendedsensitivitylabels.go @@ -0,0 +1,114 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// RecommendedSensitivityLabelsClient 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 RecommendedSensitivityLabelsClient struct { + BaseClient +} + +// NewRecommendedSensitivityLabelsClient creates an instance of the RecommendedSensitivityLabelsClient client. +func NewRecommendedSensitivityLabelsClient(subscriptionID string) RecommendedSensitivityLabelsClient { + return NewRecommendedSensitivityLabelsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewRecommendedSensitivityLabelsClientWithBaseURI creates an instance of the RecommendedSensitivityLabelsClient +// client using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI +// (sovereign clouds, Azure stack). +func NewRecommendedSensitivityLabelsClientWithBaseURI(baseURI string, subscriptionID string) RecommendedSensitivityLabelsClient { + return RecommendedSensitivityLabelsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Update update recommended sensitivity labels states of a given database using an operations batch. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database. +func (client RecommendedSensitivityLabelsClient) Update(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters RecommendedSensitivityLabelUpdateList) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RecommendedSensitivityLabelsClient.Update") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.UpdatePreparer(ctx, resourceGroupName, serverName, databaseName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.RecommendedSensitivityLabelsClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "sql.RecommendedSensitivityLabelsClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.RecommendedSensitivityLabelsClient", "Update", resp, "Failure responding to request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client RecommendedSensitivityLabelsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters RecommendedSensitivityLabelUpdateList) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.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}/recommendedSensitivityLabels", 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 RecommendedSensitivityLabelsClient) UpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client RecommendedSensitivityLabelsClient) UpdateResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/recoverabledatabases.go b/services/preview/sql/mgmt/v5.0/sql/recoverabledatabases.go new file mode 100644 index 000000000000..ef56a498903f --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/recoverabledatabases.go @@ -0,0 +1,190 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// RecoverableDatabasesClient is the the Azure SQL Database management API provides a RESTful set of web services that +// interact with Azure SQL Database services to manage your databases. The API enables you to create, retrieve, update, +// and delete databases. +type RecoverableDatabasesClient struct { + BaseClient +} + +// NewRecoverableDatabasesClient creates an instance of the RecoverableDatabasesClient client. +func NewRecoverableDatabasesClient(subscriptionID string) RecoverableDatabasesClient { + return NewRecoverableDatabasesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewRecoverableDatabasesClientWithBaseURI creates an instance of the RecoverableDatabasesClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewRecoverableDatabasesClientWithBaseURI(baseURI string, subscriptionID string) RecoverableDatabasesClient { + return RecoverableDatabasesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get gets a recoverable database, which is a resource representing a database's geo backup +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database +func (client RecoverableDatabasesClient) Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result RecoverableDatabase, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RecoverableDatabasesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.RecoverableDatabasesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.RecoverableDatabasesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.RecoverableDatabasesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client RecoverableDatabasesClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/recoverableDatabases/{databaseName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client RecoverableDatabasesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client RecoverableDatabasesClient) GetResponder(resp *http.Response) (result RecoverableDatabase, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer gets a list of recoverable databases +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +func (client RecoverableDatabasesClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result RecoverableDatabaseListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RecoverableDatabasesClient.ListByServer") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListByServerPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.RecoverableDatabasesClient", "ListByServer", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServerSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.RecoverableDatabasesClient", "ListByServer", resp, "Failure sending request") + return + } + + result, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.RecoverableDatabasesClient", "ListByServer", resp, "Failure responding to request") + return + } + + return +} + +// ListByServerPreparer prepares the ListByServer request. +func (client RecoverableDatabasesClient) ListByServerPreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/recoverableDatabases", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByServerSender sends the ListByServer request. The method will close the +// http.Response Body if it receives an error. +func (client RecoverableDatabasesClient) ListByServerSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client RecoverableDatabasesClient) ListByServerResponder(resp *http.Response) (result RecoverableDatabaseListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/recoverablemanageddatabases.go b/services/preview/sql/mgmt/v5.0/sql/recoverablemanageddatabases.go new file mode 100644 index 000000000000..e069a98d5746 --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/recoverablemanageddatabases.go @@ -0,0 +1,231 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// RecoverableManagedDatabasesClient is the the Azure SQL Database management API provides a RESTful set of web +// services that interact with Azure SQL Database services to manage your databases. The API enables you to create, +// retrieve, update, and delete databases. +type RecoverableManagedDatabasesClient struct { + BaseClient +} + +// NewRecoverableManagedDatabasesClient creates an instance of the RecoverableManagedDatabasesClient client. +func NewRecoverableManagedDatabasesClient(subscriptionID string) RecoverableManagedDatabasesClient { + return NewRecoverableManagedDatabasesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewRecoverableManagedDatabasesClientWithBaseURI creates an instance of the RecoverableManagedDatabasesClient client +// using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign +// clouds, Azure stack). +func NewRecoverableManagedDatabasesClientWithBaseURI(baseURI string, subscriptionID string) RecoverableManagedDatabasesClient { + return RecoverableManagedDatabasesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get gets a recoverable managed database. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +func (client RecoverableManagedDatabasesClient) Get(ctx context.Context, resourceGroupName string, managedInstanceName string, recoverableDatabaseName string) (result RecoverableManagedDatabase, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RecoverableManagedDatabasesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, managedInstanceName, recoverableDatabaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.RecoverableManagedDatabasesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.RecoverableManagedDatabasesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.RecoverableManagedDatabasesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client RecoverableManagedDatabasesClient) GetPreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, recoverableDatabaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "recoverableDatabaseName": autorest.Encode("path", recoverableDatabaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/recoverableDatabases/{recoverableDatabaseName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client RecoverableManagedDatabasesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client RecoverableManagedDatabasesClient) GetResponder(resp *http.Response) (result RecoverableManagedDatabase, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByInstance gets a list of recoverable managed databases. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +func (client RecoverableManagedDatabasesClient) ListByInstance(ctx context.Context, resourceGroupName string, managedInstanceName string) (result RecoverableManagedDatabaseListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RecoverableManagedDatabasesClient.ListByInstance") + defer func() { + sc := -1 + if result.rmdlr.Response.Response != nil { + sc = result.rmdlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByInstanceNextResults + req, err := client.ListByInstancePreparer(ctx, resourceGroupName, managedInstanceName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.RecoverableManagedDatabasesClient", "ListByInstance", nil, "Failure preparing request") + return + } + + resp, err := client.ListByInstanceSender(req) + if err != nil { + result.rmdlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.RecoverableManagedDatabasesClient", "ListByInstance", resp, "Failure sending request") + return + } + + result.rmdlr, err = client.ListByInstanceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.RecoverableManagedDatabasesClient", "ListByInstance", resp, "Failure responding to request") + return + } + if result.rmdlr.hasNextLink() && result.rmdlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByInstancePreparer prepares the ListByInstance request. +func (client RecoverableManagedDatabasesClient) ListByInstancePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/recoverableDatabases", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByInstanceSender sends the ListByInstance request. The method will close the +// http.Response Body if it receives an error. +func (client RecoverableManagedDatabasesClient) ListByInstanceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByInstanceResponder handles the response to the ListByInstance request. The method always +// closes the http.Response Body. +func (client RecoverableManagedDatabasesClient) ListByInstanceResponder(resp *http.Response) (result RecoverableManagedDatabaseListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByInstanceNextResults retrieves the next set of results, if any. +func (client RecoverableManagedDatabasesClient) listByInstanceNextResults(ctx context.Context, lastResults RecoverableManagedDatabaseListResult) (result RecoverableManagedDatabaseListResult, err error) { + req, err := lastResults.recoverableManagedDatabaseListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.RecoverableManagedDatabasesClient", "listByInstanceNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByInstanceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.RecoverableManagedDatabasesClient", "listByInstanceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByInstanceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.RecoverableManagedDatabasesClient", "listByInstanceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByInstanceComplete enumerates all values, automatically crossing page boundaries as required. +func (client RecoverableManagedDatabasesClient) ListByInstanceComplete(ctx context.Context, resourceGroupName string, managedInstanceName string) (result RecoverableManagedDatabaseListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RecoverableManagedDatabasesClient.ListByInstance") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByInstance(ctx, resourceGroupName, managedInstanceName) + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/replicationlinks.go b/services/preview/sql/mgmt/v5.0/sql/replicationlinks.go new file mode 100644 index 000000000000..63ff6116cbca --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/replicationlinks.go @@ -0,0 +1,685 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ReplicationLinksClient is the the Azure SQL Database management API provides a RESTful set of web services that +// interact with Azure SQL Database services to manage your databases. The API enables you to create, retrieve, update, +// and delete databases. +type ReplicationLinksClient struct { + BaseClient +} + +// NewReplicationLinksClient creates an instance of the ReplicationLinksClient client. +func NewReplicationLinksClient(subscriptionID string) ReplicationLinksClient { + return NewReplicationLinksClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewReplicationLinksClientWithBaseURI creates an instance of the ReplicationLinksClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewReplicationLinksClientWithBaseURI(baseURI string, subscriptionID string) ReplicationLinksClient { + return ReplicationLinksClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Delete deletes a database replication link. Cannot be done during failover. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database that has the replication link to be dropped. +// linkID - the ID of the replication link to be deleted. +func (client ReplicationLinksClient) Delete(ctx context.Context, resourceGroupName string, serverName string, databaseName string, linkID string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationLinksClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, serverName, databaseName, linkID) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ReplicationLinksClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "sql.ReplicationLinksClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ReplicationLinksClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ReplicationLinksClient) DeletePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, linkID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "linkId": autorest.Encode("path", linkID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/replicationLinks/{linkId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationLinksClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ReplicationLinksClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Failover sets which replica database is primary by failing over from the current primary replica database. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database that has the replication link to be failed over. +// linkID - the ID of the replication link to be failed over. +func (client ReplicationLinksClient) Failover(ctx context.Context, resourceGroupName string, serverName string, databaseName string, linkID string) (result ReplicationLinksFailoverFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationLinksClient.Failover") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.FailoverPreparer(ctx, resourceGroupName, serverName, databaseName, linkID) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ReplicationLinksClient", "Failover", nil, "Failure preparing request") + return + } + + result, err = client.FailoverSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ReplicationLinksClient", "Failover", nil, "Failure sending request") + return + } + + return +} + +// FailoverPreparer prepares the Failover request. +func (client ReplicationLinksClient) FailoverPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, linkID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "linkId": autorest.Encode("path", linkID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/replicationLinks/{linkId}/failover", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// FailoverSender sends the Failover request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationLinksClient) FailoverSender(req *http.Request) (future ReplicationLinksFailoverFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// FailoverResponder handles the response to the Failover request. The method always +// closes the http.Response Body. +func (client ReplicationLinksClient) FailoverResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// FailoverAllowDataLoss sets which replica database is primary by failing over from the current primary replica +// database. This operation might result in data loss. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database that has the replication link to be failed over. +// linkID - the ID of the replication link to be failed over. +func (client ReplicationLinksClient) FailoverAllowDataLoss(ctx context.Context, resourceGroupName string, serverName string, databaseName string, linkID string) (result ReplicationLinksFailoverAllowDataLossFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationLinksClient.FailoverAllowDataLoss") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.FailoverAllowDataLossPreparer(ctx, resourceGroupName, serverName, databaseName, linkID) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ReplicationLinksClient", "FailoverAllowDataLoss", nil, "Failure preparing request") + return + } + + result, err = client.FailoverAllowDataLossSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ReplicationLinksClient", "FailoverAllowDataLoss", nil, "Failure sending request") + return + } + + return +} + +// FailoverAllowDataLossPreparer prepares the FailoverAllowDataLoss request. +func (client ReplicationLinksClient) FailoverAllowDataLossPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, linkID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "linkId": autorest.Encode("path", linkID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/replicationLinks/{linkId}/forceFailoverAllowDataLoss", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// FailoverAllowDataLossSender sends the FailoverAllowDataLoss request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationLinksClient) FailoverAllowDataLossSender(req *http.Request) (future ReplicationLinksFailoverAllowDataLossFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// FailoverAllowDataLossResponder handles the response to the FailoverAllowDataLoss request. The method always +// closes the http.Response Body. +func (client ReplicationLinksClient) FailoverAllowDataLossResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a replication link. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database. +// linkID - the name of the replication link. +func (client ReplicationLinksClient) Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string, linkID string) (result ReplicationLink, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationLinksClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, databaseName, linkID) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ReplicationLinksClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ReplicationLinksClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ReplicationLinksClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ReplicationLinksClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, linkID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "linkId": autorest.Encode("path", linkID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-02-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/replicationLinks/{linkId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationLinksClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ReplicationLinksClient) GetResponder(resp *http.Response) (result ReplicationLink, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByDatabase gets a list of replication links on database. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database. +func (client ReplicationLinksClient) ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result ReplicationLinkListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationLinksClient.ListByDatabase") + defer func() { + sc := -1 + if result.rllr.Response.Response != nil { + sc = result.rllr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByDatabaseNextResults + req, err := client.ListByDatabasePreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ReplicationLinksClient", "ListByDatabase", nil, "Failure preparing request") + return + } + + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.rllr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ReplicationLinksClient", "ListByDatabase", resp, "Failure sending request") + return + } + + result.rllr, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ReplicationLinksClient", "ListByDatabase", resp, "Failure responding to request") + return + } + if result.rllr.hasNextLink() && result.rllr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByDatabasePreparer prepares the ListByDatabase request. +func (client ReplicationLinksClient) ListByDatabasePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-02-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/replicationLinks", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByDatabaseSender sends the ListByDatabase request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationLinksClient) ListByDatabaseSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByDatabaseResponder handles the response to the ListByDatabase request. The method always +// closes the http.Response Body. +func (client ReplicationLinksClient) ListByDatabaseResponder(resp *http.Response) (result ReplicationLinkListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByDatabaseNextResults retrieves the next set of results, if any. +func (client ReplicationLinksClient) listByDatabaseNextResults(ctx context.Context, lastResults ReplicationLinkListResult) (result ReplicationLinkListResult, err error) { + req, err := lastResults.replicationLinkListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.ReplicationLinksClient", "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.ReplicationLinksClient", "listByDatabaseNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ReplicationLinksClient", "listByDatabaseNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByDatabaseComplete enumerates all values, automatically crossing page boundaries as required. +func (client ReplicationLinksClient) ListByDatabaseComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result ReplicationLinkListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationLinksClient.ListByDatabase") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByDatabase(ctx, resourceGroupName, serverName, databaseName) + return +} + +// ListByServer gets a list of replication links. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +func (client ReplicationLinksClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result ReplicationLinkListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationLinksClient.ListByServer") + defer func() { + sc := -1 + if result.rllr.Response.Response != nil { + sc = result.rllr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByServerNextResults + req, err := client.ListByServerPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ReplicationLinksClient", "ListByServer", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServerSender(req) + if err != nil { + result.rllr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ReplicationLinksClient", "ListByServer", resp, "Failure sending request") + return + } + + result.rllr, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ReplicationLinksClient", "ListByServer", resp, "Failure responding to request") + return + } + if result.rllr.hasNextLink() && result.rllr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServerPreparer prepares the ListByServer request. +func (client ReplicationLinksClient) ListByServerPreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-02-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/replicationLinks", 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 ReplicationLinksClient) ListByServerSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client ReplicationLinksClient) ListByServerResponder(resp *http.Response) (result ReplicationLinkListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByServerNextResults retrieves the next set of results, if any. +func (client ReplicationLinksClient) listByServerNextResults(ctx context.Context, lastResults ReplicationLinkListResult) (result ReplicationLinkListResult, err error) { + req, err := lastResults.replicationLinkListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.ReplicationLinksClient", "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.ReplicationLinksClient", "listByServerNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ReplicationLinksClient", "listByServerNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServerComplete enumerates all values, automatically crossing page boundaries as required. +func (client ReplicationLinksClient) ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result ReplicationLinkListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationLinksClient.ListByServer") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByServer(ctx, resourceGroupName, serverName) + return +} + +// Unlink deletes a database replication link in forced or friendly way. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database that has the replication link to be failed over. +// linkID - the ID of the replication link to be failed over. +// parameters - the required parameters for unlinking replication link. +func (client ReplicationLinksClient) Unlink(ctx context.Context, resourceGroupName string, serverName string, databaseName string, linkID string, parameters UnlinkParameters) (result ReplicationLinksUnlinkFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationLinksClient.Unlink") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.UnlinkPreparer(ctx, resourceGroupName, serverName, databaseName, linkID, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ReplicationLinksClient", "Unlink", nil, "Failure preparing request") + return + } + + result, err = client.UnlinkSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ReplicationLinksClient", "Unlink", nil, "Failure sending request") + return + } + + return +} + +// UnlinkPreparer prepares the Unlink request. +func (client ReplicationLinksClient) UnlinkPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, linkID string, parameters UnlinkParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "linkId": autorest.Encode("path", linkID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/replicationLinks/{linkId}/unlink", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UnlinkSender sends the Unlink request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationLinksClient) UnlinkSender(req *http.Request) (future ReplicationLinksUnlinkFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// UnlinkResponder handles the response to the Unlink request. The method always +// closes the http.Response Body. +func (client ReplicationLinksClient) UnlinkResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/restorabledroppeddatabases.go b/services/preview/sql/mgmt/v5.0/sql/restorabledroppeddatabases.go new file mode 100644 index 000000000000..fba3a6c7ac5b --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/restorabledroppeddatabases.go @@ -0,0 +1,231 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// RestorableDroppedDatabasesClient is the the Azure SQL Database management API provides a RESTful set of web services +// that interact with Azure SQL Database services to manage your databases. The API enables you to create, retrieve, +// update, and delete databases. +type RestorableDroppedDatabasesClient struct { + BaseClient +} + +// NewRestorableDroppedDatabasesClient creates an instance of the RestorableDroppedDatabasesClient client. +func NewRestorableDroppedDatabasesClient(subscriptionID string) RestorableDroppedDatabasesClient { + return NewRestorableDroppedDatabasesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewRestorableDroppedDatabasesClientWithBaseURI creates an instance of the RestorableDroppedDatabasesClient client +// using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign +// clouds, Azure stack). +func NewRestorableDroppedDatabasesClientWithBaseURI(baseURI string, subscriptionID string) RestorableDroppedDatabasesClient { + return RestorableDroppedDatabasesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get gets a restorable dropped database. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +func (client RestorableDroppedDatabasesClient) Get(ctx context.Context, resourceGroupName string, serverName string, restorableDroppedDatabaseID string) (result RestorableDroppedDatabase, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RestorableDroppedDatabasesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, restorableDroppedDatabaseID) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.RestorableDroppedDatabasesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.RestorableDroppedDatabasesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.RestorableDroppedDatabasesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client RestorableDroppedDatabasesClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, restorableDroppedDatabaseID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "restorableDroppedDatabaseId": autorest.Encode("path", restorableDroppedDatabaseID), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-02-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/restorableDroppedDatabases/{restorableDroppedDatabaseId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client RestorableDroppedDatabasesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client RestorableDroppedDatabasesClient) GetResponder(resp *http.Response) (result RestorableDroppedDatabase, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer gets a list of restorable dropped databases. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +func (client RestorableDroppedDatabasesClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result RestorableDroppedDatabaseListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RestorableDroppedDatabasesClient.ListByServer") + defer func() { + sc := -1 + if result.rddlr.Response.Response != nil { + sc = result.rddlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByServerNextResults + req, err := client.ListByServerPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.RestorableDroppedDatabasesClient", "ListByServer", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServerSender(req) + if err != nil { + result.rddlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.RestorableDroppedDatabasesClient", "ListByServer", resp, "Failure sending request") + return + } + + result.rddlr, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.RestorableDroppedDatabasesClient", "ListByServer", resp, "Failure responding to request") + return + } + if result.rddlr.hasNextLink() && result.rddlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServerPreparer prepares the ListByServer request. +func (client RestorableDroppedDatabasesClient) ListByServerPreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-02-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/restorableDroppedDatabases", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByServerSender sends the ListByServer request. The method will close the +// http.Response Body if it receives an error. +func (client RestorableDroppedDatabasesClient) ListByServerSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client RestorableDroppedDatabasesClient) ListByServerResponder(resp *http.Response) (result RestorableDroppedDatabaseListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByServerNextResults retrieves the next set of results, if any. +func (client RestorableDroppedDatabasesClient) listByServerNextResults(ctx context.Context, lastResults RestorableDroppedDatabaseListResult) (result RestorableDroppedDatabaseListResult, err error) { + req, err := lastResults.restorableDroppedDatabaseListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.RestorableDroppedDatabasesClient", "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.RestorableDroppedDatabasesClient", "listByServerNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.RestorableDroppedDatabasesClient", "listByServerNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServerComplete enumerates all values, automatically crossing page boundaries as required. +func (client RestorableDroppedDatabasesClient) ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result RestorableDroppedDatabaseListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RestorableDroppedDatabasesClient.ListByServer") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByServer(ctx, resourceGroupName, serverName) + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/restorabledroppedmanageddatabases.go b/services/preview/sql/mgmt/v5.0/sql/restorabledroppedmanageddatabases.go new file mode 100644 index 000000000000..0758769aae6d --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/restorabledroppedmanageddatabases.go @@ -0,0 +1,232 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// RestorableDroppedManagedDatabasesClient is the the Azure SQL Database management API provides a RESTful set of web +// services that interact with Azure SQL Database services to manage your databases. The API enables you to create, +// retrieve, update, and delete databases. +type RestorableDroppedManagedDatabasesClient struct { + BaseClient +} + +// NewRestorableDroppedManagedDatabasesClient creates an instance of the RestorableDroppedManagedDatabasesClient +// client. +func NewRestorableDroppedManagedDatabasesClient(subscriptionID string) RestorableDroppedManagedDatabasesClient { + return NewRestorableDroppedManagedDatabasesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewRestorableDroppedManagedDatabasesClientWithBaseURI creates an instance of the +// RestorableDroppedManagedDatabasesClient client using a custom endpoint. Use this when interacting with an Azure +// cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewRestorableDroppedManagedDatabasesClientWithBaseURI(baseURI string, subscriptionID string) RestorableDroppedManagedDatabasesClient { + return RestorableDroppedManagedDatabasesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get gets a restorable dropped managed database. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +func (client RestorableDroppedManagedDatabasesClient) Get(ctx context.Context, resourceGroupName string, managedInstanceName string, restorableDroppedDatabaseID string) (result RestorableDroppedManagedDatabase, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RestorableDroppedManagedDatabasesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, managedInstanceName, restorableDroppedDatabaseID) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.RestorableDroppedManagedDatabasesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.RestorableDroppedManagedDatabasesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.RestorableDroppedManagedDatabasesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client RestorableDroppedManagedDatabasesClient) GetPreparer(ctx context.Context, resourceGroupName string, managedInstanceName string, restorableDroppedDatabaseID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "restorableDroppedDatabaseId": autorest.Encode("path", restorableDroppedDatabaseID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-02-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/restorableDroppedDatabases/{restorableDroppedDatabaseId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client RestorableDroppedManagedDatabasesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client RestorableDroppedManagedDatabasesClient) GetResponder(resp *http.Response) (result RestorableDroppedManagedDatabase, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByInstance gets a list of restorable dropped managed databases. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +func (client RestorableDroppedManagedDatabasesClient) ListByInstance(ctx context.Context, resourceGroupName string, managedInstanceName string) (result RestorableDroppedManagedDatabaseListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RestorableDroppedManagedDatabasesClient.ListByInstance") + defer func() { + sc := -1 + if result.rdmdlr.Response.Response != nil { + sc = result.rdmdlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByInstanceNextResults + req, err := client.ListByInstancePreparer(ctx, resourceGroupName, managedInstanceName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.RestorableDroppedManagedDatabasesClient", "ListByInstance", nil, "Failure preparing request") + return + } + + resp, err := client.ListByInstanceSender(req) + if err != nil { + result.rdmdlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.RestorableDroppedManagedDatabasesClient", "ListByInstance", resp, "Failure sending request") + return + } + + result.rdmdlr, err = client.ListByInstanceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.RestorableDroppedManagedDatabasesClient", "ListByInstance", resp, "Failure responding to request") + return + } + if result.rdmdlr.hasNextLink() && result.rdmdlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByInstancePreparer prepares the ListByInstance request. +func (client RestorableDroppedManagedDatabasesClient) ListByInstancePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-02-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/restorableDroppedDatabases", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByInstanceSender sends the ListByInstance request. The method will close the +// http.Response Body if it receives an error. +func (client RestorableDroppedManagedDatabasesClient) ListByInstanceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByInstanceResponder handles the response to the ListByInstance request. The method always +// closes the http.Response Body. +func (client RestorableDroppedManagedDatabasesClient) ListByInstanceResponder(resp *http.Response) (result RestorableDroppedManagedDatabaseListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByInstanceNextResults retrieves the next set of results, if any. +func (client RestorableDroppedManagedDatabasesClient) listByInstanceNextResults(ctx context.Context, lastResults RestorableDroppedManagedDatabaseListResult) (result RestorableDroppedManagedDatabaseListResult, err error) { + req, err := lastResults.restorableDroppedManagedDatabaseListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.RestorableDroppedManagedDatabasesClient", "listByInstanceNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByInstanceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.RestorableDroppedManagedDatabasesClient", "listByInstanceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByInstanceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.RestorableDroppedManagedDatabasesClient", "listByInstanceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByInstanceComplete enumerates all values, automatically crossing page boundaries as required. +func (client RestorableDroppedManagedDatabasesClient) ListByInstanceComplete(ctx context.Context, resourceGroupName string, managedInstanceName string) (result RestorableDroppedManagedDatabaseListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RestorableDroppedManagedDatabasesClient.ListByInstance") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByInstance(ctx, resourceGroupName, managedInstanceName) + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/restorepoints.go b/services/preview/sql/mgmt/v5.0/sql/restorepoints.go new file mode 100644 index 000000000000..3f7b411267e7 --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/restorepoints.go @@ -0,0 +1,406 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// RestorePointsClient is the the Azure SQL Database management API provides a RESTful set of web services that +// interact with Azure SQL Database services to manage your databases. The API enables you to create, retrieve, update, +// and delete databases. +type RestorePointsClient struct { + BaseClient +} + +// NewRestorePointsClient creates an instance of the RestorePointsClient client. +func NewRestorePointsClient(subscriptionID string) RestorePointsClient { + return NewRestorePointsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewRestorePointsClientWithBaseURI creates an instance of the RestorePointsClient client using a custom endpoint. +// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewRestorePointsClientWithBaseURI(baseURI string, subscriptionID string) RestorePointsClient { + return RestorePointsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Create creates a restore point for a data warehouse. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database. +// parameters - the definition for creating the restore point of this database. +func (client RestorePointsClient) Create(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters CreateDatabaseRestorePointDefinition) (result RestorePointsCreateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RestorePointsClient.Create") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.RestorePointLabel", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewError("sql.RestorePointsClient", "Create", err.Error()) + } + + req, err := client.CreatePreparer(ctx, resourceGroupName, serverName, databaseName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.RestorePointsClient", "Create", nil, "Failure preparing request") + return + } + + result, err = client.CreateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.RestorePointsClient", "Create", nil, "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 = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/restorePoints", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateSender sends the Create request. The method will close the +// http.Response Body if it receives an error. +func (client RestorePointsClient) CreateSender(req *http.Request) (future RestorePointsCreateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client RestorePointsClient) CreateResponder(resp *http.Response) (result RestorePoint, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a restore point. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database. +// restorePointName - the name of the restore point. +func (client RestorePointsClient) Delete(ctx context.Context, resourceGroupName string, serverName string, databaseName string, restorePointName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RestorePointsClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, serverName, databaseName, restorePointName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.RestorePointsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "sql.RestorePointsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.RestorePointsClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client RestorePointsClient) DeletePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, restorePointName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "restorePointName": autorest.Encode("path", restorePointName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/restorePoints/{restorePointName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client RestorePointsClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client RestorePointsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a restore point. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database. +// restorePointName - the name of the restore point. +func (client RestorePointsClient) Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string, restorePointName string) (result RestorePoint, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RestorePointsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, databaseName, restorePointName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.RestorePointsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.RestorePointsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.RestorePointsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client RestorePointsClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, restorePointName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "restorePointName": autorest.Encode("path", restorePointName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/restorePoints/{restorePointName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client RestorePointsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client RestorePointsClient) GetResponder(resp *http.Response) (result RestorePoint, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByDatabase gets a list of database restore points. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database. +func (client RestorePointsClient) ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result RestorePointListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RestorePointsClient.ListByDatabase") + defer func() { + sc := -1 + if result.rplr.Response.Response != nil { + sc = result.rplr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByDatabaseNextResults + req, err := client.ListByDatabasePreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.RestorePointsClient", "ListByDatabase", nil, "Failure preparing request") + return + } + + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.rplr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.RestorePointsClient", "ListByDatabase", resp, "Failure sending request") + return + } + + result.rplr, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.RestorePointsClient", "ListByDatabase", resp, "Failure responding to request") + return + } + if result.rplr.hasNextLink() && result.rplr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByDatabasePreparer prepares the ListByDatabase request. +func (client RestorePointsClient) ListByDatabasePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/restorePoints", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByDatabaseSender sends the ListByDatabase request. The method will close the +// http.Response Body if it receives an error. +func (client RestorePointsClient) ListByDatabaseSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByDatabaseResponder handles the response to the ListByDatabase request. The method always +// closes the http.Response Body. +func (client RestorePointsClient) ListByDatabaseResponder(resp *http.Response) (result RestorePointListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByDatabaseNextResults retrieves the next set of results, if any. +func (client RestorePointsClient) listByDatabaseNextResults(ctx context.Context, lastResults RestorePointListResult) (result RestorePointListResult, err error) { + req, err := lastResults.restorePointListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.RestorePointsClient", "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.RestorePointsClient", "listByDatabaseNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.RestorePointsClient", "listByDatabaseNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByDatabaseComplete enumerates all values, automatically crossing page boundaries as required. +func (client RestorePointsClient) ListByDatabaseComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result RestorePointListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RestorePointsClient.ListByDatabase") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByDatabase(ctx, resourceGroupName, serverName, databaseName) + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/sensitivitylabels.go b/services/preview/sql/mgmt/v5.0/sql/sensitivitylabels.go new file mode 100644 index 000000000000..27fff16adf22 --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/sensitivitylabels.go @@ -0,0 +1,810 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// SensitivityLabelsClient is the the Azure SQL Database management API provides a RESTful set of web services that +// interact with Azure SQL Database services to manage your databases. The API enables you to create, retrieve, update, +// and delete databases. +type SensitivityLabelsClient struct { + BaseClient +} + +// NewSensitivityLabelsClient creates an instance of the SensitivityLabelsClient client. +func NewSensitivityLabelsClient(subscriptionID string) SensitivityLabelsClient { + return NewSensitivityLabelsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewSensitivityLabelsClientWithBaseURI creates an instance of the SensitivityLabelsClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewSensitivityLabelsClientWithBaseURI(baseURI string, subscriptionID string) SensitivityLabelsClient { + return SensitivityLabelsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates the sensitivity label of a given column +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database. +// schemaName - the name of the schema. +// tableName - the name of the table. +// columnName - the name of the column. +// parameters - the column sensitivity label resource. +func (client SensitivityLabelsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, schemaName string, tableName string, columnName string, parameters SensitivityLabel) (result SensitivityLabel, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SensitivityLabelsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, databaseName, schemaName, tableName, columnName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SensitivityLabelsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.SensitivityLabelsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SensitivityLabelsClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client SensitivityLabelsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, schemaName string, tableName string, columnName string, parameters SensitivityLabel) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "columnName": autorest.Encode("path", columnName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "schemaName": autorest.Encode("path", schemaName), + "sensitivityLabelSource": autorest.Encode("path", "current"), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "tableName": autorest.Encode("path", tableName), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + parameters.ManagedBy = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client SensitivityLabelsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client SensitivityLabelsClient) CreateOrUpdateResponder(resp *http.Response) (result SensitivityLabel, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes the sensitivity label of a given column +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database. +// schemaName - the name of the schema. +// tableName - the name of the table. +// columnName - the name of the column. +func (client SensitivityLabelsClient) Delete(ctx context.Context, resourceGroupName string, serverName string, databaseName string, schemaName string, tableName string, columnName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SensitivityLabelsClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, serverName, databaseName, schemaName, tableName, columnName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SensitivityLabelsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "sql.SensitivityLabelsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SensitivityLabelsClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client SensitivityLabelsClient) DeletePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, schemaName string, tableName string, columnName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "columnName": autorest.Encode("path", columnName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "schemaName": autorest.Encode("path", schemaName), + "sensitivityLabelSource": autorest.Encode("path", "current"), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "tableName": autorest.Encode("path", tableName), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client SensitivityLabelsClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client SensitivityLabelsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// DisableRecommendation disables sensitivity recommendations on a given column +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database. +// schemaName - the name of the schema. +// tableName - the name of the table. +// columnName - the name of the column. +func (client SensitivityLabelsClient) DisableRecommendation(ctx context.Context, resourceGroupName string, serverName string, databaseName string, schemaName string, tableName string, columnName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SensitivityLabelsClient.DisableRecommendation") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DisableRecommendationPreparer(ctx, resourceGroupName, serverName, databaseName, schemaName, tableName, columnName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SensitivityLabelsClient", "DisableRecommendation", nil, "Failure preparing request") + return + } + + resp, err := client.DisableRecommendationSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "sql.SensitivityLabelsClient", "DisableRecommendation", resp, "Failure sending request") + return + } + + result, err = client.DisableRecommendationResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SensitivityLabelsClient", "DisableRecommendation", resp, "Failure responding to request") + return + } + + return +} + +// DisableRecommendationPreparer prepares the DisableRecommendation request. +func (client SensitivityLabelsClient) DisableRecommendationPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, schemaName string, tableName string, columnName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "columnName": autorest.Encode("path", columnName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "schemaName": autorest.Encode("path", schemaName), + "sensitivityLabelSource": autorest.Encode("path", "recommended"), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "tableName": autorest.Encode("path", tableName), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}/disable", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DisableRecommendationSender sends the DisableRecommendation request. The method will close the +// http.Response Body if it receives an error. +func (client SensitivityLabelsClient) DisableRecommendationSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DisableRecommendationResponder handles the response to the DisableRecommendation request. The method always +// closes the http.Response Body. +func (client SensitivityLabelsClient) DisableRecommendationResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// EnableRecommendation enables sensitivity recommendations on a given column (recommendations are enabled by default +// on all columns) +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database. +// schemaName - the name of the schema. +// tableName - the name of the table. +// columnName - the name of the column. +func (client SensitivityLabelsClient) EnableRecommendation(ctx context.Context, resourceGroupName string, serverName string, databaseName string, schemaName string, tableName string, columnName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SensitivityLabelsClient.EnableRecommendation") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.EnableRecommendationPreparer(ctx, resourceGroupName, serverName, databaseName, schemaName, tableName, columnName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SensitivityLabelsClient", "EnableRecommendation", nil, "Failure preparing request") + return + } + + resp, err := client.EnableRecommendationSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "sql.SensitivityLabelsClient", "EnableRecommendation", resp, "Failure sending request") + return + } + + result, err = client.EnableRecommendationResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SensitivityLabelsClient", "EnableRecommendation", resp, "Failure responding to request") + return + } + + return +} + +// EnableRecommendationPreparer prepares the EnableRecommendation request. +func (client SensitivityLabelsClient) EnableRecommendationPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, schemaName string, tableName string, columnName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "columnName": autorest.Encode("path", columnName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "schemaName": autorest.Encode("path", schemaName), + "sensitivityLabelSource": autorest.Encode("path", "recommended"), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "tableName": autorest.Encode("path", tableName), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}/enable", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// EnableRecommendationSender sends the EnableRecommendation request. The method will close the +// http.Response Body if it receives an error. +func (client SensitivityLabelsClient) EnableRecommendationSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// EnableRecommendationResponder handles the response to the EnableRecommendation request. The method always +// closes the http.Response Body. +func (client SensitivityLabelsClient) EnableRecommendationResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets the sensitivity label of a given column +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database. +// schemaName - the name of the schema. +// tableName - the name of the table. +// columnName - the name of the column. +// sensitivityLabelSource - the source of the sensitivity label. +func (client SensitivityLabelsClient) Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string, schemaName string, tableName string, columnName string, sensitivityLabelSource SensitivityLabelSource) (result SensitivityLabel, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SensitivityLabelsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, databaseName, schemaName, tableName, columnName, sensitivityLabelSource) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SensitivityLabelsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.SensitivityLabelsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SensitivityLabelsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client SensitivityLabelsClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, schemaName string, tableName string, columnName string, sensitivityLabelSource SensitivityLabelSource) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "columnName": autorest.Encode("path", columnName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "schemaName": autorest.Encode("path", schemaName), + "sensitivityLabelSource": autorest.Encode("path", sensitivityLabelSource), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "tableName": autorest.Encode("path", tableName), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client SensitivityLabelsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client SensitivityLabelsClient) GetResponder(resp *http.Response) (result SensitivityLabel, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListCurrentByDatabase gets the sensitivity labels of a given database +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database. +// filter - an OData filter expression that filters elements in the collection. +func (client SensitivityLabelsClient) ListCurrentByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string, skipToken string, count *bool, filter string) (result SensitivityLabelListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SensitivityLabelsClient.ListCurrentByDatabase") + defer func() { + sc := -1 + if result.sllr.Response.Response != nil { + sc = result.sllr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listCurrentByDatabaseNextResults + req, err := client.ListCurrentByDatabasePreparer(ctx, resourceGroupName, serverName, databaseName, skipToken, count, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SensitivityLabelsClient", "ListCurrentByDatabase", nil, "Failure preparing request") + return + } + + resp, err := client.ListCurrentByDatabaseSender(req) + if err != nil { + result.sllr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.SensitivityLabelsClient", "ListCurrentByDatabase", resp, "Failure sending request") + return + } + + result.sllr, err = client.ListCurrentByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SensitivityLabelsClient", "ListCurrentByDatabase", resp, "Failure responding to request") + return + } + if result.sllr.hasNextLink() && result.sllr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListCurrentByDatabasePreparer prepares the ListCurrentByDatabase request. +func (client SensitivityLabelsClient) ListCurrentByDatabasePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, skipToken string, count *bool, 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 = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(skipToken) > 0 { + queryParameters["$skipToken"] = autorest.Encode("query", skipToken) + } + if count != nil { + queryParameters["$count"] = autorest.Encode("query", *count) + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/currentSensitivityLabels", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListCurrentByDatabaseSender sends the ListCurrentByDatabase request. The method will close the +// http.Response Body if it receives an error. +func (client SensitivityLabelsClient) ListCurrentByDatabaseSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListCurrentByDatabaseResponder handles the response to the ListCurrentByDatabase request. The method always +// closes the http.Response Body. +func (client SensitivityLabelsClient) ListCurrentByDatabaseResponder(resp *http.Response) (result SensitivityLabelListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listCurrentByDatabaseNextResults retrieves the next set of results, if any. +func (client SensitivityLabelsClient) listCurrentByDatabaseNextResults(ctx context.Context, lastResults SensitivityLabelListResult) (result SensitivityLabelListResult, err error) { + req, err := lastResults.sensitivityLabelListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.SensitivityLabelsClient", "listCurrentByDatabaseNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListCurrentByDatabaseSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.SensitivityLabelsClient", "listCurrentByDatabaseNextResults", resp, "Failure sending next results request") + } + result, err = client.ListCurrentByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SensitivityLabelsClient", "listCurrentByDatabaseNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListCurrentByDatabaseComplete enumerates all values, automatically crossing page boundaries as required. +func (client SensitivityLabelsClient) ListCurrentByDatabaseComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string, skipToken string, count *bool, filter string) (result SensitivityLabelListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SensitivityLabelsClient.ListCurrentByDatabase") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListCurrentByDatabase(ctx, resourceGroupName, serverName, databaseName, skipToken, count, filter) + return +} + +// ListRecommendedByDatabase gets the sensitivity labels of a given database +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database. +// includeDisabledRecommendations - specifies whether to include disabled recommendations or not. +// filter - an OData filter expression that filters elements in the collection. +func (client SensitivityLabelsClient) ListRecommendedByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string, skipToken string, includeDisabledRecommendations *bool, filter string) (result SensitivityLabelListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SensitivityLabelsClient.ListRecommendedByDatabase") + defer func() { + sc := -1 + if result.sllr.Response.Response != nil { + sc = result.sllr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listRecommendedByDatabaseNextResults + req, err := client.ListRecommendedByDatabasePreparer(ctx, resourceGroupName, serverName, databaseName, skipToken, includeDisabledRecommendations, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SensitivityLabelsClient", "ListRecommendedByDatabase", nil, "Failure preparing request") + return + } + + resp, err := client.ListRecommendedByDatabaseSender(req) + if err != nil { + result.sllr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.SensitivityLabelsClient", "ListRecommendedByDatabase", resp, "Failure sending request") + return + } + + result.sllr, err = client.ListRecommendedByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SensitivityLabelsClient", "ListRecommendedByDatabase", resp, "Failure responding to request") + return + } + if result.sllr.hasNextLink() && result.sllr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListRecommendedByDatabasePreparer prepares the ListRecommendedByDatabase request. +func (client SensitivityLabelsClient) ListRecommendedByDatabasePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, skipToken string, includeDisabledRecommendations *bool, 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 = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(skipToken) > 0 { + queryParameters["$skipToken"] = autorest.Encode("query", skipToken) + } + if includeDisabledRecommendations != nil { + queryParameters["includeDisabledRecommendations"] = autorest.Encode("query", *includeDisabledRecommendations) + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/recommendedSensitivityLabels", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListRecommendedByDatabaseSender sends the ListRecommendedByDatabase request. The method will close the +// http.Response Body if it receives an error. +func (client SensitivityLabelsClient) ListRecommendedByDatabaseSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListRecommendedByDatabaseResponder handles the response to the ListRecommendedByDatabase request. The method always +// closes the http.Response Body. +func (client SensitivityLabelsClient) ListRecommendedByDatabaseResponder(resp *http.Response) (result SensitivityLabelListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listRecommendedByDatabaseNextResults retrieves the next set of results, if any. +func (client SensitivityLabelsClient) listRecommendedByDatabaseNextResults(ctx context.Context, lastResults SensitivityLabelListResult) (result SensitivityLabelListResult, err error) { + req, err := lastResults.sensitivityLabelListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.SensitivityLabelsClient", "listRecommendedByDatabaseNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListRecommendedByDatabaseSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.SensitivityLabelsClient", "listRecommendedByDatabaseNextResults", resp, "Failure sending next results request") + } + result, err = client.ListRecommendedByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SensitivityLabelsClient", "listRecommendedByDatabaseNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListRecommendedByDatabaseComplete enumerates all values, automatically crossing page boundaries as required. +func (client SensitivityLabelsClient) ListRecommendedByDatabaseComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string, skipToken string, includeDisabledRecommendations *bool, filter string) (result SensitivityLabelListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SensitivityLabelsClient.ListRecommendedByDatabase") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListRecommendedByDatabase(ctx, resourceGroupName, serverName, databaseName, skipToken, includeDisabledRecommendations, filter) + return +} + +// Update update sensitivity labels of a given database using an operations batch. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database. +func (client SensitivityLabelsClient) Update(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters SensitivityLabelUpdateList) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SensitivityLabelsClient.Update") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.UpdatePreparer(ctx, resourceGroupName, serverName, databaseName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SensitivityLabelsClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "sql.SensitivityLabelsClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SensitivityLabelsClient", "Update", resp, "Failure responding to request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client SensitivityLabelsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters SensitivityLabelUpdateList) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.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}/currentSensitivityLabels", 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 SensitivityLabelsClient) UpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client SensitivityLabelsClient) UpdateResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/serveradvisors.go b/services/preview/sql/mgmt/v5.0/sql/serveradvisors.go new file mode 100644 index 000000000000..c09f21826404 --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/serveradvisors.go @@ -0,0 +1,277 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ServerAdvisorsClient 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 ServerAdvisorsClient struct { + BaseClient +} + +// NewServerAdvisorsClient creates an instance of the ServerAdvisorsClient client. +func NewServerAdvisorsClient(subscriptionID string) ServerAdvisorsClient { + return NewServerAdvisorsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewServerAdvisorsClientWithBaseURI creates an instance of the ServerAdvisorsClient client using a custom endpoint. +// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewServerAdvisorsClientWithBaseURI(baseURI string, subscriptionID string) ServerAdvisorsClient { + return ServerAdvisorsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get gets a server advisor. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// advisorName - the name of the Server Advisor. +func (client ServerAdvisorsClient) Get(ctx context.Context, resourceGroupName string, serverName string, advisorName string) (result Advisor, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerAdvisorsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, advisorName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAdvisorsClient", "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.ServerAdvisorsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAdvisorsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ServerAdvisorsClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, advisorName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "advisorName": autorest.Encode("path", advisorName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/advisors/{advisorName}", 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 ServerAdvisorsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ServerAdvisorsClient) GetResponder(resp *http.Response) (result Advisor, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer gets a list of server advisors. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// expand - the child resources to include in the response. +func (client ServerAdvisorsClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string, expand string) (result ListAdvisor, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerAdvisorsClient.ListByServer") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListByServerPreparer(ctx, resourceGroupName, serverName, expand) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAdvisorsClient", "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.ServerAdvisorsClient", "ListByServer", resp, "Failure sending request") + return + } + + result, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAdvisorsClient", "ListByServer", resp, "Failure responding to request") + return + } + + return +} + +// ListByServerPreparer prepares the ListByServer request. +func (client ServerAdvisorsClient) ListByServerPreparer(ctx context.Context, resourceGroupName string, serverName string, expand string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + 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}/advisors", 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 ServerAdvisorsClient) ListByServerSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client ServerAdvisorsClient) ListByServerResponder(resp *http.Response) (result ListAdvisor, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Value), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Update updates a server advisor. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// advisorName - the name of the Server Advisor. +// parameters - the requested advisor resource state. +func (client ServerAdvisorsClient) Update(ctx context.Context, resourceGroupName string, serverName string, advisorName string, parameters Advisor) (result Advisor, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerAdvisorsClient.Update") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.UpdatePreparer(ctx, resourceGroupName, serverName, advisorName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAdvisorsClient", "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.ServerAdvisorsClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAdvisorsClient", "Update", resp, "Failure responding to request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client ServerAdvisorsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, advisorName string, parameters Advisor) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "advisorName": autorest.Encode("path", advisorName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + parameters.Kind = nil + parameters.Location = nil + 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}/advisors/{advisorName}", 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 ServerAdvisorsClient) UpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client ServerAdvisorsClient) UpdateResponder(resp *http.Response) (result Advisor, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/serverautomatictuning.go b/services/preview/sql/mgmt/v5.0/sql/serverautomatictuning.go new file mode 100644 index 000000000000..cd62367cc15c --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/serverautomatictuning.go @@ -0,0 +1,191 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ServerAutomaticTuningClient is the the Azure SQL Database management API provides a RESTful set of web services that +// interact with Azure SQL Database services to manage your databases. The API enables you to create, retrieve, update, +// and delete databases. +type ServerAutomaticTuningClient struct { + BaseClient +} + +// NewServerAutomaticTuningClient creates an instance of the ServerAutomaticTuningClient client. +func NewServerAutomaticTuningClient(subscriptionID string) ServerAutomaticTuningClient { + return NewServerAutomaticTuningClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewServerAutomaticTuningClientWithBaseURI creates an instance of the ServerAutomaticTuningClient client using a +// custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, +// Azure stack). +func NewServerAutomaticTuningClientWithBaseURI(baseURI string, subscriptionID string) ServerAutomaticTuningClient { + return ServerAutomaticTuningClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get retrieves server automatic tuning options. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +func (client ServerAutomaticTuningClient) Get(ctx context.Context, resourceGroupName string, serverName string) (result ServerAutomaticTuning, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerAutomaticTuningClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAutomaticTuningClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ServerAutomaticTuningClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAutomaticTuningClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ServerAutomaticTuningClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/automaticTuning/current", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ServerAutomaticTuningClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ServerAutomaticTuningClient) GetResponder(resp *http.Response) (result ServerAutomaticTuning, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Update update automatic tuning options on server. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// parameters - the requested automatic tuning resource state. +func (client ServerAutomaticTuningClient) Update(ctx context.Context, resourceGroupName string, serverName string, parameters ServerAutomaticTuning) (result ServerAutomaticTuning, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerAutomaticTuningClient.Update") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.UpdatePreparer(ctx, resourceGroupName, serverName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAutomaticTuningClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ServerAutomaticTuningClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAutomaticTuningClient", "Update", resp, "Failure responding to request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client ServerAutomaticTuningClient) UpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, parameters ServerAutomaticTuning) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/automaticTuning/current", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client ServerAutomaticTuningClient) UpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client ServerAutomaticTuningClient) UpdateResponder(resp *http.Response) (result ServerAutomaticTuning, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/serverazureadadministrators.go b/services/preview/sql/mgmt/v5.0/sql/serverazureadadministrators.go new file mode 100644 index 000000000000..ae7d6da09e6e --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/serverazureadadministrators.go @@ -0,0 +1,404 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ServerAzureADAdministratorsClient is the the Azure SQL Database management API provides a RESTful set of web +// services that interact with Azure SQL Database services to manage your databases. The API enables you to create, +// retrieve, update, and delete databases. +type ServerAzureADAdministratorsClient struct { + BaseClient +} + +// NewServerAzureADAdministratorsClient creates an instance of the ServerAzureADAdministratorsClient client. +func NewServerAzureADAdministratorsClient(subscriptionID string) ServerAzureADAdministratorsClient { + return NewServerAzureADAdministratorsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewServerAzureADAdministratorsClientWithBaseURI creates an instance of the ServerAzureADAdministratorsClient client +// using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign +// clouds, Azure stack). +func NewServerAzureADAdministratorsClientWithBaseURI(baseURI string, subscriptionID string) ServerAzureADAdministratorsClient { + return ServerAzureADAdministratorsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates an existing Azure Active Directory administrator. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// parameters - the requested Azure Active Directory administrator Resource state. +func (client ServerAzureADAdministratorsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, parameters ServerAzureADAdministrator) (result ServerAzureADAdministratorsCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerAzureADAdministratorsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.AdministratorProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.AdministratorProperties.AdministratorType", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.AdministratorProperties.Login", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.AdministratorProperties.Sid", Name: validation.Null, Rule: true, Chain: nil}, + }}}}}); err != nil { + return result, validation.NewError("sql.ServerAzureADAdministratorsClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAzureADAdministratorsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAzureADAdministratorsClient", "CreateOrUpdate", nil, "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ServerAzureADAdministratorsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, parameters ServerAzureADAdministrator) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "administratorName": autorest.Encode("path", "ActiveDirectory"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/administrators/{administratorName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client ServerAzureADAdministratorsClient) CreateOrUpdateSender(req *http.Request) (future ServerAzureADAdministratorsCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ServerAzureADAdministratorsClient) CreateOrUpdateResponder(resp *http.Response) (result ServerAzureADAdministrator, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes the Azure Active Directory administrator with the given name. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +func (client ServerAzureADAdministratorsClient) Delete(ctx context.Context, resourceGroupName string, serverName string) (result ServerAzureADAdministratorsDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerAzureADAdministratorsClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAzureADAdministratorsClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAzureADAdministratorsClient", "Delete", nil, "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 = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/administrators/{administratorName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client ServerAzureADAdministratorsClient) DeleteSender(req *http.Request) (future ServerAzureADAdministratorsDeleteFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ServerAzureADAdministratorsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a Azure Active Directory administrator. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +func (client ServerAzureADAdministratorsClient) Get(ctx context.Context, resourceGroupName string, serverName string) (result ServerAzureADAdministrator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerAzureADAdministratorsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAzureADAdministratorsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ServerAzureADAdministratorsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAzureADAdministratorsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ServerAzureADAdministratorsClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "administratorName": autorest.Encode("path", "ActiveDirectory"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/administrators/{administratorName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ServerAzureADAdministratorsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ServerAzureADAdministratorsClient) GetResponder(resp *http.Response) (result ServerAzureADAdministrator, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer gets a list of Azure Active Directory administrators in a server. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +func (client ServerAzureADAdministratorsClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result AdministratorListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerAzureADAdministratorsClient.ListByServer") + defer func() { + sc := -1 + if result.alr.Response.Response != nil { + sc = result.alr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByServerNextResults + req, err := client.ListByServerPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAzureADAdministratorsClient", "ListByServer", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServerSender(req) + if err != nil { + result.alr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ServerAzureADAdministratorsClient", "ListByServer", resp, "Failure sending request") + return + } + + result.alr, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAzureADAdministratorsClient", "ListByServer", resp, "Failure responding to request") + return + } + if result.alr.hasNextLink() && result.alr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServerPreparer prepares the ListByServer request. +func (client ServerAzureADAdministratorsClient) ListByServerPreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/administrators", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByServerSender sends the ListByServer request. The method will close the +// http.Response Body if it receives an error. +func (client ServerAzureADAdministratorsClient) ListByServerSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client ServerAzureADAdministratorsClient) ListByServerResponder(resp *http.Response) (result AdministratorListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByServerNextResults retrieves the next set of results, if any. +func (client ServerAzureADAdministratorsClient) listByServerNextResults(ctx context.Context, lastResults AdministratorListResult) (result AdministratorListResult, err error) { + req, err := lastResults.administratorListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.ServerAzureADAdministratorsClient", "listByServerNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByServerSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.ServerAzureADAdministratorsClient", "listByServerNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAzureADAdministratorsClient", "listByServerNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServerComplete enumerates all values, automatically crossing page boundaries as required. +func (client ServerAzureADAdministratorsClient) ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result AdministratorListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerAzureADAdministratorsClient.ListByServer") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByServer(ctx, resourceGroupName, serverName) + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/serverazureadonlyauthentications.go b/services/preview/sql/mgmt/v5.0/sql/serverazureadonlyauthentications.go new file mode 100644 index 000000000000..f956668044e4 --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/serverazureadonlyauthentications.go @@ -0,0 +1,403 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ServerAzureADOnlyAuthenticationsClient is the the Azure SQL Database management API provides a RESTful set of web +// services that interact with Azure SQL Database services to manage your databases. The API enables you to create, +// retrieve, update, and delete databases. +type ServerAzureADOnlyAuthenticationsClient struct { + BaseClient +} + +// NewServerAzureADOnlyAuthenticationsClient creates an instance of the ServerAzureADOnlyAuthenticationsClient client. +func NewServerAzureADOnlyAuthenticationsClient(subscriptionID string) ServerAzureADOnlyAuthenticationsClient { + return NewServerAzureADOnlyAuthenticationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewServerAzureADOnlyAuthenticationsClientWithBaseURI creates an instance of the +// ServerAzureADOnlyAuthenticationsClient client using a custom endpoint. Use this when interacting with an Azure +// cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewServerAzureADOnlyAuthenticationsClientWithBaseURI(baseURI string, subscriptionID string) ServerAzureADOnlyAuthenticationsClient { + return ServerAzureADOnlyAuthenticationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate sets Server Active Directory only authentication property or updates an existing server Active +// Directory only authentication property. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// parameters - the required parameters for creating or updating an Active Directory only authentication +// property. +func (client ServerAzureADOnlyAuthenticationsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, parameters ServerAzureADOnlyAuthentication) (result ServerAzureADOnlyAuthenticationsCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerAzureADOnlyAuthenticationsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.AzureADOnlyAuthProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.AzureADOnlyAuthProperties.AzureADOnlyAuthentication", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("sql.ServerAzureADOnlyAuthenticationsClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAzureADOnlyAuthenticationsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAzureADOnlyAuthenticationsClient", "CreateOrUpdate", nil, "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ServerAzureADOnlyAuthenticationsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, parameters ServerAzureADOnlyAuthentication) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "authenticationName": autorest.Encode("path", "Default"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/azureADOnlyAuthentications/{authenticationName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client ServerAzureADOnlyAuthenticationsClient) CreateOrUpdateSender(req *http.Request) (future ServerAzureADOnlyAuthenticationsCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ServerAzureADOnlyAuthenticationsClient) CreateOrUpdateResponder(resp *http.Response) (result ServerAzureADOnlyAuthentication, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes an existing server Active Directory only authentication property. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +func (client ServerAzureADOnlyAuthenticationsClient) Delete(ctx context.Context, resourceGroupName string, serverName string) (result ServerAzureADOnlyAuthenticationsDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerAzureADOnlyAuthenticationsClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAzureADOnlyAuthenticationsClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAzureADOnlyAuthenticationsClient", "Delete", nil, "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ServerAzureADOnlyAuthenticationsClient) DeletePreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "authenticationName": autorest.Encode("path", "Default"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/azureADOnlyAuthentications/{authenticationName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client ServerAzureADOnlyAuthenticationsClient) DeleteSender(req *http.Request) (future ServerAzureADOnlyAuthenticationsDeleteFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ServerAzureADOnlyAuthenticationsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a specific Azure Active Directory only authentication property. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +func (client ServerAzureADOnlyAuthenticationsClient) Get(ctx context.Context, resourceGroupName string, serverName string) (result ServerAzureADOnlyAuthentication, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerAzureADOnlyAuthenticationsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAzureADOnlyAuthenticationsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ServerAzureADOnlyAuthenticationsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAzureADOnlyAuthenticationsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ServerAzureADOnlyAuthenticationsClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "authenticationName": autorest.Encode("path", "Default"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/azureADOnlyAuthentications/{authenticationName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ServerAzureADOnlyAuthenticationsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ServerAzureADOnlyAuthenticationsClient) GetResponder(resp *http.Response) (result ServerAzureADOnlyAuthentication, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer gets a list of server Azure Active Directory only authentications. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +func (client ServerAzureADOnlyAuthenticationsClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result AzureADOnlyAuthListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerAzureADOnlyAuthenticationsClient.ListByServer") + defer func() { + sc := -1 + if result.aaoalr.Response.Response != nil { + sc = result.aaoalr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByServerNextResults + req, err := client.ListByServerPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAzureADOnlyAuthenticationsClient", "ListByServer", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServerSender(req) + if err != nil { + result.aaoalr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ServerAzureADOnlyAuthenticationsClient", "ListByServer", resp, "Failure sending request") + return + } + + result.aaoalr, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAzureADOnlyAuthenticationsClient", "ListByServer", resp, "Failure responding to request") + return + } + if result.aaoalr.hasNextLink() && result.aaoalr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServerPreparer prepares the ListByServer request. +func (client ServerAzureADOnlyAuthenticationsClient) ListByServerPreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/azureADOnlyAuthentications", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByServerSender sends the ListByServer request. The method will close the +// http.Response Body if it receives an error. +func (client ServerAzureADOnlyAuthenticationsClient) ListByServerSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client ServerAzureADOnlyAuthenticationsClient) ListByServerResponder(resp *http.Response) (result AzureADOnlyAuthListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByServerNextResults retrieves the next set of results, if any. +func (client ServerAzureADOnlyAuthenticationsClient) listByServerNextResults(ctx context.Context, lastResults AzureADOnlyAuthListResult) (result AzureADOnlyAuthListResult, err error) { + req, err := lastResults.azureADOnlyAuthListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.ServerAzureADOnlyAuthenticationsClient", "listByServerNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByServerSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.ServerAzureADOnlyAuthenticationsClient", "listByServerNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerAzureADOnlyAuthenticationsClient", "listByServerNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServerComplete enumerates all values, automatically crossing page boundaries as required. +func (client ServerAzureADOnlyAuthenticationsClient) ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result AzureADOnlyAuthListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerAzureADOnlyAuthenticationsClient.ListByServer") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByServer(ctx, resourceGroupName, serverName) + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/serverblobauditingpolicies.go b/services/preview/sql/mgmt/v5.0/sql/serverblobauditingpolicies.go new file mode 100644 index 000000000000..8081dedf4bf6 --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/serverblobauditingpolicies.go @@ -0,0 +1,314 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ServerBlobAuditingPoliciesClient is the the Azure SQL Database management API provides a RESTful set of web services +// that interact with Azure SQL Database services to manage your databases. The API enables you to create, retrieve, +// update, and delete databases. +type ServerBlobAuditingPoliciesClient struct { + BaseClient +} + +// NewServerBlobAuditingPoliciesClient creates an instance of the ServerBlobAuditingPoliciesClient client. +func NewServerBlobAuditingPoliciesClient(subscriptionID string) ServerBlobAuditingPoliciesClient { + return NewServerBlobAuditingPoliciesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewServerBlobAuditingPoliciesClientWithBaseURI creates an instance of the ServerBlobAuditingPoliciesClient client +// using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign +// clouds, Azure stack). +func NewServerBlobAuditingPoliciesClientWithBaseURI(baseURI string, subscriptionID string) ServerBlobAuditingPoliciesClient { + return ServerBlobAuditingPoliciesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a server's blob auditing policy. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// parameters - properties of blob auditing policy +func (client ServerBlobAuditingPoliciesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, parameters ServerBlobAuditingPolicy) (result ServerBlobAuditingPoliciesCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerBlobAuditingPoliciesClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerBlobAuditingPoliciesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerBlobAuditingPoliciesClient", "CreateOrUpdate", nil, "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ServerBlobAuditingPoliciesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, parameters ServerBlobAuditingPolicy) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "blobAuditingPolicyName": autorest.Encode("path", "default"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/auditingSettings/{blobAuditingPolicyName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client ServerBlobAuditingPoliciesClient) CreateOrUpdateSender(req *http.Request) (future ServerBlobAuditingPoliciesCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ServerBlobAuditingPoliciesClient) CreateOrUpdateResponder(resp *http.Response) (result ServerBlobAuditingPolicy, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets a server's blob auditing policy. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +func (client ServerBlobAuditingPoliciesClient) Get(ctx context.Context, resourceGroupName string, serverName string) (result ServerBlobAuditingPolicy, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerBlobAuditingPoliciesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerBlobAuditingPoliciesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ServerBlobAuditingPoliciesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerBlobAuditingPoliciesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ServerBlobAuditingPoliciesClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "blobAuditingPolicyName": autorest.Encode("path", "default"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/auditingSettings/{blobAuditingPolicyName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ServerBlobAuditingPoliciesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ServerBlobAuditingPoliciesClient) GetResponder(resp *http.Response) (result ServerBlobAuditingPolicy, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer lists auditing settings of a server. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +func (client ServerBlobAuditingPoliciesClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result ServerBlobAuditingPolicyListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerBlobAuditingPoliciesClient.ListByServer") + defer func() { + sc := -1 + if result.sbaplr.Response.Response != nil { + sc = result.sbaplr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByServerNextResults + req, err := client.ListByServerPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerBlobAuditingPoliciesClient", "ListByServer", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServerSender(req) + if err != nil { + result.sbaplr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ServerBlobAuditingPoliciesClient", "ListByServer", resp, "Failure sending request") + return + } + + result.sbaplr, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerBlobAuditingPoliciesClient", "ListByServer", resp, "Failure responding to request") + return + } + if result.sbaplr.hasNextLink() && result.sbaplr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServerPreparer prepares the ListByServer request. +func (client ServerBlobAuditingPoliciesClient) ListByServerPreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/auditingSettings", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByServerSender sends the ListByServer request. The method will close the +// http.Response Body if it receives an error. +func (client ServerBlobAuditingPoliciesClient) ListByServerSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client ServerBlobAuditingPoliciesClient) ListByServerResponder(resp *http.Response) (result ServerBlobAuditingPolicyListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByServerNextResults retrieves the next set of results, if any. +func (client ServerBlobAuditingPoliciesClient) listByServerNextResults(ctx context.Context, lastResults ServerBlobAuditingPolicyListResult) (result ServerBlobAuditingPolicyListResult, err error) { + req, err := lastResults.serverBlobAuditingPolicyListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.ServerBlobAuditingPoliciesClient", "listByServerNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByServerSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.ServerBlobAuditingPoliciesClient", "listByServerNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerBlobAuditingPoliciesClient", "listByServerNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServerComplete enumerates all values, automatically crossing page boundaries as required. +func (client ServerBlobAuditingPoliciesClient) ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result ServerBlobAuditingPolicyListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerBlobAuditingPoliciesClient.ListByServer") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByServer(ctx, resourceGroupName, serverName) + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/servercommunicationlinks.go b/services/preview/sql/mgmt/v5.0/sql/servercommunicationlinks.go new file mode 100644 index 000000000000..f7371d3f488f --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/servercommunicationlinks.go @@ -0,0 +1,362 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ServerCommunicationLinksClient is the the Azure SQL Database management API provides a RESTful set of web services +// that interact with Azure SQL Database services to manage your databases. The API enables you to create, retrieve, +// update, and delete databases. +type ServerCommunicationLinksClient struct { + BaseClient +} + +// NewServerCommunicationLinksClient creates an instance of the ServerCommunicationLinksClient client. +func NewServerCommunicationLinksClient(subscriptionID string) ServerCommunicationLinksClient { + return NewServerCommunicationLinksClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewServerCommunicationLinksClientWithBaseURI creates an instance of the ServerCommunicationLinksClient client using +// a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign +// clouds, Azure stack). +func NewServerCommunicationLinksClientWithBaseURI(baseURI string, subscriptionID string) ServerCommunicationLinksClient { + return ServerCommunicationLinksClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates a server communication link. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// communicationLinkName - the name of the server communication link. +// parameters - the required parameters for creating a server communication link. +func (client ServerCommunicationLinksClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, communicationLinkName string, parameters ServerCommunicationLink) (result ServerCommunicationLinksCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerCommunicationLinksClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.ServerCommunicationLinkProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ServerCommunicationLinkProperties.PartnerServer", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("sql.ServerCommunicationLinksClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, communicationLinkName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerCommunicationLinksClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerCommunicationLinksClient", "CreateOrUpdate", nil, "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ServerCommunicationLinksClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, communicationLinkName string, parameters ServerCommunicationLink) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "communicationLinkName": autorest.Encode("path", communicationLinkName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + parameters.Location = nil + parameters.Kind = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/communicationLinks/{communicationLinkName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client ServerCommunicationLinksClient) CreateOrUpdateSender(req *http.Request) (future ServerCommunicationLinksCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ServerCommunicationLinksClient) CreateOrUpdateResponder(resp *http.Response) (result ServerCommunicationLink, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a server communication link. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// communicationLinkName - the name of the server communication link. +func (client ServerCommunicationLinksClient) Delete(ctx context.Context, resourceGroupName string, serverName string, communicationLinkName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerCommunicationLinksClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, serverName, communicationLinkName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerCommunicationLinksClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "sql.ServerCommunicationLinksClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerCommunicationLinksClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ServerCommunicationLinksClient) DeletePreparer(ctx context.Context, resourceGroupName string, serverName string, communicationLinkName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "communicationLinkName": autorest.Encode("path", communicationLinkName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/communicationLinks/{communicationLinkName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client ServerCommunicationLinksClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ServerCommunicationLinksClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get returns a server communication link. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// communicationLinkName - the name of the server communication link. +func (client ServerCommunicationLinksClient) Get(ctx context.Context, resourceGroupName string, serverName string, communicationLinkName string) (result ServerCommunicationLink, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerCommunicationLinksClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, communicationLinkName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerCommunicationLinksClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ServerCommunicationLinksClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerCommunicationLinksClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ServerCommunicationLinksClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, communicationLinkName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "communicationLinkName": autorest.Encode("path", communicationLinkName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/communicationLinks/{communicationLinkName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ServerCommunicationLinksClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ServerCommunicationLinksClient) GetResponder(resp *http.Response) (result ServerCommunicationLink, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer gets a list of server communication links. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +func (client ServerCommunicationLinksClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result ServerCommunicationLinkListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerCommunicationLinksClient.ListByServer") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListByServerPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerCommunicationLinksClient", "ListByServer", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServerSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ServerCommunicationLinksClient", "ListByServer", resp, "Failure sending request") + return + } + + result, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerCommunicationLinksClient", "ListByServer", resp, "Failure responding to request") + return + } + + return +} + +// ListByServerPreparer prepares the ListByServer request. +func (client ServerCommunicationLinksClient) ListByServerPreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/communicationLinks", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByServerSender sends the ListByServer request. The method will close the +// http.Response Body if it receives an error. +func (client ServerCommunicationLinksClient) ListByServerSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client ServerCommunicationLinksClient) ListByServerResponder(resp *http.Response) (result ServerCommunicationLinkListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/serverconnectionpolicies.go b/services/preview/sql/mgmt/v5.0/sql/serverconnectionpolicies.go new file mode 100644 index 000000000000..fd714db39b75 --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/serverconnectionpolicies.go @@ -0,0 +1,195 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ServerConnectionPoliciesClient is the the Azure SQL Database management API provides a RESTful set of web services +// that interact with Azure SQL Database services to manage your databases. The API enables you to create, retrieve, +// update, and delete databases. +type ServerConnectionPoliciesClient struct { + BaseClient +} + +// NewServerConnectionPoliciesClient creates an instance of the ServerConnectionPoliciesClient client. +func NewServerConnectionPoliciesClient(subscriptionID string) ServerConnectionPoliciesClient { + return NewServerConnectionPoliciesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewServerConnectionPoliciesClientWithBaseURI creates an instance of the ServerConnectionPoliciesClient client using +// a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign +// clouds, Azure stack). +func NewServerConnectionPoliciesClientWithBaseURI(baseURI string, subscriptionID string) ServerConnectionPoliciesClient { + return ServerConnectionPoliciesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates the server's connection policy. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// parameters - the required parameters for updating a secure connection policy. +func (client ServerConnectionPoliciesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, parameters ServerConnectionPolicy) (result ServerConnectionPolicy, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerConnectionPoliciesClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerConnectionPoliciesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ServerConnectionPoliciesClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerConnectionPoliciesClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ServerConnectionPoliciesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, parameters ServerConnectionPolicy) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "connectionPolicyName": autorest.Encode("path", "default"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + parameters.Kind = nil + parameters.Location = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/connectionPolicies/{connectionPolicyName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client ServerConnectionPoliciesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ServerConnectionPoliciesClient) CreateOrUpdateResponder(resp *http.Response) (result ServerConnectionPolicy, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets the server's secure connection policy. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +func (client ServerConnectionPoliciesClient) Get(ctx context.Context, resourceGroupName string, serverName string) (result ServerConnectionPolicy, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerConnectionPoliciesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerConnectionPoliciesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ServerConnectionPoliciesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerConnectionPoliciesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ServerConnectionPoliciesClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "connectionPolicyName": autorest.Encode("path", "default"), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/connectionPolicies/{connectionPolicyName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ServerConnectionPoliciesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ServerConnectionPoliciesClient) GetResponder(resp *http.Response) (result ServerConnectionPolicy, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/serverdevopsauditsettings.go b/services/preview/sql/mgmt/v5.0/sql/serverdevopsauditsettings.go new file mode 100644 index 000000000000..96f3e06578da --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/serverdevopsauditsettings.go @@ -0,0 +1,317 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ServerDevOpsAuditSettingsClient 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 ServerDevOpsAuditSettingsClient struct { + BaseClient +} + +// NewServerDevOpsAuditSettingsClient creates an instance of the ServerDevOpsAuditSettingsClient client. +func NewServerDevOpsAuditSettingsClient(subscriptionID string) ServerDevOpsAuditSettingsClient { + return NewServerDevOpsAuditSettingsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewServerDevOpsAuditSettingsClientWithBaseURI creates an instance of the ServerDevOpsAuditSettingsClient client +// using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign +// clouds, Azure stack). +func NewServerDevOpsAuditSettingsClientWithBaseURI(baseURI string, subscriptionID string) ServerDevOpsAuditSettingsClient { + return ServerDevOpsAuditSettingsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a server's DevOps audit settings. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// devOpsAuditingSettingsName - the name of the devops audit settings. This should always be 'default'. +// parameters - properties of DevOps audit settings +func (client ServerDevOpsAuditSettingsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, devOpsAuditingSettingsName string, parameters ServerDevOpsAuditingSettings) (result ServerDevOpsAuditSettingsCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerDevOpsAuditSettingsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, devOpsAuditingSettingsName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerDevOpsAuditSettingsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerDevOpsAuditSettingsClient", "CreateOrUpdate", nil, "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ServerDevOpsAuditSettingsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, devOpsAuditingSettingsName string, parameters ServerDevOpsAuditingSettings) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "devOpsAuditingSettingsName": autorest.Encode("path", devOpsAuditingSettingsName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + parameters.SystemData = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/devOpsAuditingSettings/{devOpsAuditingSettingsName}", 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 ServerDevOpsAuditSettingsClient) CreateOrUpdateSender(req *http.Request) (future ServerDevOpsAuditSettingsCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ServerDevOpsAuditSettingsClient) CreateOrUpdateResponder(resp *http.Response) (result ServerDevOpsAuditingSettings, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets a server's DevOps audit settings. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// devOpsAuditingSettingsName - the name of the devops audit settings. This should always be 'default'. +func (client ServerDevOpsAuditSettingsClient) Get(ctx context.Context, resourceGroupName string, serverName string, devOpsAuditingSettingsName string) (result ServerDevOpsAuditingSettings, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerDevOpsAuditSettingsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, devOpsAuditingSettingsName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerDevOpsAuditSettingsClient", "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.ServerDevOpsAuditSettingsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerDevOpsAuditSettingsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ServerDevOpsAuditSettingsClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, devOpsAuditingSettingsName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "devOpsAuditingSettingsName": autorest.Encode("path", devOpsAuditingSettingsName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/devOpsAuditingSettings/{devOpsAuditingSettingsName}", 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 ServerDevOpsAuditSettingsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ServerDevOpsAuditSettingsClient) GetResponder(resp *http.Response) (result ServerDevOpsAuditingSettings, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer lists DevOps audit settings of a server. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +func (client ServerDevOpsAuditSettingsClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result ServerDevOpsAuditSettingsListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerDevOpsAuditSettingsClient.ListByServer") + defer func() { + sc := -1 + if result.sdoaslr.Response.Response != nil { + sc = result.sdoaslr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByServerNextResults + req, err := client.ListByServerPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerDevOpsAuditSettingsClient", "ListByServer", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServerSender(req) + if err != nil { + result.sdoaslr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ServerDevOpsAuditSettingsClient", "ListByServer", resp, "Failure sending request") + return + } + + result.sdoaslr, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerDevOpsAuditSettingsClient", "ListByServer", resp, "Failure responding to request") + return + } + if result.sdoaslr.hasNextLink() && result.sdoaslr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServerPreparer prepares the ListByServer request. +func (client ServerDevOpsAuditSettingsClient) ListByServerPreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/devOpsAuditingSettings", 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 ServerDevOpsAuditSettingsClient) ListByServerSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client ServerDevOpsAuditSettingsClient) ListByServerResponder(resp *http.Response) (result ServerDevOpsAuditSettingsListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByServerNextResults retrieves the next set of results, if any. +func (client ServerDevOpsAuditSettingsClient) listByServerNextResults(ctx context.Context, lastResults ServerDevOpsAuditSettingsListResult) (result ServerDevOpsAuditSettingsListResult, err error) { + req, err := lastResults.serverDevOpsAuditSettingsListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.ServerDevOpsAuditSettingsClient", "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.ServerDevOpsAuditSettingsClient", "listByServerNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerDevOpsAuditSettingsClient", "listByServerNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServerComplete enumerates all values, automatically crossing page boundaries as required. +func (client ServerDevOpsAuditSettingsClient) ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result ServerDevOpsAuditSettingsListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerDevOpsAuditSettingsClient.ListByServer") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByServer(ctx, resourceGroupName, serverName) + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/serverdnsaliases.go b/services/preview/sql/mgmt/v5.0/sql/serverdnsaliases.go new file mode 100644 index 000000000000..96d4130dea9e --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/serverdnsaliases.go @@ -0,0 +1,483 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ServerDNSAliasesClient is the the Azure SQL Database management API provides a RESTful set of web services that +// interact with Azure SQL Database services to manage your databases. The API enables you to create, retrieve, update, +// and delete databases. +type ServerDNSAliasesClient struct { + BaseClient +} + +// NewServerDNSAliasesClient creates an instance of the ServerDNSAliasesClient client. +func NewServerDNSAliasesClient(subscriptionID string) ServerDNSAliasesClient { + return NewServerDNSAliasesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewServerDNSAliasesClientWithBaseURI creates an instance of the ServerDNSAliasesClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewServerDNSAliasesClientWithBaseURI(baseURI string, subscriptionID string) ServerDNSAliasesClient { + return ServerDNSAliasesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Acquire acquires server DNS alias from another server. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server that the alias is pointing to. +// DNSAliasName - the name of the server dns alias. +func (client ServerDNSAliasesClient) Acquire(ctx context.Context, resourceGroupName string, serverName string, DNSAliasName string, parameters ServerDNSAliasAcquisition) (result ServerDNSAliasesAcquireFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerDNSAliasesClient.Acquire") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.OldServerDNSAliasID", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewError("sql.ServerDNSAliasesClient", "Acquire", 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", nil, "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 = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/dnsAliases/{dnsAliasName}/acquire", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// AcquireSender sends the Acquire request. The method will close the +// http.Response Body if it receives an error. +func (client ServerDNSAliasesClient) AcquireSender(req *http.Request) (future ServerDNSAliasesAcquireFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// AcquireResponder handles the response to the Acquire request. The method always +// closes the http.Response Body. +func (client ServerDNSAliasesClient) AcquireResponder(resp *http.Response) (result ServerDNSAlias, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// CreateOrUpdate creates a server DNS alias. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server that the alias is pointing to. +// DNSAliasName - the name of the server dns alias. +func (client ServerDNSAliasesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, DNSAliasName string) (result ServerDNSAliasesCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerDNSAliasesClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, DNSAliasName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerDNSAliasesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerDNSAliasesClient", "CreateOrUpdate", nil, "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 = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/dnsAliases/{dnsAliasName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client ServerDNSAliasesClient) CreateOrUpdateSender(req *http.Request) (future ServerDNSAliasesCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ServerDNSAliasesClient) CreateOrUpdateResponder(resp *http.Response) (result ServerDNSAlias, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes the server DNS alias with the given name. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server that the alias is pointing to. +// DNSAliasName - the name of the server dns alias. +func (client ServerDNSAliasesClient) Delete(ctx context.Context, resourceGroupName string, serverName string, DNSAliasName string) (result ServerDNSAliasesDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerDNSAliasesClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, serverName, DNSAliasName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerDNSAliasesClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerDNSAliasesClient", "Delete", nil, "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 = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/dnsAliases/{dnsAliasName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client ServerDNSAliasesClient) DeleteSender(req *http.Request) (future ServerDNSAliasesDeleteFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ServerDNSAliasesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a server DNS alias. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server that the alias is pointing to. +// DNSAliasName - the name of the server dns alias. +func (client ServerDNSAliasesClient) Get(ctx context.Context, resourceGroupName string, serverName string, DNSAliasName string) (result ServerDNSAlias, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerDNSAliasesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, DNSAliasName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerDNSAliasesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ServerDNSAliasesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerDNSAliasesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ServerDNSAliasesClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, DNSAliasName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "dnsAliasName": autorest.Encode("path", DNSAliasName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/dnsAliases/{dnsAliasName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ServerDNSAliasesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ServerDNSAliasesClient) GetResponder(resp *http.Response) (result ServerDNSAlias, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer gets a list of server DNS aliases for a server. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server that the alias is pointing to. +func (client ServerDNSAliasesClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result ServerDNSAliasListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerDNSAliasesClient.ListByServer") + defer func() { + sc := -1 + if result.sdalr.Response.Response != nil { + sc = result.sdalr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByServerNextResults + req, err := client.ListByServerPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerDNSAliasesClient", "ListByServer", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServerSender(req) + if err != nil { + result.sdalr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ServerDNSAliasesClient", "ListByServer", resp, "Failure sending request") + return + } + + result.sdalr, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerDNSAliasesClient", "ListByServer", resp, "Failure responding to request") + return + } + if result.sdalr.hasNextLink() && result.sdalr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServerPreparer prepares the ListByServer request. +func (client ServerDNSAliasesClient) ListByServerPreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/dnsAliases", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByServerSender sends the ListByServer request. The method will close the +// http.Response Body if it receives an error. +func (client ServerDNSAliasesClient) ListByServerSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client ServerDNSAliasesClient) ListByServerResponder(resp *http.Response) (result ServerDNSAliasListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByServerNextResults retrieves the next set of results, if any. +func (client ServerDNSAliasesClient) listByServerNextResults(ctx context.Context, lastResults ServerDNSAliasListResult) (result ServerDNSAliasListResult, err error) { + req, err := lastResults.serverDNSAliasListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.ServerDNSAliasesClient", "listByServerNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByServerSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.ServerDNSAliasesClient", "listByServerNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerDNSAliasesClient", "listByServerNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServerComplete enumerates all values, automatically crossing page boundaries as required. +func (client ServerDNSAliasesClient) ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result ServerDNSAliasListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerDNSAliasesClient.ListByServer") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByServer(ctx, resourceGroupName, serverName) + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/serverkeys.go b/services/preview/sql/mgmt/v5.0/sql/serverkeys.go new file mode 100644 index 000000000000..c12ff9b138ea --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/serverkeys.go @@ -0,0 +1,400 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ServerKeysClient is the the Azure SQL Database management API provides a RESTful set of web services that interact +// with Azure SQL Database services to manage your databases. The API enables you to create, retrieve, update, and +// delete databases. +type ServerKeysClient struct { + BaseClient +} + +// NewServerKeysClient creates an instance of the ServerKeysClient client. +func NewServerKeysClient(subscriptionID string) ServerKeysClient { + return NewServerKeysClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewServerKeysClientWithBaseURI creates an instance of the ServerKeysClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewServerKeysClientWithBaseURI(baseURI string, subscriptionID string) ServerKeysClient { + return ServerKeysClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a server key. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// keyName - the name of the server key to be operated on (updated or created). The key name is required to be +// in the format of 'vault_key_version'. For example, if the keyId is +// https://YourVaultName.vault.azure.net/keys/YourKeyName/YourKeyVersion, then the server key name should be +// formatted as: YourVaultName_YourKeyName_YourKeyVersion +// parameters - the requested server key resource state. +func (client ServerKeysClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, keyName string, parameters ServerKey) (result ServerKeysCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerKeysClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, keyName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerKeysClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerKeysClient", "CreateOrUpdate", nil, "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 = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + parameters.Kind = nil + parameters.Location = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/keys/{keyName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client ServerKeysClient) CreateOrUpdateSender(req *http.Request) (future ServerKeysCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ServerKeysClient) CreateOrUpdateResponder(resp *http.Response) (result ServerKey, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes the server key with the given name. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// keyName - the name of the server key to be deleted. +func (client ServerKeysClient) Delete(ctx context.Context, resourceGroupName string, serverName string, keyName string) (result ServerKeysDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerKeysClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, serverName, keyName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerKeysClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerKeysClient", "Delete", nil, "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 = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/keys/{keyName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client ServerKeysClient) DeleteSender(req *http.Request) (future ServerKeysDeleteFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ServerKeysClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a server key. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// keyName - the name of the server key to be retrieved. +func (client ServerKeysClient) Get(ctx context.Context, resourceGroupName string, serverName string, keyName string) (result ServerKey, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerKeysClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, keyName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerKeysClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ServerKeysClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerKeysClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ServerKeysClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, keyName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "keyName": autorest.Encode("path", keyName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/keys/{keyName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ServerKeysClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ServerKeysClient) GetResponder(resp *http.Response) (result ServerKey, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer gets a list of server keys. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +func (client ServerKeysClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result ServerKeyListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerKeysClient.ListByServer") + defer func() { + sc := -1 + if result.sklr.Response.Response != nil { + sc = result.sklr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByServerNextResults + req, err := client.ListByServerPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerKeysClient", "ListByServer", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServerSender(req) + if err != nil { + result.sklr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ServerKeysClient", "ListByServer", resp, "Failure sending request") + return + } + + result.sklr, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerKeysClient", "ListByServer", resp, "Failure responding to request") + return + } + if result.sklr.hasNextLink() && result.sklr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServerPreparer prepares the ListByServer request. +func (client ServerKeysClient) ListByServerPreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/keys", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByServerSender sends the ListByServer request. The method will close the +// http.Response Body if it receives an error. +func (client ServerKeysClient) ListByServerSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client ServerKeysClient) ListByServerResponder(resp *http.Response) (result ServerKeyListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByServerNextResults retrieves the next set of results, if any. +func (client ServerKeysClient) listByServerNextResults(ctx context.Context, lastResults ServerKeyListResult) (result ServerKeyListResult, err error) { + req, err := lastResults.serverKeyListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.ServerKeysClient", "listByServerNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByServerSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.ServerKeysClient", "listByServerNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerKeysClient", "listByServerNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServerComplete enumerates all values, automatically crossing page boundaries as required. +func (client ServerKeysClient) ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result ServerKeyListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerKeysClient.ListByServer") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByServer(ctx, resourceGroupName, serverName) + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/serveroperations.go b/services/preview/sql/mgmt/v5.0/sql/serveroperations.go new file mode 100644 index 000000000000..aa1b1858da36 --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/serveroperations.go @@ -0,0 +1,153 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ServerOperationsClient 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 ServerOperationsClient struct { + BaseClient +} + +// NewServerOperationsClient creates an instance of the ServerOperationsClient client. +func NewServerOperationsClient(subscriptionID string) ServerOperationsClient { + return NewServerOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewServerOperationsClientWithBaseURI creates an instance of the ServerOperationsClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewServerOperationsClientWithBaseURI(baseURI string, subscriptionID string) ServerOperationsClient { + return ServerOperationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListByServer gets a list of operations performed on the server. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +func (client ServerOperationsClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result ServerOperationListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerOperationsClient.ListByServer") + defer func() { + sc := -1 + if result.solr.Response.Response != nil { + sc = result.solr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByServerNextResults + req, err := client.ListByServerPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerOperationsClient", "ListByServer", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServerSender(req) + if err != nil { + result.solr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ServerOperationsClient", "ListByServer", resp, "Failure sending request") + return + } + + result.solr, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerOperationsClient", "ListByServer", resp, "Failure responding to request") + return + } + if result.solr.hasNextLink() && result.solr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServerPreparer prepares the ListByServer request. +func (client ServerOperationsClient) ListByServerPreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/operations", 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 ServerOperationsClient) ListByServerSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client ServerOperationsClient) ListByServerResponder(resp *http.Response) (result ServerOperationListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByServerNextResults retrieves the next set of results, if any. +func (client ServerOperationsClient) listByServerNextResults(ctx context.Context, lastResults ServerOperationListResult) (result ServerOperationListResult, err error) { + req, err := lastResults.serverOperationListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.ServerOperationsClient", "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.ServerOperationsClient", "listByServerNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerOperationsClient", "listByServerNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServerComplete enumerates all values, automatically crossing page boundaries as required. +func (client ServerOperationsClient) ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result ServerOperationListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerOperationsClient.ListByServer") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByServer(ctx, resourceGroupName, serverName) + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/servers.go b/services/preview/sql/mgmt/v5.0/sql/servers.go new file mode 100644 index 000000000000..5724c9d452a6 --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/servers.go @@ -0,0 +1,770 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ServersClient is the the Azure SQL Database management API provides a RESTful set of web services that interact with +// Azure SQL Database services to manage your databases. The API enables you to create, retrieve, update, and delete +// databases. +type ServersClient struct { + BaseClient +} + +// NewServersClient creates an instance of the ServersClient client. +func NewServersClient(subscriptionID string) ServersClient { + return NewServersClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewServersClientWithBaseURI creates an instance of the ServersClient client using a custom endpoint. Use this when +// interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewServersClientWithBaseURI(baseURI string, subscriptionID string) ServersClient { + return ServersClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CheckNameAvailability determines whether a resource can be created with the specified name. +// Parameters: +// parameters - the name availability request parameters. +func (client ServersClient) CheckNameAvailability(ctx context.Context, parameters CheckNameAvailabilityRequest) (result CheckNameAvailabilityResponse, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServersClient.CheckNameAvailability") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.Name", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.Type", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewError("sql.ServersClient", "CheckNameAvailability", err.Error()) + } + + req, err := client.CheckNameAvailabilityPreparer(ctx, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersClient", "CheckNameAvailability", nil, "Failure preparing request") + return + } + + resp, err := client.CheckNameAvailabilitySender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ServersClient", "CheckNameAvailability", resp, "Failure sending request") + return + } + + result, err = client.CheckNameAvailabilityResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersClient", "CheckNameAvailability", resp, "Failure responding to request") + return + } + + return +} + +// CheckNameAvailabilityPreparer prepares the CheckNameAvailability request. +func (client ServersClient) CheckNameAvailabilityPreparer(ctx context.Context, parameters CheckNameAvailabilityRequest) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-02-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Sql/checkNameAvailability", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CheckNameAvailabilitySender sends the CheckNameAvailability request. The method will close the +// http.Response Body if it receives an error. +func (client ServersClient) CheckNameAvailabilitySender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CheckNameAvailabilityResponder handles the response to the CheckNameAvailability request. The method always +// closes the http.Response Body. +func (client ServersClient) CheckNameAvailabilityResponder(resp *http.Response) (result CheckNameAvailabilityResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// CreateOrUpdate creates or updates a server. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// parameters - the requested server resource state. +func (client ServersClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, parameters Server) (result ServersCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServersClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersClient", "CreateOrUpdate", nil, "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 = "2021-02-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + parameters.Kind = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client ServersClient) CreateOrUpdateSender(req *http.Request) (future ServersCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ServersClient) CreateOrUpdateResponder(resp *http.Response) (result Server, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a server. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +func (client ServersClient) Delete(ctx context.Context, resourceGroupName string, serverName string) (result ServersDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServersClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersClient", "Delete", nil, "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 = "2021-02-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client ServersClient) DeleteSender(req *http.Request) (future ServersDeleteFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ServersClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a server. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// expand - the child resources to include in the response. +func (client ServersClient) Get(ctx context.Context, resourceGroupName string, serverName string, expand string) (result Server, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServersClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, expand) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ServersClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ServersClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, expand string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-02-01-preview" + 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}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ServersClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ServersClient) GetResponder(resp *http.Response) (result Server, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ImportDatabase imports a bacpac into a new database. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// parameters - the database import request parameters. +func (client ServersClient) ImportDatabase(ctx context.Context, resourceGroupName string, serverName string, parameters ImportNewDatabaseDefinition) (result ServersImportDatabaseFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServersClient.ImportDatabase") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.StorageKey", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.StorageURI", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.AdministratorLogin", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.AdministratorLoginPassword", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewError("sql.ServersClient", "ImportDatabase", err.Error()) + } + + req, err := client.ImportDatabasePreparer(ctx, resourceGroupName, serverName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersClient", "ImportDatabase", nil, "Failure preparing request") + return + } + + result, err = client.ImportDatabaseSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersClient", "ImportDatabase", nil, "Failure sending request") + return + } + + return +} + +// ImportDatabasePreparer prepares the ImportDatabase request. +func (client ServersClient) ImportDatabasePreparer(ctx context.Context, resourceGroupName string, serverName string, parameters ImportNewDatabaseDefinition) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-02-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}/import", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ImportDatabaseSender sends the ImportDatabase request. The method will close the +// http.Response Body if it receives an error. +func (client ServersClient) ImportDatabaseSender(req *http.Request) (future ServersImportDatabaseFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// ImportDatabaseResponder handles the response to the ImportDatabase request. The method always +// closes the http.Response Body. +func (client ServersClient) ImportDatabaseResponder(resp *http.Response) (result ImportExportOperationResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List gets a list of all servers in the subscription. +// Parameters: +// expand - the child resources to include in the response. +func (client ServersClient) List(ctx context.Context, expand string) (result ServerListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServersClient.List") + defer func() { + sc := -1 + if result.slr.Response.Response != nil { + sc = result.slr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, expand) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.slr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ServersClient", "List", resp, "Failure sending request") + return + } + + result.slr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersClient", "List", resp, "Failure responding to request") + return + } + if result.slr.hasNextLink() && result.slr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client ServersClient) ListPreparer(ctx context.Context, expand string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-02-01-preview" + 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}/providers/Microsoft.Sql/servers", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client ServersClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client ServersClient) ListResponder(resp *http.Response) (result ServerListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client ServersClient) listNextResults(ctx context.Context, lastResults ServerListResult) (result ServerListResult, err error) { + req, err := lastResults.serverListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.ServersClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.ServersClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client ServersClient) ListComplete(ctx context.Context, expand string) (result ServerListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServersClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx, expand) + return +} + +// ListByResourceGroup gets a list of servers in a resource groups. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// expand - the child resources to include in the response. +func (client ServersClient) ListByResourceGroup(ctx context.Context, resourceGroupName string, expand string) (result ServerListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServersClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.slr.Response.Response != nil { + sc = result.slr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByResourceGroupNextResults + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName, expand) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.slr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ServersClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result.slr, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersClient", "ListByResourceGroup", resp, "Failure responding to request") + return + } + if result.slr.hasNextLink() && result.slr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client ServersClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string, expand string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-02-01-preview" + 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", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client ServersClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client ServersClient) ListByResourceGroupResponder(resp *http.Response) (result ServerListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByResourceGroupNextResults retrieves the next set of results, if any. +func (client ServersClient) listByResourceGroupNextResults(ctx context.Context, lastResults ServerListResult) (result ServerListResult, err error) { + req, err := lastResults.serverListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.ServersClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.ServersClient", "listByResourceGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. +func (client ServersClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string, expand string) (result ServerListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServersClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByResourceGroup(ctx, resourceGroupName, expand) + return +} + +// Update updates a server. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// parameters - the requested server resource state. +func (client ServersClient) Update(ctx context.Context, resourceGroupName string, serverName string, parameters ServerUpdate) (result ServersUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServersClient.Update") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.UpdatePreparer(ctx, resourceGroupName, serverName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersClient", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServersClient", "Update", nil, "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 = "2021-02-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client ServersClient) UpdateSender(req *http.Request) (future ServersUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client ServersClient) UpdateResponder(resp *http.Response) (result Server, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/serversecurityalertpolicies.go b/services/preview/sql/mgmt/v5.0/sql/serversecurityalertpolicies.go new file mode 100644 index 000000000000..4981922c5633 --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/serversecurityalertpolicies.go @@ -0,0 +1,315 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ServerSecurityAlertPoliciesClient is the the Azure SQL Database management API provides a RESTful set of web +// services that interact with Azure SQL Database services to manage your databases. The API enables you to create, +// retrieve, update, and delete databases. +type ServerSecurityAlertPoliciesClient struct { + BaseClient +} + +// NewServerSecurityAlertPoliciesClient creates an instance of the ServerSecurityAlertPoliciesClient client. +func NewServerSecurityAlertPoliciesClient(subscriptionID string) ServerSecurityAlertPoliciesClient { + return NewServerSecurityAlertPoliciesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewServerSecurityAlertPoliciesClientWithBaseURI creates an instance of the ServerSecurityAlertPoliciesClient client +// using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign +// clouds, Azure stack). +func NewServerSecurityAlertPoliciesClientWithBaseURI(baseURI string, subscriptionID string) ServerSecurityAlertPoliciesClient { + return ServerSecurityAlertPoliciesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a threat detection policy. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// parameters - the server security alert policy. +func (client ServerSecurityAlertPoliciesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, parameters ServerSecurityAlertPolicy) (result ServerSecurityAlertPoliciesCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerSecurityAlertPoliciesClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerSecurityAlertPoliciesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerSecurityAlertPoliciesClient", "CreateOrUpdate", nil, "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ServerSecurityAlertPoliciesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, parameters ServerSecurityAlertPolicy) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "securityAlertPolicyName": autorest.Encode("path", "Default"), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + parameters.SystemData = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/securityAlertPolicies/{securityAlertPolicyName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client ServerSecurityAlertPoliciesClient) CreateOrUpdateSender(req *http.Request) (future ServerSecurityAlertPoliciesCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ServerSecurityAlertPoliciesClient) CreateOrUpdateResponder(resp *http.Response) (result ServerSecurityAlertPolicy, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get get a server's security alert policy. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +func (client ServerSecurityAlertPoliciesClient) Get(ctx context.Context, resourceGroupName string, serverName string) (result ServerSecurityAlertPolicy, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerSecurityAlertPoliciesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerSecurityAlertPoliciesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ServerSecurityAlertPoliciesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerSecurityAlertPoliciesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ServerSecurityAlertPoliciesClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "securityAlertPolicyName": autorest.Encode("path", "Default"), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/securityAlertPolicies/{securityAlertPolicyName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ServerSecurityAlertPoliciesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ServerSecurityAlertPoliciesClient) GetResponder(resp *http.Response) (result ServerSecurityAlertPolicy, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer get the server's threat detection policies. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +func (client ServerSecurityAlertPoliciesClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result LogicalServerSecurityAlertPolicyListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerSecurityAlertPoliciesClient.ListByServer") + defer func() { + sc := -1 + if result.lssaplr.Response.Response != nil { + sc = result.lssaplr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByServerNextResults + req, err := client.ListByServerPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerSecurityAlertPoliciesClient", "ListByServer", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServerSender(req) + if err != nil { + result.lssaplr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ServerSecurityAlertPoliciesClient", "ListByServer", resp, "Failure sending request") + return + } + + result.lssaplr, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerSecurityAlertPoliciesClient", "ListByServer", resp, "Failure responding to request") + return + } + if result.lssaplr.hasNextLink() && result.lssaplr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServerPreparer prepares the ListByServer request. +func (client ServerSecurityAlertPoliciesClient) ListByServerPreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/securityAlertPolicies", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByServerSender sends the ListByServer request. The method will close the +// http.Response Body if it receives an error. +func (client ServerSecurityAlertPoliciesClient) ListByServerSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client ServerSecurityAlertPoliciesClient) ListByServerResponder(resp *http.Response) (result LogicalServerSecurityAlertPolicyListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByServerNextResults retrieves the next set of results, if any. +func (client ServerSecurityAlertPoliciesClient) listByServerNextResults(ctx context.Context, lastResults LogicalServerSecurityAlertPolicyListResult) (result LogicalServerSecurityAlertPolicyListResult, err error) { + req, err := lastResults.logicalServerSecurityAlertPolicyListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.ServerSecurityAlertPoliciesClient", "listByServerNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByServerSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.ServerSecurityAlertPoliciesClient", "listByServerNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerSecurityAlertPoliciesClient", "listByServerNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServerComplete enumerates all values, automatically crossing page boundaries as required. +func (client ServerSecurityAlertPoliciesClient) ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result LogicalServerSecurityAlertPolicyListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerSecurityAlertPoliciesClient.ListByServer") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByServer(ctx, resourceGroupName, serverName) + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/servertrustgroups.go b/services/preview/sql/mgmt/v5.0/sql/servertrustgroups.go new file mode 100644 index 000000000000..cf23b3b13a64 --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/servertrustgroups.go @@ -0,0 +1,525 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ServerTrustGroupsClient is the the Azure SQL Database management API provides a RESTful set of web services that +// interact with Azure SQL Database services to manage your databases. The API enables you to create, retrieve, update, +// and delete databases. +type ServerTrustGroupsClient struct { + BaseClient +} + +// NewServerTrustGroupsClient creates an instance of the ServerTrustGroupsClient client. +func NewServerTrustGroupsClient(subscriptionID string) ServerTrustGroupsClient { + return NewServerTrustGroupsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewServerTrustGroupsClientWithBaseURI creates an instance of the ServerTrustGroupsClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewServerTrustGroupsClientWithBaseURI(baseURI string, subscriptionID string) ServerTrustGroupsClient { + return ServerTrustGroupsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a server trust group. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// locationName - the name of the region where the resource is located. +// serverTrustGroupName - the name of the server trust group. +// parameters - the server trust group parameters. +func (client ServerTrustGroupsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, locationName string, serverTrustGroupName string, parameters ServerTrustGroup) (result ServerTrustGroupsCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerTrustGroupsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.ServerTrustGroupProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ServerTrustGroupProperties.GroupMembers", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.ServerTrustGroupProperties.TrustScopes", Name: validation.Null, Rule: true, Chain: nil}, + }}}}}); err != nil { + return result, validation.NewError("sql.ServerTrustGroupsClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, locationName, serverTrustGroupName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerTrustGroupsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerTrustGroupsClient", "CreateOrUpdate", nil, "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ServerTrustGroupsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, locationName string, serverTrustGroupName string, parameters ServerTrustGroup) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "locationName": autorest.Encode("path", locationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverTrustGroupName": autorest.Encode("path", serverTrustGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/serverTrustGroups/{serverTrustGroupName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client ServerTrustGroupsClient) CreateOrUpdateSender(req *http.Request) (future ServerTrustGroupsCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ServerTrustGroupsClient) CreateOrUpdateResponder(resp *http.Response) (result ServerTrustGroup, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a server trust group. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// locationName - the name of the region where the resource is located. +// serverTrustGroupName - the name of the server trust group. +func (client ServerTrustGroupsClient) Delete(ctx context.Context, resourceGroupName string, locationName string, serverTrustGroupName string) (result ServerTrustGroupsDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerTrustGroupsClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, locationName, serverTrustGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerTrustGroupsClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerTrustGroupsClient", "Delete", nil, "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ServerTrustGroupsClient) DeletePreparer(ctx context.Context, resourceGroupName string, locationName string, serverTrustGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "locationName": autorest.Encode("path", locationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverTrustGroupName": autorest.Encode("path", serverTrustGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/serverTrustGroups/{serverTrustGroupName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client ServerTrustGroupsClient) DeleteSender(req *http.Request) (future ServerTrustGroupsDeleteFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ServerTrustGroupsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a server trust group. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// locationName - the name of the region where the resource is located. +// serverTrustGroupName - the name of the server trust group. +func (client ServerTrustGroupsClient) Get(ctx context.Context, resourceGroupName string, locationName string, serverTrustGroupName string) (result ServerTrustGroup, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerTrustGroupsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, locationName, serverTrustGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerTrustGroupsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ServerTrustGroupsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerTrustGroupsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ServerTrustGroupsClient) GetPreparer(ctx context.Context, resourceGroupName string, locationName string, serverTrustGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "locationName": autorest.Encode("path", locationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverTrustGroupName": autorest.Encode("path", serverTrustGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/serverTrustGroups/{serverTrustGroupName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ServerTrustGroupsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ServerTrustGroupsClient) GetResponder(resp *http.Response) (result ServerTrustGroup, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByInstance gets a server trust groups by instance name. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// managedInstanceName - the name of the managed instance. +func (client ServerTrustGroupsClient) ListByInstance(ctx context.Context, resourceGroupName string, managedInstanceName string) (result ServerTrustGroupListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerTrustGroupsClient.ListByInstance") + defer func() { + sc := -1 + if result.stglr.Response.Response != nil { + sc = result.stglr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByInstanceNextResults + req, err := client.ListByInstancePreparer(ctx, resourceGroupName, managedInstanceName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerTrustGroupsClient", "ListByInstance", nil, "Failure preparing request") + return + } + + resp, err := client.ListByInstanceSender(req) + if err != nil { + result.stglr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ServerTrustGroupsClient", "ListByInstance", resp, "Failure sending request") + return + } + + result.stglr, err = client.ListByInstanceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerTrustGroupsClient", "ListByInstance", resp, "Failure responding to request") + return + } + if result.stglr.hasNextLink() && result.stglr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByInstancePreparer prepares the ListByInstance request. +func (client ServerTrustGroupsClient) ListByInstancePreparer(ctx context.Context, resourceGroupName string, managedInstanceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managedInstanceName": autorest.Encode("path", managedInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/serverTrustGroups", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByInstanceSender sends the ListByInstance request. The method will close the +// http.Response Body if it receives an error. +func (client ServerTrustGroupsClient) ListByInstanceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByInstanceResponder handles the response to the ListByInstance request. The method always +// closes the http.Response Body. +func (client ServerTrustGroupsClient) ListByInstanceResponder(resp *http.Response) (result ServerTrustGroupListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByInstanceNextResults retrieves the next set of results, if any. +func (client ServerTrustGroupsClient) listByInstanceNextResults(ctx context.Context, lastResults ServerTrustGroupListResult) (result ServerTrustGroupListResult, err error) { + req, err := lastResults.serverTrustGroupListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.ServerTrustGroupsClient", "listByInstanceNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByInstanceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.ServerTrustGroupsClient", "listByInstanceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByInstanceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerTrustGroupsClient", "listByInstanceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByInstanceComplete enumerates all values, automatically crossing page boundaries as required. +func (client ServerTrustGroupsClient) ListByInstanceComplete(ctx context.Context, resourceGroupName string, managedInstanceName string) (result ServerTrustGroupListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerTrustGroupsClient.ListByInstance") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByInstance(ctx, resourceGroupName, managedInstanceName) + return +} + +// ListByLocation lists a server trust group. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// locationName - the name of the region where the resource is located. +func (client ServerTrustGroupsClient) ListByLocation(ctx context.Context, resourceGroupName string, locationName string) (result ServerTrustGroupListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerTrustGroupsClient.ListByLocation") + defer func() { + sc := -1 + if result.stglr.Response.Response != nil { + sc = result.stglr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByLocationNextResults + req, err := client.ListByLocationPreparer(ctx, resourceGroupName, locationName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerTrustGroupsClient", "ListByLocation", nil, "Failure preparing request") + return + } + + resp, err := client.ListByLocationSender(req) + if err != nil { + result.stglr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ServerTrustGroupsClient", "ListByLocation", resp, "Failure sending request") + return + } + + result.stglr, err = client.ListByLocationResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerTrustGroupsClient", "ListByLocation", resp, "Failure responding to request") + return + } + if result.stglr.hasNextLink() && result.stglr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByLocationPreparer prepares the ListByLocation request. +func (client ServerTrustGroupsClient) ListByLocationPreparer(ctx context.Context, resourceGroupName string, locationName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "locationName": autorest.Encode("path", locationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/serverTrustGroups", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByLocationSender sends the ListByLocation request. The method will close the +// http.Response Body if it receives an error. +func (client ServerTrustGroupsClient) ListByLocationSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByLocationResponder handles the response to the ListByLocation request. The method always +// closes the http.Response Body. +func (client ServerTrustGroupsClient) ListByLocationResponder(resp *http.Response) (result ServerTrustGroupListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByLocationNextResults retrieves the next set of results, if any. +func (client ServerTrustGroupsClient) listByLocationNextResults(ctx context.Context, lastResults ServerTrustGroupListResult) (result ServerTrustGroupListResult, err error) { + req, err := lastResults.serverTrustGroupListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.ServerTrustGroupsClient", "listByLocationNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByLocationSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.ServerTrustGroupsClient", "listByLocationNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByLocationResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerTrustGroupsClient", "listByLocationNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByLocationComplete enumerates all values, automatically crossing page boundaries as required. +func (client ServerTrustGroupsClient) ListByLocationComplete(ctx context.Context, resourceGroupName string, locationName string) (result ServerTrustGroupListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerTrustGroupsClient.ListByLocation") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByLocation(ctx, resourceGroupName, locationName) + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/serverusages.go b/services/preview/sql/mgmt/v5.0/sql/serverusages.go new file mode 100644 index 000000000000..662861e4c6cf --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/serverusages.go @@ -0,0 +1,110 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ServerUsagesClient is the the Azure SQL Database management API provides a RESTful set of web services that interact +// with Azure SQL Database services to manage your databases. The API enables you to create, retrieve, update, and +// delete databases. +type ServerUsagesClient struct { + BaseClient +} + +// NewServerUsagesClient creates an instance of the ServerUsagesClient client. +func NewServerUsagesClient(subscriptionID string) ServerUsagesClient { + return NewServerUsagesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewServerUsagesClientWithBaseURI creates an instance of the ServerUsagesClient client using a custom endpoint. Use +// this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewServerUsagesClientWithBaseURI(baseURI string, subscriptionID string) ServerUsagesClient { + return ServerUsagesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListByServer returns server usages. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +func (client ServerUsagesClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result ServerUsageListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerUsagesClient.ListByServer") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListByServerPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerUsagesClient", "ListByServer", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServerSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ServerUsagesClient", "ListByServer", resp, "Failure sending request") + return + } + + result, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerUsagesClient", "ListByServer", resp, "Failure responding to request") + return + } + + return +} + +// ListByServerPreparer prepares the ListByServer request. +func (client ServerUsagesClient) ListByServerPreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/usages", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByServerSender sends the ListByServer request. The method will close the +// http.Response Body if it receives an error. +func (client ServerUsagesClient) ListByServerSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client ServerUsagesClient) ListByServerResponder(resp *http.Response) (result ServerUsageListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/servervulnerabilityassessments.go b/services/preview/sql/mgmt/v5.0/sql/servervulnerabilityassessments.go new file mode 100644 index 000000000000..f80fb116c772 --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/servervulnerabilityassessments.go @@ -0,0 +1,399 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ServerVulnerabilityAssessmentsClient is the the Azure SQL Database management API provides a RESTful set of web +// services that interact with Azure SQL Database services to manage your databases. The API enables you to create, +// retrieve, update, and delete databases. +type ServerVulnerabilityAssessmentsClient struct { + BaseClient +} + +// NewServerVulnerabilityAssessmentsClient creates an instance of the ServerVulnerabilityAssessmentsClient client. +func NewServerVulnerabilityAssessmentsClient(subscriptionID string) ServerVulnerabilityAssessmentsClient { + return NewServerVulnerabilityAssessmentsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewServerVulnerabilityAssessmentsClientWithBaseURI creates an instance of the ServerVulnerabilityAssessmentsClient +// client using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI +// (sovereign clouds, Azure stack). +func NewServerVulnerabilityAssessmentsClientWithBaseURI(baseURI string, subscriptionID string) ServerVulnerabilityAssessmentsClient { + return ServerVulnerabilityAssessmentsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates the server's vulnerability assessment. Learn more about setting SQL vulnerability +// assessment with managed identity - +// https://docs.microsoft.com/azure/azure-sql/database/sql-database-vulnerability-assessment-storage +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server for which the vulnerability assessment is defined. +// parameters - the requested resource. +func (client ServerVulnerabilityAssessmentsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, parameters ServerVulnerabilityAssessment) (result ServerVulnerabilityAssessment, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerVulnerabilityAssessmentsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.ServerVulnerabilityAssessmentProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ServerVulnerabilityAssessmentProperties.StorageContainerPath", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("sql.ServerVulnerabilityAssessmentsClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerVulnerabilityAssessmentsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ServerVulnerabilityAssessmentsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerVulnerabilityAssessmentsClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ServerVulnerabilityAssessmentsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, parameters ServerVulnerabilityAssessment) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vulnerabilityAssessmentName": autorest.Encode("path", "default"), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client ServerVulnerabilityAssessmentsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ServerVulnerabilityAssessmentsClient) CreateOrUpdateResponder(resp *http.Response) (result ServerVulnerabilityAssessment, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete removes the server's vulnerability assessment. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server for which the vulnerability assessment is defined. +func (client ServerVulnerabilityAssessmentsClient) Delete(ctx context.Context, resourceGroupName string, serverName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerVulnerabilityAssessmentsClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerVulnerabilityAssessmentsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "sql.ServerVulnerabilityAssessmentsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerVulnerabilityAssessmentsClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ServerVulnerabilityAssessmentsClient) DeletePreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vulnerabilityAssessmentName": autorest.Encode("path", "default"), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client ServerVulnerabilityAssessmentsClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ServerVulnerabilityAssessmentsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets the server's vulnerability assessment. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server for which the vulnerability assessment is defined. +func (client ServerVulnerabilityAssessmentsClient) Get(ctx context.Context, resourceGroupName string, serverName string) (result ServerVulnerabilityAssessment, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerVulnerabilityAssessmentsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerVulnerabilityAssessmentsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ServerVulnerabilityAssessmentsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerVulnerabilityAssessmentsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ServerVulnerabilityAssessmentsClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vulnerabilityAssessmentName": autorest.Encode("path", "default"), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ServerVulnerabilityAssessmentsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ServerVulnerabilityAssessmentsClient) GetResponder(resp *http.Response) (result ServerVulnerabilityAssessment, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer lists the vulnerability assessment policies associated with a server. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +func (client ServerVulnerabilityAssessmentsClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result ServerVulnerabilityAssessmentListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerVulnerabilityAssessmentsClient.ListByServer") + defer func() { + sc := -1 + if result.svalr.Response.Response != nil { + sc = result.svalr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByServerNextResults + req, err := client.ListByServerPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerVulnerabilityAssessmentsClient", "ListByServer", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServerSender(req) + if err != nil { + result.svalr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ServerVulnerabilityAssessmentsClient", "ListByServer", resp, "Failure sending request") + return + } + + result.svalr, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerVulnerabilityAssessmentsClient", "ListByServer", resp, "Failure responding to request") + return + } + if result.svalr.hasNextLink() && result.svalr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServerPreparer prepares the ListByServer request. +func (client ServerVulnerabilityAssessmentsClient) ListByServerPreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/vulnerabilityAssessments", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByServerSender sends the ListByServer request. The method will close the +// http.Response Body if it receives an error. +func (client ServerVulnerabilityAssessmentsClient) ListByServerSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client ServerVulnerabilityAssessmentsClient) ListByServerResponder(resp *http.Response) (result ServerVulnerabilityAssessmentListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByServerNextResults retrieves the next set of results, if any. +func (client ServerVulnerabilityAssessmentsClient) listByServerNextResults(ctx context.Context, lastResults ServerVulnerabilityAssessmentListResult) (result ServerVulnerabilityAssessmentListResult, err error) { + req, err := lastResults.serverVulnerabilityAssessmentListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.ServerVulnerabilityAssessmentsClient", "listByServerNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByServerSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.ServerVulnerabilityAssessmentsClient", "listByServerNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServerVulnerabilityAssessmentsClient", "listByServerNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServerComplete enumerates all values, automatically crossing page boundaries as required. +func (client ServerVulnerabilityAssessmentsClient) ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result ServerVulnerabilityAssessmentListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServerVulnerabilityAssessmentsClient.ListByServer") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByServer(ctx, resourceGroupName, serverName) + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/serviceobjectives.go b/services/preview/sql/mgmt/v5.0/sql/serviceobjectives.go new file mode 100644 index 000000000000..0b21dd5344f9 --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/serviceobjectives.go @@ -0,0 +1,190 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ServiceObjectivesClient is the the Azure SQL Database management API provides a RESTful set of web services that +// interact with Azure SQL Database services to manage your databases. The API enables you to create, retrieve, update, +// and delete databases. +type ServiceObjectivesClient struct { + BaseClient +} + +// NewServiceObjectivesClient creates an instance of the ServiceObjectivesClient client. +func NewServiceObjectivesClient(subscriptionID string) ServiceObjectivesClient { + return NewServiceObjectivesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewServiceObjectivesClientWithBaseURI creates an instance of the ServiceObjectivesClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewServiceObjectivesClientWithBaseURI(baseURI string, subscriptionID string) ServiceObjectivesClient { + return ServiceObjectivesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get gets a database service objective. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// serviceObjectiveName - the name of the service objective to retrieve. +func (client ServiceObjectivesClient) Get(ctx context.Context, resourceGroupName string, serverName string, serviceObjectiveName string) (result ServiceObjective, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServiceObjectivesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, serviceObjectiveName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServiceObjectivesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ServiceObjectivesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServiceObjectivesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ServiceObjectivesClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, serviceObjectiveName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "serviceObjectiveName": autorest.Encode("path", serviceObjectiveName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/serviceObjectives/{serviceObjectiveName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ServiceObjectivesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ServiceObjectivesClient) GetResponder(resp *http.Response) (result ServiceObjective, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer returns database service objectives. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +func (client ServiceObjectivesClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result ServiceObjectiveListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServiceObjectivesClient.ListByServer") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListByServerPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServiceObjectivesClient", "ListByServer", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServerSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.ServiceObjectivesClient", "ListByServer", resp, "Failure sending request") + return + } + + result, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.ServiceObjectivesClient", "ListByServer", resp, "Failure responding to request") + return + } + + return +} + +// ListByServerPreparer prepares the ListByServer request. +func (client ServiceObjectivesClient) ListByServerPreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2014-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/serviceObjectives", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByServerSender sends the ListByServer request. The method will close the +// http.Response Body if it receives an error. +func (client ServiceObjectivesClient) ListByServerSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client ServiceObjectivesClient) ListByServerResponder(resp *http.Response) (result ServiceObjectiveListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/sqlapi/interfaces.go b/services/preview/sql/mgmt/v5.0/sql/sqlapi/interfaces.go new file mode 100644 index 000000000000..c0309960fd04 --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/sqlapi/interfaces.go @@ -0,0 +1,1297 @@ +package sqlapi + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/services/preview/sql/mgmt/v5.0/sql" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/date" + "github.com/gofrs/uuid" +) + +// RecoverableDatabasesClientAPI contains the set of methods on the RecoverableDatabasesClient type. +type RecoverableDatabasesClientAPI interface { + Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.RecoverableDatabase, err error) + ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result sql.RecoverableDatabaseListResult, err error) +} + +var _ RecoverableDatabasesClientAPI = (*sql.RecoverableDatabasesClient)(nil) + +// ServerConnectionPoliciesClientAPI contains the set of methods on the ServerConnectionPoliciesClient type. +type ServerConnectionPoliciesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, parameters sql.ServerConnectionPolicy) (result sql.ServerConnectionPolicy, err error) + Get(ctx context.Context, resourceGroupName string, serverName string) (result sql.ServerConnectionPolicy, err error) +} + +var _ ServerConnectionPoliciesClientAPI = (*sql.ServerConnectionPoliciesClient)(nil) + +// DataMaskingPoliciesClientAPI contains the set of methods on the DataMaskingPoliciesClient type. +type DataMaskingPoliciesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters sql.DataMaskingPolicy) (result sql.DataMaskingPolicy, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.DataMaskingPolicy, err error) +} + +var _ DataMaskingPoliciesClientAPI = (*sql.DataMaskingPoliciesClient)(nil) + +// DataMaskingRulesClientAPI contains the set of methods on the DataMaskingRulesClient type. +type DataMaskingRulesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, dataMaskingRuleName string, parameters sql.DataMaskingRule) (result sql.DataMaskingRule, err error) + ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.DataMaskingRuleListResult, err error) +} + +var _ DataMaskingRulesClientAPI = (*sql.DataMaskingRulesClient)(nil) + +// GeoBackupPoliciesClientAPI contains the set of methods on the GeoBackupPoliciesClient type. +type GeoBackupPoliciesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters sql.GeoBackupPolicy) (result sql.GeoBackupPolicy, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.GeoBackupPolicy, err error) + ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.GeoBackupPolicyListResult, err error) +} + +var _ GeoBackupPoliciesClientAPI = (*sql.GeoBackupPoliciesClient)(nil) + +// DatabasesClientAPI contains the set of methods on the DatabasesClient type. +type DatabasesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters sql.Database) (result sql.DatabasesCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.DatabasesDeleteFuture, err error) + Export(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters sql.ExportDatabaseDefinition) (result sql.DatabasesExportFuture, err error) + Failover(ctx context.Context, resourceGroupName string, serverName string, databaseName string, replicaType sql.ReplicaType) (result sql.DatabasesFailoverFuture, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.Database, err error) + Import(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters sql.ImportExistingDatabaseDefinition) (result sql.DatabasesImportFuture, err error) + ListByElasticPool(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string) (result sql.DatabaseListResultPage, err error) + ListByElasticPoolComplete(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string) (result sql.DatabaseListResultIterator, err error) + ListByServer(ctx context.Context, resourceGroupName string, serverName string, skipToken string) (result sql.DatabaseListResultPage, err error) + ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string, skipToken string) (result sql.DatabaseListResultIterator, err error) + ListInaccessibleByServer(ctx context.Context, resourceGroupName string, serverName string) (result sql.DatabaseListResultPage, err error) + ListInaccessibleByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result sql.DatabaseListResultIterator, err error) + ListMetricDefinitions(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.MetricDefinitionListResult, err error) + ListMetrics(ctx context.Context, resourceGroupName string, serverName string, databaseName string, filter string) (result sql.MetricListResult, err error) + Pause(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.DatabasesPauseFuture, err error) + Rename(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters sql.ResourceMoveDefinition) (result autorest.Response, err error) + Resume(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.DatabasesResumeFuture, err error) + Update(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters sql.DatabaseUpdate) (result sql.DatabasesUpdateFuture, err error) + UpgradeDataWarehouse(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.DatabasesUpgradeDataWarehouseFuture, err error) +} + +var _ DatabasesClientAPI = (*sql.DatabasesClient)(nil) + +// ElasticPoolsClientAPI contains the set of methods on the ElasticPoolsClient type. +type ElasticPoolsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string, parameters sql.ElasticPool) (result sql.ElasticPoolsCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string) (result sql.ElasticPoolsDeleteFuture, err error) + Failover(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string) (result sql.ElasticPoolsFailoverFuture, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string) (result sql.ElasticPool, err error) + ListByServer(ctx context.Context, resourceGroupName string, serverName string, skip *int32) (result sql.ElasticPoolListResultPage, err error) + ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string, skip *int32) (result sql.ElasticPoolListResultIterator, err error) + ListMetricDefinitions(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string) (result sql.MetricDefinitionListResult, err error) + ListMetrics(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string, filter string) (result sql.MetricListResult, err error) + Update(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string, parameters sql.ElasticPoolUpdate) (result sql.ElasticPoolsUpdateFuture, err error) +} + +var _ ElasticPoolsClientAPI = (*sql.ElasticPoolsClient)(nil) + +// ReplicationLinksClientAPI contains the set of methods on the ReplicationLinksClient type. +type ReplicationLinksClientAPI interface { + Delete(ctx context.Context, resourceGroupName string, serverName string, databaseName string, linkID string) (result autorest.Response, err error) + Failover(ctx context.Context, resourceGroupName string, serverName string, databaseName string, linkID string) (result sql.ReplicationLinksFailoverFuture, err error) + FailoverAllowDataLoss(ctx context.Context, resourceGroupName string, serverName string, databaseName string, linkID string) (result sql.ReplicationLinksFailoverAllowDataLossFuture, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string, linkID string) (result sql.ReplicationLink, err error) + ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.ReplicationLinkListResultPage, err error) + ListByDatabaseComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.ReplicationLinkListResultIterator, err error) + ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result sql.ReplicationLinkListResultPage, err error) + ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result sql.ReplicationLinkListResultIterator, err error) + Unlink(ctx context.Context, resourceGroupName string, serverName string, databaseName string, linkID string, parameters sql.UnlinkParameters) (result sql.ReplicationLinksUnlinkFuture, err error) +} + +var _ ReplicationLinksClientAPI = (*sql.ReplicationLinksClient)(nil) + +// ServerCommunicationLinksClientAPI contains the set of methods on the ServerCommunicationLinksClient type. +type ServerCommunicationLinksClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, communicationLinkName string, parameters sql.ServerCommunicationLink) (result sql.ServerCommunicationLinksCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, serverName string, communicationLinkName string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, communicationLinkName string) (result sql.ServerCommunicationLink, err error) + ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result sql.ServerCommunicationLinkListResult, err error) +} + +var _ ServerCommunicationLinksClientAPI = (*sql.ServerCommunicationLinksClient)(nil) + +// ServiceObjectivesClientAPI contains the set of methods on the ServiceObjectivesClient type. +type ServiceObjectivesClientAPI interface { + Get(ctx context.Context, resourceGroupName string, serverName string, serviceObjectiveName string) (result sql.ServiceObjective, err error) + ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result sql.ServiceObjectiveListResult, err error) +} + +var _ ServiceObjectivesClientAPI = (*sql.ServiceObjectivesClient)(nil) + +// ElasticPoolActivitiesClientAPI contains the set of methods on the ElasticPoolActivitiesClient type. +type ElasticPoolActivitiesClientAPI interface { + ListByElasticPool(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string) (result sql.ElasticPoolActivityListResult, err error) +} + +var _ ElasticPoolActivitiesClientAPI = (*sql.ElasticPoolActivitiesClient)(nil) + +// ElasticPoolDatabaseActivitiesClientAPI contains the set of methods on the ElasticPoolDatabaseActivitiesClient type. +type ElasticPoolDatabaseActivitiesClientAPI interface { + ListByElasticPool(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string) (result sql.ElasticPoolDatabaseActivityListResult, err error) +} + +var _ ElasticPoolDatabaseActivitiesClientAPI = (*sql.ElasticPoolDatabaseActivitiesClient)(nil) + +// TransparentDataEncryptionsClientAPI contains the set of methods on the TransparentDataEncryptionsClient type. +type TransparentDataEncryptionsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters sql.TransparentDataEncryption) (result sql.TransparentDataEncryption, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.TransparentDataEncryption, err error) +} + +var _ TransparentDataEncryptionsClientAPI = (*sql.TransparentDataEncryptionsClient)(nil) + +// TransparentDataEncryptionActivitiesClientAPI contains the set of methods on the TransparentDataEncryptionActivitiesClient type. +type TransparentDataEncryptionActivitiesClientAPI interface { + ListByConfiguration(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.TransparentDataEncryptionActivityListResult, err error) +} + +var _ TransparentDataEncryptionActivitiesClientAPI = (*sql.TransparentDataEncryptionActivitiesClient)(nil) + +// ServerUsagesClientAPI contains the set of methods on the ServerUsagesClient type. +type ServerUsagesClientAPI interface { + ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result sql.ServerUsageListResult, err error) +} + +var _ ServerUsagesClientAPI = (*sql.ServerUsagesClient)(nil) + +// ExtendedDatabaseBlobAuditingPoliciesClientAPI contains the set of methods on the ExtendedDatabaseBlobAuditingPoliciesClient type. +type ExtendedDatabaseBlobAuditingPoliciesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters sql.ExtendedDatabaseBlobAuditingPolicy) (result sql.ExtendedDatabaseBlobAuditingPolicy, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.ExtendedDatabaseBlobAuditingPolicy, err error) + ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.ExtendedDatabaseBlobAuditingPolicyListResultPage, err error) + ListByDatabaseComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.ExtendedDatabaseBlobAuditingPolicyListResultIterator, err error) +} + +var _ ExtendedDatabaseBlobAuditingPoliciesClientAPI = (*sql.ExtendedDatabaseBlobAuditingPoliciesClient)(nil) + +// ExtendedServerBlobAuditingPoliciesClientAPI contains the set of methods on the ExtendedServerBlobAuditingPoliciesClient type. +type ExtendedServerBlobAuditingPoliciesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, parameters sql.ExtendedServerBlobAuditingPolicy) (result sql.ExtendedServerBlobAuditingPoliciesCreateOrUpdateFuture, err error) + Get(ctx context.Context, resourceGroupName string, serverName string) (result sql.ExtendedServerBlobAuditingPolicy, err error) + ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result sql.ExtendedServerBlobAuditingPolicyListResultPage, err error) + ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result sql.ExtendedServerBlobAuditingPolicyListResultIterator, err error) +} + +var _ ExtendedServerBlobAuditingPoliciesClientAPI = (*sql.ExtendedServerBlobAuditingPoliciesClient)(nil) + +// ServerBlobAuditingPoliciesClientAPI contains the set of methods on the ServerBlobAuditingPoliciesClient type. +type ServerBlobAuditingPoliciesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, parameters sql.ServerBlobAuditingPolicy) (result sql.ServerBlobAuditingPoliciesCreateOrUpdateFuture, err error) + Get(ctx context.Context, resourceGroupName string, serverName string) (result sql.ServerBlobAuditingPolicy, err error) + ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result sql.ServerBlobAuditingPolicyListResultPage, err error) + ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result sql.ServerBlobAuditingPolicyListResultIterator, err error) +} + +var _ ServerBlobAuditingPoliciesClientAPI = (*sql.ServerBlobAuditingPoliciesClient)(nil) + +// DatabaseBlobAuditingPoliciesClientAPI contains the set of methods on the DatabaseBlobAuditingPoliciesClient type. +type DatabaseBlobAuditingPoliciesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters sql.DatabaseBlobAuditingPolicy) (result sql.DatabaseBlobAuditingPolicy, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.DatabaseBlobAuditingPolicy, err error) + ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.DatabaseBlobAuditingPolicyListResultPage, err error) + ListByDatabaseComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.DatabaseBlobAuditingPolicyListResultIterator, err error) +} + +var _ DatabaseBlobAuditingPoliciesClientAPI = (*sql.DatabaseBlobAuditingPoliciesClient)(nil) + +// DatabaseAdvisorsClientAPI contains the set of methods on the DatabaseAdvisorsClient type. +type DatabaseAdvisorsClientAPI interface { + Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string, advisorName string) (result sql.Advisor, err error) + ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string, expand string) (result sql.ListAdvisor, err error) + Update(ctx context.Context, resourceGroupName string, serverName string, databaseName string, advisorName string, parameters sql.Advisor) (result sql.Advisor, err error) +} + +var _ DatabaseAdvisorsClientAPI = (*sql.DatabaseAdvisorsClient)(nil) + +// DatabaseAutomaticTuningClientAPI contains the set of methods on the DatabaseAutomaticTuningClient type. +type DatabaseAutomaticTuningClientAPI interface { + Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.DatabaseAutomaticTuning, err error) + Update(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters sql.DatabaseAutomaticTuning) (result sql.DatabaseAutomaticTuning, err error) +} + +var _ DatabaseAutomaticTuningClientAPI = (*sql.DatabaseAutomaticTuningClient)(nil) + +// DatabaseColumnsClientAPI contains the set of methods on the DatabaseColumnsClient type. +type DatabaseColumnsClientAPI interface { + Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string, schemaName string, tableName string, columnName string) (result sql.DatabaseColumn, err error) + ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string, schema []string, table []string, column []string, orderBy []string, skiptoken string) (result sql.DatabaseColumnListResultPage, err error) + ListByDatabaseComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string, schema []string, table []string, column []string, orderBy []string, skiptoken string) (result sql.DatabaseColumnListResultIterator, err error) + ListByTable(ctx context.Context, resourceGroupName string, serverName string, databaseName string, schemaName string, tableName string, filter string) (result sql.DatabaseColumnListResultPage, err error) + ListByTableComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string, schemaName string, tableName string, filter string) (result sql.DatabaseColumnListResultIterator, err error) +} + +var _ DatabaseColumnsClientAPI = (*sql.DatabaseColumnsClient)(nil) + +// DatabaseRecommendedActionsClientAPI contains the set of methods on the DatabaseRecommendedActionsClient type. +type DatabaseRecommendedActionsClientAPI interface { + Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string, advisorName string, recommendedActionName string) (result sql.RecommendedAction, err error) + ListByDatabaseAdvisor(ctx context.Context, resourceGroupName string, serverName string, databaseName string, advisorName string) (result sql.ListRecommendedAction, err error) + Update(ctx context.Context, resourceGroupName string, serverName string, databaseName string, advisorName string, recommendedActionName string, parameters sql.RecommendedAction) (result sql.RecommendedAction, err error) +} + +var _ DatabaseRecommendedActionsClientAPI = (*sql.DatabaseRecommendedActionsClient)(nil) + +// DatabaseSchemasClientAPI contains the set of methods on the DatabaseSchemasClient type. +type DatabaseSchemasClientAPI interface { + Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string, schemaName string) (result sql.DatabaseSchema, err error) + ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string, filter string) (result sql.DatabaseSchemaListResultPage, err error) + ListByDatabaseComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string, filter string) (result sql.DatabaseSchemaListResultIterator, err error) +} + +var _ DatabaseSchemasClientAPI = (*sql.DatabaseSchemasClient)(nil) + +// DatabaseSecurityAlertPoliciesClientAPI contains the set of methods on the DatabaseSecurityAlertPoliciesClient type. +type DatabaseSecurityAlertPoliciesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters sql.DatabaseSecurityAlertPolicy) (result sql.DatabaseSecurityAlertPolicy, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.DatabaseSecurityAlertPolicy, err error) + ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.DatabaseSecurityAlertListResultPage, err error) + ListByDatabaseComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.DatabaseSecurityAlertListResultIterator, err error) +} + +var _ DatabaseSecurityAlertPoliciesClientAPI = (*sql.DatabaseSecurityAlertPoliciesClient)(nil) + +// DatabaseTablesClientAPI contains the set of methods on the DatabaseTablesClient type. +type DatabaseTablesClientAPI interface { + Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string, schemaName string, tableName string) (result sql.DatabaseTable, err error) + ListBySchema(ctx context.Context, resourceGroupName string, serverName string, databaseName string, schemaName string, filter string) (result sql.DatabaseTableListResultPage, err error) + ListBySchemaComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string, schemaName string, filter string) (result sql.DatabaseTableListResultIterator, err error) +} + +var _ DatabaseTablesClientAPI = (*sql.DatabaseTablesClient)(nil) + +// DatabaseVulnerabilityAssessmentRuleBaselinesClientAPI contains the set of methods on the DatabaseVulnerabilityAssessmentRuleBaselinesClient type. +type DatabaseVulnerabilityAssessmentRuleBaselinesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, ruleID string, baselineName sql.VulnerabilityAssessmentPolicyBaselineName, parameters sql.DatabaseVulnerabilityAssessmentRuleBaseline) (result sql.DatabaseVulnerabilityAssessmentRuleBaseline, err error) + Delete(ctx context.Context, resourceGroupName string, serverName string, databaseName string, ruleID string, baselineName sql.VulnerabilityAssessmentPolicyBaselineName) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string, ruleID string, baselineName sql.VulnerabilityAssessmentPolicyBaselineName) (result sql.DatabaseVulnerabilityAssessmentRuleBaseline, err error) +} + +var _ DatabaseVulnerabilityAssessmentRuleBaselinesClientAPI = (*sql.DatabaseVulnerabilityAssessmentRuleBaselinesClient)(nil) + +// DatabaseVulnerabilityAssessmentsClientAPI contains the set of methods on the DatabaseVulnerabilityAssessmentsClient type. +type DatabaseVulnerabilityAssessmentsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters sql.DatabaseVulnerabilityAssessment) (result sql.DatabaseVulnerabilityAssessment, err error) + Delete(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.DatabaseVulnerabilityAssessment, err error) + ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.DatabaseVulnerabilityAssessmentListResultPage, err error) + ListByDatabaseComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.DatabaseVulnerabilityAssessmentListResultIterator, err error) +} + +var _ DatabaseVulnerabilityAssessmentsClientAPI = (*sql.DatabaseVulnerabilityAssessmentsClient)(nil) + +// DatabaseVulnerabilityAssessmentScansClientAPI contains the set of methods on the DatabaseVulnerabilityAssessmentScansClient type. +type DatabaseVulnerabilityAssessmentScansClientAPI interface { + Export(ctx context.Context, resourceGroupName string, serverName string, databaseName string, scanID string) (result sql.DatabaseVulnerabilityAssessmentScansExport, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string, scanID string) (result sql.VulnerabilityAssessmentScanRecord, err error) + InitiateScan(ctx context.Context, resourceGroupName string, serverName string, databaseName string, scanID string) (result sql.DatabaseVulnerabilityAssessmentScansInitiateScanFuture, err error) + ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.VulnerabilityAssessmentScanRecordListResultPage, err error) + ListByDatabaseComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.VulnerabilityAssessmentScanRecordListResultIterator, err error) +} + +var _ DatabaseVulnerabilityAssessmentScansClientAPI = (*sql.DatabaseVulnerabilityAssessmentScansClient)(nil) + +// DataWarehouseUserActivitiesClientAPI contains the set of methods on the DataWarehouseUserActivitiesClient type. +type DataWarehouseUserActivitiesClientAPI interface { + Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.DataWarehouseUserActivities, err error) + ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.DataWarehouseUserActivitiesListResultPage, err error) + ListByDatabaseComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.DataWarehouseUserActivitiesListResultIterator, err error) +} + +var _ DataWarehouseUserActivitiesClientAPI = (*sql.DataWarehouseUserActivitiesClient)(nil) + +// DeletedServersClientAPI contains the set of methods on the DeletedServersClient type. +type DeletedServersClientAPI interface { + Get(ctx context.Context, locationName string, deletedServerName string) (result sql.DeletedServer, err error) + List(ctx context.Context) (result sql.DeletedServerListResultPage, err error) + ListComplete(ctx context.Context) (result sql.DeletedServerListResultIterator, err error) + ListByLocation(ctx context.Context, locationName string) (result sql.DeletedServerListResultPage, err error) + ListByLocationComplete(ctx context.Context, locationName string) (result sql.DeletedServerListResultIterator, err error) + Recover(ctx context.Context, locationName string, deletedServerName string) (result sql.DeletedServersRecoverFuture, err error) +} + +var _ DeletedServersClientAPI = (*sql.DeletedServersClient)(nil) + +// ElasticPoolOperationsClientAPI contains the set of methods on the ElasticPoolOperationsClient type. +type ElasticPoolOperationsClientAPI interface { + Cancel(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string, operationID uuid.UUID) (result autorest.Response, err error) + ListByElasticPool(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string) (result sql.ElasticPoolOperationListResultPage, err error) + ListByElasticPoolComplete(ctx context.Context, resourceGroupName string, serverName string, elasticPoolName string) (result sql.ElasticPoolOperationListResultIterator, err error) +} + +var _ ElasticPoolOperationsClientAPI = (*sql.ElasticPoolOperationsClient)(nil) + +// EncryptionProtectorsClientAPI contains the set of methods on the EncryptionProtectorsClient type. +type EncryptionProtectorsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, parameters sql.EncryptionProtector) (result sql.EncryptionProtectorsCreateOrUpdateFuture, err error) + Get(ctx context.Context, resourceGroupName string, serverName string) (result sql.EncryptionProtector, err error) + ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result sql.EncryptionProtectorListResultPage, err error) + ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result sql.EncryptionProtectorListResultIterator, err error) + Revalidate(ctx context.Context, resourceGroupName string, serverName string) (result sql.EncryptionProtectorsRevalidateFuture, err error) +} + +var _ EncryptionProtectorsClientAPI = (*sql.EncryptionProtectorsClient)(nil) + +// FailoverGroupsClientAPI contains the set of methods on the FailoverGroupsClient type. +type FailoverGroupsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, failoverGroupName string, parameters sql.FailoverGroup) (result sql.FailoverGroupsCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, serverName string, failoverGroupName string) (result sql.FailoverGroupsDeleteFuture, err error) + Failover(ctx context.Context, resourceGroupName string, serverName string, failoverGroupName string) (result sql.FailoverGroupsFailoverFuture, err error) + ForceFailoverAllowDataLoss(ctx context.Context, resourceGroupName string, serverName string, failoverGroupName string) (result sql.FailoverGroupsForceFailoverAllowDataLossFuture, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, failoverGroupName string) (result sql.FailoverGroup, err error) + ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result sql.FailoverGroupListResultPage, err error) + ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result sql.FailoverGroupListResultIterator, err error) + Update(ctx context.Context, resourceGroupName string, serverName string, failoverGroupName string, parameters sql.FailoverGroupUpdate) (result sql.FailoverGroupsUpdateFuture, err error) +} + +var _ FailoverGroupsClientAPI = (*sql.FailoverGroupsClient)(nil) + +// FirewallRulesClientAPI contains the set of methods on the FirewallRulesClient type. +type FirewallRulesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, firewallRuleName string, parameters sql.FirewallRule) (result sql.FirewallRule, err error) + Delete(ctx context.Context, resourceGroupName string, serverName string, firewallRuleName string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, firewallRuleName string) (result sql.FirewallRule, err error) + ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result sql.FirewallRuleListResultPage, err error) + ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result sql.FirewallRuleListResultIterator, err error) + Replace(ctx context.Context, resourceGroupName string, serverName string, parameters sql.FirewallRuleList) (result sql.FirewallRule, err error) +} + +var _ FirewallRulesClientAPI = (*sql.FirewallRulesClient)(nil) + +// InstanceFailoverGroupsClientAPI contains the set of methods on the InstanceFailoverGroupsClient type. +type InstanceFailoverGroupsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, locationName string, failoverGroupName string, parameters sql.InstanceFailoverGroup) (result sql.InstanceFailoverGroupsCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, locationName string, failoverGroupName string) (result sql.InstanceFailoverGroupsDeleteFuture, err error) + Failover(ctx context.Context, resourceGroupName string, locationName string, failoverGroupName string) (result sql.InstanceFailoverGroupsFailoverFuture, err error) + ForceFailoverAllowDataLoss(ctx context.Context, resourceGroupName string, locationName string, failoverGroupName string) (result sql.InstanceFailoverGroupsForceFailoverAllowDataLossFuture, err error) + Get(ctx context.Context, resourceGroupName string, locationName string, failoverGroupName string) (result sql.InstanceFailoverGroup, err error) + ListByLocation(ctx context.Context, resourceGroupName string, locationName string) (result sql.InstanceFailoverGroupListResultPage, err error) + ListByLocationComplete(ctx context.Context, resourceGroupName string, locationName string) (result sql.InstanceFailoverGroupListResultIterator, err error) +} + +var _ InstanceFailoverGroupsClientAPI = (*sql.InstanceFailoverGroupsClient)(nil) + +// InstancePoolsClientAPI contains the set of methods on the InstancePoolsClient type. +type InstancePoolsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, instancePoolName string, parameters sql.InstancePool) (result sql.InstancePoolsCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, instancePoolName string) (result sql.InstancePoolsDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, instancePoolName string) (result sql.InstancePool, err error) + List(ctx context.Context) (result sql.InstancePoolListResultPage, err error) + ListComplete(ctx context.Context) (result sql.InstancePoolListResultIterator, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string) (result sql.InstancePoolListResultPage, err error) + ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result sql.InstancePoolListResultIterator, err error) + Update(ctx context.Context, resourceGroupName string, instancePoolName string, parameters sql.InstancePoolUpdate) (result sql.InstancePoolsUpdateFuture, err error) +} + +var _ InstancePoolsClientAPI = (*sql.InstancePoolsClient)(nil) + +// JobAgentsClientAPI contains the set of methods on the JobAgentsClient type. +type JobAgentsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, parameters sql.JobAgent) (result sql.JobAgentsCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string) (result sql.JobAgentsDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string) (result sql.JobAgent, err error) + ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result sql.JobAgentListResultPage, err error) + ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result sql.JobAgentListResultIterator, err error) + Update(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, parameters sql.JobAgentUpdate) (result sql.JobAgentsUpdateFuture, err error) +} + +var _ JobAgentsClientAPI = (*sql.JobAgentsClient)(nil) + +// JobCredentialsClientAPI contains the set of methods on the JobCredentialsClient type. +type JobCredentialsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, credentialName string, parameters sql.JobCredential) (result sql.JobCredential, err error) + Delete(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, credentialName string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, credentialName string) (result sql.JobCredential, err error) + ListByAgent(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string) (result sql.JobCredentialListResultPage, err error) + ListByAgentComplete(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string) (result sql.JobCredentialListResultIterator, err error) +} + +var _ JobCredentialsClientAPI = (*sql.JobCredentialsClient)(nil) + +// JobExecutionsClientAPI contains the set of methods on the JobExecutionsClient type. +type JobExecutionsClientAPI interface { + Cancel(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, jobExecutionID uuid.UUID) (result autorest.Response, err error) + Create(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string) (result sql.JobExecutionsCreateFuture, err error) + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, jobExecutionID uuid.UUID) (result sql.JobExecutionsCreateOrUpdateFuture, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, jobExecutionID uuid.UUID) (result sql.JobExecution, err error) + ListByAgent(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, createTimeMin *date.Time, createTimeMax *date.Time, endTimeMin *date.Time, endTimeMax *date.Time, isActive *bool, skip *int32, top *int32) (result sql.JobExecutionListResultPage, err error) + ListByAgentComplete(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, createTimeMin *date.Time, createTimeMax *date.Time, endTimeMin *date.Time, endTimeMax *date.Time, isActive *bool, skip *int32, top *int32) (result sql.JobExecutionListResultIterator, err error) + ListByJob(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, createTimeMin *date.Time, createTimeMax *date.Time, endTimeMin *date.Time, endTimeMax *date.Time, isActive *bool, skip *int32, top *int32) (result sql.JobExecutionListResultPage, err error) + ListByJobComplete(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, createTimeMin *date.Time, createTimeMax *date.Time, endTimeMin *date.Time, endTimeMax *date.Time, isActive *bool, skip *int32, top *int32) (result sql.JobExecutionListResultIterator, err error) +} + +var _ JobExecutionsClientAPI = (*sql.JobExecutionsClient)(nil) + +// JobsClientAPI contains the set of methods on the JobsClient type. +type JobsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, parameters sql.Job) (result sql.Job, err error) + Delete(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string) (result sql.Job, err error) + ListByAgent(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string) (result sql.JobListResultPage, err error) + ListByAgentComplete(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string) (result sql.JobListResultIterator, err error) +} + +var _ JobsClientAPI = (*sql.JobsClient)(nil) + +// JobStepExecutionsClientAPI contains the set of methods on the JobStepExecutionsClient type. +type JobStepExecutionsClientAPI interface { + Get(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, jobExecutionID uuid.UUID, stepName string) (result sql.JobExecution, err error) + ListByJobExecution(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, jobExecutionID uuid.UUID, createTimeMin *date.Time, createTimeMax *date.Time, endTimeMin *date.Time, endTimeMax *date.Time, isActive *bool, skip *int32, top *int32) (result sql.JobExecutionListResultPage, err error) + ListByJobExecutionComplete(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, jobExecutionID uuid.UUID, createTimeMin *date.Time, createTimeMax *date.Time, endTimeMin *date.Time, endTimeMax *date.Time, isActive *bool, skip *int32, top *int32) (result sql.JobExecutionListResultIterator, err error) +} + +var _ JobStepExecutionsClientAPI = (*sql.JobStepExecutionsClient)(nil) + +// JobStepsClientAPI contains the set of methods on the JobStepsClient type. +type JobStepsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, stepName string, parameters sql.JobStep) (result sql.JobStep, err error) + Delete(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, stepName string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, stepName string) (result sql.JobStep, err error) + GetByVersion(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, jobVersion int32, stepName string) (result sql.JobStep, err error) + ListByJob(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string) (result sql.JobStepListResultPage, err error) + ListByJobComplete(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string) (result sql.JobStepListResultIterator, err error) + ListByVersion(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, jobVersion int32) (result sql.JobStepListResultPage, err error) + ListByVersionComplete(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, jobVersion int32) (result sql.JobStepListResultIterator, err error) +} + +var _ JobStepsClientAPI = (*sql.JobStepsClient)(nil) + +// JobTargetExecutionsClientAPI contains the set of methods on the JobTargetExecutionsClient type. +type JobTargetExecutionsClientAPI interface { + Get(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, jobExecutionID uuid.UUID, stepName string, targetID uuid.UUID) (result sql.JobExecution, err error) + ListByJobExecution(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, jobExecutionID uuid.UUID, createTimeMin *date.Time, createTimeMax *date.Time, endTimeMin *date.Time, endTimeMax *date.Time, isActive *bool, skip *int32, top *int32) (result sql.JobExecutionListResultPage, err error) + ListByJobExecutionComplete(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, jobExecutionID uuid.UUID, createTimeMin *date.Time, createTimeMax *date.Time, endTimeMin *date.Time, endTimeMax *date.Time, isActive *bool, skip *int32, top *int32) (result sql.JobExecutionListResultIterator, err error) + ListByStep(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, jobExecutionID uuid.UUID, stepName string, createTimeMin *date.Time, createTimeMax *date.Time, endTimeMin *date.Time, endTimeMax *date.Time, isActive *bool, skip *int32, top *int32) (result sql.JobExecutionListResultPage, err error) + ListByStepComplete(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, jobExecutionID uuid.UUID, stepName string, createTimeMin *date.Time, createTimeMax *date.Time, endTimeMin *date.Time, endTimeMax *date.Time, isActive *bool, skip *int32, top *int32) (result sql.JobExecutionListResultIterator, err error) +} + +var _ JobTargetExecutionsClientAPI = (*sql.JobTargetExecutionsClient)(nil) + +// JobTargetGroupsClientAPI contains the set of methods on the JobTargetGroupsClient type. +type JobTargetGroupsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, targetGroupName string, parameters sql.JobTargetGroup) (result sql.JobTargetGroup, err error) + Delete(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, targetGroupName string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, targetGroupName string) (result sql.JobTargetGroup, err error) + ListByAgent(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string) (result sql.JobTargetGroupListResultPage, err error) + ListByAgentComplete(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string) (result sql.JobTargetGroupListResultIterator, err error) +} + +var _ JobTargetGroupsClientAPI = (*sql.JobTargetGroupsClient)(nil) + +// JobVersionsClientAPI contains the set of methods on the JobVersionsClient type. +type JobVersionsClientAPI interface { + Get(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, jobVersion int32) (result sql.JobVersion, err error) + ListByJob(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string) (result sql.JobVersionListResultPage, err error) + ListByJobComplete(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string) (result sql.JobVersionListResultIterator, err error) +} + +var _ JobVersionsClientAPI = (*sql.JobVersionsClient)(nil) + +// CapabilitiesClientAPI contains the set of methods on the CapabilitiesClient type. +type CapabilitiesClientAPI interface { + ListByLocation(ctx context.Context, locationName string, include sql.CapabilityGroup) (result sql.LocationCapabilities, err error) +} + +var _ CapabilitiesClientAPI = (*sql.CapabilitiesClient)(nil) + +// LongTermRetentionBackupsClientAPI contains the set of methods on the LongTermRetentionBackupsClient type. +type LongTermRetentionBackupsClientAPI interface { + Copy(ctx context.Context, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, backupName string, parameters sql.CopyLongTermRetentionBackupParameters) (result sql.LongTermRetentionBackupsCopyFuture, err error) + CopyByResourceGroup(ctx context.Context, resourceGroupName string, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, backupName string, parameters sql.CopyLongTermRetentionBackupParameters) (result sql.LongTermRetentionBackupsCopyByResourceGroupFuture, err error) + Delete(ctx context.Context, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, backupName string) (result sql.LongTermRetentionBackupsDeleteFuture, err error) + DeleteByResourceGroup(ctx context.Context, resourceGroupName string, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, backupName string) (result sql.LongTermRetentionBackupsDeleteByResourceGroupFuture, err error) + Get(ctx context.Context, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, backupName string) (result sql.LongTermRetentionBackup, err error) + GetByResourceGroup(ctx context.Context, resourceGroupName string, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, backupName string) (result sql.LongTermRetentionBackup, err error) + ListByDatabase(ctx context.Context, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState) (result sql.LongTermRetentionBackupListResultPage, err error) + ListByDatabaseComplete(ctx context.Context, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState) (result sql.LongTermRetentionBackupListResultIterator, err error) + ListByLocation(ctx context.Context, locationName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState) (result sql.LongTermRetentionBackupListResultPage, err error) + ListByLocationComplete(ctx context.Context, locationName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState) (result sql.LongTermRetentionBackupListResultIterator, err error) + ListByResourceGroupDatabase(ctx context.Context, resourceGroupName string, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState) (result sql.LongTermRetentionBackupListResultPage, err error) + ListByResourceGroupDatabaseComplete(ctx context.Context, resourceGroupName string, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState) (result sql.LongTermRetentionBackupListResultIterator, err error) + ListByResourceGroupLocation(ctx context.Context, resourceGroupName string, locationName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState) (result sql.LongTermRetentionBackupListResultPage, err error) + ListByResourceGroupLocationComplete(ctx context.Context, resourceGroupName string, locationName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState) (result sql.LongTermRetentionBackupListResultIterator, err error) + ListByResourceGroupServer(ctx context.Context, resourceGroupName string, locationName string, longTermRetentionServerName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState) (result sql.LongTermRetentionBackupListResultPage, err error) + ListByResourceGroupServerComplete(ctx context.Context, resourceGroupName string, locationName string, longTermRetentionServerName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState) (result sql.LongTermRetentionBackupListResultIterator, err error) + ListByServer(ctx context.Context, locationName string, longTermRetentionServerName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState) (result sql.LongTermRetentionBackupListResultPage, err error) + ListByServerComplete(ctx context.Context, locationName string, longTermRetentionServerName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState) (result sql.LongTermRetentionBackupListResultIterator, err error) + Update(ctx context.Context, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, backupName string, parameters sql.UpdateLongTermRetentionBackupParameters) (result sql.LongTermRetentionBackupsUpdateFuture, err error) + UpdateByResourceGroup(ctx context.Context, resourceGroupName string, locationName string, longTermRetentionServerName string, longTermRetentionDatabaseName string, backupName string, parameters sql.UpdateLongTermRetentionBackupParameters) (result sql.LongTermRetentionBackupsUpdateByResourceGroupFuture, err error) +} + +var _ LongTermRetentionBackupsClientAPI = (*sql.LongTermRetentionBackupsClient)(nil) + +// LongTermRetentionManagedInstanceBackupsClientAPI contains the set of methods on the LongTermRetentionManagedInstanceBackupsClient type. +type LongTermRetentionManagedInstanceBackupsClientAPI interface { + Delete(ctx context.Context, locationName string, managedInstanceName string, databaseName string, backupName string) (result sql.LongTermRetentionManagedInstanceBackupsDeleteFuture, err error) + DeleteByResourceGroup(ctx context.Context, resourceGroupName string, locationName string, managedInstanceName string, databaseName string, backupName string) (result sql.LongTermRetentionManagedInstanceBackupsDeleteByResourceGroupFuture, err error) + Get(ctx context.Context, locationName string, managedInstanceName string, databaseName string, backupName string) (result sql.ManagedInstanceLongTermRetentionBackup, err error) + GetByResourceGroup(ctx context.Context, resourceGroupName string, locationName string, managedInstanceName string, databaseName string, backupName string) (result sql.ManagedInstanceLongTermRetentionBackup, err error) + ListByDatabase(ctx context.Context, locationName string, managedInstanceName string, databaseName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState) (result sql.ManagedInstanceLongTermRetentionBackupListResultPage, err error) + ListByDatabaseComplete(ctx context.Context, locationName string, managedInstanceName string, databaseName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState) (result sql.ManagedInstanceLongTermRetentionBackupListResultIterator, err error) + ListByInstance(ctx context.Context, locationName string, managedInstanceName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState) (result sql.ManagedInstanceLongTermRetentionBackupListResultPage, err error) + ListByInstanceComplete(ctx context.Context, locationName string, managedInstanceName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState) (result sql.ManagedInstanceLongTermRetentionBackupListResultIterator, err error) + ListByLocation(ctx context.Context, locationName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState) (result sql.ManagedInstanceLongTermRetentionBackupListResultPage, err error) + ListByLocationComplete(ctx context.Context, locationName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState) (result sql.ManagedInstanceLongTermRetentionBackupListResultIterator, err error) + ListByResourceGroupDatabase(ctx context.Context, resourceGroupName string, locationName string, managedInstanceName string, databaseName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState) (result sql.ManagedInstanceLongTermRetentionBackupListResultPage, err error) + ListByResourceGroupDatabaseComplete(ctx context.Context, resourceGroupName string, locationName string, managedInstanceName string, databaseName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState) (result sql.ManagedInstanceLongTermRetentionBackupListResultIterator, err error) + ListByResourceGroupInstance(ctx context.Context, resourceGroupName string, locationName string, managedInstanceName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState) (result sql.ManagedInstanceLongTermRetentionBackupListResultPage, err error) + ListByResourceGroupInstanceComplete(ctx context.Context, resourceGroupName string, locationName string, managedInstanceName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState) (result sql.ManagedInstanceLongTermRetentionBackupListResultIterator, err error) + ListByResourceGroupLocation(ctx context.Context, resourceGroupName string, locationName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState) (result sql.ManagedInstanceLongTermRetentionBackupListResultPage, err error) + ListByResourceGroupLocationComplete(ctx context.Context, resourceGroupName string, locationName string, onlyLatestPerDatabase *bool, databaseState sql.DatabaseState) (result sql.ManagedInstanceLongTermRetentionBackupListResultIterator, err error) +} + +var _ LongTermRetentionManagedInstanceBackupsClientAPI = (*sql.LongTermRetentionManagedInstanceBackupsClient)(nil) + +// LongTermRetentionPoliciesClientAPI contains the set of methods on the LongTermRetentionPoliciesClient type. +type LongTermRetentionPoliciesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters sql.LongTermRetentionPolicy) (result sql.LongTermRetentionPoliciesCreateOrUpdateFuture, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.LongTermRetentionPolicy, err error) + ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.LongTermRetentionPolicyListResultPage, err error) + ListByDatabaseComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.LongTermRetentionPolicyListResultIterator, err error) +} + +var _ LongTermRetentionPoliciesClientAPI = (*sql.LongTermRetentionPoliciesClient)(nil) + +// MaintenanceWindowOptionsClientAPI contains the set of methods on the MaintenanceWindowOptionsClient type. +type MaintenanceWindowOptionsClientAPI interface { + Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string, maintenanceWindowOptionsName string) (result sql.MaintenanceWindowOptions, err error) +} + +var _ MaintenanceWindowOptionsClientAPI = (*sql.MaintenanceWindowOptionsClient)(nil) + +// MaintenanceWindowsClientAPI contains the set of methods on the MaintenanceWindowsClient type. +type MaintenanceWindowsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, maintenanceWindowName string, parameters sql.MaintenanceWindows) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string, maintenanceWindowName string) (result sql.MaintenanceWindows, err error) +} + +var _ MaintenanceWindowsClientAPI = (*sql.MaintenanceWindowsClient)(nil) + +// ManagedBackupShortTermRetentionPoliciesClientAPI contains the set of methods on the ManagedBackupShortTermRetentionPoliciesClient type. +type ManagedBackupShortTermRetentionPoliciesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, parameters sql.ManagedBackupShortTermRetentionPolicy) (result sql.ManagedBackupShortTermRetentionPoliciesCreateOrUpdateFuture, err error) + Get(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (result sql.ManagedBackupShortTermRetentionPolicy, err error) + ListByDatabase(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (result sql.ManagedBackupShortTermRetentionPolicyListResultPage, err error) + ListByDatabaseComplete(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (result sql.ManagedBackupShortTermRetentionPolicyListResultIterator, err error) + Update(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, parameters sql.ManagedBackupShortTermRetentionPolicy) (result sql.ManagedBackupShortTermRetentionPoliciesUpdateFuture, err error) +} + +var _ ManagedBackupShortTermRetentionPoliciesClientAPI = (*sql.ManagedBackupShortTermRetentionPoliciesClient)(nil) + +// ManagedDatabaseColumnsClientAPI contains the set of methods on the ManagedDatabaseColumnsClient type. +type ManagedDatabaseColumnsClientAPI interface { + Get(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, schemaName string, tableName string, columnName string) (result sql.DatabaseColumn, err error) + ListByDatabase(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, schema []string, table []string, column []string, orderBy []string, skiptoken string) (result sql.DatabaseColumnListResultPage, err error) + ListByDatabaseComplete(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, schema []string, table []string, column []string, orderBy []string, skiptoken string) (result sql.DatabaseColumnListResultIterator, err error) + ListByTable(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, schemaName string, tableName string, filter string) (result sql.DatabaseColumnListResultPage, err error) + ListByTableComplete(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, schemaName string, tableName string, filter string) (result sql.DatabaseColumnListResultIterator, err error) +} + +var _ ManagedDatabaseColumnsClientAPI = (*sql.ManagedDatabaseColumnsClient)(nil) + +// ManagedDatabaseQueriesClientAPI contains the set of methods on the ManagedDatabaseQueriesClient type. +type ManagedDatabaseQueriesClientAPI interface { + Get(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, queryID string) (result sql.ManagedInstanceQuery, err error) + ListByQuery(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, queryID string, startTime string, endTime string, interval sql.QueryTimeGrainType) (result sql.ManagedInstanceQueryStatisticsPage, err error) + ListByQueryComplete(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, queryID string, startTime string, endTime string, interval sql.QueryTimeGrainType) (result sql.ManagedInstanceQueryStatisticsIterator, err error) +} + +var _ ManagedDatabaseQueriesClientAPI = (*sql.ManagedDatabaseQueriesClient)(nil) + +// ManagedDatabaseRestoreDetailsClientAPI contains the set of methods on the ManagedDatabaseRestoreDetailsClient type. +type ManagedDatabaseRestoreDetailsClientAPI interface { + Get(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (result sql.ManagedDatabaseRestoreDetailsResult, err error) +} + +var _ ManagedDatabaseRestoreDetailsClientAPI = (*sql.ManagedDatabaseRestoreDetailsClient)(nil) + +// ManagedDatabasesClientAPI contains the set of methods on the ManagedDatabasesClient type. +type ManagedDatabasesClientAPI interface { + CompleteRestore(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, parameters sql.CompleteDatabaseRestoreDefinition) (result sql.ManagedDatabasesCompleteRestoreFuture, err error) + CreateOrUpdate(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, parameters sql.ManagedDatabase) (result sql.ManagedDatabasesCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (result sql.ManagedDatabasesDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (result sql.ManagedDatabase, err error) + ListByInstance(ctx context.Context, resourceGroupName string, managedInstanceName string) (result sql.ManagedDatabaseListResultPage, err error) + ListByInstanceComplete(ctx context.Context, resourceGroupName string, managedInstanceName string) (result sql.ManagedDatabaseListResultIterator, err error) + ListInaccessibleByInstance(ctx context.Context, resourceGroupName string, managedInstanceName string) (result sql.ManagedDatabaseListResultPage, err error) + ListInaccessibleByInstanceComplete(ctx context.Context, resourceGroupName string, managedInstanceName string) (result sql.ManagedDatabaseListResultIterator, err error) + Update(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, parameters sql.ManagedDatabaseUpdate) (result sql.ManagedDatabasesUpdateFuture, err error) +} + +var _ ManagedDatabasesClientAPI = (*sql.ManagedDatabasesClient)(nil) + +// ManagedDatabaseSchemasClientAPI contains the set of methods on the ManagedDatabaseSchemasClient type. +type ManagedDatabaseSchemasClientAPI interface { + Get(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, schemaName string) (result sql.DatabaseSchema, err error) + ListByDatabase(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, filter string) (result sql.DatabaseSchemaListResultPage, err error) + ListByDatabaseComplete(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, filter string) (result sql.DatabaseSchemaListResultIterator, err error) +} + +var _ ManagedDatabaseSchemasClientAPI = (*sql.ManagedDatabaseSchemasClient)(nil) + +// ManagedDatabaseSecurityAlertPoliciesClientAPI contains the set of methods on the ManagedDatabaseSecurityAlertPoliciesClient type. +type ManagedDatabaseSecurityAlertPoliciesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, parameters sql.ManagedDatabaseSecurityAlertPolicy) (result sql.ManagedDatabaseSecurityAlertPolicy, err error) + Get(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (result sql.ManagedDatabaseSecurityAlertPolicy, err error) + ListByDatabase(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (result sql.ManagedDatabaseSecurityAlertPolicyListResultPage, err error) + ListByDatabaseComplete(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (result sql.ManagedDatabaseSecurityAlertPolicyListResultIterator, err error) +} + +var _ ManagedDatabaseSecurityAlertPoliciesClientAPI = (*sql.ManagedDatabaseSecurityAlertPoliciesClient)(nil) + +// ManagedDatabaseSecurityEventsClientAPI contains the set of methods on the ManagedDatabaseSecurityEventsClient type. +type ManagedDatabaseSecurityEventsClientAPI interface { + ListByDatabase(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, filter string, skip *int32, top *int32, skiptoken string) (result sql.SecurityEventCollectionPage, err error) + ListByDatabaseComplete(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, filter string, skip *int32, top *int32, skiptoken string) (result sql.SecurityEventCollectionIterator, err error) +} + +var _ ManagedDatabaseSecurityEventsClientAPI = (*sql.ManagedDatabaseSecurityEventsClient)(nil) + +// ManagedDatabaseSensitivityLabelsClientAPI contains the set of methods on the ManagedDatabaseSensitivityLabelsClient type. +type ManagedDatabaseSensitivityLabelsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, schemaName string, tableName string, columnName string, parameters sql.SensitivityLabel) (result sql.SensitivityLabel, err error) + Delete(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, schemaName string, tableName string, columnName string) (result autorest.Response, err error) + DisableRecommendation(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, schemaName string, tableName string, columnName string) (result autorest.Response, err error) + EnableRecommendation(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, schemaName string, tableName string, columnName string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, schemaName string, tableName string, columnName string, sensitivityLabelSource sql.SensitivityLabelSource) (result sql.SensitivityLabel, err error) + ListCurrentByDatabase(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, skipToken string, count *bool, filter string) (result sql.SensitivityLabelListResultPage, err error) + ListCurrentByDatabaseComplete(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, skipToken string, count *bool, filter string) (result sql.SensitivityLabelListResultIterator, err error) + ListRecommendedByDatabase(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, skipToken string, includeDisabledRecommendations *bool, filter string) (result sql.SensitivityLabelListResultPage, err error) + ListRecommendedByDatabaseComplete(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, skipToken string, includeDisabledRecommendations *bool, filter string) (result sql.SensitivityLabelListResultIterator, err error) + Update(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, parameters sql.SensitivityLabelUpdateList) (result autorest.Response, err error) +} + +var _ ManagedDatabaseSensitivityLabelsClientAPI = (*sql.ManagedDatabaseSensitivityLabelsClient)(nil) + +// ManagedDatabaseRecommendedSensitivityLabelsClientAPI contains the set of methods on the ManagedDatabaseRecommendedSensitivityLabelsClient type. +type ManagedDatabaseRecommendedSensitivityLabelsClientAPI interface { + Update(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, parameters sql.RecommendedSensitivityLabelUpdateList) (result autorest.Response, err error) +} + +var _ ManagedDatabaseRecommendedSensitivityLabelsClientAPI = (*sql.ManagedDatabaseRecommendedSensitivityLabelsClient)(nil) + +// ManagedDatabaseTablesClientAPI contains the set of methods on the ManagedDatabaseTablesClient type. +type ManagedDatabaseTablesClientAPI interface { + Get(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, schemaName string, tableName string) (result sql.DatabaseTable, err error) + ListBySchema(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, schemaName string, filter string) (result sql.DatabaseTableListResultPage, err error) + ListBySchemaComplete(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, schemaName string, filter string) (result sql.DatabaseTableListResultIterator, err error) +} + +var _ ManagedDatabaseTablesClientAPI = (*sql.ManagedDatabaseTablesClient)(nil) + +// ManagedDatabaseTransparentDataEncryptionClientAPI contains the set of methods on the ManagedDatabaseTransparentDataEncryptionClient type. +type ManagedDatabaseTransparentDataEncryptionClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, parameters sql.ManagedTransparentDataEncryption) (result sql.ManagedTransparentDataEncryption, err error) + Get(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (result sql.ManagedTransparentDataEncryption, err error) + ListByDatabase(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (result sql.ManagedTransparentDataEncryptionListResultPage, err error) + ListByDatabaseComplete(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (result sql.ManagedTransparentDataEncryptionListResultIterator, err error) +} + +var _ ManagedDatabaseTransparentDataEncryptionClientAPI = (*sql.ManagedDatabaseTransparentDataEncryptionClient)(nil) + +// ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClientAPI contains the set of methods on the ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient type. +type ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, ruleID string, baselineName sql.VulnerabilityAssessmentPolicyBaselineName, parameters sql.DatabaseVulnerabilityAssessmentRuleBaseline) (result sql.DatabaseVulnerabilityAssessmentRuleBaseline, err error) + Delete(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, ruleID string, baselineName sql.VulnerabilityAssessmentPolicyBaselineName) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, ruleID string, baselineName sql.VulnerabilityAssessmentPolicyBaselineName) (result sql.DatabaseVulnerabilityAssessmentRuleBaseline, err error) +} + +var _ ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClientAPI = (*sql.ManagedDatabaseVulnerabilityAssessmentRuleBaselinesClient)(nil) + +// ManagedDatabaseVulnerabilityAssessmentsClientAPI contains the set of methods on the ManagedDatabaseVulnerabilityAssessmentsClient type. +type ManagedDatabaseVulnerabilityAssessmentsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, parameters sql.DatabaseVulnerabilityAssessment) (result sql.DatabaseVulnerabilityAssessment, err error) + Delete(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (result sql.DatabaseVulnerabilityAssessment, err error) + ListByDatabase(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (result sql.DatabaseVulnerabilityAssessmentListResultPage, err error) + ListByDatabaseComplete(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (result sql.DatabaseVulnerabilityAssessmentListResultIterator, err error) +} + +var _ ManagedDatabaseVulnerabilityAssessmentsClientAPI = (*sql.ManagedDatabaseVulnerabilityAssessmentsClient)(nil) + +// ManagedDatabaseVulnerabilityAssessmentScansClientAPI contains the set of methods on the ManagedDatabaseVulnerabilityAssessmentScansClient type. +type ManagedDatabaseVulnerabilityAssessmentScansClientAPI interface { + Export(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, scanID string) (result sql.DatabaseVulnerabilityAssessmentScansExport, err error) + Get(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, scanID string) (result sql.VulnerabilityAssessmentScanRecord, err error) + InitiateScan(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, scanID string) (result sql.ManagedDatabaseVulnerabilityAssessmentScansInitiateScanFuture, err error) + ListByDatabase(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (result sql.VulnerabilityAssessmentScanRecordListResultPage, err error) + ListByDatabaseComplete(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (result sql.VulnerabilityAssessmentScanRecordListResultIterator, err error) +} + +var _ ManagedDatabaseVulnerabilityAssessmentScansClientAPI = (*sql.ManagedDatabaseVulnerabilityAssessmentScansClient)(nil) + +// ManagedInstanceAdministratorsClientAPI contains the set of methods on the ManagedInstanceAdministratorsClient type. +type ManagedInstanceAdministratorsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, managedInstanceName string, parameters sql.ManagedInstanceAdministrator) (result sql.ManagedInstanceAdministratorsCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, managedInstanceName string) (result sql.ManagedInstanceAdministratorsDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, managedInstanceName string) (result sql.ManagedInstanceAdministrator, err error) + ListByInstance(ctx context.Context, resourceGroupName string, managedInstanceName string) (result sql.ManagedInstanceAdministratorListResultPage, err error) + ListByInstanceComplete(ctx context.Context, resourceGroupName string, managedInstanceName string) (result sql.ManagedInstanceAdministratorListResultIterator, err error) +} + +var _ ManagedInstanceAdministratorsClientAPI = (*sql.ManagedInstanceAdministratorsClient)(nil) + +// ManagedInstanceAzureADOnlyAuthenticationsClientAPI contains the set of methods on the ManagedInstanceAzureADOnlyAuthenticationsClient type. +type ManagedInstanceAzureADOnlyAuthenticationsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, managedInstanceName string, parameters sql.ManagedInstanceAzureADOnlyAuthentication) (result sql.ManagedInstanceAzureADOnlyAuthenticationsCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, managedInstanceName string) (result sql.ManagedInstanceAzureADOnlyAuthenticationsDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, managedInstanceName string) (result sql.ManagedInstanceAzureADOnlyAuthentication, err error) + ListByInstance(ctx context.Context, resourceGroupName string, managedInstanceName string) (result sql.ManagedInstanceAzureADOnlyAuthListResultPage, err error) + ListByInstanceComplete(ctx context.Context, resourceGroupName string, managedInstanceName string) (result sql.ManagedInstanceAzureADOnlyAuthListResultIterator, err error) +} + +var _ ManagedInstanceAzureADOnlyAuthenticationsClientAPI = (*sql.ManagedInstanceAzureADOnlyAuthenticationsClient)(nil) + +// ManagedInstanceEncryptionProtectorsClientAPI contains the set of methods on the ManagedInstanceEncryptionProtectorsClient type. +type ManagedInstanceEncryptionProtectorsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, managedInstanceName string, parameters sql.ManagedInstanceEncryptionProtector) (result sql.ManagedInstanceEncryptionProtectorsCreateOrUpdateFuture, err error) + Get(ctx context.Context, resourceGroupName string, managedInstanceName string) (result sql.ManagedInstanceEncryptionProtector, err error) + ListByInstance(ctx context.Context, resourceGroupName string, managedInstanceName string) (result sql.ManagedInstanceEncryptionProtectorListResultPage, err error) + ListByInstanceComplete(ctx context.Context, resourceGroupName string, managedInstanceName string) (result sql.ManagedInstanceEncryptionProtectorListResultIterator, err error) + Revalidate(ctx context.Context, resourceGroupName string, managedInstanceName string) (result sql.ManagedInstanceEncryptionProtectorsRevalidateFuture, err error) +} + +var _ ManagedInstanceEncryptionProtectorsClientAPI = (*sql.ManagedInstanceEncryptionProtectorsClient)(nil) + +// ManagedInstanceKeysClientAPI contains the set of methods on the ManagedInstanceKeysClient type. +type ManagedInstanceKeysClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, managedInstanceName string, keyName string, parameters sql.ManagedInstanceKey) (result sql.ManagedInstanceKeysCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, managedInstanceName string, keyName string) (result sql.ManagedInstanceKeysDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, managedInstanceName string, keyName string) (result sql.ManagedInstanceKey, err error) + ListByInstance(ctx context.Context, resourceGroupName string, managedInstanceName string, filter string) (result sql.ManagedInstanceKeyListResultPage, err error) + ListByInstanceComplete(ctx context.Context, resourceGroupName string, managedInstanceName string, filter string) (result sql.ManagedInstanceKeyListResultIterator, err error) +} + +var _ ManagedInstanceKeysClientAPI = (*sql.ManagedInstanceKeysClient)(nil) + +// ManagedInstanceLongTermRetentionPoliciesClientAPI contains the set of methods on the ManagedInstanceLongTermRetentionPoliciesClient type. +type ManagedInstanceLongTermRetentionPoliciesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, parameters sql.ManagedInstanceLongTermRetentionPolicy) (result sql.ManagedInstanceLongTermRetentionPoliciesCreateOrUpdateFuture, err error) + Get(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (result sql.ManagedInstanceLongTermRetentionPolicy, err error) + ListByDatabase(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (result sql.ManagedInstanceLongTermRetentionPolicyListResultPage, err error) + ListByDatabaseComplete(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string) (result sql.ManagedInstanceLongTermRetentionPolicyListResultIterator, err error) +} + +var _ ManagedInstanceLongTermRetentionPoliciesClientAPI = (*sql.ManagedInstanceLongTermRetentionPoliciesClient)(nil) + +// ManagedInstanceOperationsClientAPI contains the set of methods on the ManagedInstanceOperationsClient type. +type ManagedInstanceOperationsClientAPI interface { + Cancel(ctx context.Context, resourceGroupName string, managedInstanceName string, operationID uuid.UUID) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, managedInstanceName string, operationID uuid.UUID) (result sql.ManagedInstanceOperation, err error) + ListByManagedInstance(ctx context.Context, resourceGroupName string, managedInstanceName string) (result sql.ManagedInstanceOperationListResultPage, err error) + ListByManagedInstanceComplete(ctx context.Context, resourceGroupName string, managedInstanceName string) (result sql.ManagedInstanceOperationListResultIterator, err error) +} + +var _ ManagedInstanceOperationsClientAPI = (*sql.ManagedInstanceOperationsClient)(nil) + +// ManagedInstancePrivateEndpointConnectionsClientAPI contains the set of methods on the ManagedInstancePrivateEndpointConnectionsClient type. +type ManagedInstancePrivateEndpointConnectionsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, managedInstanceName string, privateEndpointConnectionName string, parameters sql.ManagedInstancePrivateEndpointConnection) (result sql.ManagedInstancePrivateEndpointConnectionsCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, managedInstanceName string, privateEndpointConnectionName string) (result sql.ManagedInstancePrivateEndpointConnectionsDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, managedInstanceName string, privateEndpointConnectionName string) (result sql.ManagedInstancePrivateEndpointConnection, err error) + ListByManagedInstance(ctx context.Context, resourceGroupName string, managedInstanceName string) (result sql.ManagedInstancePrivateEndpointConnectionListResultPage, err error) + ListByManagedInstanceComplete(ctx context.Context, resourceGroupName string, managedInstanceName string) (result sql.ManagedInstancePrivateEndpointConnectionListResultIterator, err error) +} + +var _ ManagedInstancePrivateEndpointConnectionsClientAPI = (*sql.ManagedInstancePrivateEndpointConnectionsClient)(nil) + +// ManagedInstancePrivateLinkResourcesClientAPI contains the set of methods on the ManagedInstancePrivateLinkResourcesClient type. +type ManagedInstancePrivateLinkResourcesClientAPI interface { + Get(ctx context.Context, resourceGroupName string, managedInstanceName string, groupName string) (result sql.ManagedInstancePrivateLink, err error) + ListByManagedInstance(ctx context.Context, resourceGroupName string, managedInstanceName string) (result sql.ManagedInstancePrivateLinkListResultPage, err error) + ListByManagedInstanceComplete(ctx context.Context, resourceGroupName string, managedInstanceName string) (result sql.ManagedInstancePrivateLinkListResultIterator, err error) +} + +var _ ManagedInstancePrivateLinkResourcesClientAPI = (*sql.ManagedInstancePrivateLinkResourcesClient)(nil) + +// ManagedInstancesClientAPI contains the set of methods on the ManagedInstancesClient type. +type ManagedInstancesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, managedInstanceName string, parameters sql.ManagedInstance) (result sql.ManagedInstancesCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, managedInstanceName string) (result sql.ManagedInstancesDeleteFuture, err error) + Failover(ctx context.Context, resourceGroupName string, managedInstanceName string, replicaType sql.ReplicaType) (result sql.ManagedInstancesFailoverFuture, err error) + Get(ctx context.Context, resourceGroupName string, managedInstanceName string, expand string) (result sql.ManagedInstance, err error) + List(ctx context.Context, expand string) (result sql.ManagedInstanceListResultPage, err error) + ListComplete(ctx context.Context, expand string) (result sql.ManagedInstanceListResultIterator, err error) + ListByInstancePool(ctx context.Context, resourceGroupName string, instancePoolName string, expand string) (result sql.ManagedInstanceListResultPage, err error) + ListByInstancePoolComplete(ctx context.Context, resourceGroupName string, instancePoolName string, expand string) (result sql.ManagedInstanceListResultIterator, err error) + ListByManagedInstance(ctx context.Context, resourceGroupName string, managedInstanceName string, numberOfQueries *int32, databases string, startTime string, endTime string, interval sql.QueryTimeGrainType, aggregationFunction sql.AggregationFunctionType, observationMetric sql.MetricType) (result sql.TopQueriesListResultPage, err error) + ListByManagedInstanceComplete(ctx context.Context, resourceGroupName string, managedInstanceName string, numberOfQueries *int32, databases string, startTime string, endTime string, interval sql.QueryTimeGrainType, aggregationFunction sql.AggregationFunctionType, observationMetric sql.MetricType) (result sql.TopQueriesListResultIterator, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string, expand string) (result sql.ManagedInstanceListResultPage, err error) + ListByResourceGroupComplete(ctx context.Context, resourceGroupName string, expand string) (result sql.ManagedInstanceListResultIterator, err error) + Update(ctx context.Context, resourceGroupName string, managedInstanceName string, parameters sql.ManagedInstanceUpdate) (result sql.ManagedInstancesUpdateFuture, err error) +} + +var _ ManagedInstancesClientAPI = (*sql.ManagedInstancesClient)(nil) + +// ManagedInstanceTdeCertificatesClientAPI contains the set of methods on the ManagedInstanceTdeCertificatesClient type. +type ManagedInstanceTdeCertificatesClientAPI interface { + Create(ctx context.Context, resourceGroupName string, managedInstanceName string, parameters sql.TdeCertificate) (result sql.ManagedInstanceTdeCertificatesCreateFuture, err error) +} + +var _ ManagedInstanceTdeCertificatesClientAPI = (*sql.ManagedInstanceTdeCertificatesClient)(nil) + +// ManagedInstanceVulnerabilityAssessmentsClientAPI contains the set of methods on the ManagedInstanceVulnerabilityAssessmentsClient type. +type ManagedInstanceVulnerabilityAssessmentsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, managedInstanceName string, parameters sql.ManagedInstanceVulnerabilityAssessment) (result sql.ManagedInstanceVulnerabilityAssessment, err error) + Delete(ctx context.Context, resourceGroupName string, managedInstanceName string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, managedInstanceName string) (result sql.ManagedInstanceVulnerabilityAssessment, err error) + ListByInstance(ctx context.Context, resourceGroupName string, managedInstanceName string) (result sql.ManagedInstanceVulnerabilityAssessmentListResultPage, err error) + ListByInstanceComplete(ctx context.Context, resourceGroupName string, managedInstanceName string) (result sql.ManagedInstanceVulnerabilityAssessmentListResultIterator, err error) +} + +var _ ManagedInstanceVulnerabilityAssessmentsClientAPI = (*sql.ManagedInstanceVulnerabilityAssessmentsClient)(nil) + +// ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClientAPI contains the set of methods on the ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient type. +type ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, managedInstanceName string, restorableDroppedDatabaseID string, parameters sql.ManagedBackupShortTermRetentionPolicy) (result sql.ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesCreateOrUpdateFuture, err error) + Get(ctx context.Context, resourceGroupName string, managedInstanceName string, restorableDroppedDatabaseID string) (result sql.ManagedBackupShortTermRetentionPolicy, err error) + ListByRestorableDroppedDatabase(ctx context.Context, resourceGroupName string, managedInstanceName string, restorableDroppedDatabaseID string) (result sql.ManagedBackupShortTermRetentionPolicyListResultPage, err error) + ListByRestorableDroppedDatabaseComplete(ctx context.Context, resourceGroupName string, managedInstanceName string, restorableDroppedDatabaseID string) (result sql.ManagedBackupShortTermRetentionPolicyListResultIterator, err error) + Update(ctx context.Context, resourceGroupName string, managedInstanceName string, restorableDroppedDatabaseID string, parameters sql.ManagedBackupShortTermRetentionPolicy) (result sql.ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesUpdateFuture, err error) +} + +var _ ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClientAPI = (*sql.ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesClient)(nil) + +// ManagedServerSecurityAlertPoliciesClientAPI contains the set of methods on the ManagedServerSecurityAlertPoliciesClient type. +type ManagedServerSecurityAlertPoliciesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, managedInstanceName string, parameters sql.ManagedServerSecurityAlertPolicy) (result sql.ManagedServerSecurityAlertPoliciesCreateOrUpdateFuture, err error) + Get(ctx context.Context, resourceGroupName string, managedInstanceName string) (result sql.ManagedServerSecurityAlertPolicy, err error) + ListByInstance(ctx context.Context, resourceGroupName string, managedInstanceName string) (result sql.ManagedServerSecurityAlertPolicyListResultPage, err error) + ListByInstanceComplete(ctx context.Context, resourceGroupName string, managedInstanceName string) (result sql.ManagedServerSecurityAlertPolicyListResultIterator, err error) +} + +var _ ManagedServerSecurityAlertPoliciesClientAPI = (*sql.ManagedServerSecurityAlertPoliciesClient)(nil) + +// OperationsClientAPI contains the set of methods on the OperationsClient type. +type OperationsClientAPI interface { + List(ctx context.Context) (result sql.OperationListResultPage, err error) + ListComplete(ctx context.Context) (result sql.OperationListResultIterator, err error) +} + +var _ OperationsClientAPI = (*sql.OperationsClient)(nil) + +// OperationsHealthClientAPI contains the set of methods on the OperationsHealthClient type. +type OperationsHealthClientAPI interface { + ListByLocation(ctx context.Context, locationName string) (result sql.OperationsHealthListResultPage, err error) + ListByLocationComplete(ctx context.Context, locationName string) (result sql.OperationsHealthListResultIterator, err error) +} + +var _ OperationsHealthClientAPI = (*sql.OperationsHealthClient)(nil) + +// PrivateEndpointConnectionsClientAPI contains the set of methods on the PrivateEndpointConnectionsClient type. +type PrivateEndpointConnectionsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, privateEndpointConnectionName string, parameters sql.PrivateEndpointConnection) (result sql.PrivateEndpointConnectionsCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, serverName string, privateEndpointConnectionName string) (result sql.PrivateEndpointConnectionsDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, privateEndpointConnectionName string) (result sql.PrivateEndpointConnection, err error) + ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result sql.PrivateEndpointConnectionListResultPage, err error) + ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result sql.PrivateEndpointConnectionListResultIterator, err error) +} + +var _ PrivateEndpointConnectionsClientAPI = (*sql.PrivateEndpointConnectionsClient)(nil) + +// PrivateLinkResourcesClientAPI contains the set of methods on the PrivateLinkResourcesClient type. +type PrivateLinkResourcesClientAPI interface { + Get(ctx context.Context, resourceGroupName string, serverName string, groupName string) (result sql.PrivateLinkResource, err error) + ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result sql.PrivateLinkResourceListResultPage, err error) + ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result sql.PrivateLinkResourceListResultIterator, err error) +} + +var _ PrivateLinkResourcesClientAPI = (*sql.PrivateLinkResourcesClient)(nil) + +// RecoverableManagedDatabasesClientAPI contains the set of methods on the RecoverableManagedDatabasesClient type. +type RecoverableManagedDatabasesClientAPI interface { + Get(ctx context.Context, resourceGroupName string, managedInstanceName string, recoverableDatabaseName string) (result sql.RecoverableManagedDatabase, err error) + ListByInstance(ctx context.Context, resourceGroupName string, managedInstanceName string) (result sql.RecoverableManagedDatabaseListResultPage, err error) + ListByInstanceComplete(ctx context.Context, resourceGroupName string, managedInstanceName string) (result sql.RecoverableManagedDatabaseListResultIterator, err error) +} + +var _ RecoverableManagedDatabasesClientAPI = (*sql.RecoverableManagedDatabasesClient)(nil) + +// RestorePointsClientAPI contains the set of methods on the RestorePointsClient type. +type RestorePointsClientAPI interface { + Create(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters sql.CreateDatabaseRestorePointDefinition) (result sql.RestorePointsCreateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, serverName string, databaseName string, restorePointName string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string, restorePointName string) (result sql.RestorePoint, err error) + ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.RestorePointListResultPage, err error) + ListByDatabaseComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.RestorePointListResultIterator, err error) +} + +var _ RestorePointsClientAPI = (*sql.RestorePointsClient)(nil) + +// SensitivityLabelsClientAPI contains the set of methods on the SensitivityLabelsClient type. +type SensitivityLabelsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, schemaName string, tableName string, columnName string, parameters sql.SensitivityLabel) (result sql.SensitivityLabel, err error) + Delete(ctx context.Context, resourceGroupName string, serverName string, databaseName string, schemaName string, tableName string, columnName string) (result autorest.Response, err error) + DisableRecommendation(ctx context.Context, resourceGroupName string, serverName string, databaseName string, schemaName string, tableName string, columnName string) (result autorest.Response, err error) + EnableRecommendation(ctx context.Context, resourceGroupName string, serverName string, databaseName string, schemaName string, tableName string, columnName string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string, schemaName string, tableName string, columnName string, sensitivityLabelSource sql.SensitivityLabelSource) (result sql.SensitivityLabel, err error) + ListCurrentByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string, skipToken string, count *bool, filter string) (result sql.SensitivityLabelListResultPage, err error) + ListCurrentByDatabaseComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string, skipToken string, count *bool, filter string) (result sql.SensitivityLabelListResultIterator, err error) + ListRecommendedByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string, skipToken string, includeDisabledRecommendations *bool, filter string) (result sql.SensitivityLabelListResultPage, err error) + ListRecommendedByDatabaseComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string, skipToken string, includeDisabledRecommendations *bool, filter string) (result sql.SensitivityLabelListResultIterator, err error) + Update(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters sql.SensitivityLabelUpdateList) (result autorest.Response, err error) +} + +var _ SensitivityLabelsClientAPI = (*sql.SensitivityLabelsClient)(nil) + +// RecommendedSensitivityLabelsClientAPI contains the set of methods on the RecommendedSensitivityLabelsClient type. +type RecommendedSensitivityLabelsClientAPI interface { + Update(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters sql.RecommendedSensitivityLabelUpdateList) (result autorest.Response, err error) +} + +var _ RecommendedSensitivityLabelsClientAPI = (*sql.RecommendedSensitivityLabelsClient)(nil) + +// ServerAdvisorsClientAPI contains the set of methods on the ServerAdvisorsClient type. +type ServerAdvisorsClientAPI interface { + Get(ctx context.Context, resourceGroupName string, serverName string, advisorName string) (result sql.Advisor, err error) + ListByServer(ctx context.Context, resourceGroupName string, serverName string, expand string) (result sql.ListAdvisor, err error) + Update(ctx context.Context, resourceGroupName string, serverName string, advisorName string, parameters sql.Advisor) (result sql.Advisor, err error) +} + +var _ ServerAdvisorsClientAPI = (*sql.ServerAdvisorsClient)(nil) + +// ServerAutomaticTuningClientAPI contains the set of methods on the ServerAutomaticTuningClient type. +type ServerAutomaticTuningClientAPI interface { + Get(ctx context.Context, resourceGroupName string, serverName string) (result sql.ServerAutomaticTuning, err error) + Update(ctx context.Context, resourceGroupName string, serverName string, parameters sql.ServerAutomaticTuning) (result sql.ServerAutomaticTuning, err error) +} + +var _ ServerAutomaticTuningClientAPI = (*sql.ServerAutomaticTuningClient)(nil) + +// ServerAzureADAdministratorsClientAPI contains the set of methods on the ServerAzureADAdministratorsClient type. +type ServerAzureADAdministratorsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, parameters sql.ServerAzureADAdministrator) (result sql.ServerAzureADAdministratorsCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, serverName string) (result sql.ServerAzureADAdministratorsDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, serverName string) (result sql.ServerAzureADAdministrator, err error) + ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result sql.AdministratorListResultPage, err error) + ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result sql.AdministratorListResultIterator, err error) +} + +var _ ServerAzureADAdministratorsClientAPI = (*sql.ServerAzureADAdministratorsClient)(nil) + +// ServerAzureADOnlyAuthenticationsClientAPI contains the set of methods on the ServerAzureADOnlyAuthenticationsClient type. +type ServerAzureADOnlyAuthenticationsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, parameters sql.ServerAzureADOnlyAuthentication) (result sql.ServerAzureADOnlyAuthenticationsCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, serverName string) (result sql.ServerAzureADOnlyAuthenticationsDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, serverName string) (result sql.ServerAzureADOnlyAuthentication, err error) + ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result sql.AzureADOnlyAuthListResultPage, err error) + ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result sql.AzureADOnlyAuthListResultIterator, err error) +} + +var _ ServerAzureADOnlyAuthenticationsClientAPI = (*sql.ServerAzureADOnlyAuthenticationsClient)(nil) + +// ServerDevOpsAuditSettingsClientAPI contains the set of methods on the ServerDevOpsAuditSettingsClient type. +type ServerDevOpsAuditSettingsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, devOpsAuditingSettingsName string, parameters sql.ServerDevOpsAuditingSettings) (result sql.ServerDevOpsAuditSettingsCreateOrUpdateFuture, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, devOpsAuditingSettingsName string) (result sql.ServerDevOpsAuditingSettings, err error) + ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result sql.ServerDevOpsAuditSettingsListResultPage, err error) + ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result sql.ServerDevOpsAuditSettingsListResultIterator, err error) +} + +var _ ServerDevOpsAuditSettingsClientAPI = (*sql.ServerDevOpsAuditSettingsClient)(nil) + +// ServerDNSAliasesClientAPI contains the set of methods on the ServerDNSAliasesClient type. +type ServerDNSAliasesClientAPI interface { + Acquire(ctx context.Context, resourceGroupName string, serverName string, DNSAliasName string, parameters sql.ServerDNSAliasAcquisition) (result sql.ServerDNSAliasesAcquireFuture, err error) + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, DNSAliasName string) (result sql.ServerDNSAliasesCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, serverName string, DNSAliasName string) (result sql.ServerDNSAliasesDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, DNSAliasName string) (result sql.ServerDNSAlias, err error) + ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result sql.ServerDNSAliasListResultPage, err error) + ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result sql.ServerDNSAliasListResultIterator, err error) +} + +var _ ServerDNSAliasesClientAPI = (*sql.ServerDNSAliasesClient)(nil) + +// ServerKeysClientAPI contains the set of methods on the ServerKeysClient type. +type ServerKeysClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, keyName string, parameters sql.ServerKey) (result sql.ServerKeysCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, serverName string, keyName string) (result sql.ServerKeysDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, keyName string) (result sql.ServerKey, err error) + ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result sql.ServerKeyListResultPage, err error) + ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result sql.ServerKeyListResultIterator, err error) +} + +var _ ServerKeysClientAPI = (*sql.ServerKeysClient)(nil) + +// ServerOperationsClientAPI contains the set of methods on the ServerOperationsClient type. +type ServerOperationsClientAPI interface { + ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result sql.ServerOperationListResultPage, err error) + ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result sql.ServerOperationListResultIterator, err error) +} + +var _ ServerOperationsClientAPI = (*sql.ServerOperationsClient)(nil) + +// ServerSecurityAlertPoliciesClientAPI contains the set of methods on the ServerSecurityAlertPoliciesClient type. +type ServerSecurityAlertPoliciesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, parameters sql.ServerSecurityAlertPolicy) (result sql.ServerSecurityAlertPoliciesCreateOrUpdateFuture, err error) + Get(ctx context.Context, resourceGroupName string, serverName string) (result sql.ServerSecurityAlertPolicy, err error) + ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result sql.LogicalServerSecurityAlertPolicyListResultPage, err error) + ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result sql.LogicalServerSecurityAlertPolicyListResultIterator, err error) +} + +var _ ServerSecurityAlertPoliciesClientAPI = (*sql.ServerSecurityAlertPoliciesClient)(nil) + +// ServerTrustGroupsClientAPI contains the set of methods on the ServerTrustGroupsClient type. +type ServerTrustGroupsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, locationName string, serverTrustGroupName string, parameters sql.ServerTrustGroup) (result sql.ServerTrustGroupsCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, locationName string, serverTrustGroupName string) (result sql.ServerTrustGroupsDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, locationName string, serverTrustGroupName string) (result sql.ServerTrustGroup, err error) + ListByInstance(ctx context.Context, resourceGroupName string, managedInstanceName string) (result sql.ServerTrustGroupListResultPage, err error) + ListByInstanceComplete(ctx context.Context, resourceGroupName string, managedInstanceName string) (result sql.ServerTrustGroupListResultIterator, err error) + ListByLocation(ctx context.Context, resourceGroupName string, locationName string) (result sql.ServerTrustGroupListResultPage, err error) + ListByLocationComplete(ctx context.Context, resourceGroupName string, locationName string) (result sql.ServerTrustGroupListResultIterator, err error) +} + +var _ ServerTrustGroupsClientAPI = (*sql.ServerTrustGroupsClient)(nil) + +// ServerVulnerabilityAssessmentsClientAPI contains the set of methods on the ServerVulnerabilityAssessmentsClient type. +type ServerVulnerabilityAssessmentsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, parameters sql.ServerVulnerabilityAssessment) (result sql.ServerVulnerabilityAssessment, err error) + Delete(ctx context.Context, resourceGroupName string, serverName string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, serverName string) (result sql.ServerVulnerabilityAssessment, err error) + ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result sql.ServerVulnerabilityAssessmentListResultPage, err error) + ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result sql.ServerVulnerabilityAssessmentListResultIterator, err error) +} + +var _ ServerVulnerabilityAssessmentsClientAPI = (*sql.ServerVulnerabilityAssessmentsClient)(nil) + +// AgentClientAPI contains the set of methods on the AgentClient type. +type AgentClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, managedInstanceName string, parameters sql.AgentConfiguration) (result sql.AgentConfiguration, err error) + Get(ctx context.Context, resourceGroupName string, managedInstanceName string) (result sql.AgentConfiguration, err error) +} + +var _ AgentClientAPI = (*sql.AgentClient)(nil) + +// SubscriptionUsagesClientAPI contains the set of methods on the SubscriptionUsagesClient type. +type SubscriptionUsagesClientAPI interface { + Get(ctx context.Context, locationName string, usageName string) (result sql.SubscriptionUsage, err error) + ListByLocation(ctx context.Context, locationName string) (result sql.SubscriptionUsageListResultPage, err error) + ListByLocationComplete(ctx context.Context, locationName string) (result sql.SubscriptionUsageListResultIterator, err error) +} + +var _ SubscriptionUsagesClientAPI = (*sql.SubscriptionUsagesClient)(nil) + +// SyncAgentsClientAPI contains the set of methods on the SyncAgentsClient type. +type SyncAgentsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, syncAgentName string, parameters sql.SyncAgent) (result sql.SyncAgentsCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, serverName string, syncAgentName string) (result sql.SyncAgentsDeleteFuture, err error) + GenerateKey(ctx context.Context, resourceGroupName string, serverName string, syncAgentName string) (result sql.SyncAgentKeyProperties, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, syncAgentName string) (result sql.SyncAgent, err error) + ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result sql.SyncAgentListResultPage, err error) + ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result sql.SyncAgentListResultIterator, err error) + ListLinkedDatabases(ctx context.Context, resourceGroupName string, serverName string, syncAgentName string) (result sql.SyncAgentLinkedDatabaseListResultPage, err error) + ListLinkedDatabasesComplete(ctx context.Context, resourceGroupName string, serverName string, syncAgentName string) (result sql.SyncAgentLinkedDatabaseListResultIterator, err error) +} + +var _ SyncAgentsClientAPI = (*sql.SyncAgentsClient)(nil) + +// SyncGroupsClientAPI contains the set of methods on the SyncGroupsClient type. +type SyncGroupsClientAPI interface { + CancelSync(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string) (result autorest.Response, err error) + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, parameters sql.SyncGroup) (result sql.SyncGroupsCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string) (result sql.SyncGroupsDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string) (result sql.SyncGroup, err error) + ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.SyncGroupListResultPage, err error) + ListByDatabaseComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.SyncGroupListResultIterator, err error) + ListHubSchemas(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string) (result sql.SyncFullSchemaPropertiesListResultPage, err error) + ListHubSchemasComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string) (result sql.SyncFullSchemaPropertiesListResultIterator, err error) + ListLogs(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, startTime string, endTime string, typeParameter string, continuationToken string) (result sql.SyncGroupLogListResultPage, err error) + ListLogsComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, startTime string, endTime string, typeParameter string, continuationToken string) (result sql.SyncGroupLogListResultIterator, err error) + ListSyncDatabaseIds(ctx context.Context, locationName string) (result sql.SyncDatabaseIDListResultPage, err error) + ListSyncDatabaseIdsComplete(ctx context.Context, locationName string) (result sql.SyncDatabaseIDListResultIterator, err error) + RefreshHubSchema(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string) (result sql.SyncGroupsRefreshHubSchemaFuture, err error) + TriggerSync(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string) (result autorest.Response, err error) + Update(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, parameters sql.SyncGroup) (result sql.SyncGroupsUpdateFuture, err error) +} + +var _ SyncGroupsClientAPI = (*sql.SyncGroupsClient)(nil) + +// SyncMembersClientAPI contains the set of methods on the SyncMembersClient type. +type SyncMembersClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, syncMemberName string, parameters sql.SyncMember) (result sql.SyncMembersCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, syncMemberName string) (result sql.SyncMembersDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, syncMemberName string) (result sql.SyncMember, err error) + ListBySyncGroup(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string) (result sql.SyncMemberListResultPage, err error) + ListBySyncGroupComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string) (result sql.SyncMemberListResultIterator, err error) + ListMemberSchemas(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, syncMemberName string) (result sql.SyncFullSchemaPropertiesListResultPage, err error) + ListMemberSchemasComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, syncMemberName string) (result sql.SyncFullSchemaPropertiesListResultIterator, err error) + RefreshMemberSchema(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, syncMemberName string) (result sql.SyncMembersRefreshMemberSchemaFuture, err error) + Update(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, syncMemberName string, parameters sql.SyncMember) (result sql.SyncMembersUpdateFuture, err error) +} + +var _ SyncMembersClientAPI = (*sql.SyncMembersClient)(nil) + +// TdeCertificatesClientAPI contains the set of methods on the TdeCertificatesClient type. +type TdeCertificatesClientAPI interface { + Create(ctx context.Context, resourceGroupName string, serverName string, parameters sql.TdeCertificate) (result sql.TdeCertificatesCreateFuture, err error) +} + +var _ TdeCertificatesClientAPI = (*sql.TdeCertificatesClient)(nil) + +// TimeZonesClientAPI contains the set of methods on the TimeZonesClient type. +type TimeZonesClientAPI interface { + Get(ctx context.Context, locationName string, timeZoneID string) (result sql.TimeZone, err error) + ListByLocation(ctx context.Context, locationName string) (result sql.TimeZoneListResultPage, err error) + ListByLocationComplete(ctx context.Context, locationName string) (result sql.TimeZoneListResultIterator, err error) +} + +var _ TimeZonesClientAPI = (*sql.TimeZonesClient)(nil) + +// VirtualClustersClientAPI contains the set of methods on the VirtualClustersClient type. +type VirtualClustersClientAPI interface { + Delete(ctx context.Context, resourceGroupName string, virtualClusterName string) (result sql.VirtualClustersDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, virtualClusterName string) (result sql.VirtualCluster, err error) + List(ctx context.Context) (result sql.VirtualClusterListResultPage, err error) + ListComplete(ctx context.Context) (result sql.VirtualClusterListResultIterator, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string) (result sql.VirtualClusterListResultPage, err error) + ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result sql.VirtualClusterListResultIterator, err error) + Update(ctx context.Context, resourceGroupName string, virtualClusterName string, parameters sql.VirtualClusterUpdate) (result sql.VirtualClustersUpdateFuture, err error) + UpdateDNSServers(ctx context.Context, resourceGroupName string, virtualClusterName string) (result sql.UpdateManagedInstanceDNSServersOperation, err error) +} + +var _ VirtualClustersClientAPI = (*sql.VirtualClustersClient)(nil) + +// VirtualNetworkRulesClientAPI contains the set of methods on the VirtualNetworkRulesClient type. +type VirtualNetworkRulesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, virtualNetworkRuleName string, parameters sql.VirtualNetworkRule) (result sql.VirtualNetworkRulesCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, serverName string, virtualNetworkRuleName string) (result sql.VirtualNetworkRulesDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, virtualNetworkRuleName string) (result sql.VirtualNetworkRule, err error) + ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result sql.VirtualNetworkRuleListResultPage, err error) + ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result sql.VirtualNetworkRuleListResultIterator, err error) +} + +var _ VirtualNetworkRulesClientAPI = (*sql.VirtualNetworkRulesClient)(nil) + +// WorkloadClassifiersClientAPI contains the set of methods on the WorkloadClassifiersClient type. +type WorkloadClassifiersClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, workloadGroupName string, workloadClassifierName string, parameters sql.WorkloadClassifier) (result sql.WorkloadClassifiersCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, serverName string, databaseName string, workloadGroupName string, workloadClassifierName string) (result sql.WorkloadClassifiersDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string, workloadGroupName string, workloadClassifierName string) (result sql.WorkloadClassifier, err error) + ListByWorkloadGroup(ctx context.Context, resourceGroupName string, serverName string, databaseName string, workloadGroupName string) (result sql.WorkloadClassifierListResultPage, err error) + ListByWorkloadGroupComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string, workloadGroupName string) (result sql.WorkloadClassifierListResultIterator, err error) +} + +var _ WorkloadClassifiersClientAPI = (*sql.WorkloadClassifiersClient)(nil) + +// WorkloadGroupsClientAPI contains the set of methods on the WorkloadGroupsClient type. +type WorkloadGroupsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, workloadGroupName string, parameters sql.WorkloadGroup) (result sql.WorkloadGroupsCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, serverName string, databaseName string, workloadGroupName string) (result sql.WorkloadGroupsDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string, workloadGroupName string) (result sql.WorkloadGroup, err error) + ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.WorkloadGroupListResultPage, err error) + ListByDatabaseComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.WorkloadGroupListResultIterator, err error) +} + +var _ WorkloadGroupsClientAPI = (*sql.WorkloadGroupsClient)(nil) + +// BackupShortTermRetentionPoliciesClientAPI contains the set of methods on the BackupShortTermRetentionPoliciesClient type. +type BackupShortTermRetentionPoliciesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters sql.BackupShortTermRetentionPolicy) (result sql.BackupShortTermRetentionPoliciesCreateOrUpdateFuture, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.BackupShortTermRetentionPolicy, err error) + ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.BackupShortTermRetentionPolicyListResultPage, err error) + ListByDatabaseComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.BackupShortTermRetentionPolicyListResultIterator, err error) + Update(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters sql.BackupShortTermRetentionPolicy) (result sql.BackupShortTermRetentionPoliciesUpdateFuture, err error) +} + +var _ BackupShortTermRetentionPoliciesClientAPI = (*sql.BackupShortTermRetentionPoliciesClient)(nil) + +// DatabaseExtensionsClientAPI contains the set of methods on the DatabaseExtensionsClient type. +type DatabaseExtensionsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, extensionName string, parameters sql.DatabaseExtensions) (result sql.DatabaseExtensionsCreateOrUpdateFuture, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string, extensionName string) (result autorest.Response, err error) + ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.ImportExportExtensionsOperationListResultPage, err error) + ListByDatabaseComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.ImportExportExtensionsOperationListResultIterator, err error) +} + +var _ DatabaseExtensionsClientAPI = (*sql.DatabaseExtensionsClient)(nil) + +// DatabaseOperationsClientAPI contains the set of methods on the DatabaseOperationsClient type. +type DatabaseOperationsClientAPI interface { + Cancel(ctx context.Context, resourceGroupName string, serverName string, databaseName string, operationID uuid.UUID) (result autorest.Response, err error) + ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.DatabaseOperationListResultPage, err error) + ListByDatabaseComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.DatabaseOperationListResultIterator, err error) +} + +var _ DatabaseOperationsClientAPI = (*sql.DatabaseOperationsClient)(nil) + +// DatabaseUsagesClientAPI contains the set of methods on the DatabaseUsagesClient type. +type DatabaseUsagesClientAPI interface { + ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.DatabaseUsageListResultPage, err error) + ListByDatabaseComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.DatabaseUsageListResultIterator, err error) +} + +var _ DatabaseUsagesClientAPI = (*sql.DatabaseUsagesClient)(nil) + +// LedgerDigestUploadsClientAPI contains the set of methods on the LedgerDigestUploadsClient type. +type LedgerDigestUploadsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters sql.LedgerDigestUploads) (result sql.LedgerDigestUploads, err error) + Disable(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.LedgerDigestUploads, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.LedgerDigestUploads, err error) + ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.LedgerDigestUploadsListResultPage, err error) + ListByDatabaseComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result sql.LedgerDigestUploadsListResultIterator, err error) +} + +var _ LedgerDigestUploadsClientAPI = (*sql.LedgerDigestUploadsClient)(nil) + +// OutboundFirewallRulesClientAPI contains the set of methods on the OutboundFirewallRulesClient type. +type OutboundFirewallRulesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, outboundRuleFqdn string, parameters sql.OutboundFirewallRule) (result sql.OutboundFirewallRulesCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, serverName string, outboundRuleFqdn string) (result sql.OutboundFirewallRulesDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, outboundRuleFqdn string) (result sql.OutboundFirewallRule, err error) + ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result sql.OutboundFirewallRuleListResultPage, err error) + ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result sql.OutboundFirewallRuleListResultIterator, err error) +} + +var _ OutboundFirewallRulesClientAPI = (*sql.OutboundFirewallRulesClient)(nil) + +// RestorableDroppedDatabasesClientAPI contains the set of methods on the RestorableDroppedDatabasesClient type. +type RestorableDroppedDatabasesClientAPI interface { + Get(ctx context.Context, resourceGroupName string, serverName string, restorableDroppedDatabaseID string) (result sql.RestorableDroppedDatabase, err error) + ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result sql.RestorableDroppedDatabaseListResultPage, err error) + ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result sql.RestorableDroppedDatabaseListResultIterator, err error) +} + +var _ RestorableDroppedDatabasesClientAPI = (*sql.RestorableDroppedDatabasesClient)(nil) + +// RestorableDroppedManagedDatabasesClientAPI contains the set of methods on the RestorableDroppedManagedDatabasesClient type. +type RestorableDroppedManagedDatabasesClientAPI interface { + Get(ctx context.Context, resourceGroupName string, managedInstanceName string, restorableDroppedDatabaseID string) (result sql.RestorableDroppedManagedDatabase, err error) + ListByInstance(ctx context.Context, resourceGroupName string, managedInstanceName string) (result sql.RestorableDroppedManagedDatabaseListResultPage, err error) + ListByInstanceComplete(ctx context.Context, resourceGroupName string, managedInstanceName string) (result sql.RestorableDroppedManagedDatabaseListResultIterator, err error) +} + +var _ RestorableDroppedManagedDatabasesClientAPI = (*sql.RestorableDroppedManagedDatabasesClient)(nil) + +// ServersClientAPI contains the set of methods on the ServersClient type. +type ServersClientAPI interface { + CheckNameAvailability(ctx context.Context, parameters sql.CheckNameAvailabilityRequest) (result sql.CheckNameAvailabilityResponse, err error) + CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, parameters sql.Server) (result sql.ServersCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, serverName string) (result sql.ServersDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, serverName string, expand string) (result sql.Server, err error) + ImportDatabase(ctx context.Context, resourceGroupName string, serverName string, parameters sql.ImportNewDatabaseDefinition) (result sql.ServersImportDatabaseFuture, err error) + List(ctx context.Context, expand string) (result sql.ServerListResultPage, err error) + ListComplete(ctx context.Context, expand string) (result sql.ServerListResultIterator, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string, expand string) (result sql.ServerListResultPage, err error) + ListByResourceGroupComplete(ctx context.Context, resourceGroupName string, expand string) (result sql.ServerListResultIterator, err error) + Update(ctx context.Context, resourceGroupName string, serverName string, parameters sql.ServerUpdate) (result sql.ServersUpdateFuture, err error) +} + +var _ ServersClientAPI = (*sql.ServersClient)(nil) + +// UsagesClientAPI contains the set of methods on the UsagesClient type. +type UsagesClientAPI interface { + ListByInstancePool(ctx context.Context, resourceGroupName string, instancePoolName string, expandChildren *bool) (result sql.UsageListResultPage, err error) + ListByInstancePoolComplete(ctx context.Context, resourceGroupName string, instancePoolName string, expandChildren *bool) (result sql.UsageListResultIterator, err error) +} + +var _ UsagesClientAPI = (*sql.UsagesClient)(nil) diff --git a/services/preview/sql/mgmt/v5.0/sql/subscriptionusages.go b/services/preview/sql/mgmt/v5.0/sql/subscriptionusages.go new file mode 100644 index 000000000000..81cb2123de69 --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/subscriptionusages.go @@ -0,0 +1,226 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// SubscriptionUsagesClient is the the Azure SQL Database management API provides a RESTful set of web services that +// interact with Azure SQL Database services to manage your databases. The API enables you to create, retrieve, update, +// and delete databases. +type SubscriptionUsagesClient struct { + BaseClient +} + +// NewSubscriptionUsagesClient creates an instance of the SubscriptionUsagesClient client. +func NewSubscriptionUsagesClient(subscriptionID string) SubscriptionUsagesClient { + return NewSubscriptionUsagesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewSubscriptionUsagesClientWithBaseURI creates an instance of the SubscriptionUsagesClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewSubscriptionUsagesClientWithBaseURI(baseURI string, subscriptionID string) SubscriptionUsagesClient { + return SubscriptionUsagesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get gets a subscription usage metric. +// Parameters: +// locationName - the name of the region where the resource is located. +// usageName - name of usage metric to return. +func (client SubscriptionUsagesClient) Get(ctx context.Context, locationName string, usageName string) (result SubscriptionUsage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SubscriptionUsagesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, locationName, usageName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SubscriptionUsagesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.SubscriptionUsagesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SubscriptionUsagesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client SubscriptionUsagesClient) GetPreparer(ctx context.Context, locationName string, usageName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "locationName": autorest.Encode("path", locationName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "usageName": autorest.Encode("path", usageName), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/usages/{usageName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client SubscriptionUsagesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client SubscriptionUsagesClient) GetResponder(resp *http.Response) (result SubscriptionUsage, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByLocation gets all subscription usage metrics in a given location. +// Parameters: +// locationName - the name of the region where the resource is located. +func (client SubscriptionUsagesClient) ListByLocation(ctx context.Context, locationName string) (result SubscriptionUsageListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SubscriptionUsagesClient.ListByLocation") + defer func() { + sc := -1 + if result.sulr.Response.Response != nil { + sc = result.sulr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByLocationNextResults + req, err := client.ListByLocationPreparer(ctx, locationName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SubscriptionUsagesClient", "ListByLocation", nil, "Failure preparing request") + return + } + + resp, err := client.ListByLocationSender(req) + if err != nil { + result.sulr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.SubscriptionUsagesClient", "ListByLocation", resp, "Failure sending request") + return + } + + result.sulr, err = client.ListByLocationResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SubscriptionUsagesClient", "ListByLocation", resp, "Failure responding to request") + return + } + if result.sulr.hasNextLink() && result.sulr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByLocationPreparer prepares the ListByLocation request. +func (client SubscriptionUsagesClient) ListByLocationPreparer(ctx context.Context, locationName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "locationName": autorest.Encode("path", locationName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/usages", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByLocationSender sends the ListByLocation request. The method will close the +// http.Response Body if it receives an error. +func (client SubscriptionUsagesClient) ListByLocationSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByLocationResponder handles the response to the ListByLocation request. The method always +// closes the http.Response Body. +func (client SubscriptionUsagesClient) ListByLocationResponder(resp *http.Response) (result SubscriptionUsageListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByLocationNextResults retrieves the next set of results, if any. +func (client SubscriptionUsagesClient) listByLocationNextResults(ctx context.Context, lastResults SubscriptionUsageListResult) (result SubscriptionUsageListResult, err error) { + req, err := lastResults.subscriptionUsageListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.SubscriptionUsagesClient", "listByLocationNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByLocationSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.SubscriptionUsagesClient", "listByLocationNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByLocationResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SubscriptionUsagesClient", "listByLocationNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByLocationComplete enumerates all values, automatically crossing page boundaries as required. +func (client SubscriptionUsagesClient) ListByLocationComplete(ctx context.Context, locationName string) (result SubscriptionUsageListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SubscriptionUsagesClient.ListByLocation") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByLocation(ctx, locationName) + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/syncagents.go b/services/preview/sql/mgmt/v5.0/sql/syncagents.go new file mode 100644 index 000000000000..0212aa521ef4 --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/syncagents.go @@ -0,0 +1,595 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// SyncAgentsClient is the the Azure SQL Database management API provides a RESTful set of web services that interact +// with Azure SQL Database services to manage your databases. The API enables you to create, retrieve, update, and +// delete databases. +type SyncAgentsClient struct { + BaseClient +} + +// NewSyncAgentsClient creates an instance of the SyncAgentsClient client. +func NewSyncAgentsClient(subscriptionID string) SyncAgentsClient { + return NewSyncAgentsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewSyncAgentsClientWithBaseURI creates an instance of the SyncAgentsClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewSyncAgentsClientWithBaseURI(baseURI string, subscriptionID string) SyncAgentsClient { + return SyncAgentsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a sync agent. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server on which the sync agent is hosted. +// syncAgentName - the name of the sync agent. +// parameters - the requested sync agent resource state. +func (client SyncAgentsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, syncAgentName string, parameters SyncAgent) (result SyncAgentsCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncAgentsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, syncAgentName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncAgentsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncAgentsClient", "CreateOrUpdate", nil, "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 = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/syncAgents/{syncAgentName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client SyncAgentsClient) CreateOrUpdateSender(req *http.Request) (future SyncAgentsCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client SyncAgentsClient) CreateOrUpdateResponder(resp *http.Response) (result SyncAgent, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a sync agent. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server on which the sync agent is hosted. +// syncAgentName - the name of the sync agent. +func (client SyncAgentsClient) Delete(ctx context.Context, resourceGroupName string, serverName string, syncAgentName string) (result SyncAgentsDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncAgentsClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, serverName, syncAgentName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncAgentsClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncAgentsClient", "Delete", nil, "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 = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/syncAgents/{syncAgentName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client SyncAgentsClient) DeleteSender(req *http.Request) (future SyncAgentsDeleteFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client SyncAgentsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// GenerateKey generates a sync agent key. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server on which the sync agent is hosted. +// syncAgentName - the name of the sync agent. +func (client SyncAgentsClient) GenerateKey(ctx context.Context, resourceGroupName string, serverName string, syncAgentName string) (result SyncAgentKeyProperties, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncAgentsClient.GenerateKey") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GenerateKeyPreparer(ctx, resourceGroupName, serverName, syncAgentName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncAgentsClient", "GenerateKey", nil, "Failure preparing request") + return + } + + resp, err := client.GenerateKeySender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.SyncAgentsClient", "GenerateKey", resp, "Failure sending request") + return + } + + result, err = client.GenerateKeyResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncAgentsClient", "GenerateKey", resp, "Failure responding to request") + return + } + + return +} + +// GenerateKeyPreparer prepares the GenerateKey request. +func (client SyncAgentsClient) GenerateKeyPreparer(ctx context.Context, resourceGroupName string, serverName string, syncAgentName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "syncAgentName": autorest.Encode("path", syncAgentName), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/syncAgents/{syncAgentName}/generateKey", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GenerateKeySender sends the GenerateKey request. The method will close the +// http.Response Body if it receives an error. +func (client SyncAgentsClient) GenerateKeySender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GenerateKeyResponder handles the response to the GenerateKey request. The method always +// closes the http.Response Body. +func (client SyncAgentsClient) GenerateKeyResponder(resp *http.Response) (result SyncAgentKeyProperties, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets a sync agent. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server on which the sync agent is hosted. +// syncAgentName - the name of the sync agent. +func (client SyncAgentsClient) Get(ctx context.Context, resourceGroupName string, serverName string, syncAgentName string) (result SyncAgent, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncAgentsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, syncAgentName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncAgentsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.SyncAgentsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncAgentsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client SyncAgentsClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, syncAgentName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "syncAgentName": autorest.Encode("path", syncAgentName), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/syncAgents/{syncAgentName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client SyncAgentsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client SyncAgentsClient) GetResponder(resp *http.Response) (result SyncAgent, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer lists sync agents in a server. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server on which the sync agent is hosted. +func (client SyncAgentsClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result SyncAgentListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncAgentsClient.ListByServer") + defer func() { + sc := -1 + if result.salr.Response.Response != nil { + sc = result.salr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByServerNextResults + req, err := client.ListByServerPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncAgentsClient", "ListByServer", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServerSender(req) + if err != nil { + result.salr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.SyncAgentsClient", "ListByServer", resp, "Failure sending request") + return + } + + result.salr, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncAgentsClient", "ListByServer", resp, "Failure responding to request") + return + } + if result.salr.hasNextLink() && result.salr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServerPreparer prepares the ListByServer request. +func (client SyncAgentsClient) ListByServerPreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/syncAgents", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByServerSender sends the ListByServer request. The method will close the +// http.Response Body if it receives an error. +func (client SyncAgentsClient) ListByServerSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client SyncAgentsClient) ListByServerResponder(resp *http.Response) (result SyncAgentListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByServerNextResults retrieves the next set of results, if any. +func (client SyncAgentsClient) listByServerNextResults(ctx context.Context, lastResults SyncAgentListResult) (result SyncAgentListResult, err error) { + req, err := lastResults.syncAgentListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.SyncAgentsClient", "listByServerNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByServerSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.SyncAgentsClient", "listByServerNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncAgentsClient", "listByServerNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServerComplete enumerates all values, automatically crossing page boundaries as required. +func (client SyncAgentsClient) ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result SyncAgentListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncAgentsClient.ListByServer") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByServer(ctx, resourceGroupName, serverName) + return +} + +// ListLinkedDatabases lists databases linked to a sync agent. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server on which the sync agent is hosted. +// syncAgentName - the name of the sync agent. +func (client SyncAgentsClient) ListLinkedDatabases(ctx context.Context, resourceGroupName string, serverName string, syncAgentName string) (result SyncAgentLinkedDatabaseListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncAgentsClient.ListLinkedDatabases") + defer func() { + sc := -1 + if result.saldlr.Response.Response != nil { + sc = result.saldlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listLinkedDatabasesNextResults + req, err := client.ListLinkedDatabasesPreparer(ctx, resourceGroupName, serverName, syncAgentName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncAgentsClient", "ListLinkedDatabases", nil, "Failure preparing request") + return + } + + resp, err := client.ListLinkedDatabasesSender(req) + if err != nil { + result.saldlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.SyncAgentsClient", "ListLinkedDatabases", resp, "Failure sending request") + return + } + + result.saldlr, err = client.ListLinkedDatabasesResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncAgentsClient", "ListLinkedDatabases", resp, "Failure responding to request") + return + } + if result.saldlr.hasNextLink() && result.saldlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListLinkedDatabasesPreparer prepares the ListLinkedDatabases request. +func (client SyncAgentsClient) ListLinkedDatabasesPreparer(ctx context.Context, resourceGroupName string, serverName string, syncAgentName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "syncAgentName": autorest.Encode("path", syncAgentName), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/syncAgents/{syncAgentName}/linkedDatabases", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListLinkedDatabasesSender sends the ListLinkedDatabases request. The method will close the +// http.Response Body if it receives an error. +func (client SyncAgentsClient) ListLinkedDatabasesSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListLinkedDatabasesResponder handles the response to the ListLinkedDatabases request. The method always +// closes the http.Response Body. +func (client SyncAgentsClient) ListLinkedDatabasesResponder(resp *http.Response) (result SyncAgentLinkedDatabaseListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listLinkedDatabasesNextResults retrieves the next set of results, if any. +func (client SyncAgentsClient) listLinkedDatabasesNextResults(ctx context.Context, lastResults SyncAgentLinkedDatabaseListResult) (result SyncAgentLinkedDatabaseListResult, err error) { + req, err := lastResults.syncAgentLinkedDatabaseListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.SyncAgentsClient", "listLinkedDatabasesNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListLinkedDatabasesSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.SyncAgentsClient", "listLinkedDatabasesNextResults", resp, "Failure sending next results request") + } + result, err = client.ListLinkedDatabasesResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncAgentsClient", "listLinkedDatabasesNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListLinkedDatabasesComplete enumerates all values, automatically crossing page boundaries as required. +func (client SyncAgentsClient) ListLinkedDatabasesComplete(ctx context.Context, resourceGroupName string, serverName string, syncAgentName string) (result SyncAgentLinkedDatabaseListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncAgentsClient.ListLinkedDatabases") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListLinkedDatabases(ctx, resourceGroupName, serverName, syncAgentName) + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/syncgroups.go b/services/preview/sql/mgmt/v5.0/sql/syncgroups.go new file mode 100644 index 000000000000..f8f4350135e6 --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/syncgroups.go @@ -0,0 +1,1111 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// SyncGroupsClient is the the Azure SQL Database management API provides a RESTful set of web services that interact +// with Azure SQL Database services to manage your databases. The API enables you to create, retrieve, update, and +// delete databases. +type SyncGroupsClient struct { + BaseClient +} + +// NewSyncGroupsClient creates an instance of the SyncGroupsClient client. +func NewSyncGroupsClient(subscriptionID string) SyncGroupsClient { + return NewSyncGroupsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewSyncGroupsClientWithBaseURI creates an instance of the SyncGroupsClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewSyncGroupsClientWithBaseURI(baseURI string, subscriptionID string) SyncGroupsClient { + return SyncGroupsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CancelSync cancels a sync group synchronization. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database on which the sync group is hosted. +// syncGroupName - the name of the sync group. +func (client SyncGroupsClient) CancelSync(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncGroupsClient.CancelSync") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CancelSyncPreparer(ctx, resourceGroupName, serverName, databaseName, syncGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "CancelSync", nil, "Failure preparing request") + return + } + + resp, err := client.CancelSyncSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "CancelSync", resp, "Failure sending request") + return + } + + result, err = client.CancelSyncResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "CancelSync", resp, "Failure responding to request") + return + } + + return +} + +// CancelSyncPreparer prepares the CancelSync request. +func (client SyncGroupsClient) CancelSyncPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "syncGroupName": autorest.Encode("path", syncGroupName), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/cancelSync", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CancelSyncSender sends the CancelSync request. The method will close the +// http.Response Body if it receives an error. +func (client SyncGroupsClient) CancelSyncSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CancelSyncResponder handles the response to the CancelSync request. The method always +// closes the http.Response Body. +func (client SyncGroupsClient) CancelSyncResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// CreateOrUpdate creates or updates a sync group. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database on which the sync group is hosted. +// syncGroupName - the name of the sync group. +// parameters - the requested sync group resource state. +func (client SyncGroupsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, parameters SyncGroup) (result SyncGroupsCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncGroupsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + 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.SyncGroupsClient", "CreateOrUpdate", 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", nil, "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 = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client SyncGroupsClient) CreateOrUpdateSender(req *http.Request) (future SyncGroupsCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client SyncGroupsClient) CreateOrUpdateResponder(resp *http.Response) (result SyncGroup, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a sync group. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database on which the sync group is hosted. +// syncGroupName - the name of the sync group. +func (client SyncGroupsClient) Delete(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string) (result SyncGroupsDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncGroupsClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, serverName, databaseName, syncGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "Delete", nil, "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 = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client SyncGroupsClient) DeleteSender(req *http.Request) (future SyncGroupsDeleteFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client SyncGroupsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a sync group. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database on which the sync group is hosted. +// syncGroupName - the name of the sync group. +func (client SyncGroupsClient) Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string) (result SyncGroup, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncGroupsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, databaseName, syncGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client SyncGroupsClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "syncGroupName": autorest.Encode("path", syncGroupName), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client SyncGroupsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client SyncGroupsClient) GetResponder(resp *http.Response) (result SyncGroup, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByDatabase lists sync groups under a hub database. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database on which the sync group is hosted. +func (client SyncGroupsClient) ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result SyncGroupListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncGroupsClient.ListByDatabase") + defer func() { + sc := -1 + if result.sglr.Response.Response != nil { + sc = result.sglr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByDatabaseNextResults + req, err := client.ListByDatabasePreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "ListByDatabase", nil, "Failure preparing request") + return + } + + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.sglr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "ListByDatabase", resp, "Failure sending request") + return + } + + result.sglr, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "ListByDatabase", resp, "Failure responding to request") + return + } + if result.sglr.hasNextLink() && result.sglr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByDatabasePreparer prepares the ListByDatabase request. +func (client SyncGroupsClient) ListByDatabasePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByDatabaseSender sends the ListByDatabase request. The method will close the +// http.Response Body if it receives an error. +func (client SyncGroupsClient) ListByDatabaseSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByDatabaseResponder handles the response to the ListByDatabase request. The method always +// closes the http.Response Body. +func (client SyncGroupsClient) ListByDatabaseResponder(resp *http.Response) (result SyncGroupListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByDatabaseNextResults retrieves the next set of results, if any. +func (client SyncGroupsClient) listByDatabaseNextResults(ctx context.Context, lastResults SyncGroupListResult) (result SyncGroupListResult, err error) { + req, err := lastResults.syncGroupListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "listByDatabaseNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "listByDatabaseNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "listByDatabaseNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByDatabaseComplete enumerates all values, automatically crossing page boundaries as required. +func (client SyncGroupsClient) ListByDatabaseComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result SyncGroupListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncGroupsClient.ListByDatabase") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByDatabase(ctx, resourceGroupName, serverName, databaseName) + return +} + +// ListHubSchemas gets a collection of hub database schemas. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database on which the sync group is hosted. +// syncGroupName - the name of the sync group. +func (client SyncGroupsClient) ListHubSchemas(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string) (result SyncFullSchemaPropertiesListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncGroupsClient.ListHubSchemas") + defer func() { + sc := -1 + if result.sfsplr.Response.Response != nil { + sc = result.sfsplr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listHubSchemasNextResults + req, err := client.ListHubSchemasPreparer(ctx, resourceGroupName, serverName, databaseName, syncGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "ListHubSchemas", nil, "Failure preparing request") + return + } + + resp, err := client.ListHubSchemasSender(req) + if err != nil { + result.sfsplr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "ListHubSchemas", resp, "Failure sending request") + return + } + + result.sfsplr, err = client.ListHubSchemasResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "ListHubSchemas", resp, "Failure responding to request") + return + } + if result.sfsplr.hasNextLink() && result.sfsplr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListHubSchemasPreparer prepares the ListHubSchemas request. +func (client SyncGroupsClient) ListHubSchemasPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "syncGroupName": autorest.Encode("path", syncGroupName), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/hubSchemas", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListHubSchemasSender sends the ListHubSchemas request. The method will close the +// http.Response Body if it receives an error. +func (client SyncGroupsClient) ListHubSchemasSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListHubSchemasResponder handles the response to the ListHubSchemas request. The method always +// closes the http.Response Body. +func (client SyncGroupsClient) ListHubSchemasResponder(resp *http.Response) (result SyncFullSchemaPropertiesListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listHubSchemasNextResults retrieves the next set of results, if any. +func (client SyncGroupsClient) listHubSchemasNextResults(ctx context.Context, lastResults SyncFullSchemaPropertiesListResult) (result SyncFullSchemaPropertiesListResult, err error) { + req, err := lastResults.syncFullSchemaPropertiesListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "listHubSchemasNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListHubSchemasSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "listHubSchemasNextResults", resp, "Failure sending next results request") + } + result, err = client.ListHubSchemasResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "listHubSchemasNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListHubSchemasComplete enumerates all values, automatically crossing page boundaries as required. +func (client SyncGroupsClient) ListHubSchemasComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string) (result SyncFullSchemaPropertiesListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncGroupsClient.ListHubSchemas") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListHubSchemas(ctx, resourceGroupName, serverName, databaseName, syncGroupName) + return +} + +// ListLogs gets a collection of sync group logs. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database on which the sync group is hosted. +// syncGroupName - the name of the sync group. +// startTime - get logs generated after this time. +// endTime - get logs generated before this time. +// typeParameter - the types of logs to retrieve. +// continuationToken - the continuation token for this operation. +func (client SyncGroupsClient) ListLogs(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, startTime string, endTime string, typeParameter string, continuationToken string) (result SyncGroupLogListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncGroupsClient.ListLogs") + defer func() { + sc := -1 + if result.sgllr.Response.Response != nil { + sc = result.sgllr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listLogsNextResults + req, err := client.ListLogsPreparer(ctx, resourceGroupName, serverName, databaseName, syncGroupName, startTime, endTime, typeParameter, continuationToken) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "ListLogs", nil, "Failure preparing request") + return + } + + resp, err := client.ListLogsSender(req) + if err != nil { + result.sgllr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "ListLogs", resp, "Failure sending request") + return + } + + result.sgllr, err = client.ListLogsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "ListLogs", resp, "Failure responding to request") + return + } + if result.sgllr.hasNextLink() && result.sgllr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListLogsPreparer prepares the ListLogs request. +func (client SyncGroupsClient) ListLogsPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, startTime string, endTime string, typeParameter string, continuationToken string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "syncGroupName": autorest.Encode("path", syncGroupName), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + "endTime": autorest.Encode("query", endTime), + "startTime": autorest.Encode("query", startTime), + "type": autorest.Encode("query", typeParameter), + } + if len(continuationToken) > 0 { + queryParameters["continuationToken"] = autorest.Encode("query", continuationToken) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/logs", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListLogsSender sends the ListLogs request. The method will close the +// http.Response Body if it receives an error. +func (client SyncGroupsClient) ListLogsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListLogsResponder handles the response to the ListLogs request. The method always +// closes the http.Response Body. +func (client SyncGroupsClient) ListLogsResponder(resp *http.Response) (result SyncGroupLogListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listLogsNextResults retrieves the next set of results, if any. +func (client SyncGroupsClient) listLogsNextResults(ctx context.Context, lastResults SyncGroupLogListResult) (result SyncGroupLogListResult, err error) { + req, err := lastResults.syncGroupLogListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "listLogsNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListLogsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "listLogsNextResults", resp, "Failure sending next results request") + } + result, err = client.ListLogsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "listLogsNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListLogsComplete enumerates all values, automatically crossing page boundaries as required. +func (client SyncGroupsClient) ListLogsComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, startTime string, endTime string, typeParameter string, continuationToken string) (result SyncGroupLogListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncGroupsClient.ListLogs") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListLogs(ctx, resourceGroupName, serverName, databaseName, syncGroupName, startTime, endTime, typeParameter, continuationToken) + return +} + +// ListSyncDatabaseIds gets a collection of sync database ids. +// Parameters: +// locationName - the name of the region where the resource is located. +func (client SyncGroupsClient) ListSyncDatabaseIds(ctx context.Context, locationName string) (result SyncDatabaseIDListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncGroupsClient.ListSyncDatabaseIds") + defer func() { + sc := -1 + if result.sdilr.Response.Response != nil { + sc = result.sdilr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listSyncDatabaseIdsNextResults + req, err := client.ListSyncDatabaseIdsPreparer(ctx, locationName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "ListSyncDatabaseIds", nil, "Failure preparing request") + return + } + + resp, err := client.ListSyncDatabaseIdsSender(req) + if err != nil { + result.sdilr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "ListSyncDatabaseIds", resp, "Failure sending request") + return + } + + result.sdilr, err = client.ListSyncDatabaseIdsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "ListSyncDatabaseIds", resp, "Failure responding to request") + return + } + if result.sdilr.hasNextLink() && result.sdilr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListSyncDatabaseIdsPreparer prepares the ListSyncDatabaseIds request. +func (client SyncGroupsClient) ListSyncDatabaseIdsPreparer(ctx context.Context, locationName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "locationName": autorest.Encode("path", locationName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/syncDatabaseIds", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSyncDatabaseIdsSender sends the ListSyncDatabaseIds request. The method will close the +// http.Response Body if it receives an error. +func (client SyncGroupsClient) ListSyncDatabaseIdsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListSyncDatabaseIdsResponder handles the response to the ListSyncDatabaseIds request. The method always +// closes the http.Response Body. +func (client SyncGroupsClient) ListSyncDatabaseIdsResponder(resp *http.Response) (result SyncDatabaseIDListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listSyncDatabaseIdsNextResults retrieves the next set of results, if any. +func (client SyncGroupsClient) listSyncDatabaseIdsNextResults(ctx context.Context, lastResults SyncDatabaseIDListResult) (result SyncDatabaseIDListResult, err error) { + req, err := lastResults.syncDatabaseIDListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "listSyncDatabaseIdsNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSyncDatabaseIdsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "listSyncDatabaseIdsNextResults", resp, "Failure sending next results request") + } + result, err = client.ListSyncDatabaseIdsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "listSyncDatabaseIdsNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListSyncDatabaseIdsComplete enumerates all values, automatically crossing page boundaries as required. +func (client SyncGroupsClient) ListSyncDatabaseIdsComplete(ctx context.Context, locationName string) (result SyncDatabaseIDListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncGroupsClient.ListSyncDatabaseIds") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListSyncDatabaseIds(ctx, locationName) + return +} + +// RefreshHubSchema refreshes a hub database schema. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database on which the sync group is hosted. +// syncGroupName - the name of the sync group. +func (client SyncGroupsClient) RefreshHubSchema(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string) (result SyncGroupsRefreshHubSchemaFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncGroupsClient.RefreshHubSchema") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.RefreshHubSchemaPreparer(ctx, resourceGroupName, serverName, databaseName, syncGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "RefreshHubSchema", nil, "Failure preparing request") + return + } + + result, err = client.RefreshHubSchemaSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "RefreshHubSchema", nil, "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 = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/refreshHubSchema", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// RefreshHubSchemaSender sends the RefreshHubSchema request. The method will close the +// http.Response Body if it receives an error. +func (client SyncGroupsClient) RefreshHubSchemaSender(req *http.Request) (future SyncGroupsRefreshHubSchemaFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// RefreshHubSchemaResponder handles the response to the RefreshHubSchema request. The method always +// closes the http.Response Body. +func (client SyncGroupsClient) RefreshHubSchemaResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + +// TriggerSync triggers a sync group synchronization. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database on which the sync group is hosted. +// syncGroupName - the name of the sync group. +func (client SyncGroupsClient) TriggerSync(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncGroupsClient.TriggerSync") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.TriggerSyncPreparer(ctx, resourceGroupName, serverName, databaseName, syncGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "TriggerSync", nil, "Failure preparing request") + return + } + + resp, err := client.TriggerSyncSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "TriggerSync", resp, "Failure sending request") + return + } + + result, err = client.TriggerSyncResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "TriggerSync", resp, "Failure responding to request") + return + } + + return +} + +// TriggerSyncPreparer prepares the TriggerSync request. +func (client SyncGroupsClient) TriggerSyncPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "syncGroupName": autorest.Encode("path", syncGroupName), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/triggerSync", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// TriggerSyncSender sends the TriggerSync request. The method will close the +// http.Response Body if it receives an error. +func (client SyncGroupsClient) TriggerSyncSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// TriggerSyncResponder handles the response to the TriggerSync request. The method always +// closes the http.Response Body. +func (client SyncGroupsClient) TriggerSyncResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Update updates a sync group. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database on which the sync group is hosted. +// syncGroupName - the name of the sync group. +// parameters - the requested sync group resource state. +func (client SyncGroupsClient) Update(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, parameters SyncGroup) (result SyncGroupsUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncGroupsClient.Update") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.UpdatePreparer(ctx, resourceGroupName, serverName, databaseName, syncGroupName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncGroupsClient", "Update", nil, "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 = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client SyncGroupsClient) UpdateSender(req *http.Request) (future SyncGroupsUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client SyncGroupsClient) UpdateResponder(resp *http.Response) (result SyncGroup, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/syncmembers.go b/services/preview/sql/mgmt/v5.0/sql/syncmembers.go new file mode 100644 index 000000000000..6bcbe11da96d --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/syncmembers.go @@ -0,0 +1,708 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// SyncMembersClient is the the Azure SQL Database management API provides a RESTful set of web services that interact +// with Azure SQL Database services to manage your databases. The API enables you to create, retrieve, update, and +// delete databases. +type SyncMembersClient struct { + BaseClient +} + +// NewSyncMembersClient creates an instance of the SyncMembersClient client. +func NewSyncMembersClient(subscriptionID string) SyncMembersClient { + return NewSyncMembersClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewSyncMembersClientWithBaseURI creates an instance of the SyncMembersClient client using a custom endpoint. Use +// this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewSyncMembersClientWithBaseURI(baseURI string, subscriptionID string) SyncMembersClient { + return SyncMembersClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a sync member. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database on which the sync group is hosted. +// syncGroupName - the name of the sync group on which the sync member is hosted. +// syncMemberName - the name of the sync member. +// parameters - the requested sync member resource state. +func (client SyncMembersClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, syncMemberName string, parameters SyncMember) (result SyncMembersCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncMembersClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, databaseName, syncGroupName, syncMemberName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersClient", "CreateOrUpdate", nil, "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 = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/syncMembers/{syncMemberName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client SyncMembersClient) CreateOrUpdateSender(req *http.Request) (future SyncMembersCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client SyncMembersClient) CreateOrUpdateResponder(resp *http.Response) (result SyncMember, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a sync member. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database on which the sync group is hosted. +// syncGroupName - the name of the sync group on which the sync member is hosted. +// syncMemberName - the name of the sync member. +func (client SyncMembersClient) Delete(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, syncMemberName string) (result SyncMembersDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncMembersClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, serverName, databaseName, syncGroupName, syncMemberName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersClient", "Delete", nil, "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 = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/syncMembers/{syncMemberName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client SyncMembersClient) DeleteSender(req *http.Request) (future SyncMembersDeleteFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client SyncMembersClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a sync member. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database on which the sync group is hosted. +// syncGroupName - the name of the sync group on which the sync member is hosted. +// syncMemberName - the name of the sync member. +func (client SyncMembersClient) Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, syncMemberName string) (result SyncMember, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncMembersClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, databaseName, syncGroupName, syncMemberName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.SyncMembersClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client SyncMembersClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, syncMemberName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "syncGroupName": autorest.Encode("path", syncGroupName), + "syncMemberName": autorest.Encode("path", syncMemberName), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/syncMembers/{syncMemberName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client SyncMembersClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client SyncMembersClient) GetResponder(resp *http.Response) (result SyncMember, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListBySyncGroup lists sync members in the given sync group. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database on which the sync group is hosted. +// syncGroupName - the name of the sync group. +func (client SyncMembersClient) ListBySyncGroup(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string) (result SyncMemberListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncMembersClient.ListBySyncGroup") + defer func() { + sc := -1 + if result.smlr.Response.Response != nil { + sc = result.smlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listBySyncGroupNextResults + req, err := client.ListBySyncGroupPreparer(ctx, resourceGroupName, serverName, databaseName, syncGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersClient", "ListBySyncGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListBySyncGroupSender(req) + if err != nil { + result.smlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.SyncMembersClient", "ListBySyncGroup", resp, "Failure sending request") + return + } + + result.smlr, err = client.ListBySyncGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersClient", "ListBySyncGroup", resp, "Failure responding to request") + return + } + if result.smlr.hasNextLink() && result.smlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListBySyncGroupPreparer prepares the ListBySyncGroup request. +func (client SyncMembersClient) ListBySyncGroupPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "syncGroupName": autorest.Encode("path", syncGroupName), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/syncMembers", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListBySyncGroupSender sends the ListBySyncGroup request. The method will close the +// http.Response Body if it receives an error. +func (client SyncMembersClient) ListBySyncGroupSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListBySyncGroupResponder handles the response to the ListBySyncGroup request. The method always +// closes the http.Response Body. +func (client SyncMembersClient) ListBySyncGroupResponder(resp *http.Response) (result SyncMemberListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listBySyncGroupNextResults retrieves the next set of results, if any. +func (client SyncMembersClient) listBySyncGroupNextResults(ctx context.Context, lastResults SyncMemberListResult) (result SyncMemberListResult, err error) { + req, err := lastResults.syncMemberListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.SyncMembersClient", "listBySyncGroupNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListBySyncGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.SyncMembersClient", "listBySyncGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListBySyncGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersClient", "listBySyncGroupNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListBySyncGroupComplete enumerates all values, automatically crossing page boundaries as required. +func (client SyncMembersClient) ListBySyncGroupComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string) (result SyncMemberListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncMembersClient.ListBySyncGroup") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListBySyncGroup(ctx, resourceGroupName, serverName, databaseName, syncGroupName) + return +} + +// ListMemberSchemas gets a sync member database schema. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database on which the sync group is hosted. +// syncGroupName - the name of the sync group on which the sync member is hosted. +// syncMemberName - the name of the sync member. +func (client SyncMembersClient) ListMemberSchemas(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, syncMemberName string) (result SyncFullSchemaPropertiesListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncMembersClient.ListMemberSchemas") + defer func() { + sc := -1 + if result.sfsplr.Response.Response != nil { + sc = result.sfsplr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listMemberSchemasNextResults + req, err := client.ListMemberSchemasPreparer(ctx, resourceGroupName, serverName, databaseName, syncGroupName, syncMemberName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersClient", "ListMemberSchemas", nil, "Failure preparing request") + return + } + + resp, err := client.ListMemberSchemasSender(req) + if err != nil { + result.sfsplr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.SyncMembersClient", "ListMemberSchemas", resp, "Failure sending request") + return + } + + result.sfsplr, err = client.ListMemberSchemasResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersClient", "ListMemberSchemas", resp, "Failure responding to request") + return + } + if result.sfsplr.hasNextLink() && result.sfsplr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListMemberSchemasPreparer prepares the ListMemberSchemas request. +func (client SyncMembersClient) ListMemberSchemasPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, syncMemberName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "syncGroupName": autorest.Encode("path", syncGroupName), + "syncMemberName": autorest.Encode("path", syncMemberName), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/syncMembers/{syncMemberName}/schemas", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListMemberSchemasSender sends the ListMemberSchemas request. The method will close the +// http.Response Body if it receives an error. +func (client SyncMembersClient) ListMemberSchemasSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListMemberSchemasResponder handles the response to the ListMemberSchemas request. The method always +// closes the http.Response Body. +func (client SyncMembersClient) ListMemberSchemasResponder(resp *http.Response) (result SyncFullSchemaPropertiesListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listMemberSchemasNextResults retrieves the next set of results, if any. +func (client SyncMembersClient) listMemberSchemasNextResults(ctx context.Context, lastResults SyncFullSchemaPropertiesListResult) (result SyncFullSchemaPropertiesListResult, err error) { + req, err := lastResults.syncFullSchemaPropertiesListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.SyncMembersClient", "listMemberSchemasNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListMemberSchemasSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.SyncMembersClient", "listMemberSchemasNextResults", resp, "Failure sending next results request") + } + result, err = client.ListMemberSchemasResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersClient", "listMemberSchemasNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListMemberSchemasComplete enumerates all values, automatically crossing page boundaries as required. +func (client SyncMembersClient) ListMemberSchemasComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, syncMemberName string) (result SyncFullSchemaPropertiesListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncMembersClient.ListMemberSchemas") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListMemberSchemas(ctx, resourceGroupName, serverName, databaseName, syncGroupName, syncMemberName) + return +} + +// RefreshMemberSchema refreshes a sync member database schema. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database on which the sync group is hosted. +// syncGroupName - the name of the sync group on which the sync member is hosted. +// syncMemberName - the name of the sync member. +func (client SyncMembersClient) RefreshMemberSchema(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, syncMemberName string) (result SyncMembersRefreshMemberSchemaFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncMembersClient.RefreshMemberSchema") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.RefreshMemberSchemaPreparer(ctx, resourceGroupName, serverName, databaseName, syncGroupName, syncMemberName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersClient", "RefreshMemberSchema", nil, "Failure preparing request") + return + } + + result, err = client.RefreshMemberSchemaSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersClient", "RefreshMemberSchema", nil, "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 = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/syncMembers/{syncMemberName}/refreshSchema", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// RefreshMemberSchemaSender sends the RefreshMemberSchema request. The method will close the +// http.Response Body if it receives an error. +func (client SyncMembersClient) RefreshMemberSchemaSender(req *http.Request) (future SyncMembersRefreshMemberSchemaFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// RefreshMemberSchemaResponder handles the response to the RefreshMemberSchema request. The method always +// closes the http.Response Body. +func (client SyncMembersClient) RefreshMemberSchemaResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + +// Update updates an existing sync member. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database on which the sync group is hosted. +// syncGroupName - the name of the sync group on which the sync member is hosted. +// syncMemberName - the name of the sync member. +// parameters - the requested sync member resource state. +func (client SyncMembersClient) Update(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, syncMemberName string, parameters SyncMember) (result SyncMembersUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SyncMembersClient.Update") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.UpdatePreparer(ctx, resourceGroupName, serverName, databaseName, syncGroupName, syncMemberName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersClient", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.SyncMembersClient", "Update", nil, "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 = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/syncMembers/{syncMemberName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client SyncMembersClient) UpdateSender(req *http.Request) (future SyncMembersUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client SyncMembersClient) UpdateResponder(resp *http.Response) (result SyncMember, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/tdecertificates.go b/services/preview/sql/mgmt/v5.0/sql/tdecertificates.go new file mode 100644 index 000000000000..53dd0452e8b3 --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/tdecertificates.go @@ -0,0 +1,122 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// TdeCertificatesClient is the the Azure SQL Database management API provides a RESTful set of web services that +// interact with Azure SQL Database services to manage your databases. The API enables you to create, retrieve, update, +// and delete databases. +type TdeCertificatesClient struct { + BaseClient +} + +// NewTdeCertificatesClient creates an instance of the TdeCertificatesClient client. +func NewTdeCertificatesClient(subscriptionID string) TdeCertificatesClient { + return NewTdeCertificatesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewTdeCertificatesClientWithBaseURI creates an instance of the TdeCertificatesClient client using a custom endpoint. +// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewTdeCertificatesClientWithBaseURI(baseURI string, subscriptionID string) TdeCertificatesClient { + return TdeCertificatesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Create creates a TDE certificate for a given server. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// parameters - the requested TDE certificate to be created or updated. +func (client TdeCertificatesClient) Create(ctx context.Context, resourceGroupName string, serverName string, parameters TdeCertificate) (result TdeCertificatesCreateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TdeCertificatesClient.Create") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.TdeCertificateProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.TdeCertificateProperties.PrivateBlob", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("sql.TdeCertificatesClient", "Create", err.Error()) + } + + req, err := client.CreatePreparer(ctx, resourceGroupName, serverName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.TdeCertificatesClient", "Create", nil, "Failure preparing request") + return + } + + result, err = client.CreateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.TdeCertificatesClient", "Create", nil, "Failure sending request") + return + } + + return +} + +// CreatePreparer prepares the Create request. +func (client TdeCertificatesClient) CreatePreparer(ctx context.Context, resourceGroupName string, serverName string, parameters TdeCertificate) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/tdeCertificates", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateSender sends the Create request. The method will close the +// http.Response Body if it receives an error. +func (client TdeCertificatesClient) CreateSender(req *http.Request) (future TdeCertificatesCreateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client TdeCertificatesClient) CreateResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/timezones.go b/services/preview/sql/mgmt/v5.0/sql/timezones.go new file mode 100644 index 000000000000..5b1d38148912 --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/timezones.go @@ -0,0 +1,220 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// TimeZonesClient 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 TimeZonesClient struct { + BaseClient +} + +// NewTimeZonesClient creates an instance of the TimeZonesClient client. +func NewTimeZonesClient(subscriptionID string) TimeZonesClient { + return NewTimeZonesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewTimeZonesClientWithBaseURI creates an instance of the TimeZonesClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewTimeZonesClientWithBaseURI(baseURI string, subscriptionID string) TimeZonesClient { + return TimeZonesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get gets a managed instance time zone. +func (client TimeZonesClient) Get(ctx context.Context, locationName string, timeZoneID string) (result TimeZone, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TimeZonesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, locationName, timeZoneID) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.TimeZonesClient", "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.TimeZonesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.TimeZonesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client TimeZonesClient) GetPreparer(ctx context.Context, locationName string, timeZoneID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "locationName": autorest.Encode("path", locationName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "timeZoneId": autorest.Encode("path", timeZoneID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/timeZones/{timeZoneId}", 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 TimeZonesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client TimeZonesClient) GetResponder(resp *http.Response) (result TimeZone, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByLocation gets a list of managed instance time zones by location. +func (client TimeZonesClient) ListByLocation(ctx context.Context, locationName string) (result TimeZoneListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TimeZonesClient.ListByLocation") + defer func() { + sc := -1 + if result.tzlr.Response.Response != nil { + sc = result.tzlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByLocationNextResults + req, err := client.ListByLocationPreparer(ctx, locationName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.TimeZonesClient", "ListByLocation", nil, "Failure preparing request") + return + } + + resp, err := client.ListByLocationSender(req) + if err != nil { + result.tzlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.TimeZonesClient", "ListByLocation", resp, "Failure sending request") + return + } + + result.tzlr, err = client.ListByLocationResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.TimeZonesClient", "ListByLocation", resp, "Failure responding to request") + return + } + if result.tzlr.hasNextLink() && result.tzlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByLocationPreparer prepares the ListByLocation request. +func (client TimeZonesClient) ListByLocationPreparer(ctx context.Context, locationName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "locationName": autorest.Encode("path", locationName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/timeZones", 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 TimeZonesClient) ListByLocationSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByLocationResponder handles the response to the ListByLocation request. The method always +// closes the http.Response Body. +func (client TimeZonesClient) ListByLocationResponder(resp *http.Response) (result TimeZoneListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByLocationNextResults retrieves the next set of results, if any. +func (client TimeZonesClient) listByLocationNextResults(ctx context.Context, lastResults TimeZoneListResult) (result TimeZoneListResult, err error) { + req, err := lastResults.timeZoneListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.TimeZonesClient", "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.TimeZonesClient", "listByLocationNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByLocationResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.TimeZonesClient", "listByLocationNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByLocationComplete enumerates all values, automatically crossing page boundaries as required. +func (client TimeZonesClient) ListByLocationComplete(ctx context.Context, locationName string) (result TimeZoneListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TimeZonesClient.ListByLocation") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByLocation(ctx, locationName) + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/transparentdataencryptionactivities.go b/services/preview/sql/mgmt/v5.0/sql/transparentdataencryptionactivities.go new file mode 100644 index 000000000000..309e0d47eb0d --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/transparentdataencryptionactivities.go @@ -0,0 +1,115 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// TransparentDataEncryptionActivitiesClient is the the Azure SQL Database management API provides a RESTful set of web +// services that interact with Azure SQL Database services to manage your databases. The API enables you to create, +// retrieve, update, and delete databases. +type TransparentDataEncryptionActivitiesClient struct { + BaseClient +} + +// NewTransparentDataEncryptionActivitiesClient creates an instance of the TransparentDataEncryptionActivitiesClient +// client. +func NewTransparentDataEncryptionActivitiesClient(subscriptionID string) TransparentDataEncryptionActivitiesClient { + return NewTransparentDataEncryptionActivitiesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewTransparentDataEncryptionActivitiesClientWithBaseURI creates an instance of the +// TransparentDataEncryptionActivitiesClient client using a custom endpoint. Use this when interacting with an Azure +// cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewTransparentDataEncryptionActivitiesClientWithBaseURI(baseURI string, subscriptionID string) TransparentDataEncryptionActivitiesClient { + return TransparentDataEncryptionActivitiesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListByConfiguration returns a database's transparent data encryption operation result. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database for which the transparent data encryption applies. +func (client TransparentDataEncryptionActivitiesClient) ListByConfiguration(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result TransparentDataEncryptionActivityListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TransparentDataEncryptionActivitiesClient.ListByConfiguration") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListByConfigurationPreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.TransparentDataEncryptionActivitiesClient", "ListByConfiguration", nil, "Failure preparing request") + return + } + + resp, err := client.ListByConfigurationSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.TransparentDataEncryptionActivitiesClient", "ListByConfiguration", resp, "Failure sending request") + return + } + + result, err = client.ListByConfigurationResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.TransparentDataEncryptionActivitiesClient", "ListByConfiguration", resp, "Failure responding to request") + return + } + + return +} + +// ListByConfigurationPreparer prepares the ListByConfiguration request. +func (client TransparentDataEncryptionActivitiesClient) ListByConfigurationPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "transparentDataEncryptionName": autorest.Encode("path", "current"), + } + + const APIVersion = "2014-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/transparentDataEncryption/{transparentDataEncryptionName}/operationResults", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByConfigurationSender sends the ListByConfiguration request. The method will close the +// http.Response Body if it receives an error. +func (client TransparentDataEncryptionActivitiesClient) ListByConfigurationSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByConfigurationResponder handles the response to the ListByConfiguration request. The method always +// closes the http.Response Body. +func (client TransparentDataEncryptionActivitiesClient) ListByConfigurationResponder(resp *http.Response) (result TransparentDataEncryptionActivityListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/transparentdataencryptions.go b/services/preview/sql/mgmt/v5.0/sql/transparentdataencryptions.go new file mode 100644 index 000000000000..691b41cd1464 --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/transparentdataencryptions.go @@ -0,0 +1,198 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// TransparentDataEncryptionsClient is the the Azure SQL Database management API provides a RESTful set of web services +// that interact with Azure SQL Database services to manage your databases. The API enables you to create, retrieve, +// update, and delete databases. +type TransparentDataEncryptionsClient struct { + BaseClient +} + +// NewTransparentDataEncryptionsClient creates an instance of the TransparentDataEncryptionsClient client. +func NewTransparentDataEncryptionsClient(subscriptionID string) TransparentDataEncryptionsClient { + return NewTransparentDataEncryptionsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewTransparentDataEncryptionsClientWithBaseURI creates an instance of the TransparentDataEncryptionsClient client +// using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign +// clouds, Azure stack). +func NewTransparentDataEncryptionsClientWithBaseURI(baseURI string, subscriptionID string) TransparentDataEncryptionsClient { + return TransparentDataEncryptionsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a database's transparent data encryption configuration. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database for which setting the transparent data encryption applies. +// parameters - the required parameters for creating or updating transparent data encryption. +func (client TransparentDataEncryptionsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters TransparentDataEncryption) (result TransparentDataEncryption, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TransparentDataEncryptionsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, databaseName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.TransparentDataEncryptionsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.TransparentDataEncryptionsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.TransparentDataEncryptionsClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client TransparentDataEncryptionsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters TransparentDataEncryption) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "transparentDataEncryptionName": autorest.Encode("path", "current"), + } + + const APIVersion = "2014-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + parameters.Location = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/transparentDataEncryption/{transparentDataEncryptionName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client TransparentDataEncryptionsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client TransparentDataEncryptionsClient) CreateOrUpdateResponder(resp *http.Response) (result TransparentDataEncryption, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets a database's transparent data encryption configuration. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database for which the transparent data encryption applies. +func (client TransparentDataEncryptionsClient) Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result TransparentDataEncryption, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TransparentDataEncryptionsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.TransparentDataEncryptionsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.TransparentDataEncryptionsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.TransparentDataEncryptionsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client TransparentDataEncryptionsClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "transparentDataEncryptionName": autorest.Encode("path", "current"), + } + + const APIVersion = "2014-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/transparentDataEncryption/{transparentDataEncryptionName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client TransparentDataEncryptionsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client TransparentDataEncryptionsClient) GetResponder(resp *http.Response) (result TransparentDataEncryption, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/usages.go b/services/preview/sql/mgmt/v5.0/sql/usages.go new file mode 100644 index 000000000000..0cbb8e9b9db1 --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/usages.go @@ -0,0 +1,156 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// UsagesClient is the the Azure SQL Database management API provides a RESTful set of web services that interact with +// Azure SQL Database services to manage your databases. The API enables you to create, retrieve, update, and delete +// databases. +type UsagesClient struct { + BaseClient +} + +// NewUsagesClient creates an instance of the UsagesClient client. +func NewUsagesClient(subscriptionID string) UsagesClient { + return NewUsagesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewUsagesClientWithBaseURI creates an instance of the UsagesClient client using a custom endpoint. Use this when +// interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewUsagesClientWithBaseURI(baseURI string, subscriptionID string) UsagesClient { + return UsagesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListByInstancePool gets all instance pool usage metrics +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// instancePoolName - the name of the instance pool to be retrieved. +// expandChildren - optional request parameter to include managed instance usages within the instance pool. +func (client UsagesClient) ListByInstancePool(ctx context.Context, resourceGroupName string, instancePoolName string, expandChildren *bool) (result UsageListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/UsagesClient.ListByInstancePool") + defer func() { + sc := -1 + if result.ulr.Response.Response != nil { + sc = result.ulr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByInstancePoolNextResults + req, err := client.ListByInstancePoolPreparer(ctx, resourceGroupName, instancePoolName, expandChildren) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.UsagesClient", "ListByInstancePool", nil, "Failure preparing request") + return + } + + resp, err := client.ListByInstancePoolSender(req) + if err != nil { + result.ulr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.UsagesClient", "ListByInstancePool", resp, "Failure sending request") + return + } + + result.ulr, err = client.ListByInstancePoolResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.UsagesClient", "ListByInstancePool", resp, "Failure responding to request") + return + } + if result.ulr.hasNextLink() && result.ulr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByInstancePoolPreparer prepares the ListByInstancePool request. +func (client UsagesClient) ListByInstancePoolPreparer(ctx context.Context, resourceGroupName string, instancePoolName string, expandChildren *bool) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "instancePoolName": autorest.Encode("path", instancePoolName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-02-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if expandChildren != nil { + queryParameters["expandChildren"] = autorest.Encode("query", *expandChildren) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/instancePools/{instancePoolName}/usages", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByInstancePoolSender sends the ListByInstancePool request. The method will close the +// http.Response Body if it receives an error. +func (client UsagesClient) ListByInstancePoolSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByInstancePoolResponder handles the response to the ListByInstancePool request. The method always +// closes the http.Response Body. +func (client UsagesClient) ListByInstancePoolResponder(resp *http.Response) (result UsageListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByInstancePoolNextResults retrieves the next set of results, if any. +func (client UsagesClient) listByInstancePoolNextResults(ctx context.Context, lastResults UsageListResult) (result UsageListResult, err error) { + req, err := lastResults.usageListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.UsagesClient", "listByInstancePoolNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByInstancePoolSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.UsagesClient", "listByInstancePoolNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByInstancePoolResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.UsagesClient", "listByInstancePoolNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByInstancePoolComplete enumerates all values, automatically crossing page boundaries as required. +func (client UsagesClient) ListByInstancePoolComplete(ctx context.Context, resourceGroupName string, instancePoolName string, expandChildren *bool) (result UsageListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/UsagesClient.ListByInstancePool") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByInstancePool(ctx, resourceGroupName, instancePoolName, expandChildren) + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/version.go b/services/preview/sql/mgmt/v5.0/sql/version.go new file mode 100644 index 000000000000..4398e068fce5 --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/version.go @@ -0,0 +1,19 @@ +package sql + +import "github.com/Azure/azure-sdk-for-go/version" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// UserAgent returns the UserAgent string to use when sending http.Requests. +func UserAgent() string { + return "Azure-SDK-For-Go/" + Version() + " sql/v5.0" +} + +// Version returns the semantic version (see http://semver.org) of the client. +func Version() string { + return version.Number +} diff --git a/services/preview/sql/mgmt/v5.0/sql/virtualclusters.go b/services/preview/sql/mgmt/v5.0/sql/virtualclusters.go new file mode 100644 index 000000000000..898655b5915e --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/virtualclusters.go @@ -0,0 +1,578 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// VirtualClustersClient is the the Azure SQL Database management API provides a RESTful set of web services that +// interact with Azure SQL Database services to manage your databases. The API enables you to create, retrieve, update, +// and delete databases. +type VirtualClustersClient struct { + BaseClient +} + +// NewVirtualClustersClient creates an instance of the VirtualClustersClient client. +func NewVirtualClustersClient(subscriptionID string) VirtualClustersClient { + return NewVirtualClustersClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewVirtualClustersClientWithBaseURI creates an instance of the VirtualClustersClient client using a custom endpoint. +// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewVirtualClustersClientWithBaseURI(baseURI string, subscriptionID string) VirtualClustersClient { + return VirtualClustersClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Delete deletes a virtual cluster. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// virtualClusterName - the name of the virtual cluster. +func (client VirtualClustersClient) Delete(ctx context.Context, resourceGroupName string, virtualClusterName string) (result VirtualClustersDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/VirtualClustersClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, virtualClusterName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualClustersClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualClustersClient", "Delete", nil, "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client VirtualClustersClient) DeletePreparer(ctx context.Context, resourceGroupName string, virtualClusterName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "virtualClusterName": autorest.Encode("path", virtualClusterName), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/virtualClusters/{virtualClusterName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client VirtualClustersClient) DeleteSender(req *http.Request) (future VirtualClustersDeleteFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client VirtualClustersClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a virtual cluster. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// virtualClusterName - the name of the virtual cluster. +func (client VirtualClustersClient) Get(ctx context.Context, resourceGroupName string, virtualClusterName string) (result VirtualCluster, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/VirtualClustersClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, virtualClusterName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualClustersClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.VirtualClustersClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualClustersClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client VirtualClustersClient) GetPreparer(ctx context.Context, resourceGroupName string, virtualClusterName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "virtualClusterName": autorest.Encode("path", virtualClusterName), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/virtualClusters/{virtualClusterName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client VirtualClustersClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client VirtualClustersClient) GetResponder(resp *http.Response) (result VirtualCluster, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List gets a list of all virtualClusters in the subscription. +func (client VirtualClustersClient) List(ctx context.Context) (result VirtualClusterListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/VirtualClustersClient.List") + defer func() { + sc := -1 + if result.vclr.Response.Response != nil { + sc = result.vclr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualClustersClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.vclr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.VirtualClustersClient", "List", resp, "Failure sending request") + return + } + + result.vclr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualClustersClient", "List", resp, "Failure responding to request") + return + } + if result.vclr.hasNextLink() && result.vclr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client VirtualClustersClient) ListPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Sql/virtualClusters", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client VirtualClustersClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client VirtualClustersClient) ListResponder(resp *http.Response) (result VirtualClusterListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client VirtualClustersClient) listNextResults(ctx context.Context, lastResults VirtualClusterListResult) (result VirtualClusterListResult, err error) { + req, err := lastResults.virtualClusterListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.VirtualClustersClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.VirtualClustersClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualClustersClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client VirtualClustersClient) ListComplete(ctx context.Context) (result VirtualClusterListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/VirtualClustersClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx) + return +} + +// ListByResourceGroup gets a list of virtual clusters in a resource group. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +func (client VirtualClustersClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result VirtualClusterListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/VirtualClustersClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.vclr.Response.Response != nil { + sc = result.vclr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByResourceGroupNextResults + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualClustersClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.vclr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.VirtualClustersClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result.vclr, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualClustersClient", "ListByResourceGroup", resp, "Failure responding to request") + return + } + if result.vclr.hasNextLink() && result.vclr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client VirtualClustersClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/virtualClusters", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client VirtualClustersClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client VirtualClustersClient) ListByResourceGroupResponder(resp *http.Response) (result VirtualClusterListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByResourceGroupNextResults retrieves the next set of results, if any. +func (client VirtualClustersClient) listByResourceGroupNextResults(ctx context.Context, lastResults VirtualClusterListResult) (result VirtualClusterListResult, err error) { + req, err := lastResults.virtualClusterListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.VirtualClustersClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.VirtualClustersClient", "listByResourceGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualClustersClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. +func (client VirtualClustersClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result VirtualClusterListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/VirtualClustersClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByResourceGroup(ctx, resourceGroupName) + return +} + +// Update updates a virtual cluster. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// virtualClusterName - the name of the virtual cluster. +// parameters - the requested virtual cluster resource state. +func (client VirtualClustersClient) Update(ctx context.Context, resourceGroupName string, virtualClusterName string, parameters VirtualClusterUpdate) (result VirtualClustersUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/VirtualClustersClient.Update") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.UpdatePreparer(ctx, resourceGroupName, virtualClusterName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualClustersClient", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualClustersClient", "Update", nil, "Failure sending request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client VirtualClustersClient) UpdatePreparer(ctx context.Context, resourceGroupName string, virtualClusterName string, parameters VirtualClusterUpdate) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "virtualClusterName": autorest.Encode("path", virtualClusterName), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/virtualClusters/{virtualClusterName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client VirtualClustersClient) UpdateSender(req *http.Request) (future VirtualClustersUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client VirtualClustersClient) UpdateResponder(resp *http.Response) (result VirtualCluster, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// UpdateDNSServers synchronizes the DNS server settings used by the managed instances inside the given virtual +// cluster. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// virtualClusterName - the name of the virtual cluster. +func (client VirtualClustersClient) UpdateDNSServers(ctx context.Context, resourceGroupName string, virtualClusterName string) (result UpdateManagedInstanceDNSServersOperation, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/VirtualClustersClient.UpdateDNSServers") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.UpdateDNSServersPreparer(ctx, resourceGroupName, virtualClusterName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualClustersClient", "UpdateDNSServers", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateDNSServersSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.VirtualClustersClient", "UpdateDNSServers", resp, "Failure sending request") + return + } + + result, err = client.UpdateDNSServersResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualClustersClient", "UpdateDNSServers", resp, "Failure responding to request") + return + } + + return +} + +// UpdateDNSServersPreparer prepares the UpdateDNSServers request. +func (client VirtualClustersClient) UpdateDNSServersPreparer(ctx context.Context, resourceGroupName string, virtualClusterName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "virtualClusterName": autorest.Encode("path", virtualClusterName), + } + + const APIVersion = "2020-11-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/virtualClusters/{virtualClusterName}/updateManagedInstanceDnsServers", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateDNSServersSender sends the UpdateDNSServers request. The method will close the +// http.Response Body if it receives an error. +func (client VirtualClustersClient) UpdateDNSServersSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateDNSServersResponder handles the response to the UpdateDNSServers request. The method always +// closes the http.Response Body. +func (client VirtualClustersClient) UpdateDNSServersResponder(resp *http.Response) (result UpdateManagedInstanceDNSServersOperation, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/virtualnetworkrules.go b/services/preview/sql/mgmt/v5.0/sql/virtualnetworkrules.go new file mode 100644 index 000000000000..48beb4299743 --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/virtualnetworkrules.go @@ -0,0 +1,404 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// VirtualNetworkRulesClient is the the Azure SQL Database management API provides a RESTful set of web services that +// interact with Azure SQL Database services to manage your databases. The API enables you to create, retrieve, update, +// and delete databases. +type VirtualNetworkRulesClient struct { + BaseClient +} + +// NewVirtualNetworkRulesClient creates an instance of the VirtualNetworkRulesClient client. +func NewVirtualNetworkRulesClient(subscriptionID string) VirtualNetworkRulesClient { + return NewVirtualNetworkRulesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewVirtualNetworkRulesClientWithBaseURI creates an instance of the VirtualNetworkRulesClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewVirtualNetworkRulesClientWithBaseURI(baseURI string, subscriptionID string) VirtualNetworkRulesClient { + return VirtualNetworkRulesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates an existing virtual network rule. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// virtualNetworkRuleName - the name of the virtual network rule. +// parameters - the requested virtual Network Rule Resource state. +func (client VirtualNetworkRulesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, virtualNetworkRuleName string, parameters VirtualNetworkRule) (result VirtualNetworkRulesCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/VirtualNetworkRulesClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.VirtualNetworkRuleProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.VirtualNetworkRuleProperties.VirtualNetworkSubnetID", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("sql.VirtualNetworkRulesClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, virtualNetworkRuleName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualNetworkRulesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualNetworkRulesClient", "CreateOrUpdate", nil, "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 = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/virtualNetworkRules/{virtualNetworkRuleName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client VirtualNetworkRulesClient) CreateOrUpdateSender(req *http.Request) (future VirtualNetworkRulesCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client VirtualNetworkRulesClient) CreateOrUpdateResponder(resp *http.Response) (result VirtualNetworkRule, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes the virtual network rule with the given name. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// virtualNetworkRuleName - the name of the virtual network rule. +func (client VirtualNetworkRulesClient) Delete(ctx context.Context, resourceGroupName string, serverName string, virtualNetworkRuleName string) (result VirtualNetworkRulesDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/VirtualNetworkRulesClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, serverName, virtualNetworkRuleName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualNetworkRulesClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualNetworkRulesClient", "Delete", nil, "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 = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/virtualNetworkRules/{virtualNetworkRuleName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client VirtualNetworkRulesClient) DeleteSender(req *http.Request) (future VirtualNetworkRulesDeleteFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client VirtualNetworkRulesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a virtual network rule. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// virtualNetworkRuleName - the name of the virtual network rule. +func (client VirtualNetworkRulesClient) Get(ctx context.Context, resourceGroupName string, serverName string, virtualNetworkRuleName string) (result VirtualNetworkRule, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/VirtualNetworkRulesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, virtualNetworkRuleName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualNetworkRulesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.VirtualNetworkRulesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualNetworkRulesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client VirtualNetworkRulesClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, virtualNetworkRuleName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "virtualNetworkRuleName": autorest.Encode("path", virtualNetworkRuleName), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/virtualNetworkRules/{virtualNetworkRuleName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client VirtualNetworkRulesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client VirtualNetworkRulesClient) GetResponder(resp *http.Response) (result VirtualNetworkRule, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByServer gets a list of virtual network rules in a server. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +func (client VirtualNetworkRulesClient) ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result VirtualNetworkRuleListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/VirtualNetworkRulesClient.ListByServer") + defer func() { + sc := -1 + if result.vnrlr.Response.Response != nil { + sc = result.vnrlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByServerNextResults + req, err := client.ListByServerPreparer(ctx, resourceGroupName, serverName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualNetworkRulesClient", "ListByServer", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServerSender(req) + if err != nil { + result.vnrlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.VirtualNetworkRulesClient", "ListByServer", resp, "Failure sending request") + return + } + + result.vnrlr, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualNetworkRulesClient", "ListByServer", resp, "Failure responding to request") + return + } + if result.vnrlr.hasNextLink() && result.vnrlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByServerPreparer prepares the ListByServer request. +func (client VirtualNetworkRulesClient) ListByServerPreparer(ctx context.Context, resourceGroupName string, serverName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/virtualNetworkRules", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByServerSender sends the ListByServer request. The method will close the +// http.Response Body if it receives an error. +func (client VirtualNetworkRulesClient) ListByServerSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServerResponder handles the response to the ListByServer request. The method always +// closes the http.Response Body. +func (client VirtualNetworkRulesClient) ListByServerResponder(resp *http.Response) (result VirtualNetworkRuleListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByServerNextResults retrieves the next set of results, if any. +func (client VirtualNetworkRulesClient) listByServerNextResults(ctx context.Context, lastResults VirtualNetworkRuleListResult) (result VirtualNetworkRuleListResult, err error) { + req, err := lastResults.virtualNetworkRuleListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.VirtualNetworkRulesClient", "listByServerNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByServerSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.VirtualNetworkRulesClient", "listByServerNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByServerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.VirtualNetworkRulesClient", "listByServerNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByServerComplete enumerates all values, automatically crossing page boundaries as required. +func (client VirtualNetworkRulesClient) ListByServerComplete(ctx context.Context, resourceGroupName string, serverName string) (result VirtualNetworkRuleListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/VirtualNetworkRulesClient.ListByServer") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByServer(ctx, resourceGroupName, serverName) + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/workloadclassifiers.go b/services/preview/sql/mgmt/v5.0/sql/workloadclassifiers.go new file mode 100644 index 000000000000..8f2ec75cc043 --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/workloadclassifiers.go @@ -0,0 +1,420 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// WorkloadClassifiersClient is the the Azure SQL Database management API provides a RESTful set of web services that +// interact with Azure SQL Database services to manage your databases. The API enables you to create, retrieve, update, +// and delete databases. +type WorkloadClassifiersClient struct { + BaseClient +} + +// NewWorkloadClassifiersClient creates an instance of the WorkloadClassifiersClient client. +func NewWorkloadClassifiersClient(subscriptionID string) WorkloadClassifiersClient { + return NewWorkloadClassifiersClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewWorkloadClassifiersClientWithBaseURI creates an instance of the WorkloadClassifiersClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewWorkloadClassifiersClientWithBaseURI(baseURI string, subscriptionID string) WorkloadClassifiersClient { + return WorkloadClassifiersClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a workload classifier. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database. +// workloadGroupName - the name of the workload group from which to receive the classifier from. +// workloadClassifierName - the name of the workload classifier to create/update. +// parameters - the properties of the workload classifier. +func (client WorkloadClassifiersClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, workloadGroupName string, workloadClassifierName string, parameters WorkloadClassifier) (result WorkloadClassifiersCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkloadClassifiersClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.WorkloadClassifierProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.WorkloadClassifierProperties.MemberName", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("sql.WorkloadClassifiersClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, databaseName, workloadGroupName, workloadClassifierName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.WorkloadClassifiersClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.WorkloadClassifiersClient", "CreateOrUpdate", nil, "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client WorkloadClassifiersClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, workloadGroupName string, workloadClassifierName string, parameters WorkloadClassifier) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "workloadClassifierName": autorest.Encode("path", workloadClassifierName), + "workloadGroupName": autorest.Encode("path", workloadGroupName), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/workloadGroups/{workloadGroupName}/workloadClassifiers/{workloadClassifierName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client WorkloadClassifiersClient) CreateOrUpdateSender(req *http.Request) (future WorkloadClassifiersCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client WorkloadClassifiersClient) CreateOrUpdateResponder(resp *http.Response) (result WorkloadClassifier, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a workload classifier. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database. +// workloadGroupName - the name of the workload group from which to receive the classifier from. +// workloadClassifierName - the name of the workload classifier to delete. +func (client WorkloadClassifiersClient) Delete(ctx context.Context, resourceGroupName string, serverName string, databaseName string, workloadGroupName string, workloadClassifierName string) (result WorkloadClassifiersDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkloadClassifiersClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, serverName, databaseName, workloadGroupName, workloadClassifierName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.WorkloadClassifiersClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.WorkloadClassifiersClient", "Delete", nil, "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client WorkloadClassifiersClient) DeletePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, workloadGroupName string, workloadClassifierName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "workloadClassifierName": autorest.Encode("path", workloadClassifierName), + "workloadGroupName": autorest.Encode("path", workloadGroupName), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/workloadGroups/{workloadGroupName}/workloadClassifiers/{workloadClassifierName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client WorkloadClassifiersClient) DeleteSender(req *http.Request) (future WorkloadClassifiersDeleteFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client WorkloadClassifiersClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a workload classifier +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database. +// workloadGroupName - the name of the workload group from which to receive the classifier from. +// workloadClassifierName - the name of the workload classifier. +func (client WorkloadClassifiersClient) Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string, workloadGroupName string, workloadClassifierName string) (result WorkloadClassifier, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkloadClassifiersClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, databaseName, workloadGroupName, workloadClassifierName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.WorkloadClassifiersClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.WorkloadClassifiersClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.WorkloadClassifiersClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client WorkloadClassifiersClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, workloadGroupName string, workloadClassifierName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "workloadClassifierName": autorest.Encode("path", workloadClassifierName), + "workloadGroupName": autorest.Encode("path", workloadGroupName), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/workloadGroups/{workloadGroupName}/workloadClassifiers/{workloadClassifierName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client WorkloadClassifiersClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client WorkloadClassifiersClient) GetResponder(resp *http.Response) (result WorkloadClassifier, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByWorkloadGroup gets the list of workload classifiers for a workload group +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database. +// workloadGroupName - the name of the workload group from which to receive the classifiers from. +func (client WorkloadClassifiersClient) ListByWorkloadGroup(ctx context.Context, resourceGroupName string, serverName string, databaseName string, workloadGroupName string) (result WorkloadClassifierListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkloadClassifiersClient.ListByWorkloadGroup") + defer func() { + sc := -1 + if result.wclr.Response.Response != nil { + sc = result.wclr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByWorkloadGroupNextResults + req, err := client.ListByWorkloadGroupPreparer(ctx, resourceGroupName, serverName, databaseName, workloadGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.WorkloadClassifiersClient", "ListByWorkloadGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByWorkloadGroupSender(req) + if err != nil { + result.wclr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.WorkloadClassifiersClient", "ListByWorkloadGroup", resp, "Failure sending request") + return + } + + result.wclr, err = client.ListByWorkloadGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.WorkloadClassifiersClient", "ListByWorkloadGroup", resp, "Failure responding to request") + return + } + if result.wclr.hasNextLink() && result.wclr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByWorkloadGroupPreparer prepares the ListByWorkloadGroup request. +func (client WorkloadClassifiersClient) ListByWorkloadGroupPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, workloadGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "workloadGroupName": autorest.Encode("path", workloadGroupName), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/workloadGroups/{workloadGroupName}/workloadClassifiers", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByWorkloadGroupSender sends the ListByWorkloadGroup request. The method will close the +// http.Response Body if it receives an error. +func (client WorkloadClassifiersClient) ListByWorkloadGroupSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByWorkloadGroupResponder handles the response to the ListByWorkloadGroup request. The method always +// closes the http.Response Body. +func (client WorkloadClassifiersClient) ListByWorkloadGroupResponder(resp *http.Response) (result WorkloadClassifierListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByWorkloadGroupNextResults retrieves the next set of results, if any. +func (client WorkloadClassifiersClient) listByWorkloadGroupNextResults(ctx context.Context, lastResults WorkloadClassifierListResult) (result WorkloadClassifierListResult, err error) { + req, err := lastResults.workloadClassifierListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.WorkloadClassifiersClient", "listByWorkloadGroupNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByWorkloadGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.WorkloadClassifiersClient", "listByWorkloadGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByWorkloadGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.WorkloadClassifiersClient", "listByWorkloadGroupNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByWorkloadGroupComplete enumerates all values, automatically crossing page boundaries as required. +func (client WorkloadClassifiersClient) ListByWorkloadGroupComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string, workloadGroupName string) (result WorkloadClassifierListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkloadClassifiersClient.ListByWorkloadGroup") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByWorkloadGroup(ctx, resourceGroupName, serverName, databaseName, workloadGroupName) + return +} diff --git a/services/preview/sql/mgmt/v5.0/sql/workloadgroups.go b/services/preview/sql/mgmt/v5.0/sql/workloadgroups.go new file mode 100644 index 000000000000..19e9084c129a --- /dev/null +++ b/services/preview/sql/mgmt/v5.0/sql/workloadgroups.go @@ -0,0 +1,414 @@ +package sql + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// WorkloadGroupsClient is the the Azure SQL Database management API provides a RESTful set of web services that +// interact with Azure SQL Database services to manage your databases. The API enables you to create, retrieve, update, +// and delete databases. +type WorkloadGroupsClient struct { + BaseClient +} + +// NewWorkloadGroupsClient creates an instance of the WorkloadGroupsClient client. +func NewWorkloadGroupsClient(subscriptionID string) WorkloadGroupsClient { + return NewWorkloadGroupsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewWorkloadGroupsClientWithBaseURI creates an instance of the WorkloadGroupsClient client using a custom endpoint. +// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewWorkloadGroupsClientWithBaseURI(baseURI string, subscriptionID string) WorkloadGroupsClient { + return WorkloadGroupsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a workload group. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database. +// workloadGroupName - the name of the workload group. +// parameters - the requested workload group state. +func (client WorkloadGroupsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, workloadGroupName string, parameters WorkloadGroup) (result WorkloadGroupsCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkloadGroupsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.WorkloadGroupProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.WorkloadGroupProperties.MinResourcePercent", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.WorkloadGroupProperties.MaxResourcePercent", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.WorkloadGroupProperties.MinResourcePercentPerRequest", Name: validation.Null, Rule: true, Chain: nil}, + }}}}}); err != nil { + return result, validation.NewError("sql.WorkloadGroupsClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serverName, databaseName, workloadGroupName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.WorkloadGroupsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.WorkloadGroupsClient", "CreateOrUpdate", nil, "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client WorkloadGroupsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, workloadGroupName string, parameters WorkloadGroup) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "workloadGroupName": autorest.Encode("path", workloadGroupName), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/workloadGroups/{workloadGroupName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client WorkloadGroupsClient) CreateOrUpdateSender(req *http.Request) (future WorkloadGroupsCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client WorkloadGroupsClient) CreateOrUpdateResponder(resp *http.Response) (result WorkloadGroup, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a workload group. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database. +// workloadGroupName - the name of the workload group to delete. +func (client WorkloadGroupsClient) Delete(ctx context.Context, resourceGroupName string, serverName string, databaseName string, workloadGroupName string) (result WorkloadGroupsDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkloadGroupsClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, serverName, databaseName, workloadGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.WorkloadGroupsClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.WorkloadGroupsClient", "Delete", nil, "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client WorkloadGroupsClient) DeletePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, workloadGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "workloadGroupName": autorest.Encode("path", workloadGroupName), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/workloadGroups/{workloadGroupName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client WorkloadGroupsClient) DeleteSender(req *http.Request) (future WorkloadGroupsDeleteFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client WorkloadGroupsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a workload group +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database. +// workloadGroupName - the name of the workload group. +func (client WorkloadGroupsClient) Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string, workloadGroupName string) (result WorkloadGroup, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkloadGroupsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, serverName, databaseName, workloadGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.WorkloadGroupsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.WorkloadGroupsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.WorkloadGroupsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client WorkloadGroupsClient) GetPreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string, workloadGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "workloadGroupName": autorest.Encode("path", workloadGroupName), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/workloadGroups/{workloadGroupName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client WorkloadGroupsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client WorkloadGroupsClient) GetResponder(resp *http.Response) (result WorkloadGroup, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByDatabase gets the list of workload groups +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// serverName - the name of the server. +// databaseName - the name of the database. +func (client WorkloadGroupsClient) ListByDatabase(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result WorkloadGroupListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkloadGroupsClient.ListByDatabase") + defer func() { + sc := -1 + if result.wglr.Response.Response != nil { + sc = result.wglr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByDatabaseNextResults + req, err := client.ListByDatabasePreparer(ctx, resourceGroupName, serverName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.WorkloadGroupsClient", "ListByDatabase", nil, "Failure preparing request") + return + } + + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.wglr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "sql.WorkloadGroupsClient", "ListByDatabase", resp, "Failure sending request") + return + } + + result.wglr, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.WorkloadGroupsClient", "ListByDatabase", resp, "Failure responding to request") + return + } + if result.wglr.hasNextLink() && result.wglr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByDatabasePreparer prepares the ListByDatabase request. +func (client WorkloadGroupsClient) ListByDatabasePreparer(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serverName": autorest.Encode("path", serverName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/workloadGroups", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByDatabaseSender sends the ListByDatabase request. The method will close the +// http.Response Body if it receives an error. +func (client WorkloadGroupsClient) ListByDatabaseSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByDatabaseResponder handles the response to the ListByDatabase request. The method always +// closes the http.Response Body. +func (client WorkloadGroupsClient) ListByDatabaseResponder(resp *http.Response) (result WorkloadGroupListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByDatabaseNextResults retrieves the next set of results, if any. +func (client WorkloadGroupsClient) listByDatabaseNextResults(ctx context.Context, lastResults WorkloadGroupListResult) (result WorkloadGroupListResult, err error) { + req, err := lastResults.workloadGroupListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "sql.WorkloadGroupsClient", "listByDatabaseNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByDatabaseSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "sql.WorkloadGroupsClient", "listByDatabaseNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByDatabaseResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "sql.WorkloadGroupsClient", "listByDatabaseNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByDatabaseComplete enumerates all values, automatically crossing page boundaries as required. +func (client WorkloadGroupsClient) ListByDatabaseComplete(ctx context.Context, resourceGroupName string, serverName string, databaseName string) (result WorkloadGroupListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkloadGroupsClient.ListByDatabase") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByDatabase(ctx, resourceGroupName, serverName, databaseName) + return +} diff --git a/version/version.go b/version/version.go index 25ff8c0689b2..3e4ff42109fd 100644 --- a/version/version.go +++ b/version/version.go @@ -4,4 +4,4 @@ package version // Licensed under the MIT License. See License.txt in the project root for license information. // Number contains the semantic version of this SDK. -const Number = "v55.3.0" +const Number = "v55.4.0"