From 0b3ad839cea6029a6611548e088efb3276ed267e Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Tue, 1 Oct 2024 18:47:11 +0000 Subject: [PATCH] CodeGen from PR 30796 in Azure/azure-rest-api-specs Merge 35cfe08c583c3ef0dbe433c53f4eef038b1fb556 into 6d9e0951ddb28d567d54e4316bba6fa19626be43 --- .../GeneratedProtocol/ClustersOperations.cs | 2956 +++++++++++++++++ .../ClustersOperationsExtensions.cs | 837 +++++ .../ConfigurationsOperations.cs | 2230 +++++++++++++ .../ConfigurationsOperationsExtensions.cs | 525 +++ .../CosmosDBforPostgreSQLClient.cs | 403 +++ .../FirewallRulesOperations.cs | 1078 ++++++ .../FirewallRulesOperationsExtensions.cs | 313 ++ .../GeneratedProtocol/IClustersOperations.cs | 504 +++ .../IConfigurationsOperations.cs | 332 ++ .../ICosmosDBforPostgreSQLClient.cs | 114 + .../IFirewallRulesOperations.cs | 194 ++ .../GeneratedProtocol/IOperations.cs | 46 + .../IPrivateEndpointConnectionsOperations.cs | 201 ++ .../IPrivateLinkResourcesOperations.cs | 80 + .../GeneratedProtocol/IRolesOperations.cs | 192 ++ .../GeneratedProtocol/IServersOperations.cs | 80 + .../Models/AadEnabledEnum.cs | 22 + .../Models/ActiveDirectoryAuth.cs | 22 + .../GeneratedProtocol/Models/AuthConfig.cs | 61 + .../Models/AzureEntityResource.cs | 64 + .../GeneratedProtocol/Models/Cluster.cs | 430 +++ .../Models/ClusterForUpdate.cs | 226 ++ .../GeneratedProtocol/Models/ClusterServer.cs | 182 + .../Models/ClustersCreateHeaders.cs | 55 + .../Models/ClustersDeleteHeaders.cs | 55 + .../ClustersPromoteReadReplicaHeaders.cs | 57 + .../Models/ClustersRestartHeaders.cs | 55 + .../Models/ClustersStartHeaders.cs | 55 + .../Models/ClustersStopHeaders.cs | 55 + .../Models/ClustersUpdateHeaders.cs | 55 + .../GeneratedProtocol/Models/Configuration.cs | 141 + .../Models/ConfigurationDataType.cs | 24 + ...onfigurationsUpdateOnCoordinatorHeaders.cs | 57 + .../ConfigurationsUpdateOnNodeHeaders.cs | 57 + .../GeneratedProtocol/Models/CreatedByType.cs | 24 + .../Models/DataEncryption.cs | 74 + .../Models/DataEncryptionType.cs | 22 + .../Models/ErrorAdditionalInfo.cs | 59 + .../GeneratedProtocol/Models/ErrorDetail.cs | 85 + .../GeneratedProtocol/Models/ErrorResponse.cs | 56 + .../Models/ErrorResponseException.cs | 62 + .../GeneratedProtocol/Models/FirewallRule.cs | 117 + .../FirewallRulesCreateOrUpdateHeaders.cs | 57 + .../Models/FirewallRulesDeleteHeaders.cs | 55 + .../GeneratedProtocol/Models/Identity.cs | 72 + .../Models/IdentityProperties.cs | 61 + .../GeneratedProtocol/Models/IdentityType.cs | 22 + .../Models/MaintenanceWindow.cs | 82 + .../Models/NameAvailability.cs | 76 + .../Models/NameAvailabilityRequest.cs | 78 + .../GeneratedProtocol/Models/Operation.cs | 93 + .../Models/OperationDisplay.cs | 77 + .../Models/OperationOrigin.cs | 23 + .../GeneratedProtocol/Models/Page.cs | 53 + .../GeneratedProtocol/Models/Page1.cs | 53 + .../GeneratedProtocol/Models/PasswordAuth.cs | 22 + .../Models/PasswordEnabledEnum.cs | 22 + .../GeneratedProtocol/Models/Plan.cs | 116 + .../GeneratedProtocol/Models/PrincipalType.cs | 23 + .../Models/PrivateEndpoint.cs | 51 + .../Models/PrivateEndpointConnection.cs | 111 + ...vateEndpointConnectionProvisioningState.cs | 24 + ...ndpointConnectionsCreateOrUpdateHeaders.cs | 57 + ...PrivateEndpointConnectionsDeleteHeaders.cs | 57 + .../Models/PrivateEndpointProperty.cs | 51 + .../PrivateEndpointServiceConnectionStatus.cs | 23 + .../Models/PrivateLinkResource.cs | 83 + .../PrivateLinkServiceConnectionState.cs | 77 + .../Models/PromoteRequest.cs | 53 + .../Models/ProvisioningState.cs | 24 + .../GeneratedProtocol/Models/ProxyResource.cs | 55 + .../GeneratedProtocol/Models/Resource.cs | 89 + .../Models/ResourceIdentityType.cs | 54 + .../ResourceModelWithAllowedPropertySet.cs | 141 + ...urceModelWithAllowedPropertySetIdentity.cs | 48 + ...ResourceModelWithAllowedPropertySetPlan.cs | 63 + .../ResourceModelWithAllowedPropertySetSku.cs | 64 + .../GeneratedProtocol/Models/Role.cs | 124 + .../GeneratedProtocol/Models/RoleType.cs | 22 + .../Models/RolesCreateHeaders.cs | 55 + .../Models/RolesDeleteHeaders.cs | 55 + .../Models/ServerConfiguration.cs | 141 + .../Models/ServerNameItem.cs | 60 + .../Models/ServerProperties.cs | 106 + .../GeneratedProtocol/Models/ServerRole.cs | 22 + .../Models/ServerRoleGroupConfiguration.cs | 98 + .../Models/SimplePrivateEndpointConnection.cs | 83 + .../GeneratedProtocol/Models/Sku.cs | 110 + .../GeneratedProtocol/Models/SkuTier.cs | 72 + .../GeneratedProtocol/Models/SystemData.cs | 103 + .../Models/TrackedResource.cs | 89 + .../Models/UserAssignedIdentity.cs | 61 + .../GeneratedProtocol/Operations.cs | 229 ++ .../GeneratedProtocol/OperationsExtensions.cs | 55 + .../PrivateEndpointConnectionsOperations.cs | 1076 ++++++ ...EndpointConnectionsOperationsExtensions.cs | 309 ++ .../PrivateLinkResourcesOperations.cs | 510 +++ ...rivateLinkResourcesOperationsExtensions.cs | 113 + .../GeneratedProtocol/RolesOperations.cs | 1076 ++++++ .../RolesOperationsExtensions.cs | 309 ++ .../SdkInfo_CosmosDBforPostgreSQL.cs | 34 + .../GeneratedProtocol/ServersOperations.cs | 518 +++ .../ServersOperationsExtensions.cs | 113 + .../src/Generated/AdvisorsOperations.cs | 660 ++++ .../Generated/AdvisorsOperationsExtensions.cs | 145 + .../CheckNameAvailabilityOperations.cs | 255 ++ ...eckNameAvailabilityOperationsExtensions.cs | 59 + .../src/Generated/ConfigurationsOperations.cs | 750 +++++ .../ConfigurationsOperationsExtensions.cs | 217 ++ .../src/Generated/DatabasesOperations.cs | 993 ++++++ .../DatabasesOperationsExtensions.cs | 303 ++ .../src/Generated/FirewallRulesOperations.cs | 997 ++++++ .../FirewallRulesOperationsExtensions.cs | 303 ++ .../src/Generated/IAdvisorsOperations.cs | 102 + .../ICheckNameAvailabilityOperations.cs | 49 + .../Generated/IConfigurationsOperations.cs | 142 + .../src/Generated/IDatabasesOperations.cs | 192 ++ .../src/Generated/IFirewallRulesOperations.cs | 192 ++ ...ILocationBasedPerformanceTierOperations.cs | 50 + ...ActionSessionsOperationStatusOperations.cs | 52 + ...commendedActionSessionsResultOperations.cs | 74 + .../src/Generated/ILogFilesOperations.cs | 52 + .../src/Generated/IMariaDBManagementClient.cs | 253 ++ .../src/Generated/IOperations.cs | 46 + .../IPrivateEndpointConnectionsOperations.cs | 276 ++ .../IPrivateLinkResourcesOperations.cs | 102 + .../src/Generated/IQueryTextsOperations.cs | 105 + .../IRecommendedActionsOperations.cs | 111 + .../IRecoverableServersOperations.cs | 52 + .../src/Generated/IReplicasOperations.cs | 52 + .../IServerBasedPerformanceTierOperations.cs | 52 + .../Generated/IServerParametersOperations.cs | 83 + .../IServerSecurityAlertPoliciesOperations.cs | 155 + .../src/Generated/IServersOperations.cs | 385 +++ .../ITopQueryStatisticsOperations.cs | 107 + .../IVirtualNetworkRulesOperations.cs | 214 ++ .../Generated/IWaitStatisticsOperations.cs | 105 + .../LocationBasedPerformanceTierOperations.cs | 247 ++ ...asedPerformanceTierOperationsExtensions.cs | 63 + ...ActionSessionsOperationStatusOperations.cs | 255 ++ ...ionsOperationStatusOperationsExtensions.cs | 65 + ...commendedActionSessionsResultOperations.cs | 464 +++ ...ctionSessionsResultOperationsExtensions.cs | 99 + .../src/Generated/LogFilesOperations.cs | 266 ++ .../Generated/LogFilesOperationsExtensions.cs | 67 + .../src/Generated/MariaDBManagementClient.cs | 945 ++++++ .../MariaDBManagementClientExtensions.cs | 163 + .../src/Generated/Models/Advisor.cs | 59 + .../Generated/Models/AzureEntityResource.cs | 62 + .../src/Generated/Models/Configuration.cs | 103 + .../Models/ConfigurationListResult.cs | 53 + .../src/Generated/Models/Database.cs | 69 + .../Generated/Models/ErrorAdditionalInfo.cs | 59 + .../src/Generated/Models/ErrorResponse.cs | 90 + .../src/Generated/Models/FirewallRule.cs | 104 + .../Generated/Models/GeoRedundantBackup.cs | 22 + .../src/Generated/Models/LogFile.cs | 95 + .../Generated/Models/MinimalTlsVersionEnum.cs | 24 + .../src/Generated/Models/NameAvailability.cs | 68 + .../Models/NameAvailabilityRequest.cs | 73 + .../src/Generated/Models/Operation.cs | 84 + .../src/Generated/Models/OperationDisplay.cs | 77 + .../Generated/Models/OperationListResult.cs | 54 + .../src/Generated/Models/OperationOrigin.cs | 23 + .../src/Generated/Models/Page.cs | 53 + .../src/Generated/Models/Page1.cs | 53 + .../Models/PerformanceTierProperties.cs | 119 + .../PerformanceTierServiceLevelObjectives.cs | 118 + .../Models/PrivateEndpointConnection.cs | 93 + .../Models/PrivateEndpointProperty.cs | 50 + .../PrivateEndpointProvisioningState.cs | 25 + .../Generated/Models/PrivateLinkResource.cs | 59 + .../Models/PrivateLinkResourceProperties.cs | 64 + ...inkServiceConnectionStateActionsRequire.cs | 21 + ...ivateLinkServiceConnectionStateProperty.cs | 87 + ...PrivateLinkServiceConnectionStateStatus.cs | 24 + .../src/Generated/Models/ProxyResource.cs | 53 + .../Models/PublicNetworkAccessEnum.cs | 22 + .../QueryPerformanceInsightResetDataResult.cs | 63 + ...yPerformanceInsightResetDataResultState.cs | 22 + .../src/Generated/Models/QueryStatistic.cs | 137 + .../src/Generated/Models/QueryText.cs | 70 + .../Generated/Models/RecommendationAction.cs | 123 + ...ecommendedActionSessionsOperationStatus.cs | 69 + .../Models/RecoverableServerResource.cs | 106 + .../src/Generated/Models/Resource.cs | 79 + .../src/Generated/Models/Server.cs | 226 ++ .../src/Generated/Models/ServerForCreate.cs | 102 + .../Models/ServerPrivateEndpointConnection.cs | 76 + ...rverPrivateEndpointConnectionProperties.cs | 87 + ...ivateLinkServiceConnectionStateProperty.cs | 90 + .../Models/ServerPropertiesForCreate.cs | 97 + .../ServerPropertiesForDefaultCreate.cs | 99 + .../Models/ServerPropertiesForGeoRestore.cs | 84 + .../Models/ServerPropertiesForReplica.cs | 81 + .../Models/ServerPropertiesForRestore.cs | 91 + .../Models/ServerSecurityAlertPolicy.cs | 139 + .../Models/ServerSecurityAlertPolicyState.cs | 60 + .../src/Generated/Models/ServerState.cs | 23 + .../Models/ServerUpdateParameters.cs | 151 + .../src/Generated/Models/ServerVersion.cs | 22 + .../src/Generated/Models/Sku.cs | 110 + .../src/Generated/Models/SkuTier.cs | 23 + .../Generated/Models/SslEnforcementEnum.cs | 60 + .../src/Generated/Models/StorageAutogrow.cs | 22 + .../src/Generated/Models/StorageProfile.cs | 81 + .../src/Generated/Models/TagsObject.cs | 53 + .../Models/TopQueryStatisticsInput.cs | 118 + .../src/Generated/Models/TrackedResource.cs | 87 + .../Generated/Models/VirtualNetworkRule.cs | 97 + .../Models/VirtualNetworkRuleState.cs | 25 + .../src/Generated/Models/WaitStatistic.cs | 128 + .../Generated/Models/WaitStatisticsInput.cs | 84 + .../src/Generated/Operations.cs | 219 ++ .../src/Generated/OperationsExtensions.cs | 53 + .../PrivateEndpointConnectionsOperations.cs | 1415 ++++++++ ...EndpointConnectionsOperationsExtensions.cs | 439 +++ .../PrivateLinkResourcesOperations.cs | 660 ++++ ...rivateLinkResourcesOperationsExtensions.cs | 145 + .../src/Generated/QueryTextsOperations.cs | 682 ++++ .../QueryTextsOperationsExtensions.cs | 153 + .../Generated/RecommendedActionsOperations.cs | 686 ++++ .../RecommendedActionsOperationsExtensions.cs | 163 + .../Generated/RecoverableServersOperations.cs | 266 ++ .../RecoverableServersOperationsExtensions.cs | 65 + .../src/Generated/ReplicasOperations.cs | 266 ++ .../Generated/ReplicasOperationsExtensions.cs | 67 + .../SdkInfo_MariaDBManagementClient.cs | 52 + .../ServerBasedPerformanceTierOperations.cs | 266 ++ ...asedPerformanceTierOperationsExtensions.cs | 67 + .../Generated/ServerParametersOperations.cs | 305 ++ .../ServerParametersOperationsExtensions.cs | 117 + .../ServerSecurityAlertPoliciesOperations.cs | 912 +++++ ...curityAlertPoliciesOperationsExtensions.cs | 231 ++ .../src/Generated/ServersOperations.cs | 2032 +++++++++++ .../Generated/ServersOperationsExtensions.cs | 617 ++++ .../Generated/TopQueryStatisticsOperations.cs | 678 ++++ .../TopQueryStatisticsOperationsExtensions.cs | 151 + .../VirtualNetworkRulesOperations.cs | 1170 +++++++ ...VirtualNetworkRulesOperationsExtensions.cs | 335 ++ .../src/Generated/WaitStatisticsOperations.cs | 678 ++++ .../WaitStatisticsOperationsExtensions.cs | 151 + 242 files changed, 48215 insertions(+) create mode 100644 sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/ClustersOperations.cs create mode 100644 sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/ClustersOperationsExtensions.cs create mode 100644 sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/ConfigurationsOperations.cs create mode 100644 sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/ConfigurationsOperationsExtensions.cs create mode 100644 sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/CosmosDBforPostgreSQLClient.cs create mode 100644 sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/FirewallRulesOperations.cs create mode 100644 sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/FirewallRulesOperationsExtensions.cs create mode 100644 sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/IClustersOperations.cs create mode 100644 sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/IConfigurationsOperations.cs create mode 100644 sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/ICosmosDBforPostgreSQLClient.cs create mode 100644 sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/IFirewallRulesOperations.cs create mode 100644 sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/IOperations.cs create mode 100644 sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/IPrivateEndpointConnectionsOperations.cs create mode 100644 sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/IPrivateLinkResourcesOperations.cs create mode 100644 sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/IRolesOperations.cs create mode 100644 sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/IServersOperations.cs create mode 100644 sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/AadEnabledEnum.cs create mode 100644 sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ActiveDirectoryAuth.cs create mode 100644 sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/AuthConfig.cs create mode 100644 sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/AzureEntityResource.cs create mode 100644 sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/Cluster.cs create mode 100644 sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ClusterForUpdate.cs create mode 100644 sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ClusterServer.cs create mode 100644 sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ClustersCreateHeaders.cs create mode 100644 sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ClustersDeleteHeaders.cs create mode 100644 sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ClustersPromoteReadReplicaHeaders.cs create mode 100644 sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ClustersRestartHeaders.cs create mode 100644 sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ClustersStartHeaders.cs create mode 100644 sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ClustersStopHeaders.cs create mode 100644 sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ClustersUpdateHeaders.cs create mode 100644 sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/Configuration.cs create mode 100644 sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ConfigurationDataType.cs create mode 100644 sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ConfigurationsUpdateOnCoordinatorHeaders.cs create mode 100644 sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ConfigurationsUpdateOnNodeHeaders.cs create mode 100644 sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/CreatedByType.cs create mode 100644 sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/DataEncryption.cs create mode 100644 sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/DataEncryptionType.cs create mode 100644 sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ErrorAdditionalInfo.cs create mode 100644 sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ErrorDetail.cs create mode 100644 sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ErrorResponse.cs create mode 100644 sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ErrorResponseException.cs create mode 100644 sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/FirewallRule.cs create mode 100644 sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/FirewallRulesCreateOrUpdateHeaders.cs create mode 100644 sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/FirewallRulesDeleteHeaders.cs create mode 100644 sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/Identity.cs create mode 100644 sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/IdentityProperties.cs create mode 100644 sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/IdentityType.cs create mode 100644 sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/MaintenanceWindow.cs create mode 100644 sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/NameAvailability.cs create mode 100644 sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/NameAvailabilityRequest.cs create mode 100644 sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/Operation.cs create mode 100644 sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/OperationDisplay.cs create mode 100644 sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/OperationOrigin.cs create mode 100644 sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/Page.cs create mode 100644 sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/Page1.cs create mode 100644 sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/PasswordAuth.cs create mode 100644 sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/PasswordEnabledEnum.cs create mode 100644 sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/Plan.cs create mode 100644 sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/PrincipalType.cs create mode 100644 sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/PrivateEndpoint.cs create mode 100644 sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/PrivateEndpointConnection.cs create mode 100644 sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/PrivateEndpointConnectionProvisioningState.cs create mode 100644 sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/PrivateEndpointConnectionsCreateOrUpdateHeaders.cs create mode 100644 sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/PrivateEndpointConnectionsDeleteHeaders.cs create mode 100644 sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/PrivateEndpointProperty.cs create mode 100644 sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/PrivateEndpointServiceConnectionStatus.cs create mode 100644 sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/PrivateLinkResource.cs create mode 100644 sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/PrivateLinkServiceConnectionState.cs create mode 100644 sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/PromoteRequest.cs create mode 100644 sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ProvisioningState.cs create mode 100644 sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ProxyResource.cs create mode 100644 sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/Resource.cs create mode 100644 sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ResourceIdentityType.cs create mode 100644 sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ResourceModelWithAllowedPropertySet.cs create mode 100644 sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ResourceModelWithAllowedPropertySetIdentity.cs create mode 100644 sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ResourceModelWithAllowedPropertySetPlan.cs create mode 100644 sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ResourceModelWithAllowedPropertySetSku.cs create mode 100644 sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/Role.cs create mode 100644 sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/RoleType.cs create mode 100644 sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/RolesCreateHeaders.cs create mode 100644 sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/RolesDeleteHeaders.cs create mode 100644 sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ServerConfiguration.cs create mode 100644 sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ServerNameItem.cs create mode 100644 sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ServerProperties.cs create mode 100644 sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ServerRole.cs create mode 100644 sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ServerRoleGroupConfiguration.cs create mode 100644 sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/SimplePrivateEndpointConnection.cs create mode 100644 sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/Sku.cs create mode 100644 sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/SkuTier.cs create mode 100644 sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/SystemData.cs create mode 100644 sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/TrackedResource.cs create mode 100644 sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/UserAssignedIdentity.cs create mode 100644 sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Operations.cs create mode 100644 sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/OperationsExtensions.cs create mode 100644 sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/PrivateEndpointConnectionsOperations.cs create mode 100644 sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/PrivateEndpointConnectionsOperationsExtensions.cs create mode 100644 sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/PrivateLinkResourcesOperations.cs create mode 100644 sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/PrivateLinkResourcesOperationsExtensions.cs create mode 100644 sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/RolesOperations.cs create mode 100644 sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/RolesOperationsExtensions.cs create mode 100644 sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/SdkInfo_CosmosDBforPostgreSQL.cs create mode 100644 sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/ServersOperations.cs create mode 100644 sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/ServersOperationsExtensions.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/AdvisorsOperations.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/AdvisorsOperationsExtensions.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/CheckNameAvailabilityOperations.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/CheckNameAvailabilityOperationsExtensions.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/ConfigurationsOperations.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/ConfigurationsOperationsExtensions.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/DatabasesOperations.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/DatabasesOperationsExtensions.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/FirewallRulesOperations.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/FirewallRulesOperationsExtensions.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/IAdvisorsOperations.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/ICheckNameAvailabilityOperations.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/IConfigurationsOperations.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/IDatabasesOperations.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/IFirewallRulesOperations.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/ILocationBasedPerformanceTierOperations.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/ILocationBasedRecommendedActionSessionsOperationStatusOperations.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/ILocationBasedRecommendedActionSessionsResultOperations.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/ILogFilesOperations.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/IMariaDBManagementClient.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/IOperations.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/IPrivateEndpointConnectionsOperations.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/IPrivateLinkResourcesOperations.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/IQueryTextsOperations.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/IRecommendedActionsOperations.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/IRecoverableServersOperations.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/IReplicasOperations.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/IServerBasedPerformanceTierOperations.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/IServerParametersOperations.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/IServerSecurityAlertPoliciesOperations.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/IServersOperations.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/ITopQueryStatisticsOperations.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/IVirtualNetworkRulesOperations.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/IWaitStatisticsOperations.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/LocationBasedPerformanceTierOperations.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/LocationBasedPerformanceTierOperationsExtensions.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/LocationBasedRecommendedActionSessionsOperationStatusOperations.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/LocationBasedRecommendedActionSessionsOperationStatusOperationsExtensions.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/LocationBasedRecommendedActionSessionsResultOperations.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/LocationBasedRecommendedActionSessionsResultOperationsExtensions.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/LogFilesOperations.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/LogFilesOperationsExtensions.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/MariaDBManagementClient.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/MariaDBManagementClientExtensions.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/Advisor.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/AzureEntityResource.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/Configuration.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/ConfigurationListResult.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/Database.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/ErrorAdditionalInfo.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/ErrorResponse.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/FirewallRule.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/GeoRedundantBackup.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/LogFile.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/MinimalTlsVersionEnum.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/NameAvailability.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/NameAvailabilityRequest.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/Operation.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/OperationDisplay.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/OperationListResult.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/OperationOrigin.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/Page.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/Page1.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/PerformanceTierProperties.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/PerformanceTierServiceLevelObjectives.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/PrivateEndpointConnection.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/PrivateEndpointProperty.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/PrivateEndpointProvisioningState.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/PrivateLinkResource.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/PrivateLinkResourceProperties.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/PrivateLinkServiceConnectionStateActionsRequire.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/PrivateLinkServiceConnectionStateProperty.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/PrivateLinkServiceConnectionStateStatus.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/ProxyResource.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/PublicNetworkAccessEnum.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/QueryPerformanceInsightResetDataResult.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/QueryPerformanceInsightResetDataResultState.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/QueryStatistic.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/QueryText.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/RecommendationAction.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/RecommendedActionSessionsOperationStatus.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/RecoverableServerResource.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/Resource.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/Server.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/ServerForCreate.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/ServerPrivateEndpointConnection.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/ServerPrivateEndpointConnectionProperties.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/ServerPrivateLinkServiceConnectionStateProperty.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/ServerPropertiesForCreate.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/ServerPropertiesForDefaultCreate.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/ServerPropertiesForGeoRestore.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/ServerPropertiesForReplica.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/ServerPropertiesForRestore.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/ServerSecurityAlertPolicy.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/ServerSecurityAlertPolicyState.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/ServerState.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/ServerUpdateParameters.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/ServerVersion.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/Sku.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/SkuTier.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/SslEnforcementEnum.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/StorageAutogrow.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/StorageProfile.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/TagsObject.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/TopQueryStatisticsInput.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/TrackedResource.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/VirtualNetworkRule.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/VirtualNetworkRuleState.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/WaitStatistic.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/WaitStatisticsInput.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Operations.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/OperationsExtensions.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/PrivateEndpointConnectionsOperations.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/PrivateEndpointConnectionsOperationsExtensions.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/PrivateLinkResourcesOperations.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/PrivateLinkResourcesOperationsExtensions.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/QueryTextsOperations.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/QueryTextsOperationsExtensions.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/RecommendedActionsOperations.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/RecommendedActionsOperationsExtensions.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/RecoverableServersOperations.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/RecoverableServersOperationsExtensions.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/ReplicasOperations.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/ReplicasOperationsExtensions.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/SdkInfo_MariaDBManagementClient.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/ServerBasedPerformanceTierOperations.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/ServerBasedPerformanceTierOperationsExtensions.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/ServerParametersOperations.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/ServerParametersOperationsExtensions.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/ServerSecurityAlertPoliciesOperations.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/ServerSecurityAlertPoliciesOperationsExtensions.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/ServersOperations.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/ServersOperationsExtensions.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/TopQueryStatisticsOperations.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/TopQueryStatisticsOperationsExtensions.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/VirtualNetworkRulesOperations.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/VirtualNetworkRulesOperationsExtensions.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/WaitStatisticsOperations.cs create mode 100644 sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/WaitStatisticsOperationsExtensions.cs diff --git a/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/ClustersOperations.cs b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/ClustersOperations.cs new file mode 100644 index 000000000000..e355a32bddb7 --- /dev/null +++ b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/ClustersOperations.cs @@ -0,0 +1,2956 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDBForPostgreSql +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// ClustersOperations operations. + /// + internal partial class ClustersOperations : IServiceOperations, IClustersOperations + { + /// + /// Initializes a new instance of the ClustersOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal ClustersOperations(CosmosDBforPostgreSQLClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the CosmosDBforPostgreSQLClient + /// + public CosmosDBforPostgreSQLClient Client { get; private set; } + + /// + /// Lists all clusters in a subscription. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.DBforPostgreSQL/serverGroupsv2").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(Client.SubscriptionId, Client.SerializationSettings).Trim('"'))); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Lists all clusters in a resource group. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListByResourceGroupWithHttpMessagesAsync(string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByResourceGroup", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/serverGroupsv2").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(Client.SubscriptionId, Client.SerializationSettings).Trim('"'))); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Creates a new cluster with servers. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The required parameters for creating or updating a cluster. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> CreateWithHttpMessagesAsync(string resourceGroupName, string clusterName, Cluster parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginCreateWithHttpMessagesAsync(resourceGroupName, clusterName, parameters, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets information about a cluster such as compute and storage configuration + /// and cluster lifecycle metadata such as cluster creation date and time. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetWithHttpMessagesAsync(string resourceGroupName, string clusterName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (clusterName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "clusterName"); + } + if (clusterName != null) + { + if (clusterName.Length > 40) + { + throw new ValidationException(ValidationRules.MaxLength, "clusterName", 40); + } + if (clusterName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "clusterName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(clusterName, "^(?![0-9]+$)(?!-)[a-z0-9-]{3,40}(? tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("clusterName", clusterName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/serverGroupsv2/{clusterName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(Client.SubscriptionId, Client.SerializationSettings).Trim('"'))); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{clusterName}", System.Uri.EscapeDataString(clusterName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Deletes a cluster together with servers in it. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> DeleteWithHttpMessagesAsync(string resourceGroupName, string clusterName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationHeaderResponse _response = await BeginDeleteWithHttpMessagesAsync(resourceGroupName, clusterName, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Updates an existing cluster. The request body can contain one or several + /// properties from the cluster definition. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The parameters for updating a cluster. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> UpdateWithHttpMessagesAsync(string resourceGroupName, string clusterName, ClusterForUpdate parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginUpdateWithHttpMessagesAsync(resourceGroupName, clusterName, parameters, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Restarts all nodes in the cluster. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> RestartWithHttpMessagesAsync(string resourceGroupName, string clusterName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationHeaderResponse _response = await BeginRestartWithHttpMessagesAsync(resourceGroupName, clusterName, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Starts stopped compute on all cluster nodes. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> StartWithHttpMessagesAsync(string resourceGroupName, string clusterName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationHeaderResponse _response = await BeginStartWithHttpMessagesAsync(resourceGroupName, clusterName, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Stops compute on all cluster nodes. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> StopWithHttpMessagesAsync(string resourceGroupName, string clusterName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationHeaderResponse _response = await BeginStopWithHttpMessagesAsync(resourceGroupName, clusterName, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Promotes read replica cluster to an independent read-write cluster. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// Boolean property to enable geo-redundant replica promotion. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> PromoteReadReplicaWithHttpMessagesAsync(string resourceGroupName, string clusterName, bool? enableGeoBackup = default(bool?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationHeaderResponse _response = await BeginPromoteReadReplicaWithHttpMessagesAsync(resourceGroupName, clusterName, enableGeoBackup, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Checks availability of a cluster name. Cluster names should be globally + /// unique; at least 3 characters and at most 40 characters long; they must + /// only contain lowercase letters, numbers, and hyphens; and must not start or + /// end with a hyphen. + /// + /// + /// Cluster name to verify. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> CheckNameAvailabilityWithHttpMessagesAsync(string name, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + if (name == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "name"); + } + NameAvailabilityRequest nameAvailabilityRequest = new NameAvailabilityRequest(); + if (name != null) + { + nameAvailabilityRequest.Name = name; + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nameAvailabilityRequest", nameAvailabilityRequest); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "CheckNameAvailability", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.DBforPostgreSQL/checkNameAvailability").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(Client.SubscriptionId, Client.SerializationSettings).Trim('"'))); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(nameAvailabilityRequest != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(nameAvailabilityRequest, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Creates a new cluster with servers. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The required parameters for creating or updating a cluster. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> BeginCreateWithHttpMessagesAsync(string resourceGroupName, string clusterName, Cluster parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (clusterName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "clusterName"); + } + if (clusterName != null) + { + if (clusterName.Length > 40) + { + throw new ValidationException(ValidationRules.MaxLength, "clusterName", 40); + } + if (clusterName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "clusterName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(clusterName, "^(?![0-9]+$)(?!-)[a-z0-9-]{3,40}(? tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("clusterName", clusterName); + tracingParameters.Add("parameters", parameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginCreate", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/serverGroupsv2/{clusterName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(Client.SubscriptionId, Client.SerializationSettings).Trim('"'))); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{clusterName}", System.Uri.EscapeDataString(clusterName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PUT"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(parameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 201) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + // Deserialize Response + if ((int)_statusCode == 201) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + try + { + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().ToString(), ex); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Deletes a cluster together with servers in it. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string clusterName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (clusterName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "clusterName"); + } + if (clusterName != null) + { + if (clusterName.Length > 40) + { + throw new ValidationException(ValidationRules.MaxLength, "clusterName", 40); + } + if (clusterName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "clusterName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(clusterName, "^(?![0-9]+$)(?!-)[a-z0-9-]{3,40}(? tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("clusterName", clusterName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginDelete", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/serverGroupsv2/{clusterName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(Client.SubscriptionId, Client.SerializationSettings).Trim('"'))); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{clusterName}", System.Uri.EscapeDataString(clusterName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("DELETE"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 202 && (int)_statusCode != 204) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationHeaderResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + try + { + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().ToString(), ex); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Updates an existing cluster. The request body can contain one or several + /// properties from the cluster definition. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The parameters for updating a cluster. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> BeginUpdateWithHttpMessagesAsync(string resourceGroupName, string clusterName, ClusterForUpdate parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (clusterName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "clusterName"); + } + if (clusterName != null) + { + if (clusterName.Length > 40) + { + throw new ValidationException(ValidationRules.MaxLength, "clusterName", 40); + } + if (clusterName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "clusterName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(clusterName, "^(?![0-9]+$)(?!-)[a-z0-9-]{3,40}(? tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("clusterName", clusterName); + tracingParameters.Add("parameters", parameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginUpdate", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/serverGroupsv2/{clusterName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(Client.SubscriptionId, Client.SerializationSettings).Trim('"'))); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{clusterName}", System.Uri.EscapeDataString(clusterName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PATCH"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(parameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 202) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + // Deserialize Response + if ((int)_statusCode == 202) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + try + { + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().ToString(), ex); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Restarts all nodes in the cluster. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> BeginRestartWithHttpMessagesAsync(string resourceGroupName, string clusterName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (clusterName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "clusterName"); + } + if (clusterName != null) + { + if (clusterName.Length > 40) + { + throw new ValidationException(ValidationRules.MaxLength, "clusterName", 40); + } + if (clusterName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "clusterName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(clusterName, "^(?![0-9]+$)(?!-)[a-z0-9-]{3,40}(? tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("clusterName", clusterName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginRestart", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/serverGroupsv2/{clusterName}/restart").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(Client.SubscriptionId, Client.SerializationSettings).Trim('"'))); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{clusterName}", System.Uri.EscapeDataString(clusterName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 202) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationHeaderResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + try + { + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().ToString(), ex); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Starts stopped compute on all cluster nodes. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> BeginStartWithHttpMessagesAsync(string resourceGroupName, string clusterName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (clusterName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "clusterName"); + } + if (clusterName != null) + { + if (clusterName.Length > 40) + { + throw new ValidationException(ValidationRules.MaxLength, "clusterName", 40); + } + if (clusterName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "clusterName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(clusterName, "^(?![0-9]+$)(?!-)[a-z0-9-]{3,40}(? tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("clusterName", clusterName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginStart", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/serverGroupsv2/{clusterName}/start").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(Client.SubscriptionId, Client.SerializationSettings).Trim('"'))); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{clusterName}", System.Uri.EscapeDataString(clusterName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 202) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationHeaderResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + try + { + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().ToString(), ex); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Stops compute on all cluster nodes. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> BeginStopWithHttpMessagesAsync(string resourceGroupName, string clusterName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (clusterName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "clusterName"); + } + if (clusterName != null) + { + if (clusterName.Length > 40) + { + throw new ValidationException(ValidationRules.MaxLength, "clusterName", 40); + } + if (clusterName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "clusterName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(clusterName, "^(?![0-9]+$)(?!-)[a-z0-9-]{3,40}(? tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("clusterName", clusterName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginStop", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/serverGroupsv2/{clusterName}/stop").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(Client.SubscriptionId, Client.SerializationSettings).Trim('"'))); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{clusterName}", System.Uri.EscapeDataString(clusterName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 202) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationHeaderResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + try + { + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().ToString(), ex); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Promotes read replica cluster to an independent read-write cluster. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// Boolean property to enable geo-redundant replica promotion. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> BeginPromoteReadReplicaWithHttpMessagesAsync(string resourceGroupName, string clusterName, bool? enableGeoBackup = default(bool?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (clusterName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "clusterName"); + } + if (clusterName != null) + { + if (clusterName.Length > 40) + { + throw new ValidationException(ValidationRules.MaxLength, "clusterName", 40); + } + if (clusterName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "clusterName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(clusterName, "^(?![0-9]+$)(?!-)[a-z0-9-]{3,40}(? tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("clusterName", clusterName); + tracingParameters.Add("promoteRequest", promoteRequest); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginPromoteReadReplica", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/serverGroupsv2/{clusterName}/promote").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(Client.SubscriptionId, Client.SerializationSettings).Trim('"'))); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{clusterName}", System.Uri.EscapeDataString(clusterName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(promoteRequest != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(promoteRequest, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 202) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationHeaderResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + try + { + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().ToString(), ex); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Lists all clusters in a subscription. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Lists all clusters in a resource group. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListByResourceGroupNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByResourceGroupNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/ClustersOperationsExtensions.cs b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/ClustersOperationsExtensions.cs new file mode 100644 index 000000000000..e8977950ed30 --- /dev/null +++ b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/ClustersOperationsExtensions.cs @@ -0,0 +1,837 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDBForPostgreSql +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for ClustersOperations. + /// + public static partial class ClustersOperationsExtensions + { + /// + /// Lists all clusters in a subscription. + /// + /// + /// The operations group for this extension method. + /// + public static IPage List(this IClustersOperations operations) + { + return operations.ListAsync().GetAwaiter().GetResult(); + } + + /// + /// Lists all clusters in a subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAsync(this IClustersOperations operations, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Lists all clusters in a resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + public static IPage ListByResourceGroup(this IClustersOperations operations, string resourceGroupName) + { + return operations.ListByResourceGroupAsync(resourceGroupName).GetAwaiter().GetResult(); + } + + /// + /// Lists all clusters in a resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByResourceGroupAsync(this IClustersOperations operations, string resourceGroupName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByResourceGroupWithHttpMessagesAsync(resourceGroupName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Creates a new cluster with servers. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The required parameters for creating or updating a cluster. + /// + public static Cluster Create(this IClustersOperations operations, string resourceGroupName, string clusterName, Cluster parameters) + { + return operations.CreateAsync(resourceGroupName, clusterName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Creates a new cluster with servers. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The required parameters for creating or updating a cluster. + /// + /// + /// The cancellation token. + /// + public static async Task CreateAsync(this IClustersOperations operations, string resourceGroupName, string clusterName, Cluster parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateWithHttpMessagesAsync(resourceGroupName, clusterName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets information about a cluster such as compute and storage configuration + /// and cluster lifecycle metadata such as cluster creation date and time. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + public static Cluster Get(this IClustersOperations operations, string resourceGroupName, string clusterName) + { + return operations.GetAsync(resourceGroupName, clusterName).GetAwaiter().GetResult(); + } + + /// + /// Gets information about a cluster such as compute and storage configuration + /// and cluster lifecycle metadata such as cluster creation date and time. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IClustersOperations operations, string resourceGroupName, string clusterName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, clusterName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes a cluster together with servers in it. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + public static ClustersDeleteHeaders Delete(this IClustersOperations operations, string resourceGroupName, string clusterName) + { + return operations.DeleteAsync(resourceGroupName, clusterName).GetAwaiter().GetResult(); + } + + /// + /// Deletes a cluster together with servers in it. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this IClustersOperations operations, string resourceGroupName, string clusterName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.DeleteWithHttpMessagesAsync(resourceGroupName, clusterName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Headers; + } + } + + /// + /// Updates an existing cluster. The request body can contain one or several + /// properties from the cluster definition. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The parameters for updating a cluster. + /// + public static Cluster Update(this IClustersOperations operations, string resourceGroupName, string clusterName, ClusterForUpdate parameters) + { + return operations.UpdateAsync(resourceGroupName, clusterName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Updates an existing cluster. The request body can contain one or several + /// properties from the cluster definition. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The parameters for updating a cluster. + /// + /// + /// The cancellation token. + /// + public static async Task UpdateAsync(this IClustersOperations operations, string resourceGroupName, string clusterName, ClusterForUpdate parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.UpdateWithHttpMessagesAsync(resourceGroupName, clusterName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Restarts all nodes in the cluster. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + public static ClustersRestartHeaders Restart(this IClustersOperations operations, string resourceGroupName, string clusterName) + { + return operations.RestartAsync(resourceGroupName, clusterName).GetAwaiter().GetResult(); + } + + /// + /// Restarts all nodes in the cluster. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The cancellation token. + /// + public static async Task RestartAsync(this IClustersOperations operations, string resourceGroupName, string clusterName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.RestartWithHttpMessagesAsync(resourceGroupName, clusterName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Headers; + } + } + + /// + /// Starts stopped compute on all cluster nodes. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + public static ClustersStartHeaders Start(this IClustersOperations operations, string resourceGroupName, string clusterName) + { + return operations.StartAsync(resourceGroupName, clusterName).GetAwaiter().GetResult(); + } + + /// + /// Starts stopped compute on all cluster nodes. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The cancellation token. + /// + public static async Task StartAsync(this IClustersOperations operations, string resourceGroupName, string clusterName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.StartWithHttpMessagesAsync(resourceGroupName, clusterName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Headers; + } + } + + /// + /// Stops compute on all cluster nodes. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + public static ClustersStopHeaders Stop(this IClustersOperations operations, string resourceGroupName, string clusterName) + { + return operations.StopAsync(resourceGroupName, clusterName).GetAwaiter().GetResult(); + } + + /// + /// Stops compute on all cluster nodes. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The cancellation token. + /// + public static async Task StopAsync(this IClustersOperations operations, string resourceGroupName, string clusterName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.StopWithHttpMessagesAsync(resourceGroupName, clusterName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Headers; + } + } + + /// + /// Promotes read replica cluster to an independent read-write cluster. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// Boolean property to enable geo-redundant replica promotion. + /// + public static ClustersPromoteReadReplicaHeaders PromoteReadReplica(this IClustersOperations operations, string resourceGroupName, string clusterName, bool? enableGeoBackup = default(bool?)) + { + return operations.PromoteReadReplicaAsync(resourceGroupName, clusterName, enableGeoBackup).GetAwaiter().GetResult(); + } + + /// + /// Promotes read replica cluster to an independent read-write cluster. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// Boolean property to enable geo-redundant replica promotion. + /// + /// + /// The cancellation token. + /// + public static async Task PromoteReadReplicaAsync(this IClustersOperations operations, string resourceGroupName, string clusterName, bool? enableGeoBackup = default(bool?), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.PromoteReadReplicaWithHttpMessagesAsync(resourceGroupName, clusterName, enableGeoBackup, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Headers; + } + } + + /// + /// Checks availability of a cluster name. Cluster names should be globally + /// unique; at least 3 characters and at most 40 characters long; they must + /// only contain lowercase letters, numbers, and hyphens; and must not start or + /// end with a hyphen. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Cluster name to verify. + /// + public static NameAvailability CheckNameAvailability(this IClustersOperations operations, string name) + { + return operations.CheckNameAvailabilityAsync(name).GetAwaiter().GetResult(); + } + + /// + /// Checks availability of a cluster name. Cluster names should be globally + /// unique; at least 3 characters and at most 40 characters long; they must + /// only contain lowercase letters, numbers, and hyphens; and must not start or + /// end with a hyphen. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Cluster name to verify. + /// + /// + /// The cancellation token. + /// + public static async Task CheckNameAvailabilityAsync(this IClustersOperations operations, string name, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CheckNameAvailabilityWithHttpMessagesAsync(name, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Creates a new cluster with servers. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The required parameters for creating or updating a cluster. + /// + public static Cluster BeginCreate(this IClustersOperations operations, string resourceGroupName, string clusterName, Cluster parameters) + { + return operations.BeginCreateAsync(resourceGroupName, clusterName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Creates a new cluster with servers. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The required parameters for creating or updating a cluster. + /// + /// + /// The cancellation token. + /// + public static async Task BeginCreateAsync(this IClustersOperations operations, string resourceGroupName, string clusterName, Cluster parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginCreateWithHttpMessagesAsync(resourceGroupName, clusterName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes a cluster together with servers in it. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + public static ClustersDeleteHeaders BeginDelete(this IClustersOperations operations, string resourceGroupName, string clusterName) + { + return operations.BeginDeleteAsync(resourceGroupName, clusterName).GetAwaiter().GetResult(); + } + + /// + /// Deletes a cluster together with servers in it. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The cancellation token. + /// + public static async Task BeginDeleteAsync(this IClustersOperations operations, string resourceGroupName, string clusterName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginDeleteWithHttpMessagesAsync(resourceGroupName, clusterName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Headers; + } + } + + /// + /// Updates an existing cluster. The request body can contain one or several + /// properties from the cluster definition. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The parameters for updating a cluster. + /// + public static Cluster BeginUpdate(this IClustersOperations operations, string resourceGroupName, string clusterName, ClusterForUpdate parameters) + { + return operations.BeginUpdateAsync(resourceGroupName, clusterName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Updates an existing cluster. The request body can contain one or several + /// properties from the cluster definition. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The parameters for updating a cluster. + /// + /// + /// The cancellation token. + /// + public static async Task BeginUpdateAsync(this IClustersOperations operations, string resourceGroupName, string clusterName, ClusterForUpdate parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginUpdateWithHttpMessagesAsync(resourceGroupName, clusterName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Restarts all nodes in the cluster. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + public static ClustersRestartHeaders BeginRestart(this IClustersOperations operations, string resourceGroupName, string clusterName) + { + return operations.BeginRestartAsync(resourceGroupName, clusterName).GetAwaiter().GetResult(); + } + + /// + /// Restarts all nodes in the cluster. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The cancellation token. + /// + public static async Task BeginRestartAsync(this IClustersOperations operations, string resourceGroupName, string clusterName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginRestartWithHttpMessagesAsync(resourceGroupName, clusterName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Headers; + } + } + + /// + /// Starts stopped compute on all cluster nodes. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + public static ClustersStartHeaders BeginStart(this IClustersOperations operations, string resourceGroupName, string clusterName) + { + return operations.BeginStartAsync(resourceGroupName, clusterName).GetAwaiter().GetResult(); + } + + /// + /// Starts stopped compute on all cluster nodes. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The cancellation token. + /// + public static async Task BeginStartAsync(this IClustersOperations operations, string resourceGroupName, string clusterName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginStartWithHttpMessagesAsync(resourceGroupName, clusterName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Headers; + } + } + + /// + /// Stops compute on all cluster nodes. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + public static ClustersStopHeaders BeginStop(this IClustersOperations operations, string resourceGroupName, string clusterName) + { + return operations.BeginStopAsync(resourceGroupName, clusterName).GetAwaiter().GetResult(); + } + + /// + /// Stops compute on all cluster nodes. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The cancellation token. + /// + public static async Task BeginStopAsync(this IClustersOperations operations, string resourceGroupName, string clusterName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginStopWithHttpMessagesAsync(resourceGroupName, clusterName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Headers; + } + } + + /// + /// Promotes read replica cluster to an independent read-write cluster. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// Boolean property to enable geo-redundant replica promotion. + /// + public static ClustersPromoteReadReplicaHeaders BeginPromoteReadReplica(this IClustersOperations operations, string resourceGroupName, string clusterName, bool? enableGeoBackup = default(bool?)) + { + return operations.BeginPromoteReadReplicaAsync(resourceGroupName, clusterName, enableGeoBackup).GetAwaiter().GetResult(); + } + + /// + /// Promotes read replica cluster to an independent read-write cluster. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// Boolean property to enable geo-redundant replica promotion. + /// + /// + /// The cancellation token. + /// + public static async Task BeginPromoteReadReplicaAsync(this IClustersOperations operations, string resourceGroupName, string clusterName, bool? enableGeoBackup = default(bool?), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginPromoteReadReplicaWithHttpMessagesAsync(resourceGroupName, clusterName, enableGeoBackup, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Headers; + } + } + + /// + /// Lists all clusters in a subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListNext(this IClustersOperations operations, string nextPageLink) + { + return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Lists all clusters in a subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListNextAsync(this IClustersOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Lists all clusters in a resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListByResourceGroupNext(this IClustersOperations operations, string nextPageLink) + { + return operations.ListByResourceGroupNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Lists all clusters in a resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByResourceGroupNextAsync(this IClustersOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByResourceGroupNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/ConfigurationsOperations.cs b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/ConfigurationsOperations.cs new file mode 100644 index 000000000000..1c198898cce6 --- /dev/null +++ b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/ConfigurationsOperations.cs @@ -0,0 +1,2230 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDBForPostgreSql +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// ConfigurationsOperations operations. + /// + internal partial class ConfigurationsOperations : IServiceOperations, IConfigurationsOperations + { + /// + /// Initializes a new instance of the ConfigurationsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal ConfigurationsOperations(CosmosDBforPostgreSQLClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the CosmosDBforPostgreSQLClient + /// + public CosmosDBforPostgreSQLClient Client { get; private set; } + + /// + /// List all the configurations of a server in cluster. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The name of the server. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListByServerWithHttpMessagesAsync(string resourceGroupName, string clusterName, string serverName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (clusterName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "clusterName"); + } + if (clusterName != null) + { + if (clusterName.Length > 40) + { + throw new ValidationException(ValidationRules.MaxLength, "clusterName", 40); + } + if (clusterName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "clusterName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(clusterName, "^(?![0-9]+$)(?!-)[a-z0-9-]{3,40}(? 90) + { + throw new ValidationException(ValidationRules.MaxLength, "serverName", 90); + } + if (serverName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "serverName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(serverName, "^[-\\w\\._]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "serverName", "^[-\\w\\._]+$"); + } + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("clusterName", clusterName); + tracingParameters.Add("serverName", serverName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByServer", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/serverGroupsv2/{clusterName}/servers/{serverName}/configurations").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(Client.SubscriptionId, Client.SerializationSettings).Trim('"'))); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{clusterName}", System.Uri.EscapeDataString(clusterName)); + _url = _url.Replace("{serverName}", System.Uri.EscapeDataString(serverName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// List all the configurations of a cluster. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListByClusterWithHttpMessagesAsync(string resourceGroupName, string clusterName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (clusterName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "clusterName"); + } + if (clusterName != null) + { + if (clusterName.Length > 40) + { + throw new ValidationException(ValidationRules.MaxLength, "clusterName", 40); + } + if (clusterName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "clusterName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(clusterName, "^(?![0-9]+$)(?!-)[a-z0-9-]{3,40}(? tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("clusterName", clusterName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByCluster", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/serverGroupsv2/{clusterName}/configurations").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(Client.SubscriptionId, Client.SerializationSettings).Trim('"'))); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{clusterName}", System.Uri.EscapeDataString(clusterName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Gets information of a configuration for coordinator and nodes. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The name of the cluster configuration. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetWithHttpMessagesAsync(string resourceGroupName, string clusterName, string configurationName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (clusterName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "clusterName"); + } + if (clusterName != null) + { + if (clusterName.Length > 40) + { + throw new ValidationException(ValidationRules.MaxLength, "clusterName", 40); + } + if (clusterName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "clusterName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(clusterName, "^(?![0-9]+$)(?!-)[a-z0-9-]{3,40}(? 90) + { + throw new ValidationException(ValidationRules.MaxLength, "configurationName", 90); + } + if (configurationName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "configurationName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(configurationName, "^[-\\w\\._]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "configurationName", "^[-\\w\\._]+$"); + } + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("clusterName", clusterName); + tracingParameters.Add("configurationName", configurationName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/serverGroupsv2/{clusterName}/configurations/{configurationName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(Client.SubscriptionId, Client.SerializationSettings).Trim('"'))); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{clusterName}", System.Uri.EscapeDataString(clusterName)); + _url = _url.Replace("{configurationName}", System.Uri.EscapeDataString(configurationName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Gets information of a configuration for coordinator. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The name of the cluster configuration. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetCoordinatorWithHttpMessagesAsync(string resourceGroupName, string clusterName, string configurationName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (clusterName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "clusterName"); + } + if (clusterName != null) + { + if (clusterName.Length > 40) + { + throw new ValidationException(ValidationRules.MaxLength, "clusterName", 40); + } + if (clusterName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "clusterName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(clusterName, "^(?![0-9]+$)(?!-)[a-z0-9-]{3,40}(? 90) + { + throw new ValidationException(ValidationRules.MaxLength, "configurationName", 90); + } + if (configurationName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "configurationName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(configurationName, "^[-\\w\\._]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "configurationName", "^[-\\w\\._]+$"); + } + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("clusterName", clusterName); + tracingParameters.Add("configurationName", configurationName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetCoordinator", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/serverGroupsv2/{clusterName}/coordinatorConfigurations/{configurationName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(Client.SubscriptionId, Client.SerializationSettings).Trim('"'))); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{clusterName}", System.Uri.EscapeDataString(clusterName)); + _url = _url.Replace("{configurationName}", System.Uri.EscapeDataString(configurationName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Updates configuration of coordinator in a cluster + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The name of the cluster configuration. + /// + /// + /// Value of the configuration. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> UpdateOnCoordinatorWithHttpMessagesAsync(string resourceGroupName, string clusterName, string configurationName, string value, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginUpdateOnCoordinatorWithHttpMessagesAsync(resourceGroupName, clusterName, configurationName, value, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets information of a configuration for worker nodes. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The name of the cluster configuration. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetNodeWithHttpMessagesAsync(string resourceGroupName, string clusterName, string configurationName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (clusterName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "clusterName"); + } + if (clusterName != null) + { + if (clusterName.Length > 40) + { + throw new ValidationException(ValidationRules.MaxLength, "clusterName", 40); + } + if (clusterName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "clusterName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(clusterName, "^(?![0-9]+$)(?!-)[a-z0-9-]{3,40}(? 90) + { + throw new ValidationException(ValidationRules.MaxLength, "configurationName", 90); + } + if (configurationName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "configurationName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(configurationName, "^[-\\w\\._]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "configurationName", "^[-\\w\\._]+$"); + } + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("clusterName", clusterName); + tracingParameters.Add("configurationName", configurationName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetNode", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/serverGroupsv2/{clusterName}/nodeConfigurations/{configurationName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(Client.SubscriptionId, Client.SerializationSettings).Trim('"'))); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{clusterName}", System.Uri.EscapeDataString(clusterName)); + _url = _url.Replace("{configurationName}", System.Uri.EscapeDataString(configurationName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Updates configuration of worker nodes in a cluster + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The name of the cluster configuration. + /// + /// + /// Value of the configuration. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> UpdateOnNodeWithHttpMessagesAsync(string resourceGroupName, string clusterName, string configurationName, string value, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginUpdateOnNodeWithHttpMessagesAsync(resourceGroupName, clusterName, configurationName, value, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Updates configuration of coordinator in a cluster + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The name of the cluster configuration. + /// + /// + /// Value of the configuration. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> BeginUpdateOnCoordinatorWithHttpMessagesAsync(string resourceGroupName, string clusterName, string configurationName, string value, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (clusterName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "clusterName"); + } + if (clusterName != null) + { + if (clusterName.Length > 40) + { + throw new ValidationException(ValidationRules.MaxLength, "clusterName", 40); + } + if (clusterName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "clusterName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(clusterName, "^(?![0-9]+$)(?!-)[a-z0-9-]{3,40}(? 90) + { + throw new ValidationException(ValidationRules.MaxLength, "configurationName", 90); + } + if (configurationName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "configurationName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(configurationName, "^[-\\w\\._]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "configurationName", "^[-\\w\\._]+$"); + } + } + if (value == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "value"); + } + ServerConfiguration parameters = new ServerConfiguration(); + if (value != null) + { + parameters.Value = value; + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("clusterName", clusterName); + tracingParameters.Add("configurationName", configurationName); + tracingParameters.Add("parameters", parameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginUpdateOnCoordinator", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/serverGroupsv2/{clusterName}/coordinatorConfigurations/{configurationName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(Client.SubscriptionId, Client.SerializationSettings).Trim('"'))); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{clusterName}", System.Uri.EscapeDataString(clusterName)); + _url = _url.Replace("{configurationName}", System.Uri.EscapeDataString(configurationName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PUT"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(parameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 201) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + // Deserialize Response + if ((int)_statusCode == 201) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + try + { + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().ToString(), ex); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Updates configuration of worker nodes in a cluster + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The name of the cluster configuration. + /// + /// + /// Value of the configuration. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> BeginUpdateOnNodeWithHttpMessagesAsync(string resourceGroupName, string clusterName, string configurationName, string value, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (clusterName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "clusterName"); + } + if (clusterName != null) + { + if (clusterName.Length > 40) + { + throw new ValidationException(ValidationRules.MaxLength, "clusterName", 40); + } + if (clusterName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "clusterName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(clusterName, "^(?![0-9]+$)(?!-)[a-z0-9-]{3,40}(? 90) + { + throw new ValidationException(ValidationRules.MaxLength, "configurationName", 90); + } + if (configurationName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "configurationName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(configurationName, "^[-\\w\\._]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "configurationName", "^[-\\w\\._]+$"); + } + } + if (value == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "value"); + } + ServerConfiguration parameters = new ServerConfiguration(); + if (value != null) + { + parameters.Value = value; + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("clusterName", clusterName); + tracingParameters.Add("configurationName", configurationName); + tracingParameters.Add("parameters", parameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginUpdateOnNode", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/serverGroupsv2/{clusterName}/nodeConfigurations/{configurationName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(Client.SubscriptionId, Client.SerializationSettings).Trim('"'))); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{clusterName}", System.Uri.EscapeDataString(clusterName)); + _url = _url.Replace("{configurationName}", System.Uri.EscapeDataString(configurationName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PUT"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(parameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 201) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + // Deserialize Response + if ((int)_statusCode == 201) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + try + { + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().ToString(), ex); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// List all the configurations of a server in cluster. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListByServerNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByServerNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// List all the configurations of a cluster. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListByClusterNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByClusterNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/ConfigurationsOperationsExtensions.cs b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/ConfigurationsOperationsExtensions.cs new file mode 100644 index 000000000000..0a203a4f8e79 --- /dev/null +++ b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/ConfigurationsOperationsExtensions.cs @@ -0,0 +1,525 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDBForPostgreSql +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for ConfigurationsOperations. + /// + public static partial class ConfigurationsOperationsExtensions + { + /// + /// List all the configurations of a server in cluster. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The name of the server. + /// + public static IPage ListByServer(this IConfigurationsOperations operations, string resourceGroupName, string clusterName, string serverName) + { + return operations.ListByServerAsync(resourceGroupName, clusterName, serverName).GetAwaiter().GetResult(); + } + + /// + /// List all the configurations of a server in cluster. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The name of the server. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByServerAsync(this IConfigurationsOperations operations, string resourceGroupName, string clusterName, string serverName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByServerWithHttpMessagesAsync(resourceGroupName, clusterName, serverName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// List all the configurations of a cluster. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + public static IPage ListByCluster(this IConfigurationsOperations operations, string resourceGroupName, string clusterName) + { + return operations.ListByClusterAsync(resourceGroupName, clusterName).GetAwaiter().GetResult(); + } + + /// + /// List all the configurations of a cluster. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByClusterAsync(this IConfigurationsOperations operations, string resourceGroupName, string clusterName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByClusterWithHttpMessagesAsync(resourceGroupName, clusterName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets information of a configuration for coordinator and nodes. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The name of the cluster configuration. + /// + public static Configuration Get(this IConfigurationsOperations operations, string resourceGroupName, string clusterName, string configurationName) + { + return operations.GetAsync(resourceGroupName, clusterName, configurationName).GetAwaiter().GetResult(); + } + + /// + /// Gets information of a configuration for coordinator and nodes. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The name of the cluster configuration. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IConfigurationsOperations operations, string resourceGroupName, string clusterName, string configurationName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, clusterName, configurationName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets information of a configuration for coordinator. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The name of the cluster configuration. + /// + public static ServerConfiguration GetCoordinator(this IConfigurationsOperations operations, string resourceGroupName, string clusterName, string configurationName) + { + return operations.GetCoordinatorAsync(resourceGroupName, clusterName, configurationName).GetAwaiter().GetResult(); + } + + /// + /// Gets information of a configuration for coordinator. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The name of the cluster configuration. + /// + /// + /// The cancellation token. + /// + public static async Task GetCoordinatorAsync(this IConfigurationsOperations operations, string resourceGroupName, string clusterName, string configurationName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetCoordinatorWithHttpMessagesAsync(resourceGroupName, clusterName, configurationName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Updates configuration of coordinator in a cluster + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The name of the cluster configuration. + /// + /// + /// Value of the configuration. + /// + public static ServerConfiguration UpdateOnCoordinator(this IConfigurationsOperations operations, string resourceGroupName, string clusterName, string configurationName, string value) + { + return operations.UpdateOnCoordinatorAsync(resourceGroupName, clusterName, configurationName, value).GetAwaiter().GetResult(); + } + + /// + /// Updates configuration of coordinator in a cluster + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The name of the cluster configuration. + /// + /// + /// Value of the configuration. + /// + /// + /// The cancellation token. + /// + public static async Task UpdateOnCoordinatorAsync(this IConfigurationsOperations operations, string resourceGroupName, string clusterName, string configurationName, string value, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.UpdateOnCoordinatorWithHttpMessagesAsync(resourceGroupName, clusterName, configurationName, value, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets information of a configuration for worker nodes. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The name of the cluster configuration. + /// + public static ServerConfiguration GetNode(this IConfigurationsOperations operations, string resourceGroupName, string clusterName, string configurationName) + { + return operations.GetNodeAsync(resourceGroupName, clusterName, configurationName).GetAwaiter().GetResult(); + } + + /// + /// Gets information of a configuration for worker nodes. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The name of the cluster configuration. + /// + /// + /// The cancellation token. + /// + public static async Task GetNodeAsync(this IConfigurationsOperations operations, string resourceGroupName, string clusterName, string configurationName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetNodeWithHttpMessagesAsync(resourceGroupName, clusterName, configurationName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Updates configuration of worker nodes in a cluster + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The name of the cluster configuration. + /// + /// + /// Value of the configuration. + /// + public static ServerConfiguration UpdateOnNode(this IConfigurationsOperations operations, string resourceGroupName, string clusterName, string configurationName, string value) + { + return operations.UpdateOnNodeAsync(resourceGroupName, clusterName, configurationName, value).GetAwaiter().GetResult(); + } + + /// + /// Updates configuration of worker nodes in a cluster + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The name of the cluster configuration. + /// + /// + /// Value of the configuration. + /// + /// + /// The cancellation token. + /// + public static async Task UpdateOnNodeAsync(this IConfigurationsOperations operations, string resourceGroupName, string clusterName, string configurationName, string value, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.UpdateOnNodeWithHttpMessagesAsync(resourceGroupName, clusterName, configurationName, value, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Updates configuration of coordinator in a cluster + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The name of the cluster configuration. + /// + /// + /// Value of the configuration. + /// + public static ServerConfiguration BeginUpdateOnCoordinator(this IConfigurationsOperations operations, string resourceGroupName, string clusterName, string configurationName, string value) + { + return operations.BeginUpdateOnCoordinatorAsync(resourceGroupName, clusterName, configurationName, value).GetAwaiter().GetResult(); + } + + /// + /// Updates configuration of coordinator in a cluster + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The name of the cluster configuration. + /// + /// + /// Value of the configuration. + /// + /// + /// The cancellation token. + /// + public static async Task BeginUpdateOnCoordinatorAsync(this IConfigurationsOperations operations, string resourceGroupName, string clusterName, string configurationName, string value, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginUpdateOnCoordinatorWithHttpMessagesAsync(resourceGroupName, clusterName, configurationName, value, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Updates configuration of worker nodes in a cluster + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The name of the cluster configuration. + /// + /// + /// Value of the configuration. + /// + public static ServerConfiguration BeginUpdateOnNode(this IConfigurationsOperations operations, string resourceGroupName, string clusterName, string configurationName, string value) + { + return operations.BeginUpdateOnNodeAsync(resourceGroupName, clusterName, configurationName, value).GetAwaiter().GetResult(); + } + + /// + /// Updates configuration of worker nodes in a cluster + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The name of the cluster configuration. + /// + /// + /// Value of the configuration. + /// + /// + /// The cancellation token. + /// + public static async Task BeginUpdateOnNodeAsync(this IConfigurationsOperations operations, string resourceGroupName, string clusterName, string configurationName, string value, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginUpdateOnNodeWithHttpMessagesAsync(resourceGroupName, clusterName, configurationName, value, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// List all the configurations of a server in cluster. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListByServerNext(this IConfigurationsOperations operations, string nextPageLink) + { + return operations.ListByServerNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// List all the configurations of a server in cluster. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByServerNextAsync(this IConfigurationsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByServerNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// List all the configurations of a cluster. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListByClusterNext(this IConfigurationsOperations operations, string nextPageLink) + { + return operations.ListByClusterNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// List all the configurations of a cluster. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByClusterNextAsync(this IConfigurationsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByClusterNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/CosmosDBforPostgreSQLClient.cs b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/CosmosDBforPostgreSQLClient.cs new file mode 100644 index 000000000000..528ba4696d35 --- /dev/null +++ b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/CosmosDBforPostgreSQLClient.cs @@ -0,0 +1,403 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDBForPostgreSql +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Microsoft.Rest.Serialization; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + + /// + /// Azure Cosmos DB for PostgreSQL database service resource provider REST + /// APIs + /// + public partial class CosmosDBforPostgreSQLClient : ServiceClient, ICosmosDBforPostgreSQLClient, IAzureClient + { + /// + /// The base URI of the service. + /// + public System.Uri BaseUri { get; set; } + + /// + /// Gets or sets json serialization settings. + /// + public JsonSerializerSettings SerializationSettings { get; private set; } + + /// + /// Gets or sets json deserialization settings. + /// + public JsonSerializerSettings DeserializationSettings { get; private set; } + + /// + /// Credentials needed for the client to connect to Azure. + /// + public ServiceClientCredentials Credentials { get; private set; } + + /// + /// The ID of the target subscription. The value must be an UUID. + /// + public System.Guid SubscriptionId { get; set; } + + /// + /// The API version to use for this operation. + /// + public string ApiVersion { get; private set; } + + /// + /// The preferred language for the response. + /// + public string AcceptLanguage { get; set; } + + /// + /// The retry timeout in seconds for Long Running Operations. Default value is + /// 30. + /// + public int? LongRunningOperationRetryTimeout { get; set; } + + /// + /// Whether a unique x-ms-client-request-id should be generated. When set to + /// true a unique x-ms-client-request-id value is generated and included in + /// each request. Default is true. + /// + public bool? GenerateClientRequestId { get; set; } + + /// + /// Gets the IClustersOperations. + /// + public virtual IClustersOperations Clusters { get; private set; } + + /// + /// Gets the IServersOperations. + /// + public virtual IServersOperations Servers { get; private set; } + + /// + /// Gets the IConfigurationsOperations. + /// + public virtual IConfigurationsOperations Configurations { get; private set; } + + /// + /// Gets the IFirewallRulesOperations. + /// + public virtual IFirewallRulesOperations FirewallRules { get; private set; } + + /// + /// Gets the IRolesOperations. + /// + public virtual IRolesOperations Roles { get; private set; } + + /// + /// Gets the IOperations. + /// + public virtual IOperations Operations { get; private set; } + + /// + /// Gets the IPrivateEndpointConnectionsOperations. + /// + public virtual IPrivateEndpointConnectionsOperations PrivateEndpointConnections { get; private set; } + + /// + /// Gets the IPrivateLinkResourcesOperations. + /// + public virtual IPrivateLinkResourcesOperations PrivateLinkResources { get; private set; } + + /// + /// Initializes a new instance of the CosmosDBforPostgreSQLClient class. + /// + /// + /// HttpClient to be used + /// + /// + /// True: will dispose the provided httpClient on calling CosmosDBforPostgreSQLClient.Dispose(). False: will not dispose provided httpClient + protected CosmosDBforPostgreSQLClient(HttpClient httpClient, bool disposeHttpClient) : base(httpClient, disposeHttpClient) + { + Initialize(); + } + + /// + /// Initializes a new instance of the CosmosDBforPostgreSQLClient class. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + protected CosmosDBforPostgreSQLClient(params DelegatingHandler[] handlers) : base(handlers) + { + Initialize(); + } + + /// + /// Initializes a new instance of the CosmosDBforPostgreSQLClient class. + /// + /// + /// Optional. The http client handler used to handle http transport. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + protected CosmosDBforPostgreSQLClient(HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : base(rootHandler, handlers) + { + Initialize(); + } + + /// + /// Initializes a new instance of the CosmosDBforPostgreSQLClient class. + /// + /// + /// Optional. The base URI of the service. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + /// + /// Thrown when a required parameter is null + /// + protected CosmosDBforPostgreSQLClient(System.Uri baseUri, params DelegatingHandler[] handlers) : this(handlers) + { + if (baseUri == null) + { + throw new System.ArgumentNullException("baseUri"); + } + BaseUri = baseUri; + } + + /// + /// Initializes a new instance of the CosmosDBforPostgreSQLClient class. + /// + /// + /// Optional. The base URI of the service. + /// + /// + /// Optional. The http client handler used to handle http transport. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + /// + /// Thrown when a required parameter is null + /// + protected CosmosDBforPostgreSQLClient(System.Uri baseUri, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers) + { + if (baseUri == null) + { + throw new System.ArgumentNullException("baseUri"); + } + BaseUri = baseUri; + } + + /// + /// Initializes a new instance of the CosmosDBforPostgreSQLClient class. + /// + /// + /// Required. Credentials needed for the client to connect to Azure. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + /// + /// Thrown when a required parameter is null + /// + public CosmosDBforPostgreSQLClient(ServiceClientCredentials credentials, params DelegatingHandler[] handlers) : this(handlers) + { + if (credentials == null) + { + throw new System.ArgumentNullException("credentials"); + } + Credentials = credentials; + if (Credentials != null) + { + Credentials.InitializeServiceClient(this); + } + } + + /// + /// Initializes a new instance of the CosmosDBforPostgreSQLClient class. + /// + /// + /// Required. Credentials needed for the client to connect to Azure. + /// + /// + /// HttpClient to be used + /// + /// + /// True: will dispose the provided httpClient on calling CosmosDBforPostgreSQLClient.Dispose(). False: will not dispose provided httpClient + /// + /// Thrown when a required parameter is null + /// + public CosmosDBforPostgreSQLClient(ServiceClientCredentials credentials, HttpClient httpClient, bool disposeHttpClient) : this(httpClient, disposeHttpClient) + { + if (credentials == null) + { + throw new System.ArgumentNullException("credentials"); + } + Credentials = credentials; + if (Credentials != null) + { + Credentials.InitializeServiceClient(this); + } + } + + /// + /// Initializes a new instance of the CosmosDBforPostgreSQLClient class. + /// + /// + /// Required. Credentials needed for the client to connect to Azure. + /// + /// + /// Optional. The http client handler used to handle http transport. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + /// + /// Thrown when a required parameter is null + /// + public CosmosDBforPostgreSQLClient(ServiceClientCredentials credentials, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers) + { + if (credentials == null) + { + throw new System.ArgumentNullException("credentials"); + } + Credentials = credentials; + if (Credentials != null) + { + Credentials.InitializeServiceClient(this); + } + } + + /// + /// Initializes a new instance of the CosmosDBforPostgreSQLClient class. + /// + /// + /// Optional. The base URI of the service. + /// + /// + /// Required. Credentials needed for the client to connect to Azure. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + /// + /// Thrown when a required parameter is null + /// + public CosmosDBforPostgreSQLClient(System.Uri baseUri, ServiceClientCredentials credentials, params DelegatingHandler[] handlers) : this(handlers) + { + if (baseUri == null) + { + throw new System.ArgumentNullException("baseUri"); + } + if (credentials == null) + { + throw new System.ArgumentNullException("credentials"); + } + BaseUri = baseUri; + Credentials = credentials; + if (Credentials != null) + { + Credentials.InitializeServiceClient(this); + } + } + + /// + /// Initializes a new instance of the CosmosDBforPostgreSQLClient class. + /// + /// + /// Optional. The base URI of the service. + /// + /// + /// Required. Credentials needed for the client to connect to Azure. + /// + /// + /// Optional. The http client handler used to handle http transport. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + /// + /// Thrown when a required parameter is null + /// + public CosmosDBforPostgreSQLClient(System.Uri baseUri, ServiceClientCredentials credentials, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers) + { + if (baseUri == null) + { + throw new System.ArgumentNullException("baseUri"); + } + if (credentials == null) + { + throw new System.ArgumentNullException("credentials"); + } + BaseUri = baseUri; + Credentials = credentials; + if (Credentials != null) + { + Credentials.InitializeServiceClient(this); + } + } + + /// + /// An optional partial-method to perform custom initialization. + /// + partial void CustomInitialize(); + /// + /// Initializes client properties. + /// + private void Initialize() + { + Clusters = new ClustersOperations(this); + Servers = new ServersOperations(this); + Configurations = new ConfigurationsOperations(this); + FirewallRules = new FirewallRulesOperations(this); + Roles = new RolesOperations(this); + Operations = new Operations(this); + PrivateEndpointConnections = new PrivateEndpointConnectionsOperations(this); + PrivateLinkResources = new PrivateLinkResourcesOperations(this); + BaseUri = new System.Uri("https://management.azure.com"); + ApiVersion = "2023-03-02-preview"; + AcceptLanguage = "en-US"; + LongRunningOperationRetryTimeout = 30; + GenerateClientRequestId = true; + SerializationSettings = new JsonSerializerSettings + { + Formatting = Newtonsoft.Json.Formatting.Indented, + DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, + NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, + ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + ContractResolver = new ReadOnlyJsonContractResolver(), + Converters = new List + { + new Iso8601TimeSpanConverter() + } + }; + SerializationSettings.Converters.Add(new TransformationJsonConverter()); + DeserializationSettings = new JsonSerializerSettings + { + DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, + NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, + ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + ContractResolver = new ReadOnlyJsonContractResolver(), + Converters = new List + { + new Iso8601TimeSpanConverter() + } + }; + CustomInitialize(); + DeserializationSettings.Converters.Add(new TransformationJsonConverter()); + DeserializationSettings.Converters.Add(new CloudErrorJsonConverter()); + } + } +} diff --git a/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/FirewallRulesOperations.cs b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/FirewallRulesOperations.cs new file mode 100644 index 000000000000..5af732e11b68 --- /dev/null +++ b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/FirewallRulesOperations.cs @@ -0,0 +1,1078 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDBForPostgreSql +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// FirewallRulesOperations operations. + /// + internal partial class FirewallRulesOperations : IServiceOperations, IFirewallRulesOperations + { + /// + /// Initializes a new instance of the FirewallRulesOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal FirewallRulesOperations(CosmosDBforPostgreSQLClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the CosmosDBforPostgreSQLClient + /// + public CosmosDBforPostgreSQLClient Client { get; private set; } + + /// + /// Creates a new cluster firewall rule or updates an existing cluster firewall + /// rule. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The name of the cluster firewall rule. + /// + /// + /// The required parameters for creating or updating a firewall rule. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string clusterName, string firewallRuleName, FirewallRule parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, clusterName, firewallRuleName, parameters, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Deletes a cluster firewall rule. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The name of the cluster firewall rule. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> DeleteWithHttpMessagesAsync(string resourceGroupName, string clusterName, string firewallRuleName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationHeaderResponse _response = await BeginDeleteWithHttpMessagesAsync(resourceGroupName, clusterName, firewallRuleName, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets information about a cluster firewall rule. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The name of the cluster firewall rule. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetWithHttpMessagesAsync(string resourceGroupName, string clusterName, string firewallRuleName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (clusterName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "clusterName"); + } + if (clusterName != null) + { + if (clusterName.Length > 40) + { + throw new ValidationException(ValidationRules.MaxLength, "clusterName", 40); + } + if (clusterName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "clusterName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(clusterName, "^(?![0-9]+$)(?!-)[a-z0-9-]{3,40}(? tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("clusterName", clusterName); + tracingParameters.Add("firewallRuleName", firewallRuleName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/serverGroupsv2/{clusterName}/firewallRules/{firewallRuleName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(Client.SubscriptionId, Client.SerializationSettings).Trim('"'))); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{clusterName}", System.Uri.EscapeDataString(clusterName)); + _url = _url.Replace("{firewallRuleName}", System.Uri.EscapeDataString(firewallRuleName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Lists all the firewall rules on cluster. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListByClusterWithHttpMessagesAsync(string resourceGroupName, string clusterName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (clusterName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "clusterName"); + } + if (clusterName != null) + { + if (clusterName.Length > 40) + { + throw new ValidationException(ValidationRules.MaxLength, "clusterName", 40); + } + if (clusterName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "clusterName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(clusterName, "^(?![0-9]+$)(?!-)[a-z0-9-]{3,40}(? tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("clusterName", clusterName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByCluster", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/serverGroupsv2/{clusterName}/firewallRules").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(Client.SubscriptionId, Client.SerializationSettings).Trim('"'))); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{clusterName}", System.Uri.EscapeDataString(clusterName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Creates a new cluster firewall rule or updates an existing cluster firewall + /// rule. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The name of the cluster firewall rule. + /// + /// + /// The required parameters for creating or updating a firewall rule. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> BeginCreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string clusterName, string firewallRuleName, FirewallRule parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (clusterName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "clusterName"); + } + if (clusterName != null) + { + if (clusterName.Length > 40) + { + throw new ValidationException(ValidationRules.MaxLength, "clusterName", 40); + } + if (clusterName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "clusterName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(clusterName, "^(?![0-9]+$)(?!-)[a-z0-9-]{3,40}(? tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("clusterName", clusterName); + tracingParameters.Add("firewallRuleName", firewallRuleName); + tracingParameters.Add("parameters", parameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginCreateOrUpdate", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/serverGroupsv2/{clusterName}/firewallRules/{firewallRuleName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(Client.SubscriptionId, Client.SerializationSettings).Trim('"'))); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{clusterName}", System.Uri.EscapeDataString(clusterName)); + _url = _url.Replace("{firewallRuleName}", System.Uri.EscapeDataString(firewallRuleName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PUT"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(parameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 201) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + // Deserialize Response + if ((int)_statusCode == 201) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + try + { + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().ToString(), ex); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Deletes a cluster firewall rule. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The name of the cluster firewall rule. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string clusterName, string firewallRuleName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (clusterName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "clusterName"); + } + if (clusterName != null) + { + if (clusterName.Length > 40) + { + throw new ValidationException(ValidationRules.MaxLength, "clusterName", 40); + } + if (clusterName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "clusterName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(clusterName, "^(?![0-9]+$)(?!-)[a-z0-9-]{3,40}(? tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("clusterName", clusterName); + tracingParameters.Add("firewallRuleName", firewallRuleName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginDelete", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/serverGroupsv2/{clusterName}/firewallRules/{firewallRuleName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(Client.SubscriptionId, Client.SerializationSettings).Trim('"'))); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{clusterName}", System.Uri.EscapeDataString(clusterName)); + _url = _url.Replace("{firewallRuleName}", System.Uri.EscapeDataString(firewallRuleName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("DELETE"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 202 && (int)_statusCode != 204) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationHeaderResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + try + { + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().ToString(), ex); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/FirewallRulesOperationsExtensions.cs b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/FirewallRulesOperationsExtensions.cs new file mode 100644 index 000000000000..c5f2a938549e --- /dev/null +++ b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/FirewallRulesOperationsExtensions.cs @@ -0,0 +1,313 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDBForPostgreSql +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for FirewallRulesOperations. + /// + public static partial class FirewallRulesOperationsExtensions + { + /// + /// Creates a new cluster firewall rule or updates an existing cluster firewall + /// rule. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The name of the cluster firewall rule. + /// + /// + /// The required parameters for creating or updating a firewall rule. + /// + public static FirewallRule CreateOrUpdate(this IFirewallRulesOperations operations, string resourceGroupName, string clusterName, string firewallRuleName, FirewallRule parameters) + { + return operations.CreateOrUpdateAsync(resourceGroupName, clusterName, firewallRuleName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Creates a new cluster firewall rule or updates an existing cluster firewall + /// rule. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The name of the cluster firewall rule. + /// + /// + /// The required parameters for creating or updating a firewall rule. + /// + /// + /// The cancellation token. + /// + public static async Task CreateOrUpdateAsync(this IFirewallRulesOperations operations, string resourceGroupName, string clusterName, string firewallRuleName, FirewallRule parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, clusterName, firewallRuleName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes a cluster firewall rule. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The name of the cluster firewall rule. + /// + public static FirewallRulesDeleteHeaders Delete(this IFirewallRulesOperations operations, string resourceGroupName, string clusterName, string firewallRuleName) + { + return operations.DeleteAsync(resourceGroupName, clusterName, firewallRuleName).GetAwaiter().GetResult(); + } + + /// + /// Deletes a cluster firewall rule. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The name of the cluster firewall rule. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this IFirewallRulesOperations operations, string resourceGroupName, string clusterName, string firewallRuleName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.DeleteWithHttpMessagesAsync(resourceGroupName, clusterName, firewallRuleName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Headers; + } + } + + /// + /// Gets information about a cluster firewall rule. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The name of the cluster firewall rule. + /// + public static FirewallRule Get(this IFirewallRulesOperations operations, string resourceGroupName, string clusterName, string firewallRuleName) + { + return operations.GetAsync(resourceGroupName, clusterName, firewallRuleName).GetAwaiter().GetResult(); + } + + /// + /// Gets information about a cluster firewall rule. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The name of the cluster firewall rule. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IFirewallRulesOperations operations, string resourceGroupName, string clusterName, string firewallRuleName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, clusterName, firewallRuleName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Lists all the firewall rules on cluster. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + public static IEnumerable ListByCluster(this IFirewallRulesOperations operations, string resourceGroupName, string clusterName) + { + return operations.ListByClusterAsync(resourceGroupName, clusterName).GetAwaiter().GetResult(); + } + + /// + /// Lists all the firewall rules on cluster. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByClusterAsync(this IFirewallRulesOperations operations, string resourceGroupName, string clusterName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByClusterWithHttpMessagesAsync(resourceGroupName, clusterName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Creates a new cluster firewall rule or updates an existing cluster firewall + /// rule. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The name of the cluster firewall rule. + /// + /// + /// The required parameters for creating or updating a firewall rule. + /// + public static FirewallRule BeginCreateOrUpdate(this IFirewallRulesOperations operations, string resourceGroupName, string clusterName, string firewallRuleName, FirewallRule parameters) + { + return operations.BeginCreateOrUpdateAsync(resourceGroupName, clusterName, firewallRuleName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Creates a new cluster firewall rule or updates an existing cluster firewall + /// rule. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The name of the cluster firewall rule. + /// + /// + /// The required parameters for creating or updating a firewall rule. + /// + /// + /// The cancellation token. + /// + public static async Task BeginCreateOrUpdateAsync(this IFirewallRulesOperations operations, string resourceGroupName, string clusterName, string firewallRuleName, FirewallRule parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, clusterName, firewallRuleName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes a cluster firewall rule. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The name of the cluster firewall rule. + /// + public static FirewallRulesDeleteHeaders BeginDelete(this IFirewallRulesOperations operations, string resourceGroupName, string clusterName, string firewallRuleName) + { + return operations.BeginDeleteAsync(resourceGroupName, clusterName, firewallRuleName).GetAwaiter().GetResult(); + } + + /// + /// Deletes a cluster firewall rule. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The name of the cluster firewall rule. + /// + /// + /// The cancellation token. + /// + public static async Task BeginDeleteAsync(this IFirewallRulesOperations operations, string resourceGroupName, string clusterName, string firewallRuleName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginDeleteWithHttpMessagesAsync(resourceGroupName, clusterName, firewallRuleName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Headers; + } + } + + } +} diff --git a/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/IClustersOperations.cs b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/IClustersOperations.cs new file mode 100644 index 000000000000..dafe7954cfcc --- /dev/null +++ b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/IClustersOperations.cs @@ -0,0 +1,504 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDBForPostgreSql +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// ClustersOperations operations. + /// + public partial interface IClustersOperations + { + /// + /// Lists all clusters in a subscription. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Lists all clusters in a resource group. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListByResourceGroupWithHttpMessagesAsync(string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Creates a new cluster with servers. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The required parameters for creating or updating a cluster. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> CreateWithHttpMessagesAsync(string resourceGroupName, string clusterName, Cluster parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets information about a cluster such as compute and storage + /// configuration and cluster lifecycle metadata such as cluster + /// creation date and time. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> GetWithHttpMessagesAsync(string resourceGroupName, string clusterName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes a cluster together with servers in it. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task> DeleteWithHttpMessagesAsync(string resourceGroupName, string clusterName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Updates an existing cluster. The request body can contain one or + /// several properties from the cluster definition. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The parameters for updating a cluster. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> UpdateWithHttpMessagesAsync(string resourceGroupName, string clusterName, ClusterForUpdate parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Restarts all nodes in the cluster. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task> RestartWithHttpMessagesAsync(string resourceGroupName, string clusterName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Starts stopped compute on all cluster nodes. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task> StartWithHttpMessagesAsync(string resourceGroupName, string clusterName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Stops compute on all cluster nodes. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task> StopWithHttpMessagesAsync(string resourceGroupName, string clusterName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Promotes read replica cluster to an independent read-write cluster. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// Boolean property to enable geo-redundant replica promotion. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task> PromoteReadReplicaWithHttpMessagesAsync(string resourceGroupName, string clusterName, bool? enableGeoBackup = default(bool?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Checks availability of a cluster name. Cluster names should be + /// globally unique; at least 3 characters and at most 40 characters + /// long; they must only contain lowercase letters, numbers, and + /// hyphens; and must not start or end with a hyphen. + /// + /// + /// Cluster name to verify. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> CheckNameAvailabilityWithHttpMessagesAsync(string name, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Creates a new cluster with servers. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The required parameters for creating or updating a cluster. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> BeginCreateWithHttpMessagesAsync(string resourceGroupName, string clusterName, Cluster parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes a cluster together with servers in it. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task> BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string clusterName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Updates an existing cluster. The request body can contain one or + /// several properties from the cluster definition. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The parameters for updating a cluster. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> BeginUpdateWithHttpMessagesAsync(string resourceGroupName, string clusterName, ClusterForUpdate parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Restarts all nodes in the cluster. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task> BeginRestartWithHttpMessagesAsync(string resourceGroupName, string clusterName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Starts stopped compute on all cluster nodes. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task> BeginStartWithHttpMessagesAsync(string resourceGroupName, string clusterName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Stops compute on all cluster nodes. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task> BeginStopWithHttpMessagesAsync(string resourceGroupName, string clusterName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Promotes read replica cluster to an independent read-write cluster. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// Boolean property to enable geo-redundant replica promotion. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task> BeginPromoteReadReplicaWithHttpMessagesAsync(string resourceGroupName, string clusterName, bool? enableGeoBackup = default(bool?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Lists all clusters in a subscription. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Lists all clusters in a resource group. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListByResourceGroupNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/IConfigurationsOperations.cs b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/IConfigurationsOperations.cs new file mode 100644 index 000000000000..c76f4ed4d454 --- /dev/null +++ b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/IConfigurationsOperations.cs @@ -0,0 +1,332 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDBForPostgreSql +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// ConfigurationsOperations operations. + /// + public partial interface IConfigurationsOperations + { + /// + /// List all the configurations of a server in cluster. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The name of the server. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListByServerWithHttpMessagesAsync(string resourceGroupName, string clusterName, string serverName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// List all the configurations of a cluster. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListByClusterWithHttpMessagesAsync(string resourceGroupName, string clusterName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets information of a configuration for coordinator and nodes. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The name of the cluster configuration. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> GetWithHttpMessagesAsync(string resourceGroupName, string clusterName, string configurationName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets information of a configuration for coordinator. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The name of the cluster configuration. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> GetCoordinatorWithHttpMessagesAsync(string resourceGroupName, string clusterName, string configurationName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Updates configuration of coordinator in a cluster + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The name of the cluster configuration. + /// + /// + /// Value of the configuration. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> UpdateOnCoordinatorWithHttpMessagesAsync(string resourceGroupName, string clusterName, string configurationName, string value, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets information of a configuration for worker nodes. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The name of the cluster configuration. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> GetNodeWithHttpMessagesAsync(string resourceGroupName, string clusterName, string configurationName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Updates configuration of worker nodes in a cluster + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The name of the cluster configuration. + /// + /// + /// Value of the configuration. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> UpdateOnNodeWithHttpMessagesAsync(string resourceGroupName, string clusterName, string configurationName, string value, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Updates configuration of coordinator in a cluster + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The name of the cluster configuration. + /// + /// + /// Value of the configuration. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> BeginUpdateOnCoordinatorWithHttpMessagesAsync(string resourceGroupName, string clusterName, string configurationName, string value, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Updates configuration of worker nodes in a cluster + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The name of the cluster configuration. + /// + /// + /// Value of the configuration. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> BeginUpdateOnNodeWithHttpMessagesAsync(string resourceGroupName, string clusterName, string configurationName, string value, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// List all the configurations of a server in cluster. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListByServerNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// List all the configurations of a cluster. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListByClusterNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/ICosmosDBforPostgreSQLClient.cs b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/ICosmosDBforPostgreSQLClient.cs new file mode 100644 index 000000000000..7e5d1bc519be --- /dev/null +++ b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/ICosmosDBforPostgreSQLClient.cs @@ -0,0 +1,114 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDBForPostgreSql +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + + /// + /// Azure Cosmos DB for PostgreSQL database service resource provider REST + /// APIs + /// + public partial interface ICosmosDBforPostgreSQLClient : System.IDisposable + { + /// + /// The base URI of the service. + /// + System.Uri BaseUri { get; set; } + + /// + /// Gets or sets json serialization settings. + /// + JsonSerializerSettings SerializationSettings { get; } + + /// + /// Gets or sets json deserialization settings. + /// + JsonSerializerSettings DeserializationSettings { get; } + + /// + /// Credentials needed for the client to connect to Azure. + /// + ServiceClientCredentials Credentials { get; } + + /// + /// The ID of the target subscription. The value must be an UUID. + /// + System.Guid SubscriptionId { get; set; } + + /// + /// The API version to use for this operation. + /// + string ApiVersion { get; } + + /// + /// The preferred language for the response. + /// + string AcceptLanguage { get; set; } + + /// + /// The retry timeout in seconds for Long Running Operations. Default + /// value is 30. + /// + int? LongRunningOperationRetryTimeout { get; set; } + + /// + /// Whether a unique x-ms-client-request-id should be generated. When + /// set to true a unique x-ms-client-request-id value is generated and + /// included in each request. Default is true. + /// + bool? GenerateClientRequestId { get; set; } + + + /// + /// Gets the IClustersOperations. + /// + IClustersOperations Clusters { get; } + + /// + /// Gets the IServersOperations. + /// + IServersOperations Servers { get; } + + /// + /// Gets the IConfigurationsOperations. + /// + IConfigurationsOperations Configurations { get; } + + /// + /// Gets the IFirewallRulesOperations. + /// + IFirewallRulesOperations FirewallRules { get; } + + /// + /// Gets the IRolesOperations. + /// + IRolesOperations Roles { get; } + + /// + /// Gets the IOperations. + /// + IOperations Operations { get; } + + /// + /// Gets the IPrivateEndpointConnectionsOperations. + /// + IPrivateEndpointConnectionsOperations PrivateEndpointConnections { get; } + + /// + /// Gets the IPrivateLinkResourcesOperations. + /// + IPrivateLinkResourcesOperations PrivateLinkResources { get; } + + } +} diff --git a/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/IFirewallRulesOperations.cs b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/IFirewallRulesOperations.cs new file mode 100644 index 000000000000..7b73db96af78 --- /dev/null +++ b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/IFirewallRulesOperations.cs @@ -0,0 +1,194 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDBForPostgreSql +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// FirewallRulesOperations operations. + /// + public partial interface IFirewallRulesOperations + { + /// + /// Creates a new cluster firewall rule or updates an existing cluster + /// firewall rule. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The name of the cluster firewall rule. + /// + /// + /// The required parameters for creating or updating a firewall rule. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string clusterName, string firewallRuleName, FirewallRule parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes a cluster firewall rule. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The name of the cluster firewall rule. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task> DeleteWithHttpMessagesAsync(string resourceGroupName, string clusterName, string firewallRuleName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets information about a cluster firewall rule. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The name of the cluster firewall rule. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> GetWithHttpMessagesAsync(string resourceGroupName, string clusterName, string firewallRuleName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Lists all the firewall rules on cluster. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListByClusterWithHttpMessagesAsync(string resourceGroupName, string clusterName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Creates a new cluster firewall rule or updates an existing cluster + /// firewall rule. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The name of the cluster firewall rule. + /// + /// + /// The required parameters for creating or updating a firewall rule. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> BeginCreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string clusterName, string firewallRuleName, FirewallRule parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes a cluster firewall rule. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The name of the cluster firewall rule. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task> BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string clusterName, string firewallRuleName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/IOperations.cs b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/IOperations.cs new file mode 100644 index 000000000000..42881ac7c83f --- /dev/null +++ b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/IOperations.cs @@ -0,0 +1,46 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDBForPostgreSql +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Operations operations. + /// + public partial interface IOperations + { + /// + /// Lists all of the available REST API operations. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/IPrivateEndpointConnectionsOperations.cs b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/IPrivateEndpointConnectionsOperations.cs new file mode 100644 index 000000000000..78325eef04a7 --- /dev/null +++ b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/IPrivateEndpointConnectionsOperations.cs @@ -0,0 +1,201 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDBForPostgreSql +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// PrivateEndpointConnectionsOperations operations. + /// + public partial interface IPrivateEndpointConnectionsOperations + { + /// + /// Gets list of private endpoint connections on a cluster. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListByClusterWithHttpMessagesAsync(string resourceGroupName, string clusterName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets private endpoint connection. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The name of the private endpoint connection associated with the + /// cluster. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> GetWithHttpMessagesAsync(string resourceGroupName, string clusterName, string privateEndpointConnectionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Approves or Rejects a private endpoint connection with a given + /// name. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The name of the private endpoint connection associated with the + /// cluster. + /// + /// + /// The required parameters for approving a private endpoint + /// connection. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string clusterName, string privateEndpointConnectionName, PrivateEndpointConnection parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes a private endpoint connection with a given name. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The name of the private endpoint connection associated with the + /// cluster. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task> DeleteWithHttpMessagesAsync(string resourceGroupName, string clusterName, string privateEndpointConnectionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Approves or Rejects a private endpoint connection with a given + /// name. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The name of the private endpoint connection associated with the + /// cluster. + /// + /// + /// The required parameters for approving a private endpoint + /// connection. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> BeginCreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string clusterName, string privateEndpointConnectionName, PrivateEndpointConnection parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes a private endpoint connection with a given name. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The name of the private endpoint connection associated with the + /// cluster. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task> BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string clusterName, string privateEndpointConnectionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/IPrivateLinkResourcesOperations.cs b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/IPrivateLinkResourcesOperations.cs new file mode 100644 index 000000000000..656f2ed1c809 --- /dev/null +++ b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/IPrivateLinkResourcesOperations.cs @@ -0,0 +1,80 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDBForPostgreSql +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// PrivateLinkResourcesOperations operations. + /// + public partial interface IPrivateLinkResourcesOperations + { + /// + /// Gets the private link resources for cluster. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListByClusterWithHttpMessagesAsync(string resourceGroupName, string clusterName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets a private link resource for cluster. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The name of the private link resource. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> GetWithHttpMessagesAsync(string resourceGroupName, string clusterName, string privateLinkResourceName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/IRolesOperations.cs b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/IRolesOperations.cs new file mode 100644 index 000000000000..58568d2814f4 --- /dev/null +++ b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/IRolesOperations.cs @@ -0,0 +1,192 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDBForPostgreSql +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// RolesOperations operations. + /// + public partial interface IRolesOperations + { + /// + /// Gets information about a cluster role. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The name of the cluster role. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> GetWithHttpMessagesAsync(string resourceGroupName, string clusterName, string roleName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Creates a new role or updates an existing role. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The name of the cluster role. + /// + /// + /// The required parameters for creating or updating a role. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> CreateWithHttpMessagesAsync(string resourceGroupName, string clusterName, string roleName, Role parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes a cluster role. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The name of the cluster role. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task> DeleteWithHttpMessagesAsync(string resourceGroupName, string clusterName, string roleName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// List all the roles in a given cluster. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListByClusterWithHttpMessagesAsync(string resourceGroupName, string clusterName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Creates a new role or updates an existing role. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The name of the cluster role. + /// + /// + /// The required parameters for creating or updating a role. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> BeginCreateWithHttpMessagesAsync(string resourceGroupName, string clusterName, string roleName, Role parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes a cluster role. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The name of the cluster role. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task> BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string clusterName, string roleName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/IServersOperations.cs b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/IServersOperations.cs new file mode 100644 index 000000000000..d5cb2fd58920 --- /dev/null +++ b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/IServersOperations.cs @@ -0,0 +1,80 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDBForPostgreSql +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// ServersOperations operations. + /// + public partial interface IServersOperations + { + /// + /// Lists servers of a cluster. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListByClusterWithHttpMessagesAsync(string resourceGroupName, string clusterName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets information about a server in cluster. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The name of the server. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> GetWithHttpMessagesAsync(string resourceGroupName, string clusterName, string serverName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/AadEnabledEnum.cs b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/AadEnabledEnum.cs new file mode 100644 index 000000000000..3a9486182ba1 --- /dev/null +++ b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/AadEnabledEnum.cs @@ -0,0 +1,22 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDBForPostgreSql.Models +{ + + /// + /// Defines values for AadEnabledEnum. + /// + public static class AadEnabledEnum + { + public const string Enabled = "enabled"; + public const string Disabled = "disabled"; + } +} diff --git a/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ActiveDirectoryAuth.cs b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ActiveDirectoryAuth.cs new file mode 100644 index 000000000000..41f2f39479b2 --- /dev/null +++ b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ActiveDirectoryAuth.cs @@ -0,0 +1,22 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDBForPostgreSql.Models +{ + + /// + /// Defines values for ActiveDirectoryAuth. + /// + public static class ActiveDirectoryAuth + { + public const string Enabled = "enabled"; + public const string Disabled = "disabled"; + } +} diff --git a/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/AuthConfig.cs b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/AuthConfig.cs new file mode 100644 index 000000000000..f04c724d19e0 --- /dev/null +++ b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/AuthConfig.cs @@ -0,0 +1,61 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDBForPostgreSql.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Authentication configuration of a cluster. + /// + public partial class AuthConfig + { + /// + /// Initializes a new instance of the AuthConfig class. + /// + public AuthConfig() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the AuthConfig class. + /// + /// Possible values include: + /// 'enabled', 'disabled' + /// Possible values include: 'enabled', + /// 'disabled' + public AuthConfig(string activeDirectoryAuth = default(string), string passwordAuth = default(string)) + { + ActiveDirectoryAuth = activeDirectoryAuth; + PasswordAuth = passwordAuth; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets possible values include: 'enabled', 'disabled' + /// + [JsonProperty(PropertyName = "activeDirectoryAuth")] + public string ActiveDirectoryAuth { get; set; } + + /// + /// Gets or sets possible values include: 'enabled', 'disabled' + /// + [JsonProperty(PropertyName = "passwordAuth")] + public string PasswordAuth { get; set; } + + } +} diff --git a/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/AzureEntityResource.cs b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/AzureEntityResource.cs new file mode 100644 index 000000000000..9fc51c21a401 --- /dev/null +++ b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/AzureEntityResource.cs @@ -0,0 +1,64 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDBForPostgreSql.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Entity Resource + /// + /// + /// The resource model definition for an Azure Resource Manager resource + /// with an etag. + /// + public partial class AzureEntityResource : Resource + { + /// + /// Initializes a new instance of the AzureEntityResource class. + /// + public AzureEntityResource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the AzureEntityResource class. + /// + /// Fully qualified resource ID for the resource. E.g. + /// "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" + /// The name of the resource + /// The type of the resource. E.g. + /// "Microsoft.Compute/virtualMachines" or + /// "Microsoft.Storage/storageAccounts" + /// Azure Resource Manager metadata containing + /// createdBy and modifiedBy information. + /// Resource Etag. + public AzureEntityResource(string id = default(string), string name = default(string), string type = default(string), SystemData systemData = default(SystemData), string etag = default(string)) + : base(id, name, type, systemData) + { + Etag = etag; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets resource Etag. + /// + [JsonProperty(PropertyName = "etag")] + public string Etag { get; private set; } + + } +} diff --git a/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/Cluster.cs b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/Cluster.cs new file mode 100644 index 000000000000..9532b4799728 --- /dev/null +++ b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/Cluster.cs @@ -0,0 +1,430 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDBForPostgreSql.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Represents a cluster. + /// + [Rest.Serialization.JsonTransformation] + public partial class Cluster : TrackedResource + { + /// + /// Initializes a new instance of the Cluster class. + /// + public Cluster() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Cluster class. + /// + /// The geo-location where the resource + /// lives + /// Fully qualified resource ID for the resource. E.g. + /// "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" + /// The name of the resource + /// The type of the resource. E.g. + /// "Microsoft.Compute/virtualMachines" or + /// "Microsoft.Storage/storageAccounts" + /// Azure Resource Manager metadata containing + /// createdBy and modifiedBy information. + /// Resource tags. + /// Indicates whether the cluster was + /// created using AAD authentication. Possible values include: + /// 'enabled', 'disabled' + /// The administrator's login name of + /// the servers in the cluster. + /// The password of the + /// administrator login. Required for creation. + /// The data encryption properties of a + /// cluster. + /// Provisioning state of the + /// cluster + /// A state of a cluster/server that is visible to + /// user. + /// The major PostgreSQL version on all + /// cluster servers. + /// The Citus extension version on all + /// cluster servers. + /// Maintenance window of a + /// cluster. + /// Preferred primary availability + /// zone (AZ) for all cluster servers. + /// If distributed tables are + /// placed on coordinator or not. Should be set to 'true' on single + /// node clusters. Requires shard rebalancing after value is + /// changed. + /// If high availability (HA) is enabled or not + /// for the cluster. + /// The edition of a coordinator + /// server (default: GeneralPurpose). Required for creation. + /// The storage of a server + /// in MB. Required for creation. See + /// https://learn.microsoft.com/azure/cosmos-db/postgresql/resources-compute + /// for more information. + /// The vCores count of a server (max: + /// 96). Required for creation. See + /// https://learn.microsoft.com/azure/cosmos-db/postgresql/resources-compute + /// for more information. + /// If public access is + /// enabled on coordinator. + /// The edition of a node server + /// (default: MemoryOptimized). + /// Worker node count of the cluster. When node + /// count is 0, it represents a single node configuration with the + /// ability to create distributed tables on that node. 2 or more worker + /// nodes represent multi-node configuration. Node count value cannot + /// be 1. Required for creation. + /// The storage in MB on each worker + /// node. See + /// https://learn.microsoft.com/azure/cosmos-db/postgresql/resources-compute + /// for more information. + /// The compute in vCores on each worker node + /// (max: 104). See + /// https://learn.microsoft.com/azure/cosmos-db/postgresql/resources-compute + /// for more information. + /// If public access is enabled + /// on worker nodes. + /// The list of server names in the + /// cluster + /// The resource id of source cluster + /// for read replica clusters. + /// The Azure region of source cluster for + /// read replica clusters. + /// Indicates whether the cluster was + /// created with a password or using AAD authentication. Possible + /// values include: 'enabled', 'disabled' + /// Date and time in UTC (ISO8601 format) + /// for cluster restore. + /// The array of read replica + /// clusters. + /// The earliest restore point time + /// (ISO8601 format) for the cluster. + /// The private endpoint + /// connections for a cluster. + /// The database name of the cluster. Only + /// one database per cluster is supported. + /// If cluster backup is stored in + /// another Azure region in addition to the copy of the backup stored + /// in the cluster's region. Enabled only at the time of cluster + /// creation. + /// Authentication configuration of a + /// cluster. + /// Describes the identity of the + /// cluster. + public Cluster(string location, string id = default(string), string name = default(string), string type = default(string), SystemData systemData = default(SystemData), IDictionary tags = default(IDictionary), string aadAuthEnabled = default(string), string administratorLogin = default(string), string administratorLoginPassword = default(string), DataEncryption dataEncryption = default(DataEncryption), string provisioningState = default(string), string state = default(string), string postgresqlVersion = default(string), string citusVersion = default(string), MaintenanceWindow maintenanceWindow = default(MaintenanceWindow), string preferredPrimaryZone = default(string), bool? enableShardsOnCoordinator = default(bool?), bool? enableHa = default(bool?), string coordinatorServerEdition = default(string), int? coordinatorStorageQuotaInMb = default(int?), int? coordinatorVCores = default(int?), bool? coordinatorEnablePublicIpAccess = default(bool?), string nodeServerEdition = default(string), int? nodeCount = default(int?), int? nodeStorageQuotaInMb = default(int?), int? nodeVCores = default(int?), bool? nodeEnablePublicIpAccess = default(bool?), IList serverNames = default(IList), string sourceResourceId = default(string), string sourceLocation = default(string), string passwordEnabled = default(string), System.DateTime? pointInTimeUTC = default(System.DateTime?), IList readReplicas = default(IList), System.DateTime? earliestRestoreTime = default(System.DateTime?), IList privateEndpointConnections = default(IList), string databaseName = default(string), bool? enableGeoBackup = default(bool?), AuthConfig authConfig = default(AuthConfig), IdentityProperties identity = default(IdentityProperties)) + : base(location, id, name, type, systemData, tags) + { + AadAuthEnabled = aadAuthEnabled; + AdministratorLogin = administratorLogin; + AdministratorLoginPassword = administratorLoginPassword; + DataEncryption = dataEncryption; + ProvisioningState = provisioningState; + State = state; + PostgresqlVersion = postgresqlVersion; + CitusVersion = citusVersion; + MaintenanceWindow = maintenanceWindow; + PreferredPrimaryZone = preferredPrimaryZone; + EnableShardsOnCoordinator = enableShardsOnCoordinator; + EnableHa = enableHa; + CoordinatorServerEdition = coordinatorServerEdition; + CoordinatorStorageQuotaInMb = coordinatorStorageQuotaInMb; + CoordinatorVCores = coordinatorVCores; + CoordinatorEnablePublicIpAccess = coordinatorEnablePublicIpAccess; + NodeServerEdition = nodeServerEdition; + NodeCount = nodeCount; + NodeStorageQuotaInMb = nodeStorageQuotaInMb; + NodeVCores = nodeVCores; + NodeEnablePublicIpAccess = nodeEnablePublicIpAccess; + ServerNames = serverNames; + SourceResourceId = sourceResourceId; + SourceLocation = sourceLocation; + PasswordEnabled = passwordEnabled; + PointInTimeUTC = pointInTimeUTC; + ReadReplicas = readReplicas; + EarliestRestoreTime = earliestRestoreTime; + PrivateEndpointConnections = privateEndpointConnections; + DatabaseName = databaseName; + EnableGeoBackup = enableGeoBackup; + AuthConfig = authConfig; + Identity = identity; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets indicates whether the cluster was created using AAD + /// authentication. Possible values include: 'enabled', 'disabled' + /// + [JsonProperty(PropertyName = "properties.aadAuthEnabled")] + public string AadAuthEnabled { get; private set; } + + /// + /// Gets the administrator's login name of the servers in the cluster. + /// + [JsonProperty(PropertyName = "properties.administratorLogin")] + public string AdministratorLogin { get; private set; } + + /// + /// Gets or sets the password of the administrator login. Required for + /// creation. + /// + [JsonProperty(PropertyName = "properties.administratorLoginPassword")] + public string AdministratorLoginPassword { get; set; } + + /// + /// Gets or sets the data encryption properties of a cluster. + /// + [JsonProperty(PropertyName = "properties.dataEncryption")] + public DataEncryption DataEncryption { get; set; } + + /// + /// Gets provisioning state of the cluster + /// + [JsonProperty(PropertyName = "properties.provisioningState")] + public string ProvisioningState { get; private set; } + + /// + /// Gets a state of a cluster/server that is visible to user. + /// + [JsonProperty(PropertyName = "properties.state")] + public string State { get; private set; } + + /// + /// Gets or sets the major PostgreSQL version on all cluster servers. + /// + [JsonProperty(PropertyName = "properties.postgresqlVersion")] + public string PostgresqlVersion { get; set; } + + /// + /// Gets or sets the Citus extension version on all cluster servers. + /// + [JsonProperty(PropertyName = "properties.citusVersion")] + public string CitusVersion { get; set; } + + /// + /// Gets or sets maintenance window of a cluster. + /// + [JsonProperty(PropertyName = "properties.maintenanceWindow")] + public MaintenanceWindow MaintenanceWindow { get; set; } + + /// + /// Gets or sets preferred primary availability zone (AZ) for all + /// cluster servers. + /// + [JsonProperty(PropertyName = "properties.preferredPrimaryZone")] + public string PreferredPrimaryZone { get; set; } + + /// + /// Gets or sets if distributed tables are placed on coordinator or + /// not. Should be set to 'true' on single node clusters. Requires + /// shard rebalancing after value is changed. + /// + [JsonProperty(PropertyName = "properties.enableShardsOnCoordinator")] + public bool? EnableShardsOnCoordinator { get; set; } + + /// + /// Gets or sets if high availability (HA) is enabled or not for the + /// cluster. + /// + [JsonProperty(PropertyName = "properties.enableHa")] + public bool? EnableHa { get; set; } + + /// + /// Gets or sets the edition of a coordinator server (default: + /// GeneralPurpose). Required for creation. + /// + [JsonProperty(PropertyName = "properties.coordinatorServerEdition")] + public string CoordinatorServerEdition { get; set; } + + /// + /// Gets or sets the storage of a server in MB. Required for creation. + /// See + /// https://learn.microsoft.com/azure/cosmos-db/postgresql/resources-compute + /// for more information. + /// + [JsonProperty(PropertyName = "properties.coordinatorStorageQuotaInMb")] + public int? CoordinatorStorageQuotaInMb { get; set; } + + /// + /// Gets or sets the vCores count of a server (max: 96). Required for + /// creation. See + /// https://learn.microsoft.com/azure/cosmos-db/postgresql/resources-compute + /// for more information. + /// + [JsonProperty(PropertyName = "properties.coordinatorVCores")] + public int? CoordinatorVCores { get; set; } + + /// + /// Gets or sets if public access is enabled on coordinator. + /// + [JsonProperty(PropertyName = "properties.coordinatorEnablePublicIpAccess")] + public bool? CoordinatorEnablePublicIpAccess { get; set; } + + /// + /// Gets or sets the edition of a node server (default: + /// MemoryOptimized). + /// + [JsonProperty(PropertyName = "properties.nodeServerEdition")] + public string NodeServerEdition { get; set; } + + /// + /// Gets or sets worker node count of the cluster. When node count is + /// 0, it represents a single node configuration with the ability to + /// create distributed tables on that node. 2 or more worker nodes + /// represent multi-node configuration. Node count value cannot be 1. + /// Required for creation. + /// + [JsonProperty(PropertyName = "properties.nodeCount")] + public int? NodeCount { get; set; } + + /// + /// Gets or sets the storage in MB on each worker node. See + /// https://learn.microsoft.com/azure/cosmos-db/postgresql/resources-compute + /// for more information. + /// + [JsonProperty(PropertyName = "properties.nodeStorageQuotaInMb")] + public int? NodeStorageQuotaInMb { get; set; } + + /// + /// Gets or sets the compute in vCores on each worker node (max: 104). + /// See + /// https://learn.microsoft.com/azure/cosmos-db/postgresql/resources-compute + /// for more information. + /// + [JsonProperty(PropertyName = "properties.nodeVCores")] + public int? NodeVCores { get; set; } + + /// + /// Gets or sets if public access is enabled on worker nodes. + /// + [JsonProperty(PropertyName = "properties.nodeEnablePublicIpAccess")] + public bool? NodeEnablePublicIpAccess { get; set; } + + /// + /// Gets the list of server names in the cluster + /// + [JsonProperty(PropertyName = "properties.serverNames")] + public IList ServerNames { get; private set; } + + /// + /// Gets or sets the resource id of source cluster for read replica + /// clusters. + /// + [JsonProperty(PropertyName = "properties.sourceResourceId")] + public string SourceResourceId { get; set; } + + /// + /// Gets or sets the Azure region of source cluster for read replica + /// clusters. + /// + [JsonProperty(PropertyName = "properties.sourceLocation")] + public string SourceLocation { get; set; } + + /// + /// Gets indicates whether the cluster was created with a password or + /// using AAD authentication. Possible values include: 'enabled', + /// 'disabled' + /// + [JsonProperty(PropertyName = "properties.passwordEnabled")] + public string PasswordEnabled { get; private set; } + + /// + /// Gets or sets date and time in UTC (ISO8601 format) for cluster + /// restore. + /// + [JsonProperty(PropertyName = "properties.pointInTimeUTC")] + public System.DateTime? PointInTimeUTC { get; set; } + + /// + /// Gets the array of read replica clusters. + /// + [JsonProperty(PropertyName = "properties.readReplicas")] + public IList ReadReplicas { get; private set; } + + /// + /// Gets the earliest restore point time (ISO8601 format) for the + /// cluster. + /// + [JsonProperty(PropertyName = "properties.earliestRestoreTime")] + public System.DateTime? EarliestRestoreTime { get; private set; } + + /// + /// Gets the private endpoint connections for a cluster. + /// + [JsonProperty(PropertyName = "properties.privateEndpointConnections")] + public IList PrivateEndpointConnections { get; private set; } + + /// + /// Gets or sets the database name of the cluster. Only one database + /// per cluster is supported. + /// + [JsonProperty(PropertyName = "properties.databaseName")] + public string DatabaseName { get; set; } + + /// + /// Gets or sets if cluster backup is stored in another Azure region in + /// addition to the copy of the backup stored in the cluster's region. + /// Enabled only at the time of cluster creation. + /// + [JsonProperty(PropertyName = "properties.enableGeoBackup")] + public bool? EnableGeoBackup { get; set; } + + /// + /// Gets or sets authentication configuration of a cluster. + /// + [JsonProperty(PropertyName = "properties.authConfig")] + public AuthConfig AuthConfig { get; set; } + + /// + /// Gets or sets describes the identity of the cluster. + /// + [JsonProperty(PropertyName = "identity")] + public IdentityProperties Identity { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public override void Validate() + { + base.Validate(); + if (ServerNames != null) + { + if (ServerNames.Count != System.Linq.Enumerable.Count(System.Linq.Enumerable.Distinct(ServerNames))) + { + throw new ValidationException(ValidationRules.UniqueItems, "ServerNames"); + } + } + if (ReadReplicas != null) + { + if (ReadReplicas.Count != System.Linq.Enumerable.Count(System.Linq.Enumerable.Distinct(ReadReplicas))) + { + throw new ValidationException(ValidationRules.UniqueItems, "ReadReplicas"); + } + } + } + } +} diff --git a/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ClusterForUpdate.cs b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ClusterForUpdate.cs new file mode 100644 index 000000000000..3b4be1a7e753 --- /dev/null +++ b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ClusterForUpdate.cs @@ -0,0 +1,226 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDBForPostgreSql.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Represents a cluster for update. + /// + [Rest.Serialization.JsonTransformation] + public partial class ClusterForUpdate + { + /// + /// Initializes a new instance of the ClusterForUpdate class. + /// + public ClusterForUpdate() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ClusterForUpdate class. + /// + /// The password of the + /// administrator login. Each cluster is created with pre-defined + /// administrative role called ‘citus’.  + /// The major PostgreSQL version on all + /// cluster servers. + /// The Citus extension version on all + /// cluster servers. + /// If distributed tables are + /// placed on coordinator or not. Should be set to 'true' on single + /// node clusters. Requires shard rebalancing after value is + /// changed. + /// If high availability (HA) is enabled or not + /// for the cluster. + /// Preferred primary availability + /// zone (AZ) for all cluster servers. + /// The edition of the + /// coordinator (default: GeneralPurpose). + /// The storage of the + /// coordinator in MB. + /// The vCores count of the coordinator + /// (max: 96). + /// If public access is + /// enabled on coordinator. + /// The edition of a node (default: + /// MemoryOptimized). + /// Worker node count of the cluster. When node + /// count is 0, it represents a single node configuration with the + /// ability to create distributed tables on that node. 2 or more worker + /// nodes represent multi-node configuration. Node count value cannot + /// be 1. + /// The storage in MB on each worker + /// node. + /// The compute in vCores on each worker node + /// (max: 104). + /// If public access is enabled + /// on worker nodes. + /// Maintenance window of a + /// cluster. + /// Describes the identity of the + /// cluster. + /// Application-specific metadata in the form of + /// key-value pairs. + public ClusterForUpdate(string administratorLoginPassword = default(string), string postgresqlVersion = default(string), string citusVersion = default(string), bool? enableShardsOnCoordinator = default(bool?), bool? enableHa = default(bool?), string preferredPrimaryZone = default(string), string coordinatorServerEdition = default(string), int? coordinatorStorageQuotaInMb = default(int?), int? coordinatorVCores = default(int?), bool? coordinatorEnablePublicIpAccess = default(bool?), string nodeServerEdition = default(string), int? nodeCount = default(int?), int? nodeStorageQuotaInMb = default(int?), int? nodeVCores = default(int?), bool? nodeEnablePublicIpAccess = default(bool?), MaintenanceWindow maintenanceWindow = default(MaintenanceWindow), IdentityProperties identity = default(IdentityProperties), IDictionary tags = default(IDictionary)) + { + AdministratorLoginPassword = administratorLoginPassword; + PostgresqlVersion = postgresqlVersion; + CitusVersion = citusVersion; + EnableShardsOnCoordinator = enableShardsOnCoordinator; + EnableHa = enableHa; + PreferredPrimaryZone = preferredPrimaryZone; + CoordinatorServerEdition = coordinatorServerEdition; + CoordinatorStorageQuotaInMb = coordinatorStorageQuotaInMb; + CoordinatorVCores = coordinatorVCores; + CoordinatorEnablePublicIpAccess = coordinatorEnablePublicIpAccess; + NodeServerEdition = nodeServerEdition; + NodeCount = nodeCount; + NodeStorageQuotaInMb = nodeStorageQuotaInMb; + NodeVCores = nodeVCores; + NodeEnablePublicIpAccess = nodeEnablePublicIpAccess; + MaintenanceWindow = maintenanceWindow; + Identity = identity; + Tags = tags; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the password of the administrator login. Each cluster + /// is created with pre-defined administrative role called ‘citus’. + /// + [JsonProperty(PropertyName = "properties.administratorLoginPassword")] + public string AdministratorLoginPassword { get; set; } + + /// + /// Gets or sets the major PostgreSQL version on all cluster servers. + /// + [JsonProperty(PropertyName = "properties.postgresqlVersion")] + public string PostgresqlVersion { get; set; } + + /// + /// Gets or sets the Citus extension version on all cluster servers. + /// + [JsonProperty(PropertyName = "properties.citusVersion")] + public string CitusVersion { get; set; } + + /// + /// Gets or sets if distributed tables are placed on coordinator or + /// not. Should be set to 'true' on single node clusters. Requires + /// shard rebalancing after value is changed. + /// + [JsonProperty(PropertyName = "properties.enableShardsOnCoordinator")] + public bool? EnableShardsOnCoordinator { get; set; } + + /// + /// Gets or sets if high availability (HA) is enabled or not for the + /// cluster. + /// + [JsonProperty(PropertyName = "properties.enableHa")] + public bool? EnableHa { get; set; } + + /// + /// Gets or sets preferred primary availability zone (AZ) for all + /// cluster servers. + /// + [JsonProperty(PropertyName = "properties.preferredPrimaryZone")] + public string PreferredPrimaryZone { get; set; } + + /// + /// Gets or sets the edition of the coordinator (default: + /// GeneralPurpose). + /// + [JsonProperty(PropertyName = "properties.coordinatorServerEdition")] + public string CoordinatorServerEdition { get; set; } + + /// + /// Gets or sets the storage of the coordinator in MB. + /// + [JsonProperty(PropertyName = "properties.coordinatorStorageQuotaInMb")] + public int? CoordinatorStorageQuotaInMb { get; set; } + + /// + /// Gets or sets the vCores count of the coordinator (max: 96). + /// + [JsonProperty(PropertyName = "properties.coordinatorVCores")] + public int? CoordinatorVCores { get; set; } + + /// + /// Gets or sets if public access is enabled on coordinator. + /// + [JsonProperty(PropertyName = "properties.coordinatorEnablePublicIpAccess")] + public bool? CoordinatorEnablePublicIpAccess { get; set; } + + /// + /// Gets or sets the edition of a node (default: MemoryOptimized). + /// + [JsonProperty(PropertyName = "properties.nodeServerEdition")] + public string NodeServerEdition { get; set; } + + /// + /// Gets or sets worker node count of the cluster. When node count is + /// 0, it represents a single node configuration with the ability to + /// create distributed tables on that node. 2 or more worker nodes + /// represent multi-node configuration. Node count value cannot be 1. + /// + [JsonProperty(PropertyName = "properties.nodeCount")] + public int? NodeCount { get; set; } + + /// + /// Gets or sets the storage in MB on each worker node. + /// + [JsonProperty(PropertyName = "properties.nodeStorageQuotaInMb")] + public int? NodeStorageQuotaInMb { get; set; } + + /// + /// Gets or sets the compute in vCores on each worker node (max: 104). + /// + [JsonProperty(PropertyName = "properties.nodeVCores")] + public int? NodeVCores { get; set; } + + /// + /// Gets if public access is enabled on worker nodes. + /// + [JsonProperty(PropertyName = "properties.nodeEnablePublicIpAccess")] + public bool? NodeEnablePublicIpAccess { get; private set; } + + /// + /// Gets or sets maintenance window of a cluster. + /// + [JsonProperty(PropertyName = "properties.maintenanceWindow")] + public MaintenanceWindow MaintenanceWindow { get; set; } + + /// + /// Gets or sets describes the identity of the cluster. + /// + [JsonProperty(PropertyName = "identity")] + public IdentityProperties Identity { get; set; } + + /// + /// Gets or sets application-specific metadata in the form of key-value + /// pairs. + /// + [JsonProperty(PropertyName = "tags")] + public IDictionary Tags { get; set; } + + } +} diff --git a/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ClusterServer.cs b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ClusterServer.cs new file mode 100644 index 000000000000..c451466821b3 --- /dev/null +++ b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ClusterServer.cs @@ -0,0 +1,182 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDBForPostgreSql.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Represents a server in a cluster. + /// + [Rest.Serialization.JsonTransformation] + public partial class ClusterServer : ProxyResource + { + /// + /// Initializes a new instance of the ClusterServer class. + /// + public ClusterServer() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ClusterServer class. + /// + /// Fully qualified resource ID for the resource. E.g. + /// "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" + /// The name of the resource + /// The type of the resource. E.g. + /// "Microsoft.Compute/virtualMachines" or + /// "Microsoft.Storage/storageAccounts" + /// Azure Resource Manager metadata containing + /// createdBy and modifiedBy information. + /// The edition of a server. + /// The storage of a server in + /// MB. + /// The vCores count of a server. + /// If high availability (HA) is enabled or not + /// for the server. + /// If public access is enabled on + /// server. + /// If server database is set to read-only by + /// system maintenance depending on high disk space usage. + /// The administrator's login name of + /// the servers in the cluster. + /// The fully qualified domain + /// name of a server. + /// The role of server in the cluster. Possible + /// values include: 'Coordinator', 'Worker' + /// A state of a cluster/server that is visible to + /// user. + /// A state of HA feature for the + /// cluster. + /// Availability Zone information of the + /// server. + /// The major PostgreSQL version of + /// server. + /// The Citus extension version of + /// server. + public ClusterServer(string id = default(string), string name = default(string), string type = default(string), SystemData systemData = default(SystemData), string serverEdition = default(string), int? storageQuotaInMb = default(int?), int? vCores = default(int?), bool? enableHa = default(bool?), bool? enablePublicIpAccess = default(bool?), bool? isReadOnly = default(bool?), string administratorLogin = default(string), string fullyQualifiedDomainName = default(string), string role = default(string), string state = default(string), string haState = default(string), string availabilityZone = default(string), string postgresqlVersion = default(string), string citusVersion = default(string)) + : base(id, name, type, systemData) + { + ServerEdition = serverEdition; + StorageQuotaInMb = storageQuotaInMb; + VCores = vCores; + EnableHa = enableHa; + EnablePublicIpAccess = enablePublicIpAccess; + IsReadOnly = isReadOnly; + AdministratorLogin = administratorLogin; + FullyQualifiedDomainName = fullyQualifiedDomainName; + Role = role; + State = state; + HaState = haState; + AvailabilityZone = availabilityZone; + PostgresqlVersion = postgresqlVersion; + CitusVersion = citusVersion; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the edition of a server. + /// + [JsonProperty(PropertyName = "properties.serverEdition")] + public string ServerEdition { get; set; } + + /// + /// Gets or sets the storage of a server in MB. + /// + [JsonProperty(PropertyName = "properties.storageQuotaInMb")] + public int? StorageQuotaInMb { get; set; } + + /// + /// Gets or sets the vCores count of a server. + /// + [JsonProperty(PropertyName = "properties.vCores")] + public int? VCores { get; set; } + + /// + /// Gets or sets if high availability (HA) is enabled or not for the + /// server. + /// + [JsonProperty(PropertyName = "properties.enableHa")] + public bool? EnableHa { get; set; } + + /// + /// Gets if public access is enabled on server. + /// + [JsonProperty(PropertyName = "properties.enablePublicIpAccess")] + public bool? EnablePublicIpAccess { get; private set; } + + /// + /// Gets if server database is set to read-only by system maintenance + /// depending on high disk space usage. + /// + [JsonProperty(PropertyName = "properties.isReadOnly")] + public bool? IsReadOnly { get; private set; } + + /// + /// Gets the administrator's login name of the servers in the cluster. + /// + [JsonProperty(PropertyName = "properties.administratorLogin")] + public string AdministratorLogin { get; private set; } + + /// + /// Gets the fully qualified domain name of a server. + /// + [JsonProperty(PropertyName = "properties.fullyQualifiedDomainName")] + public string FullyQualifiedDomainName { get; private set; } + + /// + /// Gets or sets the role of server in the cluster. Possible values + /// include: 'Coordinator', 'Worker' + /// + [JsonProperty(PropertyName = "properties.role")] + public string Role { get; set; } + + /// + /// Gets a state of a cluster/server that is visible to user. + /// + [JsonProperty(PropertyName = "properties.state")] + public string State { get; private set; } + + /// + /// Gets a state of HA feature for the cluster. + /// + [JsonProperty(PropertyName = "properties.haState")] + public string HaState { get; private set; } + + /// + /// Gets or sets availability Zone information of the server. + /// + [JsonProperty(PropertyName = "properties.availabilityZone")] + public string AvailabilityZone { get; set; } + + /// + /// Gets or sets the major PostgreSQL version of server. + /// + [JsonProperty(PropertyName = "properties.postgresqlVersion")] + public string PostgresqlVersion { get; set; } + + /// + /// Gets or sets the Citus extension version of server. + /// + [JsonProperty(PropertyName = "properties.citusVersion")] + public string CitusVersion { get; set; } + + } +} diff --git a/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ClustersCreateHeaders.cs b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ClustersCreateHeaders.cs new file mode 100644 index 000000000000..5c97beca37b4 --- /dev/null +++ b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ClustersCreateHeaders.cs @@ -0,0 +1,55 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDBForPostgreSql.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Defines headers for Create operation. + /// + public partial class ClustersCreateHeaders + { + /// + /// Initializes a new instance of the ClustersCreateHeaders class. + /// + public ClustersCreateHeaders() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ClustersCreateHeaders class. + /// + public ClustersCreateHeaders(string location = default(string), string azureAsyncOperation = default(string)) + { + Location = location; + AzureAsyncOperation = azureAsyncOperation; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// + [JsonProperty(PropertyName = "location")] + public string Location { get; set; } + + /// + /// + [JsonProperty(PropertyName = "azure-async-operation")] + public string AzureAsyncOperation { get; set; } + + } +} diff --git a/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ClustersDeleteHeaders.cs b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ClustersDeleteHeaders.cs new file mode 100644 index 000000000000..74ebe9a7b269 --- /dev/null +++ b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ClustersDeleteHeaders.cs @@ -0,0 +1,55 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDBForPostgreSql.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Defines headers for Delete operation. + /// + public partial class ClustersDeleteHeaders + { + /// + /// Initializes a new instance of the ClustersDeleteHeaders class. + /// + public ClustersDeleteHeaders() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ClustersDeleteHeaders class. + /// + public ClustersDeleteHeaders(string location = default(string), string azureAsyncOperation = default(string)) + { + Location = location; + AzureAsyncOperation = azureAsyncOperation; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// + [JsonProperty(PropertyName = "location")] + public string Location { get; set; } + + /// + /// + [JsonProperty(PropertyName = "azure-async-operation")] + public string AzureAsyncOperation { get; set; } + + } +} diff --git a/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ClustersPromoteReadReplicaHeaders.cs b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ClustersPromoteReadReplicaHeaders.cs new file mode 100644 index 000000000000..73b87ded1af1 --- /dev/null +++ b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ClustersPromoteReadReplicaHeaders.cs @@ -0,0 +1,57 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDBForPostgreSql.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Defines headers for PromoteReadReplica operation. + /// + public partial class ClustersPromoteReadReplicaHeaders + { + /// + /// Initializes a new instance of the ClustersPromoteReadReplicaHeaders + /// class. + /// + public ClustersPromoteReadReplicaHeaders() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ClustersPromoteReadReplicaHeaders + /// class. + /// + public ClustersPromoteReadReplicaHeaders(string location = default(string), string azureAsyncOperation = default(string)) + { + Location = location; + AzureAsyncOperation = azureAsyncOperation; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// + [JsonProperty(PropertyName = "location")] + public string Location { get; set; } + + /// + /// + [JsonProperty(PropertyName = "azure-async-operation")] + public string AzureAsyncOperation { get; set; } + + } +} diff --git a/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ClustersRestartHeaders.cs b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ClustersRestartHeaders.cs new file mode 100644 index 000000000000..b4190398a2cc --- /dev/null +++ b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ClustersRestartHeaders.cs @@ -0,0 +1,55 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDBForPostgreSql.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Defines headers for Restart operation. + /// + public partial class ClustersRestartHeaders + { + /// + /// Initializes a new instance of the ClustersRestartHeaders class. + /// + public ClustersRestartHeaders() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ClustersRestartHeaders class. + /// + public ClustersRestartHeaders(string location = default(string), string azureAsyncOperation = default(string)) + { + Location = location; + AzureAsyncOperation = azureAsyncOperation; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// + [JsonProperty(PropertyName = "location")] + public string Location { get; set; } + + /// + /// + [JsonProperty(PropertyName = "azure-async-operation")] + public string AzureAsyncOperation { get; set; } + + } +} diff --git a/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ClustersStartHeaders.cs b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ClustersStartHeaders.cs new file mode 100644 index 000000000000..97219965083f --- /dev/null +++ b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ClustersStartHeaders.cs @@ -0,0 +1,55 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDBForPostgreSql.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Defines headers for Start operation. + /// + public partial class ClustersStartHeaders + { + /// + /// Initializes a new instance of the ClustersStartHeaders class. + /// + public ClustersStartHeaders() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ClustersStartHeaders class. + /// + public ClustersStartHeaders(string location = default(string), string azureAsyncOperation = default(string)) + { + Location = location; + AzureAsyncOperation = azureAsyncOperation; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// + [JsonProperty(PropertyName = "location")] + public string Location { get; set; } + + /// + /// + [JsonProperty(PropertyName = "azure-async-operation")] + public string AzureAsyncOperation { get; set; } + + } +} diff --git a/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ClustersStopHeaders.cs b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ClustersStopHeaders.cs new file mode 100644 index 000000000000..7c0592b196f8 --- /dev/null +++ b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ClustersStopHeaders.cs @@ -0,0 +1,55 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDBForPostgreSql.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Defines headers for Stop operation. + /// + public partial class ClustersStopHeaders + { + /// + /// Initializes a new instance of the ClustersStopHeaders class. + /// + public ClustersStopHeaders() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ClustersStopHeaders class. + /// + public ClustersStopHeaders(string location = default(string), string azureAsyncOperation = default(string)) + { + Location = location; + AzureAsyncOperation = azureAsyncOperation; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// + [JsonProperty(PropertyName = "location")] + public string Location { get; set; } + + /// + /// + [JsonProperty(PropertyName = "azure-async-operation")] + public string AzureAsyncOperation { get; set; } + + } +} diff --git a/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ClustersUpdateHeaders.cs b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ClustersUpdateHeaders.cs new file mode 100644 index 000000000000..ccbff3971849 --- /dev/null +++ b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ClustersUpdateHeaders.cs @@ -0,0 +1,55 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDBForPostgreSql.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Defines headers for Update operation. + /// + public partial class ClustersUpdateHeaders + { + /// + /// Initializes a new instance of the ClustersUpdateHeaders class. + /// + public ClustersUpdateHeaders() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ClustersUpdateHeaders class. + /// + public ClustersUpdateHeaders(string location = default(string), string azureAsyncOperation = default(string)) + { + Location = location; + AzureAsyncOperation = azureAsyncOperation; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// + [JsonProperty(PropertyName = "location")] + public string Location { get; set; } + + /// + /// + [JsonProperty(PropertyName = "azure-async-operation")] + public string AzureAsyncOperation { get; set; } + + } +} diff --git a/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/Configuration.cs b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/Configuration.cs new file mode 100644 index 000000000000..24cdc3ea7ff7 --- /dev/null +++ b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/Configuration.cs @@ -0,0 +1,141 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDBForPostgreSql.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Represents configuration details for coordinator and node. + /// + [Rest.Serialization.JsonTransformation] + public partial class Configuration : ProxyResource + { + /// + /// Initializes a new instance of the Configuration class. + /// + public Configuration() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Configuration class. + /// + /// The list of server role + /// group configuration values. + /// Fully qualified resource ID for the resource. E.g. + /// "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" + /// The name of the resource + /// The type of the resource. E.g. + /// "Microsoft.Compute/virtualMachines" or + /// "Microsoft.Storage/storageAccounts" + /// Azure Resource Manager metadata containing + /// createdBy and modifiedBy information. + /// Description of the configuration. + /// Data type of the configuration. Possible + /// values include: 'Boolean', 'Numeric', 'Integer', + /// 'Enumeration' + /// Allowed values of the + /// configuration. + /// If configuration change requires + /// restart. + /// Provisioning state of the + /// configuration. Possible values include: 'Succeeded', 'Canceled', + /// 'InProgress', 'Failed' + public Configuration(IList serverRoleGroupConfigurations, string id = default(string), string name = default(string), string type = default(string), SystemData systemData = default(SystemData), string description = default(string), string dataType = default(string), string allowedValues = default(string), bool? requiresRestart = default(bool?), string provisioningState = default(string)) + : base(id, name, type, systemData) + { + Description = description; + DataType = dataType; + AllowedValues = allowedValues; + RequiresRestart = requiresRestart; + ServerRoleGroupConfigurations = serverRoleGroupConfigurations; + ProvisioningState = provisioningState; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets description of the configuration. + /// + [JsonProperty(PropertyName = "properties.description")] + public string Description { get; private set; } + + /// + /// Gets data type of the configuration. Possible values include: + /// 'Boolean', 'Numeric', 'Integer', 'Enumeration' + /// + [JsonProperty(PropertyName = "properties.dataType")] + public string DataType { get; private set; } + + /// + /// Gets allowed values of the configuration. + /// + [JsonProperty(PropertyName = "properties.allowedValues")] + public string AllowedValues { get; private set; } + + /// + /// Gets or sets if configuration change requires restart. + /// + [JsonProperty(PropertyName = "properties.requiresRestart")] + public bool? RequiresRestart { get; set; } + + /// + /// Gets or sets the list of server role group configuration values. + /// + [JsonProperty(PropertyName = "properties.serverRoleGroupConfigurations")] + public IList ServerRoleGroupConfigurations { get; set; } + + /// + /// Gets provisioning state of the configuration. Possible values + /// include: 'Succeeded', 'Canceled', 'InProgress', 'Failed' + /// + [JsonProperty(PropertyName = "properties.provisioningState")] + public string ProvisioningState { get; private set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (ServerRoleGroupConfigurations == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "ServerRoleGroupConfigurations"); + } + if (ServerRoleGroupConfigurations != null) + { + if (ServerRoleGroupConfigurations.Count != System.Linq.Enumerable.Count(System.Linq.Enumerable.Distinct(ServerRoleGroupConfigurations))) + { + throw new ValidationException(ValidationRules.UniqueItems, "ServerRoleGroupConfigurations"); + } + foreach (var element in ServerRoleGroupConfigurations) + { + if (element != null) + { + element.Validate(); + } + } + } + } + } +} diff --git a/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ConfigurationDataType.cs b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ConfigurationDataType.cs new file mode 100644 index 000000000000..a7e709701f14 --- /dev/null +++ b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ConfigurationDataType.cs @@ -0,0 +1,24 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDBForPostgreSql.Models +{ + + /// + /// Defines values for ConfigurationDataType. + /// + public static class ConfigurationDataType + { + public const string Boolean = "Boolean"; + public const string Numeric = "Numeric"; + public const string Integer = "Integer"; + public const string Enumeration = "Enumeration"; + } +} diff --git a/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ConfigurationsUpdateOnCoordinatorHeaders.cs b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ConfigurationsUpdateOnCoordinatorHeaders.cs new file mode 100644 index 000000000000..828bd9f11b32 --- /dev/null +++ b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ConfigurationsUpdateOnCoordinatorHeaders.cs @@ -0,0 +1,57 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDBForPostgreSql.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Defines headers for UpdateOnCoordinator operation. + /// + public partial class ConfigurationsUpdateOnCoordinatorHeaders + { + /// + /// Initializes a new instance of the + /// ConfigurationsUpdateOnCoordinatorHeaders class. + /// + public ConfigurationsUpdateOnCoordinatorHeaders() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// ConfigurationsUpdateOnCoordinatorHeaders class. + /// + public ConfigurationsUpdateOnCoordinatorHeaders(string location = default(string), string azureAsyncOperation = default(string)) + { + Location = location; + AzureAsyncOperation = azureAsyncOperation; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// + [JsonProperty(PropertyName = "location")] + public string Location { get; set; } + + /// + /// + [JsonProperty(PropertyName = "azure-async-operation")] + public string AzureAsyncOperation { get; set; } + + } +} diff --git a/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ConfigurationsUpdateOnNodeHeaders.cs b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ConfigurationsUpdateOnNodeHeaders.cs new file mode 100644 index 000000000000..3bd852e34477 --- /dev/null +++ b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ConfigurationsUpdateOnNodeHeaders.cs @@ -0,0 +1,57 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDBForPostgreSql.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Defines headers for UpdateOnNode operation. + /// + public partial class ConfigurationsUpdateOnNodeHeaders + { + /// + /// Initializes a new instance of the ConfigurationsUpdateOnNodeHeaders + /// class. + /// + public ConfigurationsUpdateOnNodeHeaders() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ConfigurationsUpdateOnNodeHeaders + /// class. + /// + public ConfigurationsUpdateOnNodeHeaders(string location = default(string), string azureAsyncOperation = default(string)) + { + Location = location; + AzureAsyncOperation = azureAsyncOperation; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// + [JsonProperty(PropertyName = "location")] + public string Location { get; set; } + + /// + /// + [JsonProperty(PropertyName = "azure-async-operation")] + public string AzureAsyncOperation { get; set; } + + } +} diff --git a/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/CreatedByType.cs b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/CreatedByType.cs new file mode 100644 index 000000000000..1221ea847e1d --- /dev/null +++ b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/CreatedByType.cs @@ -0,0 +1,24 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDBForPostgreSql.Models +{ + + /// + /// Defines values for CreatedByType. + /// + public static class CreatedByType + { + public const string User = "User"; + public const string Application = "Application"; + public const string ManagedIdentity = "ManagedIdentity"; + public const string Key = "Key"; + } +} diff --git a/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/DataEncryption.cs b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/DataEncryption.cs new file mode 100644 index 000000000000..573bde203cb2 --- /dev/null +++ b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/DataEncryption.cs @@ -0,0 +1,74 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDBForPostgreSql.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The data encryption properties of a cluster. + /// + public partial class DataEncryption + { + /// + /// Initializes a new instance of the DataEncryption class. + /// + public DataEncryption() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the DataEncryption class. + /// + /// URI for the key in keyvault for data + /// encryption of the primary server. + /// Resource Id for the + /// User assigned identity to be used for data encryption of the + /// primary server. + /// Possible values include: 'AzureKeyVault', + /// 'SystemAssigned' + public DataEncryption(string primaryKeyUri = default(string), string primaryUserAssignedIdentityId = default(string), string type = default(string)) + { + PrimaryKeyUri = primaryKeyUri; + PrimaryUserAssignedIdentityId = primaryUserAssignedIdentityId; + Type = type; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets URI for the key in keyvault for data encryption of the + /// primary server. + /// + [JsonProperty(PropertyName = "primaryKeyUri")] + public string PrimaryKeyUri { get; set; } + + /// + /// Gets or sets resource Id for the User assigned identity to be used + /// for data encryption of the primary server. + /// + [JsonProperty(PropertyName = "primaryUserAssignedIdentityId")] + public string PrimaryUserAssignedIdentityId { get; set; } + + /// + /// Gets or sets possible values include: 'AzureKeyVault', + /// 'SystemAssigned' + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; set; } + + } +} diff --git a/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/DataEncryptionType.cs b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/DataEncryptionType.cs new file mode 100644 index 000000000000..8824b210aa3e --- /dev/null +++ b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/DataEncryptionType.cs @@ -0,0 +1,22 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDBForPostgreSql.Models +{ + + /// + /// Defines values for DataEncryptionType. + /// + public static class DataEncryptionType + { + public const string AzureKeyVault = "AzureKeyVault"; + public const string SystemAssigned = "SystemAssigned"; + } +} diff --git a/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ErrorAdditionalInfo.cs b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ErrorAdditionalInfo.cs new file mode 100644 index 000000000000..dabc4670474a --- /dev/null +++ b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ErrorAdditionalInfo.cs @@ -0,0 +1,59 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDBForPostgreSql.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The resource management error additional info. + /// + public partial class ErrorAdditionalInfo + { + /// + /// Initializes a new instance of the ErrorAdditionalInfo class. + /// + public ErrorAdditionalInfo() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ErrorAdditionalInfo class. + /// + /// The additional info type. + /// The additional info. + public ErrorAdditionalInfo(string type = default(string), object info = default(object)) + { + Type = type; + Info = info; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the additional info type. + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; private set; } + + /// + /// Gets the additional info. + /// + [JsonProperty(PropertyName = "info")] + public object Info { get; private set; } + + } +} diff --git a/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ErrorDetail.cs b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ErrorDetail.cs new file mode 100644 index 000000000000..c779afd5a463 --- /dev/null +++ b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ErrorDetail.cs @@ -0,0 +1,85 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDBForPostgreSql.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The error detail. + /// + public partial class ErrorDetail + { + /// + /// Initializes a new instance of the ErrorDetail class. + /// + public ErrorDetail() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ErrorDetail class. + /// + /// The error code. + /// The error message. + /// The error target. + /// The error details. + /// The error additional info. + public ErrorDetail(string code = default(string), string message = default(string), string target = default(string), IList details = default(IList), IList additionalInfo = default(IList)) + { + Code = code; + Message = message; + Target = target; + Details = details; + AdditionalInfo = additionalInfo; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the error code. + /// + [JsonProperty(PropertyName = "code")] + public string Code { get; private set; } + + /// + /// Gets the error message. + /// + [JsonProperty(PropertyName = "message")] + public string Message { get; private set; } + + /// + /// Gets the error target. + /// + [JsonProperty(PropertyName = "target")] + public string Target { get; private set; } + + /// + /// Gets the error details. + /// + [JsonProperty(PropertyName = "details")] + public IList Details { get; private set; } + + /// + /// Gets the error additional info. + /// + [JsonProperty(PropertyName = "additionalInfo")] + public IList AdditionalInfo { get; private set; } + + } +} diff --git a/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ErrorResponse.cs b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ErrorResponse.cs new file mode 100644 index 000000000000..9b32916f104b --- /dev/null +++ b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ErrorResponse.cs @@ -0,0 +1,56 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDBForPostgreSql.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Error response + /// + /// + /// Common error response for all Azure Resource Manager APIs to return + /// error details for failed operations. (This also follows the OData error + /// response format.). + /// + public partial class ErrorResponse + { + /// + /// Initializes a new instance of the ErrorResponse class. + /// + public ErrorResponse() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ErrorResponse class. + /// + /// The error object. + public ErrorResponse(ErrorDetail error = default(ErrorDetail)) + { + Error = error; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the error object. + /// + [JsonProperty(PropertyName = "error")] + public ErrorDetail Error { get; set; } + + } +} diff --git a/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ErrorResponseException.cs b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ErrorResponseException.cs new file mode 100644 index 000000000000..528f367ceeba --- /dev/null +++ b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ErrorResponseException.cs @@ -0,0 +1,62 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDBForPostgreSql.Models +{ + using Microsoft.Rest; + + /// + /// Exception thrown for an invalid response with ErrorResponse + /// information. + /// + public partial class ErrorResponseException : RestException + { + /// + /// Gets information about the associated HTTP request. + /// + public HttpRequestMessageWrapper Request { get; set; } + + /// + /// Gets information about the associated HTTP response. + /// + public HttpResponseMessageWrapper Response { get; set; } + + /// + /// Gets or sets the body object. + /// + public ErrorResponse Body { get; set; } + + /// + /// Initializes a new instance of the ErrorResponseException class. + /// + public ErrorResponseException() + { + } + + /// + /// Initializes a new instance of the ErrorResponseException class. + /// + /// The exception message. + public ErrorResponseException(string message) + : this(message, null) + { + } + + /// + /// Initializes a new instance of the ErrorResponseException class. + /// + /// The exception message. + /// Inner exception. + public ErrorResponseException(string message, System.Exception innerException) + : base(message, innerException) + { + } + } +} diff --git a/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/FirewallRule.cs b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/FirewallRule.cs new file mode 100644 index 000000000000..e9c71d96d9b9 --- /dev/null +++ b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/FirewallRule.cs @@ -0,0 +1,117 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDBForPostgreSql.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Represents a cluster firewall rule. + /// + [Rest.Serialization.JsonTransformation] + public partial class FirewallRule : ProxyResource + { + /// + /// Initializes a new instance of the FirewallRule class. + /// + public FirewallRule() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the FirewallRule class. + /// + /// The start IP address of the cluster + /// firewall rule. Must be IPv4 format. + /// The end IP address of the cluster + /// firewall rule. Must be IPv4 format. + /// Fully qualified resource ID for the resource. E.g. + /// "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" + /// The name of the resource + /// The type of the resource. E.g. + /// "Microsoft.Compute/virtualMachines" or + /// "Microsoft.Storage/storageAccounts" + /// Azure Resource Manager metadata containing + /// createdBy and modifiedBy information. + /// Provisioning state of the firewall + /// rule. Possible values include: 'Succeeded', 'Canceled', + /// 'InProgress', 'Failed' + public FirewallRule(string startIpAddress, string endIpAddress, string id = default(string), string name = default(string), string type = default(string), SystemData systemData = default(SystemData), string provisioningState = default(string)) + : base(id, name, type, systemData) + { + StartIpAddress = startIpAddress; + EndIpAddress = endIpAddress; + ProvisioningState = provisioningState; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the start IP address of the cluster firewall rule. + /// Must be IPv4 format. + /// + [JsonProperty(PropertyName = "properties.startIpAddress")] + public string StartIpAddress { get; set; } + + /// + /// Gets or sets the end IP address of the cluster firewall rule. Must + /// be IPv4 format. + /// + [JsonProperty(PropertyName = "properties.endIpAddress")] + public string EndIpAddress { get; set; } + + /// + /// Gets provisioning state of the firewall rule. Possible values + /// include: 'Succeeded', 'Canceled', 'InProgress', 'Failed' + /// + [JsonProperty(PropertyName = "properties.provisioningState")] + public string ProvisioningState { get; private set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (StartIpAddress == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "StartIpAddress"); + } + if (EndIpAddress == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "EndIpAddress"); + } + if (StartIpAddress != null) + { + if (!System.Text.RegularExpressions.Regex.IsMatch(StartIpAddress, "^(([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])$")) + { + throw new ValidationException(ValidationRules.Pattern, "StartIpAddress", "^(([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])$"); + } + } + if (EndIpAddress != null) + { + if (!System.Text.RegularExpressions.Regex.IsMatch(EndIpAddress, "^(([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])$")) + { + throw new ValidationException(ValidationRules.Pattern, "EndIpAddress", "^(([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])$"); + } + } + } + } +} diff --git a/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/FirewallRulesCreateOrUpdateHeaders.cs b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/FirewallRulesCreateOrUpdateHeaders.cs new file mode 100644 index 000000000000..cb772cbcf78d --- /dev/null +++ b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/FirewallRulesCreateOrUpdateHeaders.cs @@ -0,0 +1,57 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDBForPostgreSql.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Defines headers for CreateOrUpdate operation. + /// + public partial class FirewallRulesCreateOrUpdateHeaders + { + /// + /// Initializes a new instance of the + /// FirewallRulesCreateOrUpdateHeaders class. + /// + public FirewallRulesCreateOrUpdateHeaders() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// FirewallRulesCreateOrUpdateHeaders class. + /// + public FirewallRulesCreateOrUpdateHeaders(string location = default(string), string azureAsyncOperation = default(string)) + { + Location = location; + AzureAsyncOperation = azureAsyncOperation; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// + [JsonProperty(PropertyName = "location")] + public string Location { get; set; } + + /// + /// + [JsonProperty(PropertyName = "azure-async-operation")] + public string AzureAsyncOperation { get; set; } + + } +} diff --git a/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/FirewallRulesDeleteHeaders.cs b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/FirewallRulesDeleteHeaders.cs new file mode 100644 index 000000000000..581bcbd2fc52 --- /dev/null +++ b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/FirewallRulesDeleteHeaders.cs @@ -0,0 +1,55 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDBForPostgreSql.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Defines headers for Delete operation. + /// + public partial class FirewallRulesDeleteHeaders + { + /// + /// Initializes a new instance of the FirewallRulesDeleteHeaders class. + /// + public FirewallRulesDeleteHeaders() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the FirewallRulesDeleteHeaders class. + /// + public FirewallRulesDeleteHeaders(string location = default(string), string azureAsyncOperation = default(string)) + { + Location = location; + AzureAsyncOperation = azureAsyncOperation; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// + [JsonProperty(PropertyName = "location")] + public string Location { get; set; } + + /// + /// + [JsonProperty(PropertyName = "azure-async-operation")] + public string AzureAsyncOperation { get; set; } + + } +} diff --git a/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/Identity.cs b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/Identity.cs new file mode 100644 index 000000000000..1b2ee1f26194 --- /dev/null +++ b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/Identity.cs @@ -0,0 +1,72 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDBForPostgreSql.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Identity for the resource. + /// + public partial class Identity + { + /// + /// Initializes a new instance of the Identity class. + /// + public Identity() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Identity class. + /// + /// The principal ID of resource identity. + /// The value must be an UUID. + /// The tenant ID of resource. The value must be + /// an UUID. + /// The identity type. Possible values include: + /// 'SystemAssigned' + public Identity(System.Guid? principalId = default(System.Guid?), System.Guid? tenantId = default(System.Guid?), ResourceIdentityType? type = default(ResourceIdentityType?)) + { + PrincipalId = principalId; + TenantId = tenantId; + Type = type; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the principal ID of resource identity. The value must be an + /// UUID. + /// + [JsonProperty(PropertyName = "principalId")] + public System.Guid? PrincipalId { get; private set; } + + /// + /// Gets the tenant ID of resource. The value must be an UUID. + /// + [JsonProperty(PropertyName = "tenantId")] + public System.Guid? TenantId { get; private set; } + + /// + /// Gets or sets the identity type. Possible values include: + /// 'SystemAssigned' + /// + [JsonProperty(PropertyName = "type")] + public ResourceIdentityType? Type { get; set; } + + } +} diff --git a/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/IdentityProperties.cs b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/IdentityProperties.cs new file mode 100644 index 000000000000..d65e2bd5d8a8 --- /dev/null +++ b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/IdentityProperties.cs @@ -0,0 +1,61 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDBForPostgreSql.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Describes the identity of the cluster. + /// + public partial class IdentityProperties + { + /// + /// Initializes a new instance of the IdentityProperties class. + /// + public IdentityProperties() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the IdentityProperties class. + /// + /// Possible values include: 'UserAssigned', + /// 'SystemAssigned' + public IdentityProperties(string type = default(string), IDictionary userAssignedIdentities = default(IDictionary)) + { + Type = type; + UserAssignedIdentities = userAssignedIdentities; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets possible values include: 'UserAssigned', + /// 'SystemAssigned' + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; set; } + + /// + /// + [JsonProperty(PropertyName = "userAssignedIdentities")] + public IDictionary UserAssignedIdentities { get; set; } + + } +} diff --git a/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/IdentityType.cs b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/IdentityType.cs new file mode 100644 index 000000000000..99b6bd3ff4b2 --- /dev/null +++ b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/IdentityType.cs @@ -0,0 +1,22 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDBForPostgreSql.Models +{ + + /// + /// Defines values for IdentityType. + /// + public static class IdentityType + { + public const string UserAssigned = "UserAssigned"; + public const string SystemAssigned = "SystemAssigned"; + } +} diff --git a/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/MaintenanceWindow.cs b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/MaintenanceWindow.cs new file mode 100644 index 000000000000..17cfe7881519 --- /dev/null +++ b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/MaintenanceWindow.cs @@ -0,0 +1,82 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDBForPostgreSql.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Schedule settings for regular cluster updates. + /// + public partial class MaintenanceWindow + { + /// + /// Initializes a new instance of the MaintenanceWindow class. + /// + public MaintenanceWindow() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the MaintenanceWindow class. + /// + /// Indicates whether custom maintenance + /// window is enabled or not. + /// Start hour within preferred day of the week + /// for maintenance window. + /// Start minute within the start hour for + /// maintenance window. + /// Preferred day of the week for maintenance + /// window. + public MaintenanceWindow(string customWindow = default(string), int? startHour = default(int?), int? startMinute = default(int?), int? dayOfWeek = default(int?)) + { + CustomWindow = customWindow; + StartHour = startHour; + StartMinute = startMinute; + DayOfWeek = dayOfWeek; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets indicates whether custom maintenance window is enabled + /// or not. + /// + [JsonProperty(PropertyName = "customWindow")] + public string CustomWindow { get; set; } + + /// + /// Gets or sets start hour within preferred day of the week for + /// maintenance window. + /// + [JsonProperty(PropertyName = "startHour")] + public int? StartHour { get; set; } + + /// + /// Gets or sets start minute within the start hour for maintenance + /// window. + /// + [JsonProperty(PropertyName = "startMinute")] + public int? StartMinute { get; set; } + + /// + /// Gets or sets preferred day of the week for maintenance window. + /// + [JsonProperty(PropertyName = "dayOfWeek")] + public int? DayOfWeek { get; set; } + + } +} diff --git a/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/NameAvailability.cs b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/NameAvailability.cs new file mode 100644 index 000000000000..eb31a2dfddcb --- /dev/null +++ b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/NameAvailability.cs @@ -0,0 +1,76 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDBForPostgreSql.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Represents cluster name availability. + /// + public partial class NameAvailability + { + /// + /// Initializes a new instance of the NameAvailability class. + /// + public NameAvailability() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the NameAvailability class. + /// + /// Error message. + /// Indicates whether the cluster name is + /// available. + /// Name of the cluster. + /// Type of the cluster. + public NameAvailability(string message = default(string), bool? nameAvailable = default(bool?), string name = default(string), string type = default(string)) + { + Message = message; + NameAvailable = nameAvailable; + Name = name; + Type = type; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets error message. + /// + [JsonProperty(PropertyName = "message")] + public string Message { get; set; } + + /// + /// Gets or sets indicates whether the cluster name is available. + /// + [JsonProperty(PropertyName = "nameAvailable")] + public bool? NameAvailable { get; set; } + + /// + /// Gets or sets name of the cluster. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Gets or sets type of the cluster. + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; set; } + + } +} diff --git a/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/NameAvailabilityRequest.cs b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/NameAvailabilityRequest.cs new file mode 100644 index 000000000000..4c13a000d1dd --- /dev/null +++ b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/NameAvailabilityRequest.cs @@ -0,0 +1,78 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDBForPostgreSql.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Request from client to check cluster name availability. + /// + public partial class NameAvailabilityRequest + { + /// + /// Initializes a new instance of the NameAvailabilityRequest class. + /// + public NameAvailabilityRequest() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the NameAvailabilityRequest class. + /// + /// Cluster name to verify. + public NameAvailabilityRequest(string name) + { + Name = name; + CustomInit(); + } + /// + /// Static constructor for NameAvailabilityRequest class. + /// + static NameAvailabilityRequest() + { + Type = "Microsoft.DBforPostgreSQL/serverGroupsv2"; + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets cluster name to verify. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Resource type used for verification. + /// + [JsonProperty(PropertyName = "type")] + public static string Type { get; private set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Name == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Name"); + } + } + } +} diff --git a/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/Operation.cs b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/Operation.cs new file mode 100644 index 000000000000..82c6674466a9 --- /dev/null +++ b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/Operation.cs @@ -0,0 +1,93 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDBForPostgreSql.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// REST API operation definition. + /// + public partial class Operation + { + /// + /// Initializes a new instance of the Operation class. + /// + public Operation() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Operation class. + /// + /// The name of the operation being performed on + /// this particular object. + /// The localized display information for this + /// particular operation or action. + /// Indicates whether the operation is a + /// data action. + /// The intended executor of the operation. + /// Possible values include: 'NotSpecified', 'user', 'system' + /// Additional descriptions for the + /// operation. + public Operation(string name = default(string), OperationDisplay display = default(OperationDisplay), bool? isDataAction = default(bool?), string origin = default(string), IDictionary properties = default(IDictionary)) + { + Name = name; + Display = display; + IsDataAction = isDataAction; + Origin = origin; + Properties = properties; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the name of the operation being performed on this particular + /// object. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; private set; } + + /// + /// Gets the localized display information for this particular + /// operation or action. + /// + [JsonProperty(PropertyName = "display")] + public OperationDisplay Display { get; private set; } + + /// + /// Gets or sets indicates whether the operation is a data action. + /// + [JsonProperty(PropertyName = "isDataAction")] + public bool? IsDataAction { get; set; } + + /// + /// Gets the intended executor of the operation. Possible values + /// include: 'NotSpecified', 'user', 'system' + /// + [JsonProperty(PropertyName = "origin")] + public string Origin { get; private set; } + + /// + /// Gets additional descriptions for the operation. + /// + [JsonProperty(PropertyName = "properties")] + public IDictionary Properties { get; private set; } + + } +} diff --git a/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/OperationDisplay.cs b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/OperationDisplay.cs new file mode 100644 index 000000000000..8030f92e7653 --- /dev/null +++ b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/OperationDisplay.cs @@ -0,0 +1,77 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDBForPostgreSql.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Display metadata associated with the operation. + /// + public partial class OperationDisplay + { + /// + /// Initializes a new instance of the OperationDisplay class. + /// + public OperationDisplay() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the OperationDisplay class. + /// + /// Operation resource provider name. + /// Resource on which the operation is + /// performed. + /// Localized friendly name for the + /// operation. + /// Operation description. + public OperationDisplay(string provider = default(string), string resource = default(string), string operation = default(string), string description = default(string)) + { + Provider = provider; + Resource = resource; + Operation = operation; + Description = description; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets operation resource provider name. + /// + [JsonProperty(PropertyName = "provider")] + public string Provider { get; private set; } + + /// + /// Gets resource on which the operation is performed. + /// + [JsonProperty(PropertyName = "resource")] + public string Resource { get; private set; } + + /// + /// Gets localized friendly name for the operation. + /// + [JsonProperty(PropertyName = "operation")] + public string Operation { get; private set; } + + /// + /// Gets operation description. + /// + [JsonProperty(PropertyName = "description")] + public string Description { get; private set; } + + } +} diff --git a/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/OperationOrigin.cs b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/OperationOrigin.cs new file mode 100644 index 000000000000..6b8a97b936a6 --- /dev/null +++ b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/OperationOrigin.cs @@ -0,0 +1,23 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDBForPostgreSql.Models +{ + + /// + /// Defines values for OperationOrigin. + /// + public static class OperationOrigin + { + public const string NotSpecified = "NotSpecified"; + public const string User = "user"; + public const string System = "system"; + } +} diff --git a/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/Page.cs b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/Page.cs new file mode 100644 index 000000000000..5f568a69cc26 --- /dev/null +++ b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/Page.cs @@ -0,0 +1,53 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDBForPostgreSql.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + + /// + /// Defines a page in Azure responses. + /// + /// Type of the page content items + [JsonObject] + public class Page : IPage + { + /// + /// Gets the link to the next page. + /// + [JsonProperty("nextLink")] + public string NextPageLink { get; private set; } + + [JsonProperty("value")] + private IList Items{ get; set; } + + /// + /// Returns an enumerator that iterates through the collection. + /// + /// A an enumerator that can be used to iterate through the collection. + public IEnumerator GetEnumerator() + { + return Items == null ? System.Linq.Enumerable.Empty().GetEnumerator() : Items.GetEnumerator(); + } + + /// + /// Returns an enumerator that iterates through the collection. + /// + /// A an enumerator that can be used to iterate through the collection. + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + } +} diff --git a/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/Page1.cs b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/Page1.cs new file mode 100644 index 000000000000..deaebfa6e4f1 --- /dev/null +++ b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/Page1.cs @@ -0,0 +1,53 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDBForPostgreSql.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + + /// + /// Defines a page in Azure responses. + /// + /// Type of the page content items + [JsonObject] + public class Page1 : IPage + { + /// + /// Gets the link to the next page. + /// + [JsonProperty("")] + public string NextPageLink { get; private set; } + + [JsonProperty("value")] + private IList Items{ get; set; } + + /// + /// Returns an enumerator that iterates through the collection. + /// + /// A an enumerator that can be used to iterate through the collection. + public IEnumerator GetEnumerator() + { + return Items == null ? System.Linq.Enumerable.Empty().GetEnumerator() : Items.GetEnumerator(); + } + + /// + /// Returns an enumerator that iterates through the collection. + /// + /// A an enumerator that can be used to iterate through the collection. + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + } +} diff --git a/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/PasswordAuth.cs b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/PasswordAuth.cs new file mode 100644 index 000000000000..771295959d7d --- /dev/null +++ b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/PasswordAuth.cs @@ -0,0 +1,22 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDBForPostgreSql.Models +{ + + /// + /// Defines values for PasswordAuth. + /// + public static class PasswordAuth + { + public const string Enabled = "enabled"; + public const string Disabled = "disabled"; + } +} diff --git a/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/PasswordEnabledEnum.cs b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/PasswordEnabledEnum.cs new file mode 100644 index 000000000000..af191a0e755e --- /dev/null +++ b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/PasswordEnabledEnum.cs @@ -0,0 +1,22 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDBForPostgreSql.Models +{ + + /// + /// Defines values for PasswordEnabledEnum. + /// + public static class PasswordEnabledEnum + { + public const string Enabled = "enabled"; + public const string Disabled = "disabled"; + } +} diff --git a/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/Plan.cs b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/Plan.cs new file mode 100644 index 000000000000..4d93e1898adc --- /dev/null +++ b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/Plan.cs @@ -0,0 +1,116 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDBForPostgreSql.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Plan for the resource. + /// + public partial class Plan + { + /// + /// Initializes a new instance of the Plan class. + /// + public Plan() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Plan class. + /// + /// A user defined name of the 3rd Party Artifact + /// that is being procured. + /// The publisher of the 3rd Party Artifact + /// that is being bought. E.g. NewRelic + /// 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. + /// A publisher provided promotion code as + /// provisioned in Data Market for the said product/artifact. + /// The version of the desired + /// product/artifact. + public Plan(string name, string publisher, string product, string promotionCode = default(string), string version = default(string)) + { + Name = name; + Publisher = publisher; + Product = product; + PromotionCode = promotionCode; + Version = version; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets a user defined name of the 3rd Party Artifact that is + /// being procured. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Gets or sets the publisher of the 3rd Party Artifact that is being + /// bought. E.g. NewRelic + /// + [JsonProperty(PropertyName = "publisher")] + public string Publisher { get; set; } + + /// + /// Gets or sets 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. + /// + [JsonProperty(PropertyName = "product")] + public string Product { get; set; } + + /// + /// Gets or sets a publisher provided promotion code as provisioned in + /// Data Market for the said product/artifact. + /// + [JsonProperty(PropertyName = "promotionCode")] + public string PromotionCode { get; set; } + + /// + /// Gets or sets the version of the desired product/artifact. + /// + [JsonProperty(PropertyName = "version")] + public string Version { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Name == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Name"); + } + if (Publisher == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Publisher"); + } + if (Product == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Product"); + } + } + } +} diff --git a/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/PrincipalType.cs b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/PrincipalType.cs new file mode 100644 index 000000000000..196624244744 --- /dev/null +++ b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/PrincipalType.cs @@ -0,0 +1,23 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDBForPostgreSql.Models +{ + + /// + /// Defines values for PrincipalType. + /// + public static class PrincipalType + { + public const string User = "user"; + public const string ServicePrincipal = "servicePrincipal"; + public const string Group = "group"; + } +} diff --git a/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/PrivateEndpoint.cs b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/PrivateEndpoint.cs new file mode 100644 index 000000000000..c771875b3386 --- /dev/null +++ b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/PrivateEndpoint.cs @@ -0,0 +1,51 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDBForPostgreSql.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The private endpoint resource. + /// + public partial class PrivateEndpoint + { + /// + /// Initializes a new instance of the PrivateEndpoint class. + /// + public PrivateEndpoint() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the PrivateEndpoint class. + /// + /// The ARM identifier for private endpoint. + public PrivateEndpoint(string id = default(string)) + { + Id = id; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the ARM identifier for private endpoint. + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; private set; } + + } +} diff --git a/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/PrivateEndpointConnection.cs b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/PrivateEndpointConnection.cs new file mode 100644 index 000000000000..8f381be26452 --- /dev/null +++ b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/PrivateEndpointConnection.cs @@ -0,0 +1,111 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDBForPostgreSql.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The private endpoint connection resource. + /// + [Rest.Serialization.JsonTransformation] + public partial class PrivateEndpointConnection : Resource + { + /// + /// Initializes a new instance of the PrivateEndpointConnection class. + /// + public PrivateEndpointConnection() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the PrivateEndpointConnection class. + /// + /// A collection of + /// information about the state of the connection between service + /// consumer and provider. + /// Fully qualified resource ID for the resource. E.g. + /// "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" + /// The name of the resource + /// The type of the resource. E.g. + /// "Microsoft.Compute/virtualMachines" or + /// "Microsoft.Storage/storageAccounts" + /// Azure Resource Manager metadata containing + /// createdBy and modifiedBy information. + /// The group ids for the private endpoint + /// resource. + /// The private endpoint + /// resource. + /// The provisioning state of the + /// private endpoint connection resource. Possible values include: + /// 'Succeeded', 'Creating', 'Deleting', 'Failed' + public PrivateEndpointConnection(PrivateLinkServiceConnectionState privateLinkServiceConnectionState, string id = default(string), string name = default(string), string type = default(string), SystemData systemData = default(SystemData), IList groupIds = default(IList), PrivateEndpoint privateEndpoint = default(PrivateEndpoint), string provisioningState = default(string)) + : base(id, name, type, systemData) + { + GroupIds = groupIds; + PrivateEndpoint = privateEndpoint; + PrivateLinkServiceConnectionState = privateLinkServiceConnectionState; + ProvisioningState = provisioningState; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the group ids for the private endpoint resource. + /// + [JsonProperty(PropertyName = "properties.groupIds")] + public IList GroupIds { get; private set; } + + /// + /// Gets or sets the private endpoint resource. + /// + [JsonProperty(PropertyName = "properties.privateEndpoint")] + public PrivateEndpoint PrivateEndpoint { get; set; } + + /// + /// Gets or sets a collection of information about the state of the + /// connection between service consumer and provider. + /// + [JsonProperty(PropertyName = "properties.privateLinkServiceConnectionState")] + public PrivateLinkServiceConnectionState PrivateLinkServiceConnectionState { get; set; } + + /// + /// Gets or sets the provisioning state of the private endpoint + /// connection resource. Possible values include: 'Succeeded', + /// 'Creating', 'Deleting', 'Failed' + /// + [JsonProperty(PropertyName = "properties.provisioningState")] + public string ProvisioningState { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (PrivateLinkServiceConnectionState == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "PrivateLinkServiceConnectionState"); + } + } + } +} diff --git a/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/PrivateEndpointConnectionProvisioningState.cs b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/PrivateEndpointConnectionProvisioningState.cs new file mode 100644 index 000000000000..04b567eb109c --- /dev/null +++ b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/PrivateEndpointConnectionProvisioningState.cs @@ -0,0 +1,24 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDBForPostgreSql.Models +{ + + /// + /// Defines values for PrivateEndpointConnectionProvisioningState. + /// + public static class PrivateEndpointConnectionProvisioningState + { + public const string Succeeded = "Succeeded"; + public const string Creating = "Creating"; + public const string Deleting = "Deleting"; + public const string Failed = "Failed"; + } +} diff --git a/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/PrivateEndpointConnectionsCreateOrUpdateHeaders.cs b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/PrivateEndpointConnectionsCreateOrUpdateHeaders.cs new file mode 100644 index 000000000000..c724b17070f8 --- /dev/null +++ b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/PrivateEndpointConnectionsCreateOrUpdateHeaders.cs @@ -0,0 +1,57 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDBForPostgreSql.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Defines headers for CreateOrUpdate operation. + /// + public partial class PrivateEndpointConnectionsCreateOrUpdateHeaders + { + /// + /// Initializes a new instance of the + /// PrivateEndpointConnectionsCreateOrUpdateHeaders class. + /// + public PrivateEndpointConnectionsCreateOrUpdateHeaders() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// PrivateEndpointConnectionsCreateOrUpdateHeaders class. + /// + public PrivateEndpointConnectionsCreateOrUpdateHeaders(string location = default(string), string azureAsyncOperation = default(string)) + { + Location = location; + AzureAsyncOperation = azureAsyncOperation; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// + [JsonProperty(PropertyName = "location")] + public string Location { get; set; } + + /// + /// + [JsonProperty(PropertyName = "azure-async-operation")] + public string AzureAsyncOperation { get; set; } + + } +} diff --git a/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/PrivateEndpointConnectionsDeleteHeaders.cs b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/PrivateEndpointConnectionsDeleteHeaders.cs new file mode 100644 index 000000000000..5de9d6d9a883 --- /dev/null +++ b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/PrivateEndpointConnectionsDeleteHeaders.cs @@ -0,0 +1,57 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDBForPostgreSql.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Defines headers for Delete operation. + /// + public partial class PrivateEndpointConnectionsDeleteHeaders + { + /// + /// Initializes a new instance of the + /// PrivateEndpointConnectionsDeleteHeaders class. + /// + public PrivateEndpointConnectionsDeleteHeaders() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// PrivateEndpointConnectionsDeleteHeaders class. + /// + public PrivateEndpointConnectionsDeleteHeaders(string location = default(string), string azureAsyncOperation = default(string)) + { + Location = location; + AzureAsyncOperation = azureAsyncOperation; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// + [JsonProperty(PropertyName = "location")] + public string Location { get; set; } + + /// + /// + [JsonProperty(PropertyName = "azure-async-operation")] + public string AzureAsyncOperation { get; set; } + + } +} diff --git a/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/PrivateEndpointProperty.cs b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/PrivateEndpointProperty.cs new file mode 100644 index 000000000000..b643e39876e3 --- /dev/null +++ b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/PrivateEndpointProperty.cs @@ -0,0 +1,51 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDBForPostgreSql.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Property to represent resource id of the private endpoint. + /// + public partial class PrivateEndpointProperty + { + /// + /// Initializes a new instance of the PrivateEndpointProperty class. + /// + public PrivateEndpointProperty() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the PrivateEndpointProperty class. + /// + /// Resource id of the private endpoint. + public PrivateEndpointProperty(string id = default(string)) + { + Id = id; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets resource id of the private endpoint. + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; set; } + + } +} diff --git a/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/PrivateEndpointServiceConnectionStatus.cs b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/PrivateEndpointServiceConnectionStatus.cs new file mode 100644 index 000000000000..6606bada3f54 --- /dev/null +++ b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/PrivateEndpointServiceConnectionStatus.cs @@ -0,0 +1,23 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDBForPostgreSql.Models +{ + + /// + /// Defines values for PrivateEndpointServiceConnectionStatus. + /// + public static class PrivateEndpointServiceConnectionStatus + { + public const string Pending = "Pending"; + public const string Approved = "Approved"; + public const string Rejected = "Rejected"; + } +} diff --git a/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/PrivateLinkResource.cs b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/PrivateLinkResource.cs new file mode 100644 index 000000000000..05e0e965c4bd --- /dev/null +++ b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/PrivateLinkResource.cs @@ -0,0 +1,83 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDBForPostgreSql.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// A private link resource. + /// + [Rest.Serialization.JsonTransformation] + public partial class PrivateLinkResource : Resource + { + /// + /// Initializes a new instance of the PrivateLinkResource class. + /// + public PrivateLinkResource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the PrivateLinkResource class. + /// + /// Fully qualified resource ID for the resource. E.g. + /// "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" + /// The name of the resource + /// The type of the resource. E.g. + /// "Microsoft.Compute/virtualMachines" or + /// "Microsoft.Storage/storageAccounts" + /// Azure Resource Manager metadata containing + /// createdBy and modifiedBy information. + /// The private link resource group id. + /// The private link resource required + /// member names. + /// The private link resource private + /// link DNS zone name. + public PrivateLinkResource(string id = default(string), string name = default(string), string type = default(string), SystemData systemData = default(SystemData), string groupId = default(string), IList requiredMembers = default(IList), IList requiredZoneNames = default(IList)) + : base(id, name, type, systemData) + { + GroupId = groupId; + RequiredMembers = requiredMembers; + RequiredZoneNames = requiredZoneNames; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the private link resource group id. + /// + [JsonProperty(PropertyName = "properties.groupId")] + public string GroupId { get; private set; } + + /// + /// Gets the private link resource required member names. + /// + [JsonProperty(PropertyName = "properties.requiredMembers")] + public IList RequiredMembers { get; private set; } + + /// + /// Gets or sets the private link resource private link DNS zone name. + /// + [JsonProperty(PropertyName = "properties.requiredZoneNames")] + public IList RequiredZoneNames { get; set; } + + } +} diff --git a/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/PrivateLinkServiceConnectionState.cs b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/PrivateLinkServiceConnectionState.cs new file mode 100644 index 000000000000..07ccfd155f72 --- /dev/null +++ b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/PrivateLinkServiceConnectionState.cs @@ -0,0 +1,77 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDBForPostgreSql.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// A collection of information about the state of the connection between + /// service consumer and provider. + /// + public partial class PrivateLinkServiceConnectionState + { + /// + /// Initializes a new instance of the PrivateLinkServiceConnectionState + /// class. + /// + public PrivateLinkServiceConnectionState() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the PrivateLinkServiceConnectionState + /// class. + /// + /// Indicates whether the connection has been + /// Approved/Rejected/Removed by the owner of the service. Possible + /// values include: 'Pending', 'Approved', 'Rejected' + /// The reason for approval/rejection of the + /// connection. + /// A message indicating if changes on + /// the service provider require any updates on the consumer. + public PrivateLinkServiceConnectionState(string status = default(string), string description = default(string), string actionsRequired = default(string)) + { + Status = status; + Description = description; + ActionsRequired = actionsRequired; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets indicates whether the connection has been + /// Approved/Rejected/Removed by the owner of the service. Possible + /// values include: 'Pending', 'Approved', 'Rejected' + /// + [JsonProperty(PropertyName = "status")] + public string Status { get; set; } + + /// + /// Gets or sets the reason for approval/rejection of the connection. + /// + [JsonProperty(PropertyName = "description")] + public string Description { get; set; } + + /// + /// Gets or sets a message indicating if changes on the service + /// provider require any updates on the consumer. + /// + [JsonProperty(PropertyName = "actionsRequired")] + public string ActionsRequired { get; set; } + + } +} diff --git a/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/PromoteRequest.cs b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/PromoteRequest.cs new file mode 100644 index 000000000000..dd3f4e3bdc29 --- /dev/null +++ b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/PromoteRequest.cs @@ -0,0 +1,53 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDBForPostgreSql.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Request from client to promote geo-redundant replica + /// + public partial class PromoteRequest + { + /// + /// Initializes a new instance of the PromoteRequest class. + /// + public PromoteRequest() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the PromoteRequest class. + /// + /// Boolean property to enable + /// geo-redundant replica promotion. + public PromoteRequest(bool? enableGeoBackup = default(bool?)) + { + EnableGeoBackup = enableGeoBackup; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets boolean property to enable geo-redundant replica + /// promotion. + /// + [JsonProperty(PropertyName = "enableGeoBackup")] + public bool? EnableGeoBackup { get; set; } + + } +} diff --git a/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ProvisioningState.cs b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ProvisioningState.cs new file mode 100644 index 000000000000..81b477ab1e65 --- /dev/null +++ b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ProvisioningState.cs @@ -0,0 +1,24 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDBForPostgreSql.Models +{ + + /// + /// Defines values for ProvisioningState. + /// + public static class ProvisioningState + { + public const string Succeeded = "Succeeded"; + public const string Canceled = "Canceled"; + public const string InProgress = "InProgress"; + public const string Failed = "Failed"; + } +} diff --git a/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ProxyResource.cs b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ProxyResource.cs new file mode 100644 index 000000000000..b989af02d55b --- /dev/null +++ b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ProxyResource.cs @@ -0,0 +1,55 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDBForPostgreSql.Models +{ + using System.Linq; + + /// + /// Proxy Resource + /// + /// + /// The resource model definition for a Azure Resource Manager proxy + /// resource. It will not have tags and a location + /// + public partial class ProxyResource : Resource + { + /// + /// Initializes a new instance of the ProxyResource class. + /// + public ProxyResource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ProxyResource class. + /// + /// Fully qualified resource ID for the resource. E.g. + /// "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" + /// The name of the resource + /// The type of the resource. E.g. + /// "Microsoft.Compute/virtualMachines" or + /// "Microsoft.Storage/storageAccounts" + /// Azure Resource Manager metadata containing + /// createdBy and modifiedBy information. + public ProxyResource(string id = default(string), string name = default(string), string type = default(string), SystemData systemData = default(SystemData)) + : base(id, name, type, systemData) + { + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + } +} diff --git a/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/Resource.cs b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/Resource.cs new file mode 100644 index 000000000000..cd0a1c06fc07 --- /dev/null +++ b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/Resource.cs @@ -0,0 +1,89 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDBForPostgreSql.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Resource + /// + /// + /// Common fields that are returned in the response for all Azure Resource + /// Manager resources + /// + public partial class Resource : IResource + { + /// + /// Initializes a new instance of the Resource class. + /// + public Resource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Resource class. + /// + /// Fully qualified resource ID for the resource. E.g. + /// "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" + /// The name of the resource + /// The type of the resource. E.g. + /// "Microsoft.Compute/virtualMachines" or + /// "Microsoft.Storage/storageAccounts" + /// Azure Resource Manager metadata containing + /// createdBy and modifiedBy information. + public Resource(string id = default(string), string name = default(string), string type = default(string), SystemData systemData = default(SystemData)) + { + Id = id; + Name = name; + Type = type; + SystemData = systemData; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets fully qualified resource ID for the resource. E.g. + /// "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; private set; } + + /// + /// Gets the name of the resource + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; private set; } + + /// + /// Gets the type of the resource. E.g. + /// "Microsoft.Compute/virtualMachines" or + /// "Microsoft.Storage/storageAccounts" + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; private set; } + + /// + /// Gets azure Resource Manager metadata containing createdBy and + /// modifiedBy information. + /// + [JsonProperty(PropertyName = "systemData")] + public SystemData SystemData { get; private set; } + + } +} diff --git a/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ResourceIdentityType.cs b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ResourceIdentityType.cs new file mode 100644 index 000000000000..364d75d4d17b --- /dev/null +++ b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ResourceIdentityType.cs @@ -0,0 +1,54 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDBForPostgreSql.Models +{ + using Newtonsoft.Json; + using Newtonsoft.Json.Converters; + using System.Runtime; + using System.Runtime.Serialization; + + /// + /// Defines values for ResourceIdentityType. + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum ResourceIdentityType + { + [EnumMember(Value = "SystemAssigned")] + SystemAssigned + } + internal static class ResourceIdentityTypeEnumExtension + { + internal static string ToSerializedValue(this ResourceIdentityType? value) + { + return value == null ? null : ((ResourceIdentityType)value).ToSerializedValue(); + } + + internal static string ToSerializedValue(this ResourceIdentityType value) + { + switch( value ) + { + case ResourceIdentityType.SystemAssigned: + return "SystemAssigned"; + } + return null; + } + + internal static ResourceIdentityType? ParseResourceIdentityType(this string value) + { + switch( value ) + { + case "SystemAssigned": + return ResourceIdentityType.SystemAssigned; + } + return null; + } + } +} diff --git a/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ResourceModelWithAllowedPropertySet.cs b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ResourceModelWithAllowedPropertySet.cs new file mode 100644 index 000000000000..687ad58e9b84 --- /dev/null +++ b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ResourceModelWithAllowedPropertySet.cs @@ -0,0 +1,141 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDBForPostgreSql.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Newtonsoft.Json; + using System.Linq; + + /// + /// 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. + /// + public partial class ResourceModelWithAllowedPropertySet : IResource + { + /// + /// Initializes a new instance of the + /// ResourceModelWithAllowedPropertySet class. + /// + public ResourceModelWithAllowedPropertySet() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// ResourceModelWithAllowedPropertySet class. + /// + /// 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. + /// 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. + /// 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. + public ResourceModelWithAllowedPropertySet(string managedBy = default(string), string kind = default(string), string etag = default(string), ResourceModelWithAllowedPropertySetIdentity identity = default(ResourceModelWithAllowedPropertySetIdentity), ResourceModelWithAllowedPropertySetSku sku = default(ResourceModelWithAllowedPropertySetSku), ResourceModelWithAllowedPropertySetPlan plan = default(ResourceModelWithAllowedPropertySetPlan)) + { + ManagedBy = managedBy; + Kind = kind; + Etag = etag; + Identity = identity; + Sku = sku; + Plan = plan; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets 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. + /// + [JsonProperty(PropertyName = "managedBy")] + public string ManagedBy { get; set; } + + /// + /// Gets or sets 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. + /// + [JsonProperty(PropertyName = "kind")] + public string Kind { get; set; } + + /// + /// Gets 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. + /// + [JsonProperty(PropertyName = "etag")] + public string Etag { get; private set; } + + /// + /// + [JsonProperty(PropertyName = "identity")] + public ResourceModelWithAllowedPropertySetIdentity Identity { get; set; } + + /// + /// + [JsonProperty(PropertyName = "sku")] + public ResourceModelWithAllowedPropertySetSku Sku { get; set; } + + /// + /// + [JsonProperty(PropertyName = "plan")] + public ResourceModelWithAllowedPropertySetPlan Plan { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Kind != null) + { + if (!System.Text.RegularExpressions.Regex.IsMatch(Kind, "^[-\\w\\._,\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "Kind", "^[-\\w\\._,\\(\\)]+$"); + } + } + if (Sku != null) + { + Sku.Validate(); + } + if (Plan != null) + { + Plan.Validate(); + } + } + } +} diff --git a/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ResourceModelWithAllowedPropertySetIdentity.cs b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ResourceModelWithAllowedPropertySetIdentity.cs new file mode 100644 index 000000000000..0f803ba556ac --- /dev/null +++ b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ResourceModelWithAllowedPropertySetIdentity.cs @@ -0,0 +1,48 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDBForPostgreSql.Models +{ + using System.Linq; + + public partial class ResourceModelWithAllowedPropertySetIdentity : Identity + { + /// + /// Initializes a new instance of the + /// ResourceModelWithAllowedPropertySetIdentity class. + /// + public ResourceModelWithAllowedPropertySetIdentity() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// ResourceModelWithAllowedPropertySetIdentity class. + /// + /// The principal ID of resource identity. + /// The value must be an UUID. + /// The tenant ID of resource. The value must be + /// an UUID. + /// The identity type. Possible values include: + /// 'SystemAssigned' + public ResourceModelWithAllowedPropertySetIdentity(System.Guid? principalId = default(System.Guid?), System.Guid? tenantId = default(System.Guid?), ResourceIdentityType? type = default(ResourceIdentityType?)) + : base(principalId, tenantId, type) + { + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + } +} diff --git a/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ResourceModelWithAllowedPropertySetPlan.cs b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ResourceModelWithAllowedPropertySetPlan.cs new file mode 100644 index 000000000000..8a7f1909ee4f --- /dev/null +++ b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ResourceModelWithAllowedPropertySetPlan.cs @@ -0,0 +1,63 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDBForPostgreSql.Models +{ + using System.Linq; + + public partial class ResourceModelWithAllowedPropertySetPlan : Plan + { + /// + /// Initializes a new instance of the + /// ResourceModelWithAllowedPropertySetPlan class. + /// + public ResourceModelWithAllowedPropertySetPlan() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// ResourceModelWithAllowedPropertySetPlan class. + /// + /// A user defined name of the 3rd Party Artifact + /// that is being procured. + /// The publisher of the 3rd Party Artifact + /// that is being bought. E.g. NewRelic + /// 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. + /// A publisher provided promotion code as + /// provisioned in Data Market for the said product/artifact. + /// The version of the desired + /// product/artifact. + public ResourceModelWithAllowedPropertySetPlan(string name, string publisher, string product, string promotionCode = default(string), string version = default(string)) + : base(name, publisher, product, promotionCode, version) + { + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public override void Validate() + { + base.Validate(); + } + } +} diff --git a/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ResourceModelWithAllowedPropertySetSku.cs b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ResourceModelWithAllowedPropertySetSku.cs new file mode 100644 index 000000000000..5e1fef7e1fbb --- /dev/null +++ b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ResourceModelWithAllowedPropertySetSku.cs @@ -0,0 +1,64 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDBForPostgreSql.Models +{ + using System.Linq; + + public partial class ResourceModelWithAllowedPropertySetSku : Sku + { + /// + /// Initializes a new instance of the + /// ResourceModelWithAllowedPropertySetSku class. + /// + public ResourceModelWithAllowedPropertySetSku() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// ResourceModelWithAllowedPropertySetSku class. + /// + /// The name of the SKU. E.g. P3. It is typically a + /// letter+number code + /// Possible values include: 'Free', 'Basic', + /// 'Standard', 'Premium' + /// The SKU size. When the name field is the + /// combination of tier and some other value, this would be the + /// standalone code. + /// If the service has different generations of + /// hardware, for the same SKU, then that can be captured here. + /// If the SKU supports scale out/in then the + /// capacity integer should be included. If scale out/in is not + /// possible for the resource this may be omitted. + public ResourceModelWithAllowedPropertySetSku(string name, SkuTier? tier = default(SkuTier?), string size = default(string), string family = default(string), int? capacity = default(int?)) + : base(name, tier, size, family, capacity) + { + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public override void Validate() + { + base.Validate(); + } + } +} diff --git a/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/Role.cs b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/Role.cs new file mode 100644 index 000000000000..0e3132bb5ab6 --- /dev/null +++ b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/Role.cs @@ -0,0 +1,124 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDBForPostgreSql.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Represents a cluster role. + /// + [Rest.Serialization.JsonTransformation] + public partial class Role : ProxyResource + { + /// + /// Initializes a new instance of the Role class. + /// + public Role() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Role class. + /// + /// Possible values include: 'user', + /// 'servicePrincipal', 'group' + /// Fully qualified resource ID for the resource. E.g. + /// "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" + /// The name of the resource + /// The type of the resource. E.g. + /// "Microsoft.Compute/virtualMachines" or + /// "Microsoft.Storage/storageAccounts" + /// Azure Resource Manager metadata containing + /// createdBy and modifiedBy information. + /// Possible values include: 'user', + /// 'admin' + /// The password of the cluster role. If an + /// identity is used, password will not be required. + /// Provisioning state of the role. + /// Possible values include: 'Succeeded', 'Canceled', 'InProgress', + /// 'Failed' + public Role(string objectId, string principalType, string id = default(string), string name = default(string), string type = default(string), SystemData systemData = default(SystemData), string roleType = default(string), string password = default(string), string tenantId = default(string), string provisioningState = default(string)) + : base(id, name, type, systemData) + { + RoleType = roleType; + Password = password; + ObjectId = objectId; + PrincipalType = principalType; + TenantId = tenantId; + ProvisioningState = provisioningState; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets possible values include: 'user', 'admin' + /// + [JsonProperty(PropertyName = "properties.roleType")] + public string RoleType { get; set; } + + /// + /// Gets or sets the password of the cluster role. If an identity is + /// used, password will not be required. + /// + [JsonProperty(PropertyName = "properties.password")] + public string Password { get; set; } + + /// + /// + [JsonProperty(PropertyName = "properties.externalIdentity.objectId")] + public string ObjectId { get; set; } + + /// + /// Gets or sets possible values include: 'user', 'servicePrincipal', + /// 'group' + /// + [JsonProperty(PropertyName = "properties.externalIdentity.principalType")] + public string PrincipalType { get; set; } + + /// + /// + [JsonProperty(PropertyName = "properties.externalIdentity.tenantId")] + public string TenantId { get; set; } + + /// + /// Gets provisioning state of the role. Possible values include: + /// 'Succeeded', 'Canceled', 'InProgress', 'Failed' + /// + [JsonProperty(PropertyName = "properties.provisioningState")] + public string ProvisioningState { get; private set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (ObjectId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "ObjectId"); + } + if (PrincipalType == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "PrincipalType"); + } + } + } +} diff --git a/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/RoleType.cs b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/RoleType.cs new file mode 100644 index 000000000000..155299d1b01f --- /dev/null +++ b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/RoleType.cs @@ -0,0 +1,22 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDBForPostgreSql.Models +{ + + /// + /// Defines values for RoleType. + /// + public static class RoleType + { + public const string User = "user"; + public const string Admin = "admin"; + } +} diff --git a/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/RolesCreateHeaders.cs b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/RolesCreateHeaders.cs new file mode 100644 index 000000000000..c9feb739cb06 --- /dev/null +++ b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/RolesCreateHeaders.cs @@ -0,0 +1,55 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDBForPostgreSql.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Defines headers for Create operation. + /// + public partial class RolesCreateHeaders + { + /// + /// Initializes a new instance of the RolesCreateHeaders class. + /// + public RolesCreateHeaders() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the RolesCreateHeaders class. + /// + public RolesCreateHeaders(string location = default(string), string azureAsyncOperation = default(string)) + { + Location = location; + AzureAsyncOperation = azureAsyncOperation; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// + [JsonProperty(PropertyName = "location")] + public string Location { get; set; } + + /// + /// + [JsonProperty(PropertyName = "azure-async-operation")] + public string AzureAsyncOperation { get; set; } + + } +} diff --git a/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/RolesDeleteHeaders.cs b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/RolesDeleteHeaders.cs new file mode 100644 index 000000000000..f2957443361d --- /dev/null +++ b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/RolesDeleteHeaders.cs @@ -0,0 +1,55 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDBForPostgreSql.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Defines headers for Delete operation. + /// + public partial class RolesDeleteHeaders + { + /// + /// Initializes a new instance of the RolesDeleteHeaders class. + /// + public RolesDeleteHeaders() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the RolesDeleteHeaders class. + /// + public RolesDeleteHeaders(string location = default(string), string azureAsyncOperation = default(string)) + { + Location = location; + AzureAsyncOperation = azureAsyncOperation; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// + [JsonProperty(PropertyName = "location")] + public string Location { get; set; } + + /// + /// + [JsonProperty(PropertyName = "azure-async-operation")] + public string AzureAsyncOperation { get; set; } + + } +} diff --git a/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ServerConfiguration.cs b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ServerConfiguration.cs new file mode 100644 index 000000000000..e892a5151346 --- /dev/null +++ b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ServerConfiguration.cs @@ -0,0 +1,141 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDBForPostgreSql.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Represents a configuration. + /// + [Rest.Serialization.JsonTransformation] + public partial class ServerConfiguration : ProxyResource + { + /// + /// Initializes a new instance of the ServerConfiguration class. + /// + public ServerConfiguration() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ServerConfiguration class. + /// + /// Value of the configuration. + /// Fully qualified resource ID for the resource. E.g. + /// "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" + /// The name of the resource + /// The type of the resource. E.g. + /// "Microsoft.Compute/virtualMachines" or + /// "Microsoft.Storage/storageAccounts" + /// Azure Resource Manager metadata containing + /// createdBy and modifiedBy information. + /// Source of the configuration. + /// Description of the configuration. + /// Default value of the + /// configuration. + /// Data type of the configuration. Possible + /// values include: 'Boolean', 'Numeric', 'Integer', + /// 'Enumeration' + /// Allowed values of the + /// configuration. + /// If configuration change requires + /// restart. + /// Provisioning state of the + /// configuration. Possible values include: 'Succeeded', 'Canceled', + /// 'InProgress', 'Failed' + public ServerConfiguration(string value, string id = default(string), string name = default(string), string type = default(string), SystemData systemData = default(SystemData), string source = default(string), string description = default(string), string defaultValue = default(string), string dataType = default(string), string allowedValues = default(string), bool? requiresRestart = default(bool?), string provisioningState = default(string)) + : base(id, name, type, systemData) + { + Value = value; + Source = source; + Description = description; + DefaultValue = defaultValue; + DataType = dataType; + AllowedValues = allowedValues; + RequiresRestart = requiresRestart; + ProvisioningState = provisioningState; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets value of the configuration. + /// + [JsonProperty(PropertyName = "properties.value")] + public string Value { get; set; } + + /// + /// Gets source of the configuration. + /// + [JsonProperty(PropertyName = "properties.source")] + public string Source { get; private set; } + + /// + /// Gets description of the configuration. + /// + [JsonProperty(PropertyName = "properties.description")] + public string Description { get; private set; } + + /// + /// Gets default value of the configuration. + /// + [JsonProperty(PropertyName = "properties.defaultValue")] + public string DefaultValue { get; private set; } + + /// + /// Gets data type of the configuration. Possible values include: + /// 'Boolean', 'Numeric', 'Integer', 'Enumeration' + /// + [JsonProperty(PropertyName = "properties.dataType")] + public string DataType { get; private set; } + + /// + /// Gets allowed values of the configuration. + /// + [JsonProperty(PropertyName = "properties.allowedValues")] + public string AllowedValues { get; private set; } + + /// + /// Gets if configuration change requires restart. + /// + [JsonProperty(PropertyName = "properties.requiresRestart")] + public bool? RequiresRestart { get; private set; } + + /// + /// Gets provisioning state of the configuration. Possible values + /// include: 'Succeeded', 'Canceled', 'InProgress', 'Failed' + /// + [JsonProperty(PropertyName = "properties.provisioningState")] + public string ProvisioningState { get; private set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Value == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Value"); + } + } + } +} diff --git a/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ServerNameItem.cs b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ServerNameItem.cs new file mode 100644 index 000000000000..6d7f2606d849 --- /dev/null +++ b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ServerNameItem.cs @@ -0,0 +1,60 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDBForPostgreSql.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The name object for a server. + /// + public partial class ServerNameItem + { + /// + /// Initializes a new instance of the ServerNameItem class. + /// + public ServerNameItem() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ServerNameItem class. + /// + /// The name of a server. + /// The fully qualified domain + /// name of a server. + public ServerNameItem(string name = default(string), string fullyQualifiedDomainName = default(string)) + { + Name = name; + FullyQualifiedDomainName = fullyQualifiedDomainName; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the name of a server. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Gets the fully qualified domain name of a server. + /// + [JsonProperty(PropertyName = "fullyQualifiedDomainName")] + public string FullyQualifiedDomainName { get; private set; } + + } +} diff --git a/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ServerProperties.cs b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ServerProperties.cs new file mode 100644 index 000000000000..3078c24d261b --- /dev/null +++ b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ServerProperties.cs @@ -0,0 +1,106 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDBForPostgreSql.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The properties of a server. + /// + public partial class ServerProperties + { + /// + /// Initializes a new instance of the ServerProperties class. + /// + public ServerProperties() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ServerProperties class. + /// + /// The edition of a server. + /// The storage of a server in + /// MB. + /// The vCores count of a server. + /// If high availability (HA) is enabled or not + /// for the server. + /// If public access is enabled on + /// server. + /// If server database is set to read-only by + /// system maintenance depending on high disk space usage. + /// The administrator's login name of + /// the servers in the cluster. + public ServerProperties(string serverEdition = default(string), int? storageQuotaInMb = default(int?), int? vCores = default(int?), bool? enableHa = default(bool?), bool? enablePublicIpAccess = default(bool?), bool? isReadOnly = default(bool?), string administratorLogin = default(string)) + { + ServerEdition = serverEdition; + StorageQuotaInMb = storageQuotaInMb; + VCores = vCores; + EnableHa = enableHa; + EnablePublicIpAccess = enablePublicIpAccess; + IsReadOnly = isReadOnly; + AdministratorLogin = administratorLogin; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the edition of a server. + /// + [JsonProperty(PropertyName = "serverEdition")] + public string ServerEdition { get; set; } + + /// + /// Gets or sets the storage of a server in MB. + /// + [JsonProperty(PropertyName = "storageQuotaInMb")] + public int? StorageQuotaInMb { get; set; } + + /// + /// Gets or sets the vCores count of a server. + /// + [JsonProperty(PropertyName = "vCores")] + public int? VCores { get; set; } + + /// + /// Gets or sets if high availability (HA) is enabled or not for the + /// server. + /// + [JsonProperty(PropertyName = "enableHa")] + public bool? EnableHa { get; set; } + + /// + /// Gets if public access is enabled on server. + /// + [JsonProperty(PropertyName = "enablePublicIpAccess")] + public bool? EnablePublicIpAccess { get; private set; } + + /// + /// Gets if server database is set to read-only by system maintenance + /// depending on high disk space usage. + /// + [JsonProperty(PropertyName = "isReadOnly")] + public bool? IsReadOnly { get; private set; } + + /// + /// Gets the administrator's login name of the servers in the cluster. + /// + [JsonProperty(PropertyName = "administratorLogin")] + public string AdministratorLogin { get; private set; } + + } +} diff --git a/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ServerRole.cs b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ServerRole.cs new file mode 100644 index 000000000000..670f6805196a --- /dev/null +++ b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ServerRole.cs @@ -0,0 +1,22 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDBForPostgreSql.Models +{ + + /// + /// Defines values for ServerRole. + /// + public static class ServerRole + { + public const string Coordinator = "Coordinator"; + public const string Worker = "Worker"; + } +} diff --git a/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ServerRoleGroupConfiguration.cs b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ServerRoleGroupConfiguration.cs new file mode 100644 index 000000000000..ed71d11640de --- /dev/null +++ b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/ServerRoleGroupConfiguration.cs @@ -0,0 +1,98 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDBForPostgreSql.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Represents server role group configuration value. + /// + public partial class ServerRoleGroupConfiguration + { + /// + /// Initializes a new instance of the ServerRoleGroupConfiguration + /// class. + /// + public ServerRoleGroupConfiguration() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ServerRoleGroupConfiguration + /// class. + /// + /// The role of servers in the server role group. + /// Possible values include: 'Coordinator', 'Worker' + /// Value of the configuration. + /// Default value of the + /// configuration. + /// Source of the configuration. + public ServerRoleGroupConfiguration(string role, string value, string defaultValue = default(string), string source = default(string)) + { + Role = role; + Value = value; + DefaultValue = defaultValue; + Source = source; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the role of servers in the server role group. Possible + /// values include: 'Coordinator', 'Worker' + /// + [JsonProperty(PropertyName = "role")] + public string Role { get; set; } + + /// + /// Gets or sets value of the configuration. + /// + [JsonProperty(PropertyName = "value")] + public string Value { get; set; } + + /// + /// Gets default value of the configuration. + /// + [JsonProperty(PropertyName = "defaultValue")] + public string DefaultValue { get; private set; } + + /// + /// Gets source of the configuration. + /// + [JsonProperty(PropertyName = "source")] + public string Source { get; private set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Role == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Role"); + } + if (Value == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Value"); + } + } + } +} diff --git a/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/SimplePrivateEndpointConnection.cs b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/SimplePrivateEndpointConnection.cs new file mode 100644 index 000000000000..7c0c927acf63 --- /dev/null +++ b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/SimplePrivateEndpointConnection.cs @@ -0,0 +1,83 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDBForPostgreSql.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// A private endpoint connection. + /// + [Rest.Serialization.JsonTransformation] + public partial class SimplePrivateEndpointConnection : ProxyResource + { + /// + /// Initializes a new instance of the SimplePrivateEndpointConnection + /// class. + /// + public SimplePrivateEndpointConnection() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the SimplePrivateEndpointConnection + /// class. + /// + /// Fully qualified resource ID for the resource. E.g. + /// "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" + /// The name of the resource + /// The type of the resource. E.g. + /// "Microsoft.Compute/virtualMachines" or + /// "Microsoft.Storage/storageAccounts" + /// Azure Resource Manager metadata containing + /// createdBy and modifiedBy information. + /// Private endpoint which the connection + /// belongs to. + /// Group ids of the private endpoint + /// connection. + public SimplePrivateEndpointConnection(string id = default(string), string name = default(string), string type = default(string), SystemData systemData = default(SystemData), PrivateEndpointProperty privateEndpoint = default(PrivateEndpointProperty), IList groupIds = default(IList), PrivateLinkServiceConnectionState privateLinkServiceConnectionState = default(PrivateLinkServiceConnectionState)) + : base(id, name, type, systemData) + { + PrivateEndpoint = privateEndpoint; + GroupIds = groupIds; + PrivateLinkServiceConnectionState = privateLinkServiceConnectionState; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets private endpoint which the connection belongs to. + /// + [JsonProperty(PropertyName = "properties.privateEndpoint")] + public PrivateEndpointProperty PrivateEndpoint { get; set; } + + /// + /// Gets or sets group ids of the private endpoint connection. + /// + [JsonProperty(PropertyName = "properties.groupIds")] + public IList GroupIds { get; set; } + + /// + /// + [JsonProperty(PropertyName = "properties.privateLinkServiceConnectionState")] + public PrivateLinkServiceConnectionState PrivateLinkServiceConnectionState { get; set; } + + } +} diff --git a/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/Sku.cs b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/Sku.cs new file mode 100644 index 000000000000..3212b10934f0 --- /dev/null +++ b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/Sku.cs @@ -0,0 +1,110 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDBForPostgreSql.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// The resource model definition representing SKU + /// + public partial class Sku + { + /// + /// Initializes a new instance of the Sku class. + /// + public Sku() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Sku class. + /// + /// The name of the SKU. E.g. P3. It is typically a + /// letter+number code + /// Possible values include: 'Free', 'Basic', + /// 'Standard', 'Premium' + /// The SKU size. When the name field is the + /// combination of tier and some other value, this would be the + /// standalone code. + /// If the service has different generations of + /// hardware, for the same SKU, then that can be captured here. + /// If the SKU supports scale out/in then the + /// capacity integer should be included. If scale out/in is not + /// possible for the resource this may be omitted. + public Sku(string name, SkuTier? tier = default(SkuTier?), string size = default(string), string family = default(string), int? capacity = default(int?)) + { + Name = name; + Tier = tier; + Size = size; + Family = family; + Capacity = capacity; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the name of the SKU. E.g. P3. It is typically a + /// letter+number code + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Gets or sets possible values include: 'Free', 'Basic', 'Standard', + /// 'Premium' + /// + [JsonProperty(PropertyName = "tier")] + public SkuTier? Tier { get; set; } + + /// + /// Gets or sets the SKU size. When the name field is the combination + /// of tier and some other value, this would be the standalone code. + /// + [JsonProperty(PropertyName = "size")] + public string Size { get; set; } + + /// + /// Gets or sets if the service has different generations of hardware, + /// for the same SKU, then that can be captured here. + /// + [JsonProperty(PropertyName = "family")] + public string Family { get; set; } + + /// + /// Gets or sets if the SKU supports scale out/in then the capacity + /// integer should be included. If scale out/in is not possible for the + /// resource this may be omitted. + /// + [JsonProperty(PropertyName = "capacity")] + public int? Capacity { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Name == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Name"); + } + } + } +} diff --git a/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/SkuTier.cs b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/SkuTier.cs new file mode 100644 index 000000000000..8fa4bb71b2fd --- /dev/null +++ b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/SkuTier.cs @@ -0,0 +1,72 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDBForPostgreSql.Models +{ + using Newtonsoft.Json; + using Newtonsoft.Json.Converters; + using System.Runtime; + using System.Runtime.Serialization; + + /// + /// Defines values for SkuTier. + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum SkuTier + { + [EnumMember(Value = "Free")] + Free, + [EnumMember(Value = "Basic")] + Basic, + [EnumMember(Value = "Standard")] + Standard, + [EnumMember(Value = "Premium")] + Premium + } + internal static class SkuTierEnumExtension + { + internal static string ToSerializedValue(this SkuTier? value) + { + return value == null ? null : ((SkuTier)value).ToSerializedValue(); + } + + internal static string ToSerializedValue(this SkuTier value) + { + switch( value ) + { + case SkuTier.Free: + return "Free"; + case SkuTier.Basic: + return "Basic"; + case SkuTier.Standard: + return "Standard"; + case SkuTier.Premium: + return "Premium"; + } + return null; + } + + internal static SkuTier? ParseSkuTier(this string value) + { + switch( value ) + { + case "Free": + return SkuTier.Free; + case "Basic": + return SkuTier.Basic; + case "Standard": + return SkuTier.Standard; + case "Premium": + return SkuTier.Premium; + } + return null; + } + } +} diff --git a/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/SystemData.cs b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/SystemData.cs new file mode 100644 index 000000000000..9c0095ec28c3 --- /dev/null +++ b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/SystemData.cs @@ -0,0 +1,103 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDBForPostgreSql.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Metadata pertaining to creation and last modification of the resource. + /// + public partial class SystemData + { + /// + /// Initializes a new instance of the SystemData class. + /// + public SystemData() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the SystemData class. + /// + /// The identity that created the + /// resource. + /// The type of identity that created the + /// resource. Possible values include: 'User', 'Application', + /// 'ManagedIdentity', 'Key' + /// The timestamp of resource creation + /// (UTC). + /// The identity that last modified the + /// resource. + /// The type of identity that last + /// modified the resource. Possible values include: 'User', + /// 'Application', 'ManagedIdentity', 'Key' + /// The timestamp of resource last + /// modification (UTC) + public SystemData(string createdBy = default(string), string createdByType = default(string), System.DateTime? createdAt = default(System.DateTime?), string lastModifiedBy = default(string), string lastModifiedByType = default(string), System.DateTime? lastModifiedAt = default(System.DateTime?)) + { + CreatedBy = createdBy; + CreatedByType = createdByType; + CreatedAt = createdAt; + LastModifiedBy = lastModifiedBy; + LastModifiedByType = lastModifiedByType; + LastModifiedAt = lastModifiedAt; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the identity that created the resource. + /// + [JsonProperty(PropertyName = "createdBy")] + public string CreatedBy { get; set; } + + /// + /// Gets or sets the type of identity that created the resource. + /// Possible values include: 'User', 'Application', 'ManagedIdentity', + /// 'Key' + /// + [JsonProperty(PropertyName = "createdByType")] + public string CreatedByType { get; set; } + + /// + /// Gets or sets the timestamp of resource creation (UTC). + /// + [JsonProperty(PropertyName = "createdAt")] + public System.DateTime? CreatedAt { get; set; } + + /// + /// Gets or sets the identity that last modified the resource. + /// + [JsonProperty(PropertyName = "lastModifiedBy")] + public string LastModifiedBy { get; set; } + + /// + /// Gets or sets the type of identity that last modified the resource. + /// Possible values include: 'User', 'Application', 'ManagedIdentity', + /// 'Key' + /// + [JsonProperty(PropertyName = "lastModifiedByType")] + public string LastModifiedByType { get; set; } + + /// + /// Gets or sets the timestamp of resource last modification (UTC) + /// + [JsonProperty(PropertyName = "lastModifiedAt")] + public System.DateTime? LastModifiedAt { get; set; } + + } +} diff --git a/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/TrackedResource.cs b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/TrackedResource.cs new file mode 100644 index 000000000000..defc6b048228 --- /dev/null +++ b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/TrackedResource.cs @@ -0,0 +1,89 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDBForPostgreSql.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Tracked Resource + /// + /// + /// The resource model definition for an Azure Resource Manager tracked top + /// level resource which has 'tags' and a 'location' + /// + public partial class TrackedResource : Resource + { + /// + /// Initializes a new instance of the TrackedResource class. + /// + public TrackedResource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the TrackedResource class. + /// + /// The geo-location where the resource + /// lives + /// Fully qualified resource ID for the resource. E.g. + /// "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" + /// The name of the resource + /// The type of the resource. E.g. + /// "Microsoft.Compute/virtualMachines" or + /// "Microsoft.Storage/storageAccounts" + /// Azure Resource Manager metadata containing + /// createdBy and modifiedBy information. + /// Resource tags. + public TrackedResource(string location, string id = default(string), string name = default(string), string type = default(string), SystemData systemData = default(SystemData), IDictionary tags = default(IDictionary)) + : base(id, name, type, systemData) + { + Tags = tags; + Location = location; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets resource tags. + /// + [JsonProperty(PropertyName = "tags")] + public IDictionary Tags { get; set; } + + /// + /// Gets or sets the geo-location where the resource lives + /// + [JsonProperty(PropertyName = "location")] + public string Location { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Location == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Location"); + } + } + } +} diff --git a/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/UserAssignedIdentity.cs b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/UserAssignedIdentity.cs new file mode 100644 index 000000000000..40b5e3256eaa --- /dev/null +++ b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Models/UserAssignedIdentity.cs @@ -0,0 +1,61 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDBForPostgreSql.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// User assigned identity properties + /// + public partial class UserAssignedIdentity + { + /// + /// Initializes a new instance of the UserAssignedIdentity class. + /// + public UserAssignedIdentity() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the UserAssignedIdentity class. + /// + /// The principal ID of the assigned + /// identity. + /// The client ID of the assigned + /// identity. + public UserAssignedIdentity(System.Guid? principalId = default(System.Guid?), System.Guid? clientId = default(System.Guid?)) + { + PrincipalId = principalId; + ClientId = clientId; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the principal ID of the assigned identity. + /// + [JsonProperty(PropertyName = "principalId")] + public System.Guid? PrincipalId { get; private set; } + + /// + /// Gets the client ID of the assigned identity. + /// + [JsonProperty(PropertyName = "clientId")] + public System.Guid? ClientId { get; private set; } + + } +} diff --git a/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Operations.cs b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Operations.cs new file mode 100644 index 000000000000..074e10ea6f66 --- /dev/null +++ b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/Operations.cs @@ -0,0 +1,229 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDBForPostgreSql +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Operations operations. + /// + internal partial class Operations : IServiceOperations, IOperations + { + /// + /// Initializes a new instance of the Operations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal Operations(CosmosDBforPostgreSQLClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the CosmosDBforPostgreSQLClient + /// + public CosmosDBforPostgreSQLClient Client { get; private set; } + + /// + /// Lists all of the available REST API operations. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.DBforPostgreSQL/operations").ToString(); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/OperationsExtensions.cs b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/OperationsExtensions.cs new file mode 100644 index 000000000000..c12b6f9d234e --- /dev/null +++ b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/OperationsExtensions.cs @@ -0,0 +1,55 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDBForPostgreSql +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for Operations. + /// + public static partial class OperationsExtensions + { + /// + /// Lists all of the available REST API operations. + /// + /// + /// The operations group for this extension method. + /// + public static IEnumerable List(this IOperations operations) + { + return operations.ListAsync().GetAwaiter().GetResult(); + } + + /// + /// Lists all of the available REST API operations. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAsync(this IOperations operations, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/PrivateEndpointConnectionsOperations.cs b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/PrivateEndpointConnectionsOperations.cs new file mode 100644 index 000000000000..bd2efa06c98d --- /dev/null +++ b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/PrivateEndpointConnectionsOperations.cs @@ -0,0 +1,1076 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDBForPostgreSql +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// PrivateEndpointConnectionsOperations operations. + /// + internal partial class PrivateEndpointConnectionsOperations : IServiceOperations, IPrivateEndpointConnectionsOperations + { + /// + /// Initializes a new instance of the PrivateEndpointConnectionsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal PrivateEndpointConnectionsOperations(CosmosDBforPostgreSQLClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the CosmosDBforPostgreSQLClient + /// + public CosmosDBforPostgreSQLClient Client { get; private set; } + + /// + /// Gets list of private endpoint connections on a cluster. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListByClusterWithHttpMessagesAsync(string resourceGroupName, string clusterName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (clusterName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "clusterName"); + } + if (clusterName != null) + { + if (clusterName.Length > 40) + { + throw new ValidationException(ValidationRules.MaxLength, "clusterName", 40); + } + if (clusterName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "clusterName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(clusterName, "^(?![0-9]+$)(?!-)[a-z0-9-]{3,40}(? tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("clusterName", clusterName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByCluster", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/serverGroupsv2/{clusterName}/privateEndpointConnections").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(Client.SubscriptionId, Client.SerializationSettings).Trim('"'))); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{clusterName}", System.Uri.EscapeDataString(clusterName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Gets private endpoint connection. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The name of the private endpoint connection associated with the cluster. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetWithHttpMessagesAsync(string resourceGroupName, string clusterName, string privateEndpointConnectionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (clusterName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "clusterName"); + } + if (clusterName != null) + { + if (clusterName.Length > 40) + { + throw new ValidationException(ValidationRules.MaxLength, "clusterName", 40); + } + if (clusterName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "clusterName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(clusterName, "^(?![0-9]+$)(?!-)[a-z0-9-]{3,40}(? tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("clusterName", clusterName); + tracingParameters.Add("privateEndpointConnectionName", privateEndpointConnectionName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/serverGroupsv2/{clusterName}/privateEndpointConnections/{privateEndpointConnectionName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(Client.SubscriptionId, Client.SerializationSettings).Trim('"'))); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{clusterName}", System.Uri.EscapeDataString(clusterName)); + _url = _url.Replace("{privateEndpointConnectionName}", System.Uri.EscapeDataString(privateEndpointConnectionName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Approves or Rejects a private endpoint connection with a given name. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The name of the private endpoint connection associated with the cluster. + /// + /// + /// The required parameters for approving a private endpoint connection. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string clusterName, string privateEndpointConnectionName, PrivateEndpointConnection parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, clusterName, privateEndpointConnectionName, parameters, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Deletes a private endpoint connection with a given name. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The name of the private endpoint connection associated with the cluster. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> DeleteWithHttpMessagesAsync(string resourceGroupName, string clusterName, string privateEndpointConnectionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationHeaderResponse _response = await BeginDeleteWithHttpMessagesAsync(resourceGroupName, clusterName, privateEndpointConnectionName, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Approves or Rejects a private endpoint connection with a given name. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The name of the private endpoint connection associated with the cluster. + /// + /// + /// The required parameters for approving a private endpoint connection. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> BeginCreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string clusterName, string privateEndpointConnectionName, PrivateEndpointConnection parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (clusterName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "clusterName"); + } + if (clusterName != null) + { + if (clusterName.Length > 40) + { + throw new ValidationException(ValidationRules.MaxLength, "clusterName", 40); + } + if (clusterName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "clusterName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(clusterName, "^(?![0-9]+$)(?!-)[a-z0-9-]{3,40}(? tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("clusterName", clusterName); + tracingParameters.Add("privateEndpointConnectionName", privateEndpointConnectionName); + tracingParameters.Add("parameters", parameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginCreateOrUpdate", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/serverGroupsv2/{clusterName}/privateEndpointConnections/{privateEndpointConnectionName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(Client.SubscriptionId, Client.SerializationSettings).Trim('"'))); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{clusterName}", System.Uri.EscapeDataString(clusterName)); + _url = _url.Replace("{privateEndpointConnectionName}", System.Uri.EscapeDataString(privateEndpointConnectionName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PUT"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(parameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 201) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + // Deserialize Response + if ((int)_statusCode == 201) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + try + { + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().ToString(), ex); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Deletes a private endpoint connection with a given name. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The name of the private endpoint connection associated with the cluster. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string clusterName, string privateEndpointConnectionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (clusterName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "clusterName"); + } + if (clusterName != null) + { + if (clusterName.Length > 40) + { + throw new ValidationException(ValidationRules.MaxLength, "clusterName", 40); + } + if (clusterName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "clusterName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(clusterName, "^(?![0-9]+$)(?!-)[a-z0-9-]{3,40}(? tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("clusterName", clusterName); + tracingParameters.Add("privateEndpointConnectionName", privateEndpointConnectionName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginDelete", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/serverGroupsv2/{clusterName}/privateEndpointConnections/{privateEndpointConnectionName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(Client.SubscriptionId, Client.SerializationSettings).Trim('"'))); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{clusterName}", System.Uri.EscapeDataString(clusterName)); + _url = _url.Replace("{privateEndpointConnectionName}", System.Uri.EscapeDataString(privateEndpointConnectionName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("DELETE"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 202 && (int)_statusCode != 204) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationHeaderResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + try + { + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().ToString(), ex); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/PrivateEndpointConnectionsOperationsExtensions.cs b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/PrivateEndpointConnectionsOperationsExtensions.cs new file mode 100644 index 000000000000..b01c0e248684 --- /dev/null +++ b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/PrivateEndpointConnectionsOperationsExtensions.cs @@ -0,0 +1,309 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDBForPostgreSql +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for PrivateEndpointConnectionsOperations. + /// + public static partial class PrivateEndpointConnectionsOperationsExtensions + { + /// + /// Gets list of private endpoint connections on a cluster. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + public static IEnumerable ListByCluster(this IPrivateEndpointConnectionsOperations operations, string resourceGroupName, string clusterName) + { + return operations.ListByClusterAsync(resourceGroupName, clusterName).GetAwaiter().GetResult(); + } + + /// + /// Gets list of private endpoint connections on a cluster. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByClusterAsync(this IPrivateEndpointConnectionsOperations operations, string resourceGroupName, string clusterName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByClusterWithHttpMessagesAsync(resourceGroupName, clusterName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets private endpoint connection. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The name of the private endpoint connection associated with the cluster. + /// + public static PrivateEndpointConnection Get(this IPrivateEndpointConnectionsOperations operations, string resourceGroupName, string clusterName, string privateEndpointConnectionName) + { + return operations.GetAsync(resourceGroupName, clusterName, privateEndpointConnectionName).GetAwaiter().GetResult(); + } + + /// + /// Gets private endpoint connection. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The name of the private endpoint connection associated with the cluster. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IPrivateEndpointConnectionsOperations operations, string resourceGroupName, string clusterName, string privateEndpointConnectionName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, clusterName, privateEndpointConnectionName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Approves or Rejects a private endpoint connection with a given name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The name of the private endpoint connection associated with the cluster. + /// + /// + /// The required parameters for approving a private endpoint connection. + /// + public static PrivateEndpointConnection CreateOrUpdate(this IPrivateEndpointConnectionsOperations operations, string resourceGroupName, string clusterName, string privateEndpointConnectionName, PrivateEndpointConnection parameters) + { + return operations.CreateOrUpdateAsync(resourceGroupName, clusterName, privateEndpointConnectionName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Approves or Rejects a private endpoint connection with a given name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The name of the private endpoint connection associated with the cluster. + /// + /// + /// The required parameters for approving a private endpoint connection. + /// + /// + /// The cancellation token. + /// + public static async Task CreateOrUpdateAsync(this IPrivateEndpointConnectionsOperations operations, string resourceGroupName, string clusterName, string privateEndpointConnectionName, PrivateEndpointConnection parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, clusterName, privateEndpointConnectionName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes a private endpoint connection with a given name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The name of the private endpoint connection associated with the cluster. + /// + public static PrivateEndpointConnectionsDeleteHeaders Delete(this IPrivateEndpointConnectionsOperations operations, string resourceGroupName, string clusterName, string privateEndpointConnectionName) + { + return operations.DeleteAsync(resourceGroupName, clusterName, privateEndpointConnectionName).GetAwaiter().GetResult(); + } + + /// + /// Deletes a private endpoint connection with a given name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The name of the private endpoint connection associated with the cluster. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this IPrivateEndpointConnectionsOperations operations, string resourceGroupName, string clusterName, string privateEndpointConnectionName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.DeleteWithHttpMessagesAsync(resourceGroupName, clusterName, privateEndpointConnectionName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Headers; + } + } + + /// + /// Approves or Rejects a private endpoint connection with a given name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The name of the private endpoint connection associated with the cluster. + /// + /// + /// The required parameters for approving a private endpoint connection. + /// + public static PrivateEndpointConnection BeginCreateOrUpdate(this IPrivateEndpointConnectionsOperations operations, string resourceGroupName, string clusterName, string privateEndpointConnectionName, PrivateEndpointConnection parameters) + { + return operations.BeginCreateOrUpdateAsync(resourceGroupName, clusterName, privateEndpointConnectionName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Approves or Rejects a private endpoint connection with a given name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The name of the private endpoint connection associated with the cluster. + /// + /// + /// The required parameters for approving a private endpoint connection. + /// + /// + /// The cancellation token. + /// + public static async Task BeginCreateOrUpdateAsync(this IPrivateEndpointConnectionsOperations operations, string resourceGroupName, string clusterName, string privateEndpointConnectionName, PrivateEndpointConnection parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, clusterName, privateEndpointConnectionName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes a private endpoint connection with a given name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The name of the private endpoint connection associated with the cluster. + /// + public static PrivateEndpointConnectionsDeleteHeaders BeginDelete(this IPrivateEndpointConnectionsOperations operations, string resourceGroupName, string clusterName, string privateEndpointConnectionName) + { + return operations.BeginDeleteAsync(resourceGroupName, clusterName, privateEndpointConnectionName).GetAwaiter().GetResult(); + } + + /// + /// Deletes a private endpoint connection with a given name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The name of the private endpoint connection associated with the cluster. + /// + /// + /// The cancellation token. + /// + public static async Task BeginDeleteAsync(this IPrivateEndpointConnectionsOperations operations, string resourceGroupName, string clusterName, string privateEndpointConnectionName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginDeleteWithHttpMessagesAsync(resourceGroupName, clusterName, privateEndpointConnectionName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Headers; + } + } + + } +} diff --git a/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/PrivateLinkResourcesOperations.cs b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/PrivateLinkResourcesOperations.cs new file mode 100644 index 000000000000..66079f2a0597 --- /dev/null +++ b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/PrivateLinkResourcesOperations.cs @@ -0,0 +1,510 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDBForPostgreSql +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// PrivateLinkResourcesOperations operations. + /// + internal partial class PrivateLinkResourcesOperations : IServiceOperations, IPrivateLinkResourcesOperations + { + /// + /// Initializes a new instance of the PrivateLinkResourcesOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal PrivateLinkResourcesOperations(CosmosDBforPostgreSQLClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the CosmosDBforPostgreSQLClient + /// + public CosmosDBforPostgreSQLClient Client { get; private set; } + + /// + /// Gets the private link resources for cluster. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListByClusterWithHttpMessagesAsync(string resourceGroupName, string clusterName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (clusterName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "clusterName"); + } + if (clusterName != null) + { + if (clusterName.Length > 40) + { + throw new ValidationException(ValidationRules.MaxLength, "clusterName", 40); + } + if (clusterName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "clusterName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(clusterName, "^(?![0-9]+$)(?!-)[a-z0-9-]{3,40}(? tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("clusterName", clusterName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByCluster", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/serverGroupsv2/{clusterName}/privateLinkResources").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(Client.SubscriptionId, Client.SerializationSettings).Trim('"'))); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{clusterName}", System.Uri.EscapeDataString(clusterName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Gets a private link resource for cluster. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The name of the private link resource. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetWithHttpMessagesAsync(string resourceGroupName, string clusterName, string privateLinkResourceName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (clusterName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "clusterName"); + } + if (clusterName != null) + { + if (clusterName.Length > 40) + { + throw new ValidationException(ValidationRules.MaxLength, "clusterName", 40); + } + if (clusterName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "clusterName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(clusterName, "^(?![0-9]+$)(?!-)[a-z0-9-]{3,40}(? tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("clusterName", clusterName); + tracingParameters.Add("privateLinkResourceName", privateLinkResourceName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/serverGroupsv2/{clusterName}/privateLinkResources/{privateLinkResourceName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(Client.SubscriptionId, Client.SerializationSettings).Trim('"'))); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{clusterName}", System.Uri.EscapeDataString(clusterName)); + _url = _url.Replace("{privateLinkResourceName}", System.Uri.EscapeDataString(privateLinkResourceName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/PrivateLinkResourcesOperationsExtensions.cs b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/PrivateLinkResourcesOperationsExtensions.cs new file mode 100644 index 000000000000..afccafaee16a --- /dev/null +++ b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/PrivateLinkResourcesOperationsExtensions.cs @@ -0,0 +1,113 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDBForPostgreSql +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for PrivateLinkResourcesOperations. + /// + public static partial class PrivateLinkResourcesOperationsExtensions + { + /// + /// Gets the private link resources for cluster. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + public static IEnumerable ListByCluster(this IPrivateLinkResourcesOperations operations, string resourceGroupName, string clusterName) + { + return operations.ListByClusterAsync(resourceGroupName, clusterName).GetAwaiter().GetResult(); + } + + /// + /// Gets the private link resources for cluster. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByClusterAsync(this IPrivateLinkResourcesOperations operations, string resourceGroupName, string clusterName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByClusterWithHttpMessagesAsync(resourceGroupName, clusterName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets a private link resource for cluster. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The name of the private link resource. + /// + public static PrivateLinkResource Get(this IPrivateLinkResourcesOperations operations, string resourceGroupName, string clusterName, string privateLinkResourceName) + { + return operations.GetAsync(resourceGroupName, clusterName, privateLinkResourceName).GetAwaiter().GetResult(); + } + + /// + /// Gets a private link resource for cluster. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The name of the private link resource. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IPrivateLinkResourcesOperations operations, string resourceGroupName, string clusterName, string privateLinkResourceName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, clusterName, privateLinkResourceName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/RolesOperations.cs b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/RolesOperations.cs new file mode 100644 index 000000000000..94d04497aa44 --- /dev/null +++ b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/RolesOperations.cs @@ -0,0 +1,1076 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDBForPostgreSql +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// RolesOperations operations. + /// + internal partial class RolesOperations : IServiceOperations, IRolesOperations + { + /// + /// Initializes a new instance of the RolesOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal RolesOperations(CosmosDBforPostgreSQLClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the CosmosDBforPostgreSQLClient + /// + public CosmosDBforPostgreSQLClient Client { get; private set; } + + /// + /// Gets information about a cluster role. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The name of the cluster role. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetWithHttpMessagesAsync(string resourceGroupName, string clusterName, string roleName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (clusterName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "clusterName"); + } + if (clusterName != null) + { + if (clusterName.Length > 40) + { + throw new ValidationException(ValidationRules.MaxLength, "clusterName", 40); + } + if (clusterName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "clusterName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(clusterName, "^(?![0-9]+$)(?!-)[a-z0-9-]{3,40}(? tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("clusterName", clusterName); + tracingParameters.Add("roleName", roleName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/serverGroupsv2/{clusterName}/roles/{roleName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(Client.SubscriptionId, Client.SerializationSettings).Trim('"'))); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{clusterName}", System.Uri.EscapeDataString(clusterName)); + _url = _url.Replace("{roleName}", System.Uri.EscapeDataString(roleName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Creates a new role or updates an existing role. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The name of the cluster role. + /// + /// + /// The required parameters for creating or updating a role. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> CreateWithHttpMessagesAsync(string resourceGroupName, string clusterName, string roleName, Role parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginCreateWithHttpMessagesAsync(resourceGroupName, clusterName, roleName, parameters, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Deletes a cluster role. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The name of the cluster role. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> DeleteWithHttpMessagesAsync(string resourceGroupName, string clusterName, string roleName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationHeaderResponse _response = await BeginDeleteWithHttpMessagesAsync(resourceGroupName, clusterName, roleName, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// List all the roles in a given cluster. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListByClusterWithHttpMessagesAsync(string resourceGroupName, string clusterName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (clusterName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "clusterName"); + } + if (clusterName != null) + { + if (clusterName.Length > 40) + { + throw new ValidationException(ValidationRules.MaxLength, "clusterName", 40); + } + if (clusterName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "clusterName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(clusterName, "^(?![0-9]+$)(?!-)[a-z0-9-]{3,40}(? tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("clusterName", clusterName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByCluster", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/serverGroupsv2/{clusterName}/roles").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(Client.SubscriptionId, Client.SerializationSettings).Trim('"'))); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{clusterName}", System.Uri.EscapeDataString(clusterName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Creates a new role or updates an existing role. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The name of the cluster role. + /// + /// + /// The required parameters for creating or updating a role. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> BeginCreateWithHttpMessagesAsync(string resourceGroupName, string clusterName, string roleName, Role parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (clusterName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "clusterName"); + } + if (clusterName != null) + { + if (clusterName.Length > 40) + { + throw new ValidationException(ValidationRules.MaxLength, "clusterName", 40); + } + if (clusterName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "clusterName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(clusterName, "^(?![0-9]+$)(?!-)[a-z0-9-]{3,40}(? tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("clusterName", clusterName); + tracingParameters.Add("roleName", roleName); + tracingParameters.Add("parameters", parameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginCreate", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/serverGroupsv2/{clusterName}/roles/{roleName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(Client.SubscriptionId, Client.SerializationSettings).Trim('"'))); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{clusterName}", System.Uri.EscapeDataString(clusterName)); + _url = _url.Replace("{roleName}", System.Uri.EscapeDataString(roleName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PUT"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(parameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 201) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + // Deserialize Response + if ((int)_statusCode == 201) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + try + { + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().ToString(), ex); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Deletes a cluster role. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The name of the cluster role. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string clusterName, string roleName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (clusterName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "clusterName"); + } + if (clusterName != null) + { + if (clusterName.Length > 40) + { + throw new ValidationException(ValidationRules.MaxLength, "clusterName", 40); + } + if (clusterName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "clusterName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(clusterName, "^(?![0-9]+$)(?!-)[a-z0-9-]{3,40}(? tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("clusterName", clusterName); + tracingParameters.Add("roleName", roleName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginDelete", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/serverGroupsv2/{clusterName}/roles/{roleName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(Client.SubscriptionId, Client.SerializationSettings).Trim('"'))); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{clusterName}", System.Uri.EscapeDataString(clusterName)); + _url = _url.Replace("{roleName}", System.Uri.EscapeDataString(roleName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("DELETE"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 202 && (int)_statusCode != 204) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationHeaderResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + try + { + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().ToString(), ex); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/RolesOperationsExtensions.cs b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/RolesOperationsExtensions.cs new file mode 100644 index 000000000000..215050650afb --- /dev/null +++ b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/RolesOperationsExtensions.cs @@ -0,0 +1,309 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDBForPostgreSql +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for RolesOperations. + /// + public static partial class RolesOperationsExtensions + { + /// + /// Gets information about a cluster role. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The name of the cluster role. + /// + public static Role Get(this IRolesOperations operations, string resourceGroupName, string clusterName, string roleName) + { + return operations.GetAsync(resourceGroupName, clusterName, roleName).GetAwaiter().GetResult(); + } + + /// + /// Gets information about a cluster role. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The name of the cluster role. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IRolesOperations operations, string resourceGroupName, string clusterName, string roleName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, clusterName, roleName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Creates a new role or updates an existing role. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The name of the cluster role. + /// + /// + /// The required parameters for creating or updating a role. + /// + public static Role Create(this IRolesOperations operations, string resourceGroupName, string clusterName, string roleName, Role parameters) + { + return operations.CreateAsync(resourceGroupName, clusterName, roleName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Creates a new role or updates an existing role. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The name of the cluster role. + /// + /// + /// The required parameters for creating or updating a role. + /// + /// + /// The cancellation token. + /// + public static async Task CreateAsync(this IRolesOperations operations, string resourceGroupName, string clusterName, string roleName, Role parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateWithHttpMessagesAsync(resourceGroupName, clusterName, roleName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes a cluster role. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The name of the cluster role. + /// + public static RolesDeleteHeaders Delete(this IRolesOperations operations, string resourceGroupName, string clusterName, string roleName) + { + return operations.DeleteAsync(resourceGroupName, clusterName, roleName).GetAwaiter().GetResult(); + } + + /// + /// Deletes a cluster role. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The name of the cluster role. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this IRolesOperations operations, string resourceGroupName, string clusterName, string roleName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.DeleteWithHttpMessagesAsync(resourceGroupName, clusterName, roleName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Headers; + } + } + + /// + /// List all the roles in a given cluster. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + public static IEnumerable ListByCluster(this IRolesOperations operations, string resourceGroupName, string clusterName) + { + return operations.ListByClusterAsync(resourceGroupName, clusterName).GetAwaiter().GetResult(); + } + + /// + /// List all the roles in a given cluster. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByClusterAsync(this IRolesOperations operations, string resourceGroupName, string clusterName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByClusterWithHttpMessagesAsync(resourceGroupName, clusterName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Creates a new role or updates an existing role. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The name of the cluster role. + /// + /// + /// The required parameters for creating or updating a role. + /// + public static Role BeginCreate(this IRolesOperations operations, string resourceGroupName, string clusterName, string roleName, Role parameters) + { + return operations.BeginCreateAsync(resourceGroupName, clusterName, roleName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Creates a new role or updates an existing role. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The name of the cluster role. + /// + /// + /// The required parameters for creating or updating a role. + /// + /// + /// The cancellation token. + /// + public static async Task BeginCreateAsync(this IRolesOperations operations, string resourceGroupName, string clusterName, string roleName, Role parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginCreateWithHttpMessagesAsync(resourceGroupName, clusterName, roleName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes a cluster role. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The name of the cluster role. + /// + public static RolesDeleteHeaders BeginDelete(this IRolesOperations operations, string resourceGroupName, string clusterName, string roleName) + { + return operations.BeginDeleteAsync(resourceGroupName, clusterName, roleName).GetAwaiter().GetResult(); + } + + /// + /// Deletes a cluster role. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The name of the cluster role. + /// + /// + /// The cancellation token. + /// + public static async Task BeginDeleteAsync(this IRolesOperations operations, string resourceGroupName, string clusterName, string roleName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginDeleteWithHttpMessagesAsync(resourceGroupName, clusterName, roleName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Headers; + } + } + + } +} diff --git a/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/SdkInfo_CosmosDBforPostgreSQL.cs b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/SdkInfo_CosmosDBforPostgreSQL.cs new file mode 100644 index 000000000000..3d8e0c956cf8 --- /dev/null +++ b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/SdkInfo_CosmosDBforPostgreSQL.cs @@ -0,0 +1,34 @@ + +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDBForPostgreSql +{ + using System; + using System.Collections.Generic; + using System.Linq; + + internal static partial class SdkInfo + { + public static IEnumerable> ApiInfo_CosmosDBforPostgreSQL + { + get + { + return new Tuple[] + { + new Tuple("DBforPostgreSQL", "Clusters", "2023-03-02-preview"), + new Tuple("DBforPostgreSQL", "Configurations", "2023-03-02-preview"), + new Tuple("DBforPostgreSQL", "FirewallRules", "2023-03-02-preview"), + new Tuple("DBforPostgreSQL", "Operations", "2023-03-02-preview"), + new Tuple("DBforPostgreSQL", "PrivateEndpointConnections", "2023-03-02-preview"), + new Tuple("DBforPostgreSQL", "PrivateLinkResources", "2023-03-02-preview"), + new Tuple("DBforPostgreSQL", "Roles", "2023-03-02-preview"), + new Tuple("DBforPostgreSQL", "Servers", "2023-03-02-preview"), + }.AsEnumerable(); + } + } + } +} diff --git a/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/ServersOperations.cs b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/ServersOperations.cs new file mode 100644 index 000000000000..247f9a94d185 --- /dev/null +++ b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/ServersOperations.cs @@ -0,0 +1,518 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDBForPostgreSql +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// ServersOperations operations. + /// + internal partial class ServersOperations : IServiceOperations, IServersOperations + { + /// + /// Initializes a new instance of the ServersOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal ServersOperations(CosmosDBforPostgreSQLClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the CosmosDBforPostgreSQLClient + /// + public CosmosDBforPostgreSQLClient Client { get; private set; } + + /// + /// Lists servers of a cluster. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListByClusterWithHttpMessagesAsync(string resourceGroupName, string clusterName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (clusterName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "clusterName"); + } + if (clusterName != null) + { + if (clusterName.Length > 40) + { + throw new ValidationException(ValidationRules.MaxLength, "clusterName", 40); + } + if (clusterName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "clusterName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(clusterName, "^(?![0-9]+$)(?!-)[a-z0-9-]{3,40}(? tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("clusterName", clusterName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByCluster", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/serverGroupsv2/{clusterName}/servers").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(Client.SubscriptionId, Client.SerializationSettings).Trim('"'))); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{clusterName}", System.Uri.EscapeDataString(clusterName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Gets information about a server in cluster. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The name of the server. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetWithHttpMessagesAsync(string resourceGroupName, string clusterName, string serverName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.ApiVersion != null) + { + if (Client.ApiVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.ApiVersion", 1); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (clusterName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "clusterName"); + } + if (clusterName != null) + { + if (clusterName.Length > 40) + { + throw new ValidationException(ValidationRules.MaxLength, "clusterName", 40); + } + if (clusterName.Length < 3) + { + throw new ValidationException(ValidationRules.MinLength, "clusterName", 3); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(clusterName, "^(?![0-9]+$)(?!-)[a-z0-9-]{3,40}(? 90) + { + throw new ValidationException(ValidationRules.MaxLength, "serverName", 90); + } + if (serverName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "serverName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(serverName, "^[-\\w\\._]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "serverName", "^[-\\w\\._]+$"); + } + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("clusterName", clusterName); + tracingParameters.Add("serverName", serverName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/serverGroupsv2/{clusterName}/servers/{serverName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(Client.SubscriptionId, Client.SerializationSettings).Trim('"'))); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{clusterName}", System.Uri.EscapeDataString(clusterName)); + _url = _url.Replace("{serverName}", System.Uri.EscapeDataString(serverName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/ServersOperationsExtensions.cs b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/ServersOperationsExtensions.cs new file mode 100644 index 000000000000..17f6ce2929d8 --- /dev/null +++ b/sdk/cosmosdbforpostgresql/management/CosmosDBForPostgreSql/GeneratedProtocol/ServersOperationsExtensions.cs @@ -0,0 +1,113 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CosmosDBForPostgreSql +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for ServersOperations. + /// + public static partial class ServersOperationsExtensions + { + /// + /// Lists servers of a cluster. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + public static IEnumerable ListByCluster(this IServersOperations operations, string resourceGroupName, string clusterName) + { + return operations.ListByClusterAsync(resourceGroupName, clusterName).GetAwaiter().GetResult(); + } + + /// + /// Lists servers of a cluster. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByClusterAsync(this IServersOperations operations, string resourceGroupName, string clusterName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByClusterWithHttpMessagesAsync(resourceGroupName, clusterName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets information about a server in cluster. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The name of the server. + /// + public static ClusterServer Get(this IServersOperations operations, string resourceGroupName, string clusterName, string serverName) + { + return operations.GetAsync(resourceGroupName, clusterName, serverName).GetAwaiter().GetResult(); + } + + /// + /// Gets information about a server in cluster. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the cluster. + /// + /// + /// The name of the server. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IServersOperations operations, string resourceGroupName, string clusterName, string serverName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, clusterName, serverName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/AdvisorsOperations.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/AdvisorsOperations.cs new file mode 100644 index 000000000000..1f3c9b6164cd --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/AdvisorsOperations.cs @@ -0,0 +1,660 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// AdvisorsOperations operations. + /// + internal partial class AdvisorsOperations : IServiceOperations, IAdvisorsOperations + { + /// + /// Initializes a new instance of the AdvisorsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal AdvisorsOperations(MariaDBManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the MariaDBManagementClient + /// + public MariaDBManagementClient Client { get; private set; } + + /// + /// Get a recommendation action advisor. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The advisor name for recommendation action. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetWithHttpMessagesAsync(string resourceGroupName, string serverName, string advisorName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (serverName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "serverName"); + } + if (advisorName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "advisorName"); + } + string apiVersion = "2018-06-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("serverName", serverName); + tracingParameters.Add("advisorName", advisorName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMariaDB/servers/{serverName}/advisors/{advisorName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{serverName}", System.Uri.EscapeDataString(serverName)); + _url = _url.Replace("{advisorName}", System.Uri.EscapeDataString(advisorName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// List recommendation action advisors. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListByServerWithHttpMessagesAsync(string resourceGroupName, string serverName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (serverName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "serverName"); + } + string apiVersion = "2018-06-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("serverName", serverName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByServer", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMariaDB/servers/{serverName}/advisors").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{serverName}", System.Uri.EscapeDataString(serverName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// List recommendation action advisors. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListByServerNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByServerNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/AdvisorsOperationsExtensions.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/AdvisorsOperationsExtensions.cs new file mode 100644 index 000000000000..976d3afcb74c --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/AdvisorsOperationsExtensions.cs @@ -0,0 +1,145 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for AdvisorsOperations. + /// + public static partial class AdvisorsOperationsExtensions + { + /// + /// Get a recommendation action advisor. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The advisor name for recommendation action. + /// + public static Advisor Get(this IAdvisorsOperations operations, string resourceGroupName, string serverName, string advisorName) + { + return operations.GetAsync(resourceGroupName, serverName, advisorName).GetAwaiter().GetResult(); + } + + /// + /// Get a recommendation action advisor. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The advisor name for recommendation action. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IAdvisorsOperations operations, string resourceGroupName, string serverName, string advisorName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, serverName, advisorName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// List recommendation action advisors. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + public static IPage ListByServer(this IAdvisorsOperations operations, string resourceGroupName, string serverName) + { + return operations.ListByServerAsync(resourceGroupName, serverName).GetAwaiter().GetResult(); + } + + /// + /// List recommendation action advisors. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByServerAsync(this IAdvisorsOperations operations, string resourceGroupName, string serverName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByServerWithHttpMessagesAsync(resourceGroupName, serverName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// List recommendation action advisors. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListByServerNext(this IAdvisorsOperations operations, string nextPageLink) + { + return operations.ListByServerNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// List recommendation action advisors. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByServerNextAsync(this IAdvisorsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByServerNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/CheckNameAvailabilityOperations.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/CheckNameAvailabilityOperations.cs new file mode 100644 index 000000000000..c842a6c28e4c --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/CheckNameAvailabilityOperations.cs @@ -0,0 +1,255 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// CheckNameAvailabilityOperations operations. + /// + internal partial class CheckNameAvailabilityOperations : IServiceOperations, ICheckNameAvailabilityOperations + { + /// + /// Initializes a new instance of the CheckNameAvailabilityOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal CheckNameAvailabilityOperations(MariaDBManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the MariaDBManagementClient + /// + public MariaDBManagementClient Client { get; private set; } + + /// + /// Check the availability of name for resource + /// + /// + /// The required parameters for checking if resource name is available. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> ExecuteWithHttpMessagesAsync(NameAvailabilityRequest nameAvailabilityRequest, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + if (nameAvailabilityRequest == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nameAvailabilityRequest"); + } + if (nameAvailabilityRequest != null) + { + nameAvailabilityRequest.Validate(); + } + string apiVersion = "2018-06-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("nameAvailabilityRequest", nameAvailabilityRequest); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Execute", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.DBforMariaDB/checkNameAvailability").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(nameAvailabilityRequest != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(nameAvailabilityRequest, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/CheckNameAvailabilityOperationsExtensions.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/CheckNameAvailabilityOperationsExtensions.cs new file mode 100644 index 000000000000..bee67b2b2351 --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/CheckNameAvailabilityOperationsExtensions.cs @@ -0,0 +1,59 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for CheckNameAvailabilityOperations. + /// + public static partial class CheckNameAvailabilityOperationsExtensions + { + /// + /// Check the availability of name for resource + /// + /// + /// The operations group for this extension method. + /// + /// + /// The required parameters for checking if resource name is available. + /// + public static NameAvailability Execute(this ICheckNameAvailabilityOperations operations, NameAvailabilityRequest nameAvailabilityRequest) + { + return operations.ExecuteAsync(nameAvailabilityRequest).GetAwaiter().GetResult(); + } + + /// + /// Check the availability of name for resource + /// + /// + /// The operations group for this extension method. + /// + /// + /// The required parameters for checking if resource name is available. + /// + /// + /// The cancellation token. + /// + public static async Task ExecuteAsync(this ICheckNameAvailabilityOperations operations, NameAvailabilityRequest nameAvailabilityRequest, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ExecuteWithHttpMessagesAsync(nameAvailabilityRequest, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/ConfigurationsOperations.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/ConfigurationsOperations.cs new file mode 100644 index 000000000000..5cb417fdbc7d --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/ConfigurationsOperations.cs @@ -0,0 +1,750 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// ConfigurationsOperations operations. + /// + internal partial class ConfigurationsOperations : IServiceOperations, IConfigurationsOperations + { + /// + /// Initializes a new instance of the ConfigurationsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal ConfigurationsOperations(MariaDBManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the MariaDBManagementClient + /// + public MariaDBManagementClient Client { get; private set; } + + /// + /// Updates a configuration of a server. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The name of the server configuration. + /// + /// + /// The required parameters for updating a server configuration. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string serverName, string configurationName, Configuration parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, serverName, configurationName, parameters, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets information about a configuration of server. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The name of the server configuration. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetWithHttpMessagesAsync(string resourceGroupName, string serverName, string configurationName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (serverName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "serverName"); + } + if (configurationName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "configurationName"); + } + string apiVersion = "2018-06-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("serverName", serverName); + tracingParameters.Add("configurationName", configurationName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMariaDB/servers/{serverName}/configurations/{configurationName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{serverName}", System.Uri.EscapeDataString(serverName)); + _url = _url.Replace("{configurationName}", System.Uri.EscapeDataString(configurationName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// List all the configurations in a given server. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListByServerWithHttpMessagesAsync(string resourceGroupName, string serverName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (serverName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "serverName"); + } + string apiVersion = "2018-06-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("serverName", serverName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByServer", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMariaDB/servers/{serverName}/configurations").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{serverName}", System.Uri.EscapeDataString(serverName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Updates a configuration of a server. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The name of the server configuration. + /// + /// + /// The required parameters for updating a server configuration. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> BeginCreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string serverName, string configurationName, Configuration parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (serverName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "serverName"); + } + if (configurationName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "configurationName"); + } + if (parameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); + } + string apiVersion = "2018-06-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("serverName", serverName); + tracingParameters.Add("configurationName", configurationName); + tracingParameters.Add("parameters", parameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginCreateOrUpdate", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMariaDB/servers/{serverName}/configurations/{configurationName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{serverName}", System.Uri.EscapeDataString(serverName)); + _url = _url.Replace("{configurationName}", System.Uri.EscapeDataString(configurationName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PUT"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(parameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 202) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/ConfigurationsOperationsExtensions.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/ConfigurationsOperationsExtensions.cs new file mode 100644 index 000000000000..e93f92d4ecc3 --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/ConfigurationsOperationsExtensions.cs @@ -0,0 +1,217 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for ConfigurationsOperations. + /// + public static partial class ConfigurationsOperationsExtensions + { + /// + /// Updates a configuration of a server. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The name of the server configuration. + /// + /// + /// The required parameters for updating a server configuration. + /// + public static Configuration CreateOrUpdate(this IConfigurationsOperations operations, string resourceGroupName, string serverName, string configurationName, Configuration parameters) + { + return operations.CreateOrUpdateAsync(resourceGroupName, serverName, configurationName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Updates a configuration of a server. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The name of the server configuration. + /// + /// + /// The required parameters for updating a server configuration. + /// + /// + /// The cancellation token. + /// + public static async Task CreateOrUpdateAsync(this IConfigurationsOperations operations, string resourceGroupName, string serverName, string configurationName, Configuration parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, serverName, configurationName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets information about a configuration of server. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The name of the server configuration. + /// + public static Configuration Get(this IConfigurationsOperations operations, string resourceGroupName, string serverName, string configurationName) + { + return operations.GetAsync(resourceGroupName, serverName, configurationName).GetAwaiter().GetResult(); + } + + /// + /// Gets information about a configuration of server. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The name of the server configuration. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IConfigurationsOperations operations, string resourceGroupName, string serverName, string configurationName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, serverName, configurationName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// List all the configurations in a given server. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + public static IEnumerable ListByServer(this IConfigurationsOperations operations, string resourceGroupName, string serverName) + { + return operations.ListByServerAsync(resourceGroupName, serverName).GetAwaiter().GetResult(); + } + + /// + /// List all the configurations in a given server. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByServerAsync(this IConfigurationsOperations operations, string resourceGroupName, string serverName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByServerWithHttpMessagesAsync(resourceGroupName, serverName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Updates a configuration of a server. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The name of the server configuration. + /// + /// + /// The required parameters for updating a server configuration. + /// + public static Configuration BeginCreateOrUpdate(this IConfigurationsOperations operations, string resourceGroupName, string serverName, string configurationName, Configuration parameters) + { + return operations.BeginCreateOrUpdateAsync(resourceGroupName, serverName, configurationName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Updates a configuration of a server. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The name of the server configuration. + /// + /// + /// The required parameters for updating a server configuration. + /// + /// + /// The cancellation token. + /// + public static async Task BeginCreateOrUpdateAsync(this IConfigurationsOperations operations, string resourceGroupName, string serverName, string configurationName, Configuration parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, serverName, configurationName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/DatabasesOperations.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/DatabasesOperations.cs new file mode 100644 index 000000000000..1178bebaed4e --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/DatabasesOperations.cs @@ -0,0 +1,993 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// DatabasesOperations operations. + /// + internal partial class DatabasesOperations : IServiceOperations, IDatabasesOperations + { + /// + /// Initializes a new instance of the DatabasesOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal DatabasesOperations(MariaDBManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the MariaDBManagementClient + /// + public MariaDBManagementClient Client { get; private set; } + + /// + /// Creates a new database or updates an existing database. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database. + /// + /// + /// The required parameters for creating or updating a database. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string serverName, string databaseName, Database parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, serverName, databaseName, parameters, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Deletes a database. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task DeleteWithHttpMessagesAsync(string resourceGroupName, string serverName, string databaseName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginDeleteWithHttpMessagesAsync(resourceGroupName, serverName, databaseName, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets information about a database. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetWithHttpMessagesAsync(string resourceGroupName, string serverName, string databaseName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (serverName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "serverName"); + } + if (databaseName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "databaseName"); + } + string apiVersion = "2018-06-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("serverName", serverName); + tracingParameters.Add("databaseName", databaseName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMariaDB/servers/{serverName}/databases/{databaseName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{serverName}", System.Uri.EscapeDataString(serverName)); + _url = _url.Replace("{databaseName}", System.Uri.EscapeDataString(databaseName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// List all the databases in a given server. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListByServerWithHttpMessagesAsync(string resourceGroupName, string serverName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (serverName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "serverName"); + } + string apiVersion = "2018-06-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("serverName", serverName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByServer", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMariaDB/servers/{serverName}/databases").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{serverName}", System.Uri.EscapeDataString(serverName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Creates a new database or updates an existing database. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database. + /// + /// + /// The required parameters for creating or updating a database. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> BeginCreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string serverName, string databaseName, Database parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (serverName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "serverName"); + } + if (databaseName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "databaseName"); + } + if (parameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); + } + string apiVersion = "2018-06-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("serverName", serverName); + tracingParameters.Add("databaseName", databaseName); + tracingParameters.Add("parameters", parameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginCreateOrUpdate", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMariaDB/servers/{serverName}/databases/{databaseName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{serverName}", System.Uri.EscapeDataString(serverName)); + _url = _url.Replace("{databaseName}", System.Uri.EscapeDataString(databaseName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PUT"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(parameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 201 && (int)_statusCode != 202) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + // Deserialize Response + if ((int)_statusCode == 201) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Deletes a database. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string serverName, string databaseName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (serverName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "serverName"); + } + if (databaseName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "databaseName"); + } + string apiVersion = "2018-06-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("serverName", serverName); + tracingParameters.Add("databaseName", databaseName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginDelete", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMariaDB/servers/{serverName}/databases/{databaseName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{serverName}", System.Uri.EscapeDataString(serverName)); + _url = _url.Replace("{databaseName}", System.Uri.EscapeDataString(databaseName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("DELETE"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 202 && (int)_statusCode != 204) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/DatabasesOperationsExtensions.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/DatabasesOperationsExtensions.cs new file mode 100644 index 000000000000..8fb9c7971c18 --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/DatabasesOperationsExtensions.cs @@ -0,0 +1,303 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for DatabasesOperations. + /// + public static partial class DatabasesOperationsExtensions + { + /// + /// Creates a new database or updates an existing database. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database. + /// + /// + /// The required parameters for creating or updating a database. + /// + public static Database CreateOrUpdate(this IDatabasesOperations operations, string resourceGroupName, string serverName, string databaseName, Database parameters) + { + return operations.CreateOrUpdateAsync(resourceGroupName, serverName, databaseName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Creates a new database or updates an existing database. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database. + /// + /// + /// The required parameters for creating or updating a database. + /// + /// + /// The cancellation token. + /// + public static async Task CreateOrUpdateAsync(this IDatabasesOperations operations, string resourceGroupName, string serverName, string databaseName, Database parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, serverName, databaseName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes a database. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database. + /// + public static void Delete(this IDatabasesOperations operations, string resourceGroupName, string serverName, string databaseName) + { + operations.DeleteAsync(resourceGroupName, serverName, databaseName).GetAwaiter().GetResult(); + } + + /// + /// Deletes a database. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this IDatabasesOperations operations, string resourceGroupName, string serverName, string databaseName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, serverName, databaseName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Gets information about a database. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database. + /// + public static Database Get(this IDatabasesOperations operations, string resourceGroupName, string serverName, string databaseName) + { + return operations.GetAsync(resourceGroupName, serverName, databaseName).GetAwaiter().GetResult(); + } + + /// + /// Gets information about a database. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IDatabasesOperations operations, string resourceGroupName, string serverName, string databaseName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, serverName, databaseName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// List all the databases in a given server. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + public static IEnumerable ListByServer(this IDatabasesOperations operations, string resourceGroupName, string serverName) + { + return operations.ListByServerAsync(resourceGroupName, serverName).GetAwaiter().GetResult(); + } + + /// + /// List all the databases in a given server. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByServerAsync(this IDatabasesOperations operations, string resourceGroupName, string serverName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByServerWithHttpMessagesAsync(resourceGroupName, serverName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Creates a new database or updates an existing database. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database. + /// + /// + /// The required parameters for creating or updating a database. + /// + public static Database BeginCreateOrUpdate(this IDatabasesOperations operations, string resourceGroupName, string serverName, string databaseName, Database parameters) + { + return operations.BeginCreateOrUpdateAsync(resourceGroupName, serverName, databaseName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Creates a new database or updates an existing database. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database. + /// + /// + /// The required parameters for creating or updating a database. + /// + /// + /// The cancellation token. + /// + public static async Task BeginCreateOrUpdateAsync(this IDatabasesOperations operations, string resourceGroupName, string serverName, string databaseName, Database parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, serverName, databaseName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes a database. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database. + /// + public static void BeginDelete(this IDatabasesOperations operations, string resourceGroupName, string serverName, string databaseName) + { + operations.BeginDeleteAsync(resourceGroupName, serverName, databaseName).GetAwaiter().GetResult(); + } + + /// + /// Deletes a database. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database. + /// + /// + /// The cancellation token. + /// + public static async Task BeginDeleteAsync(this IDatabasesOperations operations, string resourceGroupName, string serverName, string databaseName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.BeginDeleteWithHttpMessagesAsync(resourceGroupName, serverName, databaseName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/FirewallRulesOperations.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/FirewallRulesOperations.cs new file mode 100644 index 000000000000..e98bbf8e80f5 --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/FirewallRulesOperations.cs @@ -0,0 +1,997 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// FirewallRulesOperations operations. + /// + internal partial class FirewallRulesOperations : IServiceOperations, IFirewallRulesOperations + { + /// + /// Initializes a new instance of the FirewallRulesOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal FirewallRulesOperations(MariaDBManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the MariaDBManagementClient + /// + public MariaDBManagementClient Client { get; private set; } + + /// + /// Creates a new firewall rule or updates an existing firewall rule. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The name of the server firewall rule. + /// + /// + /// The required parameters for creating or updating a firewall rule. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string serverName, string firewallRuleName, FirewallRule parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, serverName, firewallRuleName, parameters, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Deletes a server firewall rule. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The name of the server firewall rule. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task DeleteWithHttpMessagesAsync(string resourceGroupName, string serverName, string firewallRuleName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginDeleteWithHttpMessagesAsync(resourceGroupName, serverName, firewallRuleName, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets information about a server firewall rule. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The name of the server firewall rule. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetWithHttpMessagesAsync(string resourceGroupName, string serverName, string firewallRuleName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (serverName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "serverName"); + } + if (firewallRuleName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "firewallRuleName"); + } + string apiVersion = "2018-06-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("serverName", serverName); + tracingParameters.Add("firewallRuleName", firewallRuleName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMariaDB/servers/{serverName}/firewallRules/{firewallRuleName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{serverName}", System.Uri.EscapeDataString(serverName)); + _url = _url.Replace("{firewallRuleName}", System.Uri.EscapeDataString(firewallRuleName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// List all the firewall rules in a given server. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListByServerWithHttpMessagesAsync(string resourceGroupName, string serverName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (serverName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "serverName"); + } + string apiVersion = "2018-06-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("serverName", serverName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByServer", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMariaDB/servers/{serverName}/firewallRules").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{serverName}", System.Uri.EscapeDataString(serverName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Creates a new firewall rule or updates an existing firewall rule. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The name of the server firewall rule. + /// + /// + /// The required parameters for creating or updating a firewall rule. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> BeginCreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string serverName, string firewallRuleName, FirewallRule parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (serverName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "serverName"); + } + if (firewallRuleName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "firewallRuleName"); + } + if (parameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); + } + if (parameters != null) + { + parameters.Validate(); + } + string apiVersion = "2018-06-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("serverName", serverName); + tracingParameters.Add("firewallRuleName", firewallRuleName); + tracingParameters.Add("parameters", parameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginCreateOrUpdate", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMariaDB/servers/{serverName}/firewallRules/{firewallRuleName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{serverName}", System.Uri.EscapeDataString(serverName)); + _url = _url.Replace("{firewallRuleName}", System.Uri.EscapeDataString(firewallRuleName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PUT"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(parameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 201 && (int)_statusCode != 202) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + // Deserialize Response + if ((int)_statusCode == 201) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Deletes a server firewall rule. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The name of the server firewall rule. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string serverName, string firewallRuleName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (serverName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "serverName"); + } + if (firewallRuleName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "firewallRuleName"); + } + string apiVersion = "2018-06-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("serverName", serverName); + tracingParameters.Add("firewallRuleName", firewallRuleName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginDelete", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMariaDB/servers/{serverName}/firewallRules/{firewallRuleName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{serverName}", System.Uri.EscapeDataString(serverName)); + _url = _url.Replace("{firewallRuleName}", System.Uri.EscapeDataString(firewallRuleName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("DELETE"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 202 && (int)_statusCode != 204) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/FirewallRulesOperationsExtensions.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/FirewallRulesOperationsExtensions.cs new file mode 100644 index 000000000000..b9755073c6cc --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/FirewallRulesOperationsExtensions.cs @@ -0,0 +1,303 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for FirewallRulesOperations. + /// + public static partial class FirewallRulesOperationsExtensions + { + /// + /// Creates a new firewall rule or updates an existing firewall rule. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The name of the server firewall rule. + /// + /// + /// The required parameters for creating or updating a firewall rule. + /// + public static FirewallRule CreateOrUpdate(this IFirewallRulesOperations operations, string resourceGroupName, string serverName, string firewallRuleName, FirewallRule parameters) + { + return operations.CreateOrUpdateAsync(resourceGroupName, serverName, firewallRuleName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Creates a new firewall rule or updates an existing firewall rule. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The name of the server firewall rule. + /// + /// + /// The required parameters for creating or updating a firewall rule. + /// + /// + /// The cancellation token. + /// + public static async Task CreateOrUpdateAsync(this IFirewallRulesOperations operations, string resourceGroupName, string serverName, string firewallRuleName, FirewallRule parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, serverName, firewallRuleName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes a server firewall rule. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The name of the server firewall rule. + /// + public static void Delete(this IFirewallRulesOperations operations, string resourceGroupName, string serverName, string firewallRuleName) + { + operations.DeleteAsync(resourceGroupName, serverName, firewallRuleName).GetAwaiter().GetResult(); + } + + /// + /// Deletes a server firewall rule. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The name of the server firewall rule. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this IFirewallRulesOperations operations, string resourceGroupName, string serverName, string firewallRuleName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, serverName, firewallRuleName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Gets information about a server firewall rule. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The name of the server firewall rule. + /// + public static FirewallRule Get(this IFirewallRulesOperations operations, string resourceGroupName, string serverName, string firewallRuleName) + { + return operations.GetAsync(resourceGroupName, serverName, firewallRuleName).GetAwaiter().GetResult(); + } + + /// + /// Gets information about a server firewall rule. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The name of the server firewall rule. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IFirewallRulesOperations operations, string resourceGroupName, string serverName, string firewallRuleName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, serverName, firewallRuleName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// List all the firewall rules in a given server. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + public static IEnumerable ListByServer(this IFirewallRulesOperations operations, string resourceGroupName, string serverName) + { + return operations.ListByServerAsync(resourceGroupName, serverName).GetAwaiter().GetResult(); + } + + /// + /// List all the firewall rules in a given server. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByServerAsync(this IFirewallRulesOperations operations, string resourceGroupName, string serverName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByServerWithHttpMessagesAsync(resourceGroupName, serverName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Creates a new firewall rule or updates an existing firewall rule. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The name of the server firewall rule. + /// + /// + /// The required parameters for creating or updating a firewall rule. + /// + public static FirewallRule BeginCreateOrUpdate(this IFirewallRulesOperations operations, string resourceGroupName, string serverName, string firewallRuleName, FirewallRule parameters) + { + return operations.BeginCreateOrUpdateAsync(resourceGroupName, serverName, firewallRuleName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Creates a new firewall rule or updates an existing firewall rule. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The name of the server firewall rule. + /// + /// + /// The required parameters for creating or updating a firewall rule. + /// + /// + /// The cancellation token. + /// + public static async Task BeginCreateOrUpdateAsync(this IFirewallRulesOperations operations, string resourceGroupName, string serverName, string firewallRuleName, FirewallRule parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, serverName, firewallRuleName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes a server firewall rule. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The name of the server firewall rule. + /// + public static void BeginDelete(this IFirewallRulesOperations operations, string resourceGroupName, string serverName, string firewallRuleName) + { + operations.BeginDeleteAsync(resourceGroupName, serverName, firewallRuleName).GetAwaiter().GetResult(); + } + + /// + /// Deletes a server firewall rule. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The name of the server firewall rule. + /// + /// + /// The cancellation token. + /// + public static async Task BeginDeleteAsync(this IFirewallRulesOperations operations, string resourceGroupName, string serverName, string firewallRuleName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.BeginDeleteWithHttpMessagesAsync(resourceGroupName, serverName, firewallRuleName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/IAdvisorsOperations.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/IAdvisorsOperations.cs new file mode 100644 index 000000000000..d51a0fa03f9c --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/IAdvisorsOperations.cs @@ -0,0 +1,102 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// AdvisorsOperations operations. + /// + public partial interface IAdvisorsOperations + { + /// + /// Get a recommendation action advisor. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The advisor name for recommendation action. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> GetWithHttpMessagesAsync(string resourceGroupName, string serverName, string advisorName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// List recommendation action advisors. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListByServerWithHttpMessagesAsync(string resourceGroupName, string serverName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// List recommendation action advisors. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListByServerNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/ICheckNameAvailabilityOperations.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/ICheckNameAvailabilityOperations.cs new file mode 100644 index 000000000000..68410a659d75 --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/ICheckNameAvailabilityOperations.cs @@ -0,0 +1,49 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// CheckNameAvailabilityOperations operations. + /// + public partial interface ICheckNameAvailabilityOperations + { + /// + /// Check the availability of name for resource + /// + /// + /// The required parameters for checking if resource name is available. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> ExecuteWithHttpMessagesAsync(NameAvailabilityRequest nameAvailabilityRequest, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/IConfigurationsOperations.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/IConfigurationsOperations.cs new file mode 100644 index 000000000000..267517638925 --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/IConfigurationsOperations.cs @@ -0,0 +1,142 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// ConfigurationsOperations operations. + /// + public partial interface IConfigurationsOperations + { + /// + /// Updates a configuration of a server. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The name of the server configuration. + /// + /// + /// The required parameters for updating a server configuration. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string serverName, string configurationName, Configuration parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets information about a configuration of server. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The name of the server configuration. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> GetWithHttpMessagesAsync(string resourceGroupName, string serverName, string configurationName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// List all the configurations in a given server. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListByServerWithHttpMessagesAsync(string resourceGroupName, string serverName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Updates a configuration of a server. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The name of the server configuration. + /// + /// + /// The required parameters for updating a server configuration. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> BeginCreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string serverName, string configurationName, Configuration parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/IDatabasesOperations.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/IDatabasesOperations.cs new file mode 100644 index 000000000000..22f9146e5ef9 --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/IDatabasesOperations.cs @@ -0,0 +1,192 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// DatabasesOperations operations. + /// + public partial interface IDatabasesOperations + { + /// + /// Creates a new database or updates an existing database. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database. + /// + /// + /// The required parameters for creating or updating a database. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string serverName, string databaseName, Database parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes a database. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task DeleteWithHttpMessagesAsync(string resourceGroupName, string serverName, string databaseName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets information about a database. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> GetWithHttpMessagesAsync(string resourceGroupName, string serverName, string databaseName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// List all the databases in a given server. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListByServerWithHttpMessagesAsync(string resourceGroupName, string serverName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Creates a new database or updates an existing database. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database. + /// + /// + /// The required parameters for creating or updating a database. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> BeginCreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string serverName, string databaseName, Database parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes a database. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string serverName, string databaseName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/IFirewallRulesOperations.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/IFirewallRulesOperations.cs new file mode 100644 index 000000000000..fd3ddb2e9bc8 --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/IFirewallRulesOperations.cs @@ -0,0 +1,192 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// FirewallRulesOperations operations. + /// + public partial interface IFirewallRulesOperations + { + /// + /// Creates a new firewall rule or updates an existing firewall rule. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The name of the server firewall rule. + /// + /// + /// The required parameters for creating or updating a firewall rule. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string serverName, string firewallRuleName, FirewallRule parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes a server firewall rule. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The name of the server firewall rule. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task DeleteWithHttpMessagesAsync(string resourceGroupName, string serverName, string firewallRuleName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets information about a server firewall rule. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The name of the server firewall rule. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> GetWithHttpMessagesAsync(string resourceGroupName, string serverName, string firewallRuleName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// List all the firewall rules in a given server. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListByServerWithHttpMessagesAsync(string resourceGroupName, string serverName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Creates a new firewall rule or updates an existing firewall rule. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The name of the server firewall rule. + /// + /// + /// The required parameters for creating or updating a firewall rule. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> BeginCreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string serverName, string firewallRuleName, FirewallRule parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes a server firewall rule. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The name of the server firewall rule. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string serverName, string firewallRuleName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/ILocationBasedPerformanceTierOperations.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/ILocationBasedPerformanceTierOperations.cs new file mode 100644 index 000000000000..d99026d02581 --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/ILocationBasedPerformanceTierOperations.cs @@ -0,0 +1,50 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// LocationBasedPerformanceTierOperations operations. + /// + public partial interface ILocationBasedPerformanceTierOperations + { + /// + /// List all the performance tiers at specified location in a given + /// subscription. + /// + /// + /// The name of the location. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListWithHttpMessagesAsync(string locationName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/ILocationBasedRecommendedActionSessionsOperationStatusOperations.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/ILocationBasedRecommendedActionSessionsOperationStatusOperations.cs new file mode 100644 index 000000000000..81f13b447f36 --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/ILocationBasedRecommendedActionSessionsOperationStatusOperations.cs @@ -0,0 +1,52 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// LocationBasedRecommendedActionSessionsOperationStatusOperations operations. + /// + public partial interface ILocationBasedRecommendedActionSessionsOperationStatusOperations + { + /// + /// Recommendation action session operation status. + /// + /// + /// The name of the location. + /// + /// + /// The operation identifier. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> GetWithHttpMessagesAsync(string locationName, string operationId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/ILocationBasedRecommendedActionSessionsResultOperations.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/ILocationBasedRecommendedActionSessionsResultOperations.cs new file mode 100644 index 000000000000..9abcdd335f76 --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/ILocationBasedRecommendedActionSessionsResultOperations.cs @@ -0,0 +1,74 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// LocationBasedRecommendedActionSessionsResultOperations operations. + /// + public partial interface ILocationBasedRecommendedActionSessionsResultOperations + { + /// + /// Recommendation action session operation result. + /// + /// + /// The name of the location. + /// + /// + /// The operation identifier. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListWithHttpMessagesAsync(string locationName, string operationId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Recommendation action session operation result. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/ILogFilesOperations.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/ILogFilesOperations.cs new file mode 100644 index 000000000000..fa220aab0adb --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/ILogFilesOperations.cs @@ -0,0 +1,52 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// LogFilesOperations operations. + /// + public partial interface ILogFilesOperations + { + /// + /// List all the log files in a given server. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListByServerWithHttpMessagesAsync(string resourceGroupName, string serverName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/IMariaDBManagementClient.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/IMariaDBManagementClient.cs new file mode 100644 index 000000000000..3d3b36a030ce --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/IMariaDBManagementClient.cs @@ -0,0 +1,253 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// The Microsoft Azure management API provides create, read, update, and + /// delete functionality for Azure MariaDB resources including servers, + /// databases, firewall rules, VNET rules, log files and configurations + /// with new business model. + /// + public partial interface IMariaDBManagementClient : System.IDisposable + { + /// + /// The base URI of the service. + /// + System.Uri BaseUri { get; set; } + + /// + /// Gets or sets json serialization settings. + /// + JsonSerializerSettings SerializationSettings { get; } + + /// + /// Gets or sets json deserialization settings. + /// + JsonSerializerSettings DeserializationSettings { get; } + + /// + /// Credentials needed for the client to connect to Azure. + /// + ServiceClientCredentials Credentials { get; } + + /// + /// The ID of the target subscription. + /// + string SubscriptionId { get; set; } + + /// + /// The preferred language for the response. + /// + string AcceptLanguage { get; set; } + + /// + /// The retry timeout in seconds for Long Running Operations. Default + /// value is 30. + /// + int? LongRunningOperationRetryTimeout { get; set; } + + /// + /// Whether a unique x-ms-client-request-id should be generated. When + /// set to true a unique x-ms-client-request-id value is generated and + /// included in each request. Default is true. + /// + bool? GenerateClientRequestId { get; set; } + + + /// + /// Gets the IServersOperations. + /// + IServersOperations Servers { get; } + + /// + /// Gets the IReplicasOperations. + /// + IReplicasOperations Replicas { get; } + + /// + /// Gets the IFirewallRulesOperations. + /// + IFirewallRulesOperations FirewallRules { get; } + + /// + /// Gets the IVirtualNetworkRulesOperations. + /// + IVirtualNetworkRulesOperations VirtualNetworkRules { get; } + + /// + /// Gets the IDatabasesOperations. + /// + IDatabasesOperations Databases { get; } + + /// + /// Gets the IConfigurationsOperations. + /// + IConfigurationsOperations Configurations { get; } + + /// + /// Gets the IServerParametersOperations. + /// + IServerParametersOperations ServerParameters { get; } + + /// + /// Gets the ILogFilesOperations. + /// + ILogFilesOperations LogFiles { get; } + + /// + /// Gets the IRecoverableServersOperations. + /// + IRecoverableServersOperations RecoverableServers { get; } + + /// + /// Gets the IServerBasedPerformanceTierOperations. + /// + IServerBasedPerformanceTierOperations ServerBasedPerformanceTier { get; } + + /// + /// Gets the ILocationBasedPerformanceTierOperations. + /// + ILocationBasedPerformanceTierOperations LocationBasedPerformanceTier { get; } + + /// + /// Gets the ICheckNameAvailabilityOperations. + /// + ICheckNameAvailabilityOperations CheckNameAvailability { get; } + + /// + /// Gets the IOperations. + /// + IOperations Operations { get; } + + /// + /// Gets the IQueryTextsOperations. + /// + IQueryTextsOperations QueryTexts { get; } + + /// + /// Gets the ITopQueryStatisticsOperations. + /// + ITopQueryStatisticsOperations TopQueryStatistics { get; } + + /// + /// Gets the IWaitStatisticsOperations. + /// + IWaitStatisticsOperations WaitStatistics { get; } + + /// + /// Gets the IAdvisorsOperations. + /// + IAdvisorsOperations Advisors { get; } + + /// + /// Gets the IRecommendedActionsOperations. + /// + IRecommendedActionsOperations RecommendedActions { get; } + + /// + /// Gets the ILocationBasedRecommendedActionSessionsOperationStatusOperations. + /// + ILocationBasedRecommendedActionSessionsOperationStatusOperations LocationBasedRecommendedActionSessionsOperationStatus { get; } + + /// + /// Gets the ILocationBasedRecommendedActionSessionsResultOperations. + /// + ILocationBasedRecommendedActionSessionsResultOperations LocationBasedRecommendedActionSessionsResult { get; } + + /// + /// Gets the IPrivateEndpointConnectionsOperations. + /// + IPrivateEndpointConnectionsOperations PrivateEndpointConnections { get; } + + /// + /// Gets the IPrivateLinkResourcesOperations. + /// + IPrivateLinkResourcesOperations PrivateLinkResources { get; } + + /// + /// Gets the IServerSecurityAlertPoliciesOperations. + /// + IServerSecurityAlertPoliciesOperations ServerSecurityAlertPolicies { get; } + + /// + /// Reset data for Query Performance Insight. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + Task> ResetQueryPerformanceInsightDataWithHttpMessagesAsync(string resourceGroupName, string serverName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + + /// + /// Create recommendation action session for the advisor. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The advisor name for recommendation action. + /// + /// + /// The name of the database. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + Task CreateRecommendedActionSessionWithHttpMessagesAsync(string resourceGroupName, string serverName, string advisorName, string databaseName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + + /// + /// Create recommendation action session for the advisor. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The advisor name for recommendation action. + /// + /// + /// The name of the database. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + Task BeginCreateRecommendedActionSessionWithHttpMessagesAsync(string resourceGroupName, string serverName, string advisorName, string databaseName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/IOperations.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/IOperations.cs new file mode 100644 index 000000000000..6dca13ca5a91 --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/IOperations.cs @@ -0,0 +1,46 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Operations operations. + /// + public partial interface IOperations + { + /// + /// Lists all of the available REST API operations. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/IPrivateEndpointConnectionsOperations.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/IPrivateEndpointConnectionsOperations.cs new file mode 100644 index 000000000000..cd2b9ad7b471 --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/IPrivateEndpointConnectionsOperations.cs @@ -0,0 +1,276 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// PrivateEndpointConnectionsOperations operations. + /// + public partial interface IPrivateEndpointConnectionsOperations + { + /// + /// Gets a private endpoint connection. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The name of the private endpoint connection. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> GetWithHttpMessagesAsync(string resourceGroupName, string serverName, string privateEndpointConnectionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Approve or reject a private endpoint connection with a given name. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// + /// + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string serverName, string privateEndpointConnectionName, PrivateEndpointConnection parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes a private endpoint connection with a given name. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task DeleteWithHttpMessagesAsync(string resourceGroupName, string serverName, string privateEndpointConnectionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Updates tags on private endpoint connection. + /// + /// + /// Updates private endpoint connection with the specified tags. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// + /// + /// Parameters supplied to the Update private endpoint connection Tags + /// operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> UpdateTagsWithHttpMessagesAsync(string resourceGroupName, string serverName, string privateEndpointConnectionName, TagsObject parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets all private endpoint connections on a server. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListByServerWithHttpMessagesAsync(string resourceGroupName, string serverName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Approve or reject a private endpoint connection with a given name. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// + /// + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> BeginCreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string serverName, string privateEndpointConnectionName, PrivateEndpointConnection parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes a private endpoint connection with a given name. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string serverName, string privateEndpointConnectionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Updates tags on private endpoint connection. + /// + /// + /// Updates private endpoint connection with the specified tags. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// + /// + /// Parameters supplied to the Update private endpoint connection Tags + /// operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> BeginUpdateTagsWithHttpMessagesAsync(string resourceGroupName, string serverName, string privateEndpointConnectionName, TagsObject parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets all private endpoint connections on a server. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListByServerNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/IPrivateLinkResourcesOperations.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/IPrivateLinkResourcesOperations.cs new file mode 100644 index 000000000000..0a791d8fda48 --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/IPrivateLinkResourcesOperations.cs @@ -0,0 +1,102 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// PrivateLinkResourcesOperations operations. + /// + public partial interface IPrivateLinkResourcesOperations + { + /// + /// Gets the private link resources for MariaDB server. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListByServerWithHttpMessagesAsync(string resourceGroupName, string serverName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets a private link resource for MariaDB server. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The name of the private link resource. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> GetWithHttpMessagesAsync(string resourceGroupName, string serverName, string groupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets the private link resources for MariaDB server. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListByServerNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/IQueryTextsOperations.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/IQueryTextsOperations.cs new file mode 100644 index 000000000000..db54042a6190 --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/IQueryTextsOperations.cs @@ -0,0 +1,105 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// QueryTextsOperations operations. + /// + public partial interface IQueryTextsOperations + { + /// + /// Retrieve the Query-Store query texts for the queryId. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The Query-Store query identifier. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> GetWithHttpMessagesAsync(string resourceGroupName, string serverName, string queryId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Retrieve the Query-Store query texts for specified queryIds. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The query identifiers + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListByServerWithHttpMessagesAsync(string resourceGroupName, string serverName, IList queryIds, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Retrieve the Query-Store query texts for specified queryIds. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListByServerNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/IRecommendedActionsOperations.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/IRecommendedActionsOperations.cs new file mode 100644 index 000000000000..36280fa485dc --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/IRecommendedActionsOperations.cs @@ -0,0 +1,111 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// RecommendedActionsOperations operations. + /// + public partial interface IRecommendedActionsOperations + { + /// + /// Retrieve recommended actions from the advisor. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The advisor name for recommendation action. + /// + /// + /// The recommended action name. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> GetWithHttpMessagesAsync(string resourceGroupName, string serverName, string advisorName, string recommendedActionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Retrieve recommended actions from the advisor. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The advisor name for recommendation action. + /// + /// + /// The recommendation action session identifier. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListByServerWithHttpMessagesAsync(string resourceGroupName, string serverName, string advisorName, string sessionId = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Retrieve recommended actions from the advisor. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListByServerNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/IRecoverableServersOperations.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/IRecoverableServersOperations.cs new file mode 100644 index 000000000000..397ee1d4dfe8 --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/IRecoverableServersOperations.cs @@ -0,0 +1,52 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// RecoverableServersOperations operations. + /// + public partial interface IRecoverableServersOperations + { + /// + /// Gets a recoverable MariaDB Server. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> GetWithHttpMessagesAsync(string resourceGroupName, string serverName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/IReplicasOperations.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/IReplicasOperations.cs new file mode 100644 index 000000000000..f55dd6e5e7dc --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/IReplicasOperations.cs @@ -0,0 +1,52 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// ReplicasOperations operations. + /// + public partial interface IReplicasOperations + { + /// + /// List all the replicas for a given server. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListByServerWithHttpMessagesAsync(string resourceGroupName, string serverName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/IServerBasedPerformanceTierOperations.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/IServerBasedPerformanceTierOperations.cs new file mode 100644 index 000000000000..257fca752cd3 --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/IServerBasedPerformanceTierOperations.cs @@ -0,0 +1,52 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// ServerBasedPerformanceTierOperations operations. + /// + public partial interface IServerBasedPerformanceTierOperations + { + /// + /// List all the performance tiers for a MariaDB server. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListWithHttpMessagesAsync(string resourceGroupName, string serverName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/IServerParametersOperations.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/IServerParametersOperations.cs new file mode 100644 index 000000000000..0477148ddca9 --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/IServerParametersOperations.cs @@ -0,0 +1,83 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// ServerParametersOperations operations. + /// + public partial interface IServerParametersOperations + { + /// + /// Update a list of configurations in a given server. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The parameters for updating a list of server configuration. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> ListUpdateConfigurationsWithHttpMessagesAsync(string resourceGroupName, string serverName, ConfigurationListResult value, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Update a list of configurations in a given server. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The parameters for updating a list of server configuration. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> BeginListUpdateConfigurationsWithHttpMessagesAsync(string resourceGroupName, string serverName, ConfigurationListResult value, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/IServerSecurityAlertPoliciesOperations.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/IServerSecurityAlertPoliciesOperations.cs new file mode 100644 index 000000000000..077bc755a777 --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/IServerSecurityAlertPoliciesOperations.cs @@ -0,0 +1,155 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// ServerSecurityAlertPoliciesOperations operations. + /// + public partial interface IServerSecurityAlertPoliciesOperations + { + /// + /// Get a server's security alert policy. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> GetWithHttpMessagesAsync(string resourceGroupName, string serverName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Creates or updates a threat detection policy. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The server security alert policy. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string serverName, ServerSecurityAlertPolicy parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get the server's threat detection policies. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListByServerWithHttpMessagesAsync(string resourceGroupName, string serverName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Creates or updates a threat detection policy. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The server security alert policy. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> BeginCreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string serverName, ServerSecurityAlertPolicy parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get the server's threat detection policies. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListByServerNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/IServersOperations.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/IServersOperations.cs new file mode 100644 index 000000000000..70d4861b7c99 --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/IServersOperations.cs @@ -0,0 +1,385 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// ServersOperations operations. + /// + public partial interface IServersOperations + { + /// + /// Creates a new server or updates an existing server. The update + /// action will overwrite the existing server. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The required parameters for creating or updating a server. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> CreateWithHttpMessagesAsync(string resourceGroupName, string serverName, ServerForCreate parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Updates an existing server. The request body can contain one to + /// many of the properties present in the normal server definition. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The required parameters for updating a server. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> UpdateWithHttpMessagesAsync(string resourceGroupName, string serverName, ServerUpdateParameters parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes a server. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task DeleteWithHttpMessagesAsync(string resourceGroupName, string serverName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets information about a server. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> GetWithHttpMessagesAsync(string resourceGroupName, string serverName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// List all the servers in a given resource group. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListByResourceGroupWithHttpMessagesAsync(string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// List all the servers in a given subscription. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Restarts a server. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task RestartWithHttpMessagesAsync(string resourceGroupName, string serverName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Starts a stopped server. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task StartWithHttpMessagesAsync(string resourceGroupName, string serverName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Stops a running server. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task StopWithHttpMessagesAsync(string resourceGroupName, string serverName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Creates a new server or updates an existing server. The update + /// action will overwrite the existing server. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The required parameters for creating or updating a server. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> BeginCreateWithHttpMessagesAsync(string resourceGroupName, string serverName, ServerForCreate parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Updates an existing server. The request body can contain one to + /// many of the properties present in the normal server definition. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The required parameters for updating a server. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> BeginUpdateWithHttpMessagesAsync(string resourceGroupName, string serverName, ServerUpdateParameters parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes a server. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string serverName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Restarts a server. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task BeginRestartWithHttpMessagesAsync(string resourceGroupName, string serverName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Starts a stopped server. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task BeginStartWithHttpMessagesAsync(string resourceGroupName, string serverName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Stops a running server. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task BeginStopWithHttpMessagesAsync(string resourceGroupName, string serverName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/ITopQueryStatisticsOperations.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/ITopQueryStatisticsOperations.cs new file mode 100644 index 000000000000..d942f7c594f9 --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/ITopQueryStatisticsOperations.cs @@ -0,0 +1,107 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// TopQueryStatisticsOperations operations. + /// + public partial interface ITopQueryStatisticsOperations + { + /// + /// Retrieve the query statistic for specified identifier. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The Query Statistic identifier. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> GetWithHttpMessagesAsync(string resourceGroupName, string serverName, string queryStatisticId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Retrieve the Query-Store top queries for specified metric and + /// aggregation. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The required parameters for retrieving top query statistics. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListByServerWithHttpMessagesAsync(string resourceGroupName, string serverName, TopQueryStatisticsInput parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Retrieve the Query-Store top queries for specified metric and + /// aggregation. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListByServerNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/IVirtualNetworkRulesOperations.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/IVirtualNetworkRulesOperations.cs new file mode 100644 index 000000000000..9c0b32bebbd0 --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/IVirtualNetworkRulesOperations.cs @@ -0,0 +1,214 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// VirtualNetworkRulesOperations operations. + /// + public partial interface IVirtualNetworkRulesOperations + { + /// + /// Gets a virtual network rule. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The name of the virtual network rule. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> GetWithHttpMessagesAsync(string resourceGroupName, string serverName, string virtualNetworkRuleName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Creates or updates an existing virtual network rule. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The name of the virtual network rule. + /// + /// + /// The requested virtual Network Rule Resource state. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string serverName, string virtualNetworkRuleName, VirtualNetworkRule parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes the virtual network rule with the given name. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The name of the virtual network rule. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task DeleteWithHttpMessagesAsync(string resourceGroupName, string serverName, string virtualNetworkRuleName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets a list of virtual network rules in a server. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListByServerWithHttpMessagesAsync(string resourceGroupName, string serverName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Creates or updates an existing virtual network rule. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The name of the virtual network rule. + /// + /// + /// The requested virtual Network Rule Resource state. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> BeginCreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string serverName, string virtualNetworkRuleName, VirtualNetworkRule parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes the virtual network rule with the given name. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The name of the virtual network rule. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string serverName, string virtualNetworkRuleName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets a list of virtual network rules in a server. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListByServerNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/IWaitStatisticsOperations.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/IWaitStatisticsOperations.cs new file mode 100644 index 000000000000..596b7f29da73 --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/IWaitStatisticsOperations.cs @@ -0,0 +1,105 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// WaitStatisticsOperations operations. + /// + public partial interface IWaitStatisticsOperations + { + /// + /// Retrieve wait statistics for specified identifier. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The Wait Statistic identifier. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> GetWithHttpMessagesAsync(string resourceGroupName, string serverName, string waitStatisticsId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Retrieve wait statistics for specified aggregation window. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The required parameters for retrieving wait statistics. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListByServerWithHttpMessagesAsync(string resourceGroupName, string serverName, WaitStatisticsInput parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Retrieve wait statistics for specified aggregation window. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListByServerNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/LocationBasedPerformanceTierOperations.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/LocationBasedPerformanceTierOperations.cs new file mode 100644 index 000000000000..8cbfae187ac8 --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/LocationBasedPerformanceTierOperations.cs @@ -0,0 +1,247 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// LocationBasedPerformanceTierOperations operations. + /// + internal partial class LocationBasedPerformanceTierOperations : IServiceOperations, ILocationBasedPerformanceTierOperations + { + /// + /// Initializes a new instance of the LocationBasedPerformanceTierOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal LocationBasedPerformanceTierOperations(MariaDBManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the MariaDBManagementClient + /// + public MariaDBManagementClient Client { get; private set; } + + /// + /// List all the performance tiers at specified location in a given + /// subscription. + /// + /// + /// The name of the location. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListWithHttpMessagesAsync(string locationName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + if (locationName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "locationName"); + } + string apiVersion = "2018-06-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("locationName", locationName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.DBforMariaDB/locations/{locationName}/performanceTiers").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{locationName}", System.Uri.EscapeDataString(locationName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/LocationBasedPerformanceTierOperationsExtensions.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/LocationBasedPerformanceTierOperationsExtensions.cs new file mode 100644 index 000000000000..df4882755a92 --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/LocationBasedPerformanceTierOperationsExtensions.cs @@ -0,0 +1,63 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for LocationBasedPerformanceTierOperations. + /// + public static partial class LocationBasedPerformanceTierOperationsExtensions + { + /// + /// List all the performance tiers at specified location in a given + /// subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the location. + /// + public static IEnumerable List(this ILocationBasedPerformanceTierOperations operations, string locationName) + { + return operations.ListAsync(locationName).GetAwaiter().GetResult(); + } + + /// + /// List all the performance tiers at specified location in a given + /// subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the location. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAsync(this ILocationBasedPerformanceTierOperations operations, string locationName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(locationName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/LocationBasedRecommendedActionSessionsOperationStatusOperations.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/LocationBasedRecommendedActionSessionsOperationStatusOperations.cs new file mode 100644 index 000000000000..5d13849f6471 --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/LocationBasedRecommendedActionSessionsOperationStatusOperations.cs @@ -0,0 +1,255 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// LocationBasedRecommendedActionSessionsOperationStatusOperations operations. + /// + internal partial class LocationBasedRecommendedActionSessionsOperationStatusOperations : IServiceOperations, ILocationBasedRecommendedActionSessionsOperationStatusOperations + { + /// + /// Initializes a new instance of the LocationBasedRecommendedActionSessionsOperationStatusOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal LocationBasedRecommendedActionSessionsOperationStatusOperations(MariaDBManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the MariaDBManagementClient + /// + public MariaDBManagementClient Client { get; private set; } + + /// + /// Recommendation action session operation status. + /// + /// + /// The name of the location. + /// + /// + /// The operation identifier. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetWithHttpMessagesAsync(string locationName, string operationId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + if (locationName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "locationName"); + } + if (operationId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "operationId"); + } + string apiVersion = "2018-06-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("locationName", locationName); + tracingParameters.Add("operationId", operationId); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.DBforMariaDB/locations/{locationName}/recommendedActionSessionsAzureAsyncOperation/{operationId}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{locationName}", System.Uri.EscapeDataString(locationName)); + _url = _url.Replace("{operationId}", System.Uri.EscapeDataString(operationId)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/LocationBasedRecommendedActionSessionsOperationStatusOperationsExtensions.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/LocationBasedRecommendedActionSessionsOperationStatusOperationsExtensions.cs new file mode 100644 index 000000000000..5c884514208d --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/LocationBasedRecommendedActionSessionsOperationStatusOperationsExtensions.cs @@ -0,0 +1,65 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for LocationBasedRecommendedActionSessionsOperationStatusOperations. + /// + public static partial class LocationBasedRecommendedActionSessionsOperationStatusOperationsExtensions + { + /// + /// Recommendation action session operation status. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the location. + /// + /// + /// The operation identifier. + /// + public static RecommendedActionSessionsOperationStatus Get(this ILocationBasedRecommendedActionSessionsOperationStatusOperations operations, string locationName, string operationId) + { + return operations.GetAsync(locationName, operationId).GetAwaiter().GetResult(); + } + + /// + /// Recommendation action session operation status. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the location. + /// + /// + /// The operation identifier. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this ILocationBasedRecommendedActionSessionsOperationStatusOperations operations, string locationName, string operationId, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(locationName, operationId, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/LocationBasedRecommendedActionSessionsResultOperations.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/LocationBasedRecommendedActionSessionsResultOperations.cs new file mode 100644 index 000000000000..2311014c05d2 --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/LocationBasedRecommendedActionSessionsResultOperations.cs @@ -0,0 +1,464 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// LocationBasedRecommendedActionSessionsResultOperations operations. + /// + internal partial class LocationBasedRecommendedActionSessionsResultOperations : IServiceOperations, ILocationBasedRecommendedActionSessionsResultOperations + { + /// + /// Initializes a new instance of the LocationBasedRecommendedActionSessionsResultOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal LocationBasedRecommendedActionSessionsResultOperations(MariaDBManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the MariaDBManagementClient + /// + public MariaDBManagementClient Client { get; private set; } + + /// + /// Recommendation action session operation result. + /// + /// + /// The name of the location. + /// + /// + /// The operation identifier. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListWithHttpMessagesAsync(string locationName, string operationId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + if (locationName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "locationName"); + } + if (operationId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "operationId"); + } + string apiVersion = "2018-06-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("locationName", locationName); + tracingParameters.Add("operationId", operationId); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.DBforMariaDB/locations/{locationName}/recommendedActionSessionsOperationResults/{operationId}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{locationName}", System.Uri.EscapeDataString(locationName)); + _url = _url.Replace("{operationId}", System.Uri.EscapeDataString(operationId)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 201) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + // Deserialize Response + if ((int)_statusCode == 201) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Recommendation action session operation result. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 201) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + // Deserialize Response + if ((int)_statusCode == 201) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/LocationBasedRecommendedActionSessionsResultOperationsExtensions.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/LocationBasedRecommendedActionSessionsResultOperationsExtensions.cs new file mode 100644 index 000000000000..a5cdfc7e278b --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/LocationBasedRecommendedActionSessionsResultOperationsExtensions.cs @@ -0,0 +1,99 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for LocationBasedRecommendedActionSessionsResultOperations. + /// + public static partial class LocationBasedRecommendedActionSessionsResultOperationsExtensions + { + /// + /// Recommendation action session operation result. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the location. + /// + /// + /// The operation identifier. + /// + public static IPage List(this ILocationBasedRecommendedActionSessionsResultOperations operations, string locationName, string operationId) + { + return operations.ListAsync(locationName, operationId).GetAwaiter().GetResult(); + } + + /// + /// Recommendation action session operation result. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the location. + /// + /// + /// The operation identifier. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAsync(this ILocationBasedRecommendedActionSessionsResultOperations operations, string locationName, string operationId, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(locationName, operationId, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Recommendation action session operation result. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListNext(this ILocationBasedRecommendedActionSessionsResultOperations operations, string nextPageLink) + { + return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Recommendation action session operation result. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListNextAsync(this ILocationBasedRecommendedActionSessionsResultOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/LogFilesOperations.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/LogFilesOperations.cs new file mode 100644 index 000000000000..8cc3685f039a --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/LogFilesOperations.cs @@ -0,0 +1,266 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// LogFilesOperations operations. + /// + internal partial class LogFilesOperations : IServiceOperations, ILogFilesOperations + { + /// + /// Initializes a new instance of the LogFilesOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal LogFilesOperations(MariaDBManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the MariaDBManagementClient + /// + public MariaDBManagementClient Client { get; private set; } + + /// + /// List all the log files in a given server. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListByServerWithHttpMessagesAsync(string resourceGroupName, string serverName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (serverName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "serverName"); + } + string apiVersion = "2018-06-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("serverName", serverName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByServer", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMariaDB/servers/{serverName}/logFiles").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{serverName}", System.Uri.EscapeDataString(serverName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/LogFilesOperationsExtensions.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/LogFilesOperationsExtensions.cs new file mode 100644 index 000000000000..079d506f7a24 --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/LogFilesOperationsExtensions.cs @@ -0,0 +1,67 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for LogFilesOperations. + /// + public static partial class LogFilesOperationsExtensions + { + /// + /// List all the log files in a given server. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + public static IEnumerable ListByServer(this ILogFilesOperations operations, string resourceGroupName, string serverName) + { + return operations.ListByServerAsync(resourceGroupName, serverName).GetAwaiter().GetResult(); + } + + /// + /// List all the log files in a given server. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByServerAsync(this ILogFilesOperations operations, string resourceGroupName, string serverName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByServerWithHttpMessagesAsync(resourceGroupName, serverName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/MariaDBManagementClient.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/MariaDBManagementClient.cs new file mode 100644 index 000000000000..a382a31d4ca8 --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/MariaDBManagementClient.cs @@ -0,0 +1,945 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Microsoft.Rest.Serialization; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// The Microsoft Azure management API provides create, read, update, and + /// delete functionality for Azure MariaDB resources including servers, + /// databases, firewall rules, VNET rules, log files and configurations + /// with new business model. + /// + public partial class MariaDBManagementClient : ServiceClient, IMariaDBManagementClient, IAzureClient + { + /// + /// The base URI of the service. + /// + public System.Uri BaseUri { get; set; } + + /// + /// Gets or sets json serialization settings. + /// + public JsonSerializerSettings SerializationSettings { get; private set; } + + /// + /// Gets or sets json deserialization settings. + /// + public JsonSerializerSettings DeserializationSettings { get; private set; } + + /// + /// Credentials needed for the client to connect to Azure. + /// + public ServiceClientCredentials Credentials { get; private set; } + + /// + /// The ID of the target subscription. + /// + public string SubscriptionId { get; set; } + + /// + /// The preferred language for the response. + /// + public string AcceptLanguage { get; set; } + + /// + /// The retry timeout in seconds for Long Running Operations. Default value is + /// 30. + /// + public int? LongRunningOperationRetryTimeout { get; set; } + + /// + /// Whether a unique x-ms-client-request-id should be generated. When set to + /// true a unique x-ms-client-request-id value is generated and included in + /// each request. Default is true. + /// + public bool? GenerateClientRequestId { get; set; } + + /// + /// Gets the IServersOperations. + /// + public virtual IServersOperations Servers { get; private set; } + + /// + /// Gets the IReplicasOperations. + /// + public virtual IReplicasOperations Replicas { get; private set; } + + /// + /// Gets the IFirewallRulesOperations. + /// + public virtual IFirewallRulesOperations FirewallRules { get; private set; } + + /// + /// Gets the IVirtualNetworkRulesOperations. + /// + public virtual IVirtualNetworkRulesOperations VirtualNetworkRules { get; private set; } + + /// + /// Gets the IDatabasesOperations. + /// + public virtual IDatabasesOperations Databases { get; private set; } + + /// + /// Gets the IConfigurationsOperations. + /// + public virtual IConfigurationsOperations Configurations { get; private set; } + + /// + /// Gets the IServerParametersOperations. + /// + public virtual IServerParametersOperations ServerParameters { get; private set; } + + /// + /// Gets the ILogFilesOperations. + /// + public virtual ILogFilesOperations LogFiles { get; private set; } + + /// + /// Gets the IRecoverableServersOperations. + /// + public virtual IRecoverableServersOperations RecoverableServers { get; private set; } + + /// + /// Gets the IServerBasedPerformanceTierOperations. + /// + public virtual IServerBasedPerformanceTierOperations ServerBasedPerformanceTier { get; private set; } + + /// + /// Gets the ILocationBasedPerformanceTierOperations. + /// + public virtual ILocationBasedPerformanceTierOperations LocationBasedPerformanceTier { get; private set; } + + /// + /// Gets the ICheckNameAvailabilityOperations. + /// + public virtual ICheckNameAvailabilityOperations CheckNameAvailability { get; private set; } + + /// + /// Gets the IOperations. + /// + public virtual IOperations Operations { get; private set; } + + /// + /// Gets the IQueryTextsOperations. + /// + public virtual IQueryTextsOperations QueryTexts { get; private set; } + + /// + /// Gets the ITopQueryStatisticsOperations. + /// + public virtual ITopQueryStatisticsOperations TopQueryStatistics { get; private set; } + + /// + /// Gets the IWaitStatisticsOperations. + /// + public virtual IWaitStatisticsOperations WaitStatistics { get; private set; } + + /// + /// Gets the IAdvisorsOperations. + /// + public virtual IAdvisorsOperations Advisors { get; private set; } + + /// + /// Gets the IRecommendedActionsOperations. + /// + public virtual IRecommendedActionsOperations RecommendedActions { get; private set; } + + /// + /// Gets the ILocationBasedRecommendedActionSessionsOperationStatusOperations. + /// + public virtual ILocationBasedRecommendedActionSessionsOperationStatusOperations LocationBasedRecommendedActionSessionsOperationStatus { get; private set; } + + /// + /// Gets the ILocationBasedRecommendedActionSessionsResultOperations. + /// + public virtual ILocationBasedRecommendedActionSessionsResultOperations LocationBasedRecommendedActionSessionsResult { get; private set; } + + /// + /// Gets the IPrivateEndpointConnectionsOperations. + /// + public virtual IPrivateEndpointConnectionsOperations PrivateEndpointConnections { get; private set; } + + /// + /// Gets the IPrivateLinkResourcesOperations. + /// + public virtual IPrivateLinkResourcesOperations PrivateLinkResources { get; private set; } + + /// + /// Gets the IServerSecurityAlertPoliciesOperations. + /// + public virtual IServerSecurityAlertPoliciesOperations ServerSecurityAlertPolicies { get; private set; } + + /// + /// Initializes a new instance of the MariaDBManagementClient class. + /// + /// + /// HttpClient to be used + /// + /// + /// True: will dispose the provided httpClient on calling MariaDBManagementClient.Dispose(). False: will not dispose provided httpClient + protected MariaDBManagementClient(HttpClient httpClient, bool disposeHttpClient) : base(httpClient, disposeHttpClient) + { + Initialize(); + } + + /// + /// Initializes a new instance of the MariaDBManagementClient class. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + protected MariaDBManagementClient(params DelegatingHandler[] handlers) : base(handlers) + { + Initialize(); + } + + /// + /// Initializes a new instance of the MariaDBManagementClient class. + /// + /// + /// Optional. The http client handler used to handle http transport. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + protected MariaDBManagementClient(HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : base(rootHandler, handlers) + { + Initialize(); + } + + /// + /// Initializes a new instance of the MariaDBManagementClient class. + /// + /// + /// Optional. The base URI of the service. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + /// + /// Thrown when a required parameter is null + /// + protected MariaDBManagementClient(System.Uri baseUri, params DelegatingHandler[] handlers) : this(handlers) + { + if (baseUri == null) + { + throw new System.ArgumentNullException("baseUri"); + } + BaseUri = baseUri; + } + + /// + /// Initializes a new instance of the MariaDBManagementClient class. + /// + /// + /// Optional. The base URI of the service. + /// + /// + /// Optional. The http client handler used to handle http transport. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + /// + /// Thrown when a required parameter is null + /// + protected MariaDBManagementClient(System.Uri baseUri, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers) + { + if (baseUri == null) + { + throw new System.ArgumentNullException("baseUri"); + } + BaseUri = baseUri; + } + + /// + /// Initializes a new instance of the MariaDBManagementClient class. + /// + /// + /// Required. Credentials needed for the client to connect to Azure. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + /// + /// Thrown when a required parameter is null + /// + public MariaDBManagementClient(ServiceClientCredentials credentials, params DelegatingHandler[] handlers) : this(handlers) + { + if (credentials == null) + { + throw new System.ArgumentNullException("credentials"); + } + Credentials = credentials; + if (Credentials != null) + { + Credentials.InitializeServiceClient(this); + } + } + + /// + /// Initializes a new instance of the MariaDBManagementClient class. + /// + /// + /// Required. Credentials needed for the client to connect to Azure. + /// + /// + /// HttpClient to be used + /// + /// + /// True: will dispose the provided httpClient on calling MariaDBManagementClient.Dispose(). False: will not dispose provided httpClient + /// + /// Thrown when a required parameter is null + /// + public MariaDBManagementClient(ServiceClientCredentials credentials, HttpClient httpClient, bool disposeHttpClient) : this(httpClient, disposeHttpClient) + { + if (credentials == null) + { + throw new System.ArgumentNullException("credentials"); + } + Credentials = credentials; + if (Credentials != null) + { + Credentials.InitializeServiceClient(this); + } + } + + /// + /// Initializes a new instance of the MariaDBManagementClient class. + /// + /// + /// Required. Credentials needed for the client to connect to Azure. + /// + /// + /// Optional. The http client handler used to handle http transport. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + /// + /// Thrown when a required parameter is null + /// + public MariaDBManagementClient(ServiceClientCredentials credentials, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers) + { + if (credentials == null) + { + throw new System.ArgumentNullException("credentials"); + } + Credentials = credentials; + if (Credentials != null) + { + Credentials.InitializeServiceClient(this); + } + } + + /// + /// Initializes a new instance of the MariaDBManagementClient class. + /// + /// + /// Optional. The base URI of the service. + /// + /// + /// Required. Credentials needed for the client to connect to Azure. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + /// + /// Thrown when a required parameter is null + /// + public MariaDBManagementClient(System.Uri baseUri, ServiceClientCredentials credentials, params DelegatingHandler[] handlers) : this(handlers) + { + if (baseUri == null) + { + throw new System.ArgumentNullException("baseUri"); + } + if (credentials == null) + { + throw new System.ArgumentNullException("credentials"); + } + BaseUri = baseUri; + Credentials = credentials; + if (Credentials != null) + { + Credentials.InitializeServiceClient(this); + } + } + + /// + /// Initializes a new instance of the MariaDBManagementClient class. + /// + /// + /// Optional. The base URI of the service. + /// + /// + /// Required. Credentials needed for the client to connect to Azure. + /// + /// + /// Optional. The http client handler used to handle http transport. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + /// + /// Thrown when a required parameter is null + /// + public MariaDBManagementClient(System.Uri baseUri, ServiceClientCredentials credentials, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers) + { + if (baseUri == null) + { + throw new System.ArgumentNullException("baseUri"); + } + if (credentials == null) + { + throw new System.ArgumentNullException("credentials"); + } + BaseUri = baseUri; + Credentials = credentials; + if (Credentials != null) + { + Credentials.InitializeServiceClient(this); + } + } + + /// + /// An optional partial-method to perform custom initialization. + /// + partial void CustomInitialize(); + /// + /// Initializes client properties. + /// + private void Initialize() + { + Servers = new ServersOperations(this); + Replicas = new ReplicasOperations(this); + FirewallRules = new FirewallRulesOperations(this); + VirtualNetworkRules = new VirtualNetworkRulesOperations(this); + Databases = new DatabasesOperations(this); + Configurations = new ConfigurationsOperations(this); + ServerParameters = new ServerParametersOperations(this); + LogFiles = new LogFilesOperations(this); + RecoverableServers = new RecoverableServersOperations(this); + ServerBasedPerformanceTier = new ServerBasedPerformanceTierOperations(this); + LocationBasedPerformanceTier = new LocationBasedPerformanceTierOperations(this); + CheckNameAvailability = new CheckNameAvailabilityOperations(this); + Operations = new Operations(this); + QueryTexts = new QueryTextsOperations(this); + TopQueryStatistics = new TopQueryStatisticsOperations(this); + WaitStatistics = new WaitStatisticsOperations(this); + Advisors = new AdvisorsOperations(this); + RecommendedActions = new RecommendedActionsOperations(this); + LocationBasedRecommendedActionSessionsOperationStatus = new LocationBasedRecommendedActionSessionsOperationStatusOperations(this); + LocationBasedRecommendedActionSessionsResult = new LocationBasedRecommendedActionSessionsResultOperations(this); + PrivateEndpointConnections = new PrivateEndpointConnectionsOperations(this); + PrivateLinkResources = new PrivateLinkResourcesOperations(this); + ServerSecurityAlertPolicies = new ServerSecurityAlertPoliciesOperations(this); + BaseUri = new System.Uri("https://management.azure.com"); + AcceptLanguage = "en-US"; + LongRunningOperationRetryTimeout = 30; + GenerateClientRequestId = true; + SerializationSettings = new JsonSerializerSettings + { + Formatting = Newtonsoft.Json.Formatting.Indented, + DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, + NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, + ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + ContractResolver = new ReadOnlyJsonContractResolver(), + Converters = new List + { + new Iso8601TimeSpanConverter() + } + }; + SerializationSettings.Converters.Add(new TransformationJsonConverter()); + DeserializationSettings = new JsonSerializerSettings + { + DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, + NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, + ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + ContractResolver = new ReadOnlyJsonContractResolver(), + Converters = new List + { + new Iso8601TimeSpanConverter() + } + }; + SerializationSettings.Converters.Add(new PolymorphicSerializeJsonConverter("createMode")); + DeserializationSettings.Converters.Add(new PolymorphicDeserializeJsonConverter("createMode")); + CustomInitialize(); + DeserializationSettings.Converters.Add(new TransformationJsonConverter()); + DeserializationSettings.Converters.Add(new CloudErrorJsonConverter()); + } + /// + /// Reset data for Query Performance Insight. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> ResetQueryPerformanceInsightDataWithHttpMessagesAsync(string resourceGroupName, string serverName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.SubscriptionId"); + } + if (SubscriptionId != null) + { + if (SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "SubscriptionId", 1); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (serverName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "serverName"); + } + string apiVersion = "2018-06-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("serverName", serverName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ResetQueryPerformanceInsightData", tracingParameters); + } + // Construct URL + var _baseUrl = BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMariaDB/servers/{serverName}/resetQueryPerformanceInsightData").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{serverName}", System.Uri.EscapeDataString(serverName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (GenerateClientRequestId != null && GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Create recommendation action session for the advisor. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The advisor name for recommendation action. + /// + /// + /// The name of the database. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task CreateRecommendedActionSessionWithHttpMessagesAsync(string resourceGroupName, string serverName, string advisorName, string databaseName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginCreateRecommendedActionSessionWithHttpMessagesAsync(resourceGroupName, serverName, advisorName, databaseName, customHeaders, cancellationToken).ConfigureAwait(false); + return await this.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Create recommendation action session for the advisor. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The advisor name for recommendation action. + /// + /// + /// The name of the database. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task BeginCreateRecommendedActionSessionWithHttpMessagesAsync(string resourceGroupName, string serverName, string advisorName, string databaseName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.SubscriptionId"); + } + if (SubscriptionId != null) + { + if (SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "SubscriptionId", 1); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (serverName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "serverName"); + } + if (advisorName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "advisorName"); + } + if (databaseName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "databaseName"); + } + string apiVersion = "2018-06-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("serverName", serverName); + tracingParameters.Add("advisorName", advisorName); + tracingParameters.Add("databaseName", databaseName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginCreateRecommendedActionSession", tracingParameters); + } + // Construct URL + var _baseUrl = BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMariaDB/servers/{serverName}/advisors/{advisorName}/createRecommendedActionSession").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{serverName}", System.Uri.EscapeDataString(serverName)); + _url = _url.Replace("{advisorName}", System.Uri.EscapeDataString(advisorName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (databaseName != null) + { + _queryParameters.Add(string.Format("databaseName={0}", System.Uri.EscapeDataString(databaseName))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (GenerateClientRequestId != null && GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 202) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/MariaDBManagementClientExtensions.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/MariaDBManagementClientExtensions.cs new file mode 100644 index 000000000000..2f9346d15b31 --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/MariaDBManagementClientExtensions.cs @@ -0,0 +1,163 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for MariaDBManagementClient. + /// + public static partial class MariaDBManagementClientExtensions + { + /// + /// Reset data for Query Performance Insight. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + public static QueryPerformanceInsightResetDataResult ResetQueryPerformanceInsightData(this IMariaDBManagementClient operations, string resourceGroupName, string serverName) + { + return operations.ResetQueryPerformanceInsightDataAsync(resourceGroupName, serverName).GetAwaiter().GetResult(); + } + + /// + /// Reset data for Query Performance Insight. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The cancellation token. + /// + public static async Task ResetQueryPerformanceInsightDataAsync(this IMariaDBManagementClient operations, string resourceGroupName, string serverName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ResetQueryPerformanceInsightDataWithHttpMessagesAsync(resourceGroupName, serverName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Create recommendation action session for the advisor. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The advisor name for recommendation action. + /// + /// + /// The name of the database. + /// + public static void CreateRecommendedActionSession(this IMariaDBManagementClient operations, string resourceGroupName, string serverName, string advisorName, string databaseName) + { + operations.CreateRecommendedActionSessionAsync(resourceGroupName, serverName, advisorName, databaseName).GetAwaiter().GetResult(); + } + + /// + /// Create recommendation action session for the advisor. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The advisor name for recommendation action. + /// + /// + /// The name of the database. + /// + /// + /// The cancellation token. + /// + public static async Task CreateRecommendedActionSessionAsync(this IMariaDBManagementClient operations, string resourceGroupName, string serverName, string advisorName, string databaseName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.CreateRecommendedActionSessionWithHttpMessagesAsync(resourceGroupName, serverName, advisorName, databaseName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Create recommendation action session for the advisor. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The advisor name for recommendation action. + /// + /// + /// The name of the database. + /// + public static void BeginCreateRecommendedActionSession(this IMariaDBManagementClient operations, string resourceGroupName, string serverName, string advisorName, string databaseName) + { + operations.BeginCreateRecommendedActionSessionAsync(resourceGroupName, serverName, advisorName, databaseName).GetAwaiter().GetResult(); + } + + /// + /// Create recommendation action session for the advisor. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The advisor name for recommendation action. + /// + /// + /// The name of the database. + /// + /// + /// The cancellation token. + /// + public static async Task BeginCreateRecommendedActionSessionAsync(this IMariaDBManagementClient operations, string resourceGroupName, string serverName, string advisorName, string databaseName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.BeginCreateRecommendedActionSessionWithHttpMessagesAsync(resourceGroupName, serverName, advisorName, databaseName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/Advisor.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/Advisor.cs new file mode 100644 index 000000000000..44f618429a5a --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/Advisor.cs @@ -0,0 +1,59 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Represents a recommendation action advisor. + /// + public partial class Advisor : ProxyResource + { + /// + /// Initializes a new instance of the Advisor class. + /// + public Advisor() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Advisor class. + /// + /// Fully qualified resource ID for the resource. Ex - + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + /// The name of the resource + /// The type of the resource. E.g. + /// "Microsoft.Compute/virtualMachines" or + /// "Microsoft.Storage/storageAccounts" + /// The properties of a recommendation action + /// advisor. + public Advisor(string id = default(string), string name = default(string), string type = default(string), object properties = default(object)) + : base(id, name, type) + { + Properties = properties; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the properties of a recommendation action advisor. + /// + [JsonProperty(PropertyName = "properties")] + public object Properties { get; set; } + + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/AzureEntityResource.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/AzureEntityResource.cs new file mode 100644 index 000000000000..1b0bc414f05f --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/AzureEntityResource.cs @@ -0,0 +1,62 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Entity Resource + /// + /// + /// The resource model definition for an Azure Resource Manager resource + /// with an etag. + /// + public partial class AzureEntityResource : Resource + { + /// + /// Initializes a new instance of the AzureEntityResource class. + /// + public AzureEntityResource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the AzureEntityResource class. + /// + /// Fully qualified resource ID for the resource. Ex - + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + /// The name of the resource + /// The type of the resource. E.g. + /// "Microsoft.Compute/virtualMachines" or + /// "Microsoft.Storage/storageAccounts" + /// Resource Etag. + public AzureEntityResource(string id = default(string), string name = default(string), string type = default(string), string etag = default(string)) + : base(id, name, type) + { + Etag = etag; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets resource Etag. + /// + [JsonProperty(PropertyName = "etag")] + public string Etag { get; private set; } + + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/Configuration.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/Configuration.cs new file mode 100644 index 000000000000..5eed059c18d7 --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/Configuration.cs @@ -0,0 +1,103 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Represents a Configuration. + /// + [Rest.Serialization.JsonTransformation] + public partial class Configuration : ProxyResource + { + /// + /// Initializes a new instance of the Configuration class. + /// + public Configuration() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Configuration class. + /// + /// Fully qualified resource ID for the resource. Ex - + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + /// The name of the resource + /// The type of the resource. E.g. + /// "Microsoft.Compute/virtualMachines" or + /// "Microsoft.Storage/storageAccounts" + /// Value of the configuration. + /// Description of the configuration. + /// Default value of the + /// configuration. + /// Data type of the configuration. + /// Allowed values of the + /// configuration. + /// Source of the configuration. + public Configuration(string id = default(string), string name = default(string), string type = default(string), string value = default(string), string description = default(string), string defaultValue = default(string), string dataType = default(string), string allowedValues = default(string), string source = default(string)) + : base(id, name, type) + { + Value = value; + Description = description; + DefaultValue = defaultValue; + DataType = dataType; + AllowedValues = allowedValues; + Source = source; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets value of the configuration. + /// + [JsonProperty(PropertyName = "properties.value")] + public string Value { get; set; } + + /// + /// Gets description of the configuration. + /// + [JsonProperty(PropertyName = "properties.description")] + public string Description { get; private set; } + + /// + /// Gets default value of the configuration. + /// + [JsonProperty(PropertyName = "properties.defaultValue")] + public string DefaultValue { get; private set; } + + /// + /// Gets data type of the configuration. + /// + [JsonProperty(PropertyName = "properties.dataType")] + public string DataType { get; private set; } + + /// + /// Gets allowed values of the configuration. + /// + [JsonProperty(PropertyName = "properties.allowedValues")] + public string AllowedValues { get; private set; } + + /// + /// Gets or sets source of the configuration. + /// + [JsonProperty(PropertyName = "properties.source")] + public string Source { get; set; } + + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/ConfigurationListResult.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/ConfigurationListResult.cs new file mode 100644 index 000000000000..2d1c7bf72827 --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/ConfigurationListResult.cs @@ -0,0 +1,53 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// A list of server configurations. + /// + public partial class ConfigurationListResult + { + /// + /// Initializes a new instance of the ConfigurationListResult class. + /// + public ConfigurationListResult() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ConfigurationListResult class. + /// + /// The list of server configurations. + public ConfigurationListResult(IList value = default(IList)) + { + Value = value; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the list of server configurations. + /// + [JsonProperty(PropertyName = "value")] + public IList Value { get; set; } + + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/Database.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/Database.cs new file mode 100644 index 000000000000..828fbfe63b69 --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/Database.cs @@ -0,0 +1,69 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Represents a Database. + /// + [Rest.Serialization.JsonTransformation] + public partial class Database : ProxyResource + { + /// + /// Initializes a new instance of the Database class. + /// + public Database() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Database class. + /// + /// Fully qualified resource ID for the resource. Ex - + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + /// The name of the resource + /// The type of the resource. E.g. + /// "Microsoft.Compute/virtualMachines" or + /// "Microsoft.Storage/storageAccounts" + /// The charset of the database. + /// The collation of the database. + public Database(string id = default(string), string name = default(string), string type = default(string), string charset = default(string), string collation = default(string)) + : base(id, name, type) + { + Charset = charset; + Collation = collation; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the charset of the database. + /// + [JsonProperty(PropertyName = "properties.charset")] + public string Charset { get; set; } + + /// + /// Gets or sets the collation of the database. + /// + [JsonProperty(PropertyName = "properties.collation")] + public string Collation { get; set; } + + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/ErrorAdditionalInfo.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/ErrorAdditionalInfo.cs new file mode 100644 index 000000000000..46c717b137cc --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/ErrorAdditionalInfo.cs @@ -0,0 +1,59 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The resource management error additional info. + /// + public partial class ErrorAdditionalInfo + { + /// + /// Initializes a new instance of the ErrorAdditionalInfo class. + /// + public ErrorAdditionalInfo() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ErrorAdditionalInfo class. + /// + /// The additional info type. + /// The additional info. + public ErrorAdditionalInfo(string type = default(string), object info = default(object)) + { + Type = type; + Info = info; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the additional info type. + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; private set; } + + /// + /// Gets the additional info. + /// + [JsonProperty(PropertyName = "info")] + public object Info { get; private set; } + + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/ErrorResponse.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/ErrorResponse.cs new file mode 100644 index 000000000000..634c87fd0df4 --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/ErrorResponse.cs @@ -0,0 +1,90 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Error Response + /// + /// + /// Common error response for all Azure Resource Manager APIs to return + /// error details for failed operations. (This also follows the OData error + /// response format.) + /// + public partial class ErrorResponse + { + /// + /// Initializes a new instance of the ErrorResponse class. + /// + public ErrorResponse() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ErrorResponse class. + /// + /// The error code. + /// The error message. + /// The error target. + /// The error details. + /// The error additional info. + public ErrorResponse(string code = default(string), string message = default(string), string target = default(string), IList details = default(IList), IList additionalInfo = default(IList)) + { + Code = code; + Message = message; + Target = target; + Details = details; + AdditionalInfo = additionalInfo; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the error code. + /// + [JsonProperty(PropertyName = "code")] + public string Code { get; private set; } + + /// + /// Gets the error message. + /// + [JsonProperty(PropertyName = "message")] + public string Message { get; private set; } + + /// + /// Gets the error target. + /// + [JsonProperty(PropertyName = "target")] + public string Target { get; private set; } + + /// + /// Gets the error details. + /// + [JsonProperty(PropertyName = "details")] + public IList Details { get; private set; } + + /// + /// Gets the error additional info. + /// + [JsonProperty(PropertyName = "additionalInfo")] + public IList AdditionalInfo { get; private set; } + + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/FirewallRule.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/FirewallRule.cs new file mode 100644 index 000000000000..90c041efcd6b --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/FirewallRule.cs @@ -0,0 +1,104 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Represents a server firewall rule. + /// + [Rest.Serialization.JsonTransformation] + public partial class FirewallRule : ProxyResource + { + /// + /// Initializes a new instance of the FirewallRule class. + /// + public FirewallRule() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the FirewallRule class. + /// + /// The start IP address of the server + /// firewall rule. Must be IPv4 format. + /// The end IP address of the server + /// firewall rule. Must be IPv4 format. + /// Fully qualified resource ID for the resource. Ex - + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + /// The name of the resource + /// The type of the resource. E.g. + /// "Microsoft.Compute/virtualMachines" or + /// "Microsoft.Storage/storageAccounts" + public FirewallRule(string startIpAddress, string endIpAddress, string id = default(string), string name = default(string), string type = default(string)) + : base(id, name, type) + { + StartIpAddress = startIpAddress; + EndIpAddress = endIpAddress; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the start IP address of the server firewall rule. Must + /// be IPv4 format. + /// + [JsonProperty(PropertyName = "properties.startIpAddress")] + public string StartIpAddress { get; set; } + + /// + /// Gets or sets the end IP address of the server firewall rule. Must + /// be IPv4 format. + /// + [JsonProperty(PropertyName = "properties.endIpAddress")] + public string EndIpAddress { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (StartIpAddress == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "StartIpAddress"); + } + if (EndIpAddress == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "EndIpAddress"); + } + if (StartIpAddress != null) + { + if (!System.Text.RegularExpressions.Regex.IsMatch(StartIpAddress, "^(([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])$")) + { + throw new ValidationException(ValidationRules.Pattern, "StartIpAddress", "^(([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])$"); + } + } + if (EndIpAddress != null) + { + if (!System.Text.RegularExpressions.Regex.IsMatch(EndIpAddress, "^(([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])$")) + { + throw new ValidationException(ValidationRules.Pattern, "EndIpAddress", "^(([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])$"); + } + } + } + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/GeoRedundantBackup.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/GeoRedundantBackup.cs new file mode 100644 index 000000000000..17bb323d6a49 --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/GeoRedundantBackup.cs @@ -0,0 +1,22 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB.Models +{ + + /// + /// Defines values for GeoRedundantBackup. + /// + public static class GeoRedundantBackup + { + public const string Enabled = "Enabled"; + public const string Disabled = "Disabled"; + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/LogFile.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/LogFile.cs new file mode 100644 index 000000000000..46be8d210e97 --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/LogFile.cs @@ -0,0 +1,95 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Represents a log file. + /// + [Rest.Serialization.JsonTransformation] + public partial class LogFile : ProxyResource + { + /// + /// Initializes a new instance of the LogFile class. + /// + public LogFile() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the LogFile class. + /// + /// Fully qualified resource ID for the resource. Ex - + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + /// The name of the resource + /// The type of the resource. E.g. + /// "Microsoft.Compute/virtualMachines" or + /// "Microsoft.Storage/storageAccounts" + /// Size of the log file. + /// Creation timestamp of the log + /// file. + /// Last modified timestamp of the log + /// file. + /// Type of the log file. + /// The url to download the log file from. + public LogFile(string id = default(string), string name = default(string), string type = default(string), long? sizeInKB = default(long?), System.DateTime? createdTime = default(System.DateTime?), System.DateTime? lastModifiedTime = default(System.DateTime?), string logFileType = default(string), string url = default(string)) + : base(id, name, type) + { + SizeInKB = sizeInKB; + CreatedTime = createdTime; + LastModifiedTime = lastModifiedTime; + LogFileType = logFileType; + Url = url; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets size of the log file. + /// + [JsonProperty(PropertyName = "properties.sizeInKB")] + public long? SizeInKB { get; set; } + + /// + /// Gets creation timestamp of the log file. + /// + [JsonProperty(PropertyName = "properties.createdTime")] + public System.DateTime? CreatedTime { get; private set; } + + /// + /// Gets last modified timestamp of the log file. + /// + [JsonProperty(PropertyName = "properties.lastModifiedTime")] + public System.DateTime? LastModifiedTime { get; private set; } + + /// + /// Gets or sets type of the log file. + /// + [JsonProperty(PropertyName = "properties.type")] + public string LogFileType { get; set; } + + /// + /// Gets the url to download the log file from. + /// + [JsonProperty(PropertyName = "properties.url")] + public string Url { get; private set; } + + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/MinimalTlsVersionEnum.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/MinimalTlsVersionEnum.cs new file mode 100644 index 000000000000..964d580ade79 --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/MinimalTlsVersionEnum.cs @@ -0,0 +1,24 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB.Models +{ + + /// + /// Defines values for MinimalTlsVersionEnum. + /// + public static class MinimalTlsVersionEnum + { + public const string TLS10 = "TLS1_0"; + public const string TLS11 = "TLS1_1"; + public const string TLS12 = "TLS1_2"; + public const string TLSEnforcementDisabled = "TLSEnforcementDisabled"; + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/NameAvailability.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/NameAvailability.cs new file mode 100644 index 000000000000..b76586b8ad32 --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/NameAvailability.cs @@ -0,0 +1,68 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Represents a resource name availability. + /// + public partial class NameAvailability + { + /// + /// Initializes a new instance of the NameAvailability class. + /// + public NameAvailability() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the NameAvailability class. + /// + /// Error Message. + /// Indicates whether the resource name is + /// available. + /// Reason for name being unavailable. + public NameAvailability(string message = default(string), bool? nameAvailable = default(bool?), string reason = default(string)) + { + Message = message; + NameAvailable = nameAvailable; + Reason = reason; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets error Message. + /// + [JsonProperty(PropertyName = "message")] + public string Message { get; set; } + + /// + /// Gets or sets indicates whether the resource name is available. + /// + [JsonProperty(PropertyName = "nameAvailable")] + public bool? NameAvailable { get; set; } + + /// + /// Gets or sets reason for name being unavailable. + /// + [JsonProperty(PropertyName = "reason")] + public string Reason { get; set; } + + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/NameAvailabilityRequest.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/NameAvailabilityRequest.cs new file mode 100644 index 000000000000..2f7afe5ae516 --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/NameAvailabilityRequest.cs @@ -0,0 +1,73 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Request from client to check resource name availability. + /// + public partial class NameAvailabilityRequest + { + /// + /// Initializes a new instance of the NameAvailabilityRequest class. + /// + public NameAvailabilityRequest() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the NameAvailabilityRequest class. + /// + /// Resource name to verify. + /// Resource type used for verification. + public NameAvailabilityRequest(string name, string type = default(string)) + { + Name = name; + Type = type; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets resource name to verify. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Gets or sets resource type used for verification. + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Name == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Name"); + } + } + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/Operation.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/Operation.cs new file mode 100644 index 000000000000..6b75b9d50ecc --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/Operation.cs @@ -0,0 +1,84 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// REST API operation definition. + /// + public partial class Operation + { + /// + /// Initializes a new instance of the Operation class. + /// + public Operation() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Operation class. + /// + /// The name of the operation being performed on + /// this particular object. + /// The localized display information for this + /// particular operation or action. + /// The intended executor of the operation. + /// Possible values include: 'NotSpecified', 'user', 'system' + /// Additional descriptions for the + /// operation. + public Operation(string name = default(string), OperationDisplay display = default(OperationDisplay), string origin = default(string), IDictionary properties = default(IDictionary)) + { + Name = name; + Display = display; + Origin = origin; + Properties = properties; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the name of the operation being performed on this particular + /// object. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; private set; } + + /// + /// Gets the localized display information for this particular + /// operation or action. + /// + [JsonProperty(PropertyName = "display")] + public OperationDisplay Display { get; private set; } + + /// + /// Gets the intended executor of the operation. Possible values + /// include: 'NotSpecified', 'user', 'system' + /// + [JsonProperty(PropertyName = "origin")] + public string Origin { get; private set; } + + /// + /// Gets additional descriptions for the operation. + /// + [JsonProperty(PropertyName = "properties")] + public IDictionary Properties { get; private set; } + + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/OperationDisplay.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/OperationDisplay.cs new file mode 100644 index 000000000000..4e34b583f1fd --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/OperationDisplay.cs @@ -0,0 +1,77 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Display metadata associated with the operation. + /// + public partial class OperationDisplay + { + /// + /// Initializes a new instance of the OperationDisplay class. + /// + public OperationDisplay() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the OperationDisplay class. + /// + /// Operation resource provider name. + /// Resource on which the operation is + /// performed. + /// Localized friendly name for the + /// operation. + /// Operation description. + public OperationDisplay(string provider = default(string), string resource = default(string), string operation = default(string), string description = default(string)) + { + Provider = provider; + Resource = resource; + Operation = operation; + Description = description; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets operation resource provider name. + /// + [JsonProperty(PropertyName = "provider")] + public string Provider { get; private set; } + + /// + /// Gets resource on which the operation is performed. + /// + [JsonProperty(PropertyName = "resource")] + public string Resource { get; private set; } + + /// + /// Gets localized friendly name for the operation. + /// + [JsonProperty(PropertyName = "operation")] + public string Operation { get; private set; } + + /// + /// Gets operation description. + /// + [JsonProperty(PropertyName = "description")] + public string Description { get; private set; } + + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/OperationListResult.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/OperationListResult.cs new file mode 100644 index 000000000000..b9ee208ffbe9 --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/OperationListResult.cs @@ -0,0 +1,54 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// A list of resource provider operations. + /// + public partial class OperationListResult + { + /// + /// Initializes a new instance of the OperationListResult class. + /// + public OperationListResult() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the OperationListResult class. + /// + /// The list of resource provider + /// operations. + public OperationListResult(IList value = default(IList)) + { + Value = value; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the list of resource provider operations. + /// + [JsonProperty(PropertyName = "value")] + public IList Value { get; set; } + + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/OperationOrigin.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/OperationOrigin.cs new file mode 100644 index 000000000000..05488af6325e --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/OperationOrigin.cs @@ -0,0 +1,23 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB.Models +{ + + /// + /// Defines values for OperationOrigin. + /// + public static class OperationOrigin + { + public const string NotSpecified = "NotSpecified"; + public const string User = "user"; + public const string System = "system"; + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/Page.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/Page.cs new file mode 100644 index 000000000000..ac64ee043ee2 --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/Page.cs @@ -0,0 +1,53 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + + /// + /// Defines a page in Azure responses. + /// + /// Type of the page content items + [JsonObject] + public class Page : IPage + { + /// + /// Gets the link to the next page. + /// + [JsonProperty("")] + public string NextPageLink { get; private set; } + + [JsonProperty("value")] + private IList Items{ get; set; } + + /// + /// Returns an enumerator that iterates through the collection. + /// + /// A an enumerator that can be used to iterate through the collection. + public IEnumerator GetEnumerator() + { + return Items == null ? System.Linq.Enumerable.Empty().GetEnumerator() : Items.GetEnumerator(); + } + + /// + /// Returns an enumerator that iterates through the collection. + /// + /// A an enumerator that can be used to iterate through the collection. + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/Page1.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/Page1.cs new file mode 100644 index 000000000000..dd969f6410b5 --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/Page1.cs @@ -0,0 +1,53 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + + /// + /// Defines a page in Azure responses. + /// + /// Type of the page content items + [JsonObject] + public class Page1 : IPage + { + /// + /// Gets the link to the next page. + /// + [JsonProperty("nextLink")] + public string NextPageLink { get; private set; } + + [JsonProperty("value")] + private IList Items{ get; set; } + + /// + /// Returns an enumerator that iterates through the collection. + /// + /// A an enumerator that can be used to iterate through the collection. + public IEnumerator GetEnumerator() + { + return Items == null ? System.Linq.Enumerable.Empty().GetEnumerator() : Items.GetEnumerator(); + } + + /// + /// Returns an enumerator that iterates through the collection. + /// + /// A an enumerator that can be used to iterate through the collection. + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/PerformanceTierProperties.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/PerformanceTierProperties.cs new file mode 100644 index 000000000000..4e2b077a55ff --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/PerformanceTierProperties.cs @@ -0,0 +1,119 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Performance tier properties + /// + public partial class PerformanceTierProperties + { + /// + /// Initializes a new instance of the PerformanceTierProperties class. + /// + public PerformanceTierProperties() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the PerformanceTierProperties class. + /// + /// ID of the performance tier. + /// Maximum Backup retention in + /// days for the performance tier edition + /// Minimum Backup retention in + /// days for the performance tier edition + /// Max storage allowed for a + /// server. + /// Max storage allowed for a + /// server. + /// Max storage allowed for a + /// server. + /// Max storage allowed for a + /// server. + /// Service level objectives + /// associated with the performance tier + public PerformanceTierProperties(string id = default(string), int? maxBackupRetentionDays = default(int?), int? minBackupRetentionDays = default(int?), int? maxStorageMB = default(int?), int? minLargeStorageMB = default(int?), int? maxLargeStorageMB = default(int?), int? minStorageMB = default(int?), IList serviceLevelObjectives = default(IList)) + { + Id = id; + MaxBackupRetentionDays = maxBackupRetentionDays; + MinBackupRetentionDays = minBackupRetentionDays; + MaxStorageMB = maxStorageMB; + MinLargeStorageMB = minLargeStorageMB; + MaxLargeStorageMB = maxLargeStorageMB; + MinStorageMB = minStorageMB; + ServiceLevelObjectives = serviceLevelObjectives; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets ID of the performance tier. + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; set; } + + /// + /// Gets or sets maximum Backup retention in days for the performance + /// tier edition + /// + [JsonProperty(PropertyName = "maxBackupRetentionDays")] + public int? MaxBackupRetentionDays { get; set; } + + /// + /// Gets or sets minimum Backup retention in days for the performance + /// tier edition + /// + [JsonProperty(PropertyName = "minBackupRetentionDays")] + public int? MinBackupRetentionDays { get; set; } + + /// + /// Gets or sets max storage allowed for a server. + /// + [JsonProperty(PropertyName = "maxStorageMB")] + public int? MaxStorageMB { get; set; } + + /// + /// Gets or sets max storage allowed for a server. + /// + [JsonProperty(PropertyName = "minLargeStorageMB")] + public int? MinLargeStorageMB { get; set; } + + /// + /// Gets or sets max storage allowed for a server. + /// + [JsonProperty(PropertyName = "maxLargeStorageMB")] + public int? MaxLargeStorageMB { get; set; } + + /// + /// Gets or sets max storage allowed for a server. + /// + [JsonProperty(PropertyName = "minStorageMB")] + public int? MinStorageMB { get; set; } + + /// + /// Gets or sets service level objectives associated with the + /// performance tier + /// + [JsonProperty(PropertyName = "serviceLevelObjectives")] + public IList ServiceLevelObjectives { get; set; } + + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/PerformanceTierServiceLevelObjectives.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/PerformanceTierServiceLevelObjectives.cs new file mode 100644 index 000000000000..a5bb6c686ebe --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/PerformanceTierServiceLevelObjectives.cs @@ -0,0 +1,118 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Service level objectives for performance tier. + /// + public partial class PerformanceTierServiceLevelObjectives + { + /// + /// Initializes a new instance of the + /// PerformanceTierServiceLevelObjectives class. + /// + public PerformanceTierServiceLevelObjectives() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// PerformanceTierServiceLevelObjectives class. + /// + /// ID for the service level objective. + /// Edition of the performance tier. + /// vCore associated with the service level + /// objective + /// Hardware generation associated + /// with the service level objective + /// Maximum Backup retention in + /// days for the performance tier edition + /// Minimum Backup retention in + /// days for the performance tier edition + /// Max storage allowed for a + /// server. + /// Max storage allowed for a + /// server. + public PerformanceTierServiceLevelObjectives(string id = default(string), string edition = default(string), int? vCore = default(int?), string hardwareGeneration = default(string), int? maxBackupRetentionDays = default(int?), int? minBackupRetentionDays = default(int?), int? maxStorageMB = default(int?), int? minStorageMB = default(int?)) + { + Id = id; + Edition = edition; + VCore = vCore; + HardwareGeneration = hardwareGeneration; + MaxBackupRetentionDays = maxBackupRetentionDays; + MinBackupRetentionDays = minBackupRetentionDays; + MaxStorageMB = maxStorageMB; + MinStorageMB = minStorageMB; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets ID for the service level objective. + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; set; } + + /// + /// Gets or sets edition of the performance tier. + /// + [JsonProperty(PropertyName = "edition")] + public string Edition { get; set; } + + /// + /// Gets or sets vCore associated with the service level objective + /// + [JsonProperty(PropertyName = "vCore")] + public int? VCore { get; set; } + + /// + /// Gets or sets hardware generation associated with the service level + /// objective + /// + [JsonProperty(PropertyName = "hardwareGeneration")] + public string HardwareGeneration { get; set; } + + /// + /// Gets or sets maximum Backup retention in days for the performance + /// tier edition + /// + [JsonProperty(PropertyName = "maxBackupRetentionDays")] + public int? MaxBackupRetentionDays { get; set; } + + /// + /// Gets or sets minimum Backup retention in days for the performance + /// tier edition + /// + [JsonProperty(PropertyName = "minBackupRetentionDays")] + public int? MinBackupRetentionDays { get; set; } + + /// + /// Gets or sets max storage allowed for a server. + /// + [JsonProperty(PropertyName = "maxStorageMB")] + public int? MaxStorageMB { get; set; } + + /// + /// Gets or sets max storage allowed for a server. + /// + [JsonProperty(PropertyName = "minStorageMB")] + public int? MinStorageMB { get; set; } + + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/PrivateEndpointConnection.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/PrivateEndpointConnection.cs new file mode 100644 index 000000000000..8c722e03442a --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/PrivateEndpointConnection.cs @@ -0,0 +1,93 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Linq; + + /// + /// A private endpoint connection + /// + [Rest.Serialization.JsonTransformation] + public partial class PrivateEndpointConnection : ProxyResource + { + /// + /// Initializes a new instance of the PrivateEndpointConnection class. + /// + public PrivateEndpointConnection() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the PrivateEndpointConnection class. + /// + /// Fully qualified resource ID for the resource. Ex - + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + /// The name of the resource + /// The type of the resource. E.g. + /// "Microsoft.Compute/virtualMachines" or + /// "Microsoft.Storage/storageAccounts" + /// Private endpoint which the connection + /// belongs to. + /// Connection state of + /// the private endpoint connection. + /// State of the private endpoint + /// connection. + public PrivateEndpointConnection(string id = default(string), string name = default(string), string type = default(string), PrivateEndpointProperty privateEndpoint = default(PrivateEndpointProperty), PrivateLinkServiceConnectionStateProperty privateLinkServiceConnectionState = default(PrivateLinkServiceConnectionStateProperty), string provisioningState = default(string)) + : base(id, name, type) + { + PrivateEndpoint = privateEndpoint; + PrivateLinkServiceConnectionState = privateLinkServiceConnectionState; + ProvisioningState = provisioningState; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets private endpoint which the connection belongs to. + /// + [JsonProperty(PropertyName = "properties.privateEndpoint")] + public PrivateEndpointProperty PrivateEndpoint { get; set; } + + /// + /// Gets or sets connection state of the private endpoint connection. + /// + [JsonProperty(PropertyName = "properties.privateLinkServiceConnectionState")] + public PrivateLinkServiceConnectionStateProperty PrivateLinkServiceConnectionState { get; set; } + + /// + /// Gets state of the private endpoint connection. + /// + [JsonProperty(PropertyName = "properties.provisioningState")] + public string ProvisioningState { get; private set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (PrivateLinkServiceConnectionState != null) + { + PrivateLinkServiceConnectionState.Validate(); + } + } + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/PrivateEndpointProperty.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/PrivateEndpointProperty.cs new file mode 100644 index 000000000000..4309c3cb12c5 --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/PrivateEndpointProperty.cs @@ -0,0 +1,50 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Newtonsoft.Json; + using System.Linq; + + public partial class PrivateEndpointProperty : IResource + { + /// + /// Initializes a new instance of the PrivateEndpointProperty class. + /// + public PrivateEndpointProperty() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the PrivateEndpointProperty class. + /// + /// Resource id of the private endpoint. + public PrivateEndpointProperty(string id = default(string)) + { + Id = id; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets resource id of the private endpoint. + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; set; } + + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/PrivateEndpointProvisioningState.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/PrivateEndpointProvisioningState.cs new file mode 100644 index 000000000000..25cbdc7289fa --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/PrivateEndpointProvisioningState.cs @@ -0,0 +1,25 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB.Models +{ + + /// + /// Defines values for PrivateEndpointProvisioningState. + /// + public static class PrivateEndpointProvisioningState + { + public const string Approving = "Approving"; + public const string Ready = "Ready"; + public const string Dropping = "Dropping"; + public const string Failed = "Failed"; + public const string Rejecting = "Rejecting"; + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/PrivateLinkResource.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/PrivateLinkResource.cs new file mode 100644 index 000000000000..886035371c4c --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/PrivateLinkResource.cs @@ -0,0 +1,59 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// A private link resource + /// + public partial class PrivateLinkResource : ProxyResource + { + /// + /// Initializes a new instance of the PrivateLinkResource class. + /// + public PrivateLinkResource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the PrivateLinkResource class. + /// + /// Fully qualified resource ID for the resource. Ex - + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + /// The name of the resource + /// The type of the resource. E.g. + /// "Microsoft.Compute/virtualMachines" or + /// "Microsoft.Storage/storageAccounts" + /// The private link resource group + /// id. + public PrivateLinkResource(string id = default(string), string name = default(string), string type = default(string), PrivateLinkResourceProperties properties = default(PrivateLinkResourceProperties)) + : base(id, name, type) + { + Properties = properties; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the private link resource group id. + /// + [JsonProperty(PropertyName = "properties")] + public PrivateLinkResourceProperties Properties { get; private set; } + + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/PrivateLinkResourceProperties.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/PrivateLinkResourceProperties.cs new file mode 100644 index 000000000000..10cbb4fe66b2 --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/PrivateLinkResourceProperties.cs @@ -0,0 +1,64 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Properties of a private link resource. + /// + public partial class PrivateLinkResourceProperties + { + /// + /// Initializes a new instance of the PrivateLinkResourceProperties + /// class. + /// + public PrivateLinkResourceProperties() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the PrivateLinkResourceProperties + /// class. + /// + /// The private link resource group id. + /// The private link resource required + /// member names. + public PrivateLinkResourceProperties(string groupId = default(string), IList requiredMembers = default(IList)) + { + GroupId = groupId; + RequiredMembers = requiredMembers; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the private link resource group id. + /// + [JsonProperty(PropertyName = "groupId")] + public string GroupId { get; private set; } + + /// + /// Gets the private link resource required member names. + /// + [JsonProperty(PropertyName = "requiredMembers")] + public IList RequiredMembers { get; private set; } + + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/PrivateLinkServiceConnectionStateActionsRequire.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/PrivateLinkServiceConnectionStateActionsRequire.cs new file mode 100644 index 000000000000..1f19264b19dc --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/PrivateLinkServiceConnectionStateActionsRequire.cs @@ -0,0 +1,21 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB.Models +{ + + /// + /// Defines values for PrivateLinkServiceConnectionStateActionsRequire. + /// + public static class PrivateLinkServiceConnectionStateActionsRequire + { + public const string None = "None"; + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/PrivateLinkServiceConnectionStateProperty.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/PrivateLinkServiceConnectionStateProperty.cs new file mode 100644 index 000000000000..69fb20969e4a --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/PrivateLinkServiceConnectionStateProperty.cs @@ -0,0 +1,87 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + public partial class PrivateLinkServiceConnectionStateProperty + { + /// + /// Initializes a new instance of the + /// PrivateLinkServiceConnectionStateProperty class. + /// + public PrivateLinkServiceConnectionStateProperty() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// PrivateLinkServiceConnectionStateProperty class. + /// + /// The private link service connection + /// status. + /// The private link service connection + /// description. + /// The actions required for private link + /// service connection. + public PrivateLinkServiceConnectionStateProperty(string status, string description, string actionsRequired = default(string)) + { + Status = status; + Description = description; + ActionsRequired = actionsRequired; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the private link service connection status. + /// + [JsonProperty(PropertyName = "status")] + public string Status { get; set; } + + /// + /// Gets or sets the private link service connection description. + /// + [JsonProperty(PropertyName = "description")] + public string Description { get; set; } + + /// + /// Gets the actions required for private link service connection. + /// + [JsonProperty(PropertyName = "actionsRequired")] + public string ActionsRequired { get; private set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Status == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Status"); + } + if (Description == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Description"); + } + } + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/PrivateLinkServiceConnectionStateStatus.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/PrivateLinkServiceConnectionStateStatus.cs new file mode 100644 index 000000000000..8071e0a1577d --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/PrivateLinkServiceConnectionStateStatus.cs @@ -0,0 +1,24 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB.Models +{ + + /// + /// Defines values for PrivateLinkServiceConnectionStateStatus. + /// + public static class PrivateLinkServiceConnectionStateStatus + { + public const string Approved = "Approved"; + public const string Pending = "Pending"; + public const string Rejected = "Rejected"; + public const string Disconnected = "Disconnected"; + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/ProxyResource.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/ProxyResource.cs new file mode 100644 index 000000000000..ddad86b2e104 --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/ProxyResource.cs @@ -0,0 +1,53 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB.Models +{ + using System.Linq; + + /// + /// Proxy Resource + /// + /// + /// The resource model definition for a Azure Resource Manager proxy + /// resource. It will not have tags and a location + /// + public partial class ProxyResource : Resource + { + /// + /// Initializes a new instance of the ProxyResource class. + /// + public ProxyResource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ProxyResource class. + /// + /// Fully qualified resource ID for the resource. Ex - + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + /// The name of the resource + /// The type of the resource. E.g. + /// "Microsoft.Compute/virtualMachines" or + /// "Microsoft.Storage/storageAccounts" + public ProxyResource(string id = default(string), string name = default(string), string type = default(string)) + : base(id, name, type) + { + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/PublicNetworkAccessEnum.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/PublicNetworkAccessEnum.cs new file mode 100644 index 000000000000..02f3556c1e50 --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/PublicNetworkAccessEnum.cs @@ -0,0 +1,22 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB.Models +{ + + /// + /// Defines values for PublicNetworkAccessEnum. + /// + public static class PublicNetworkAccessEnum + { + public const string Enabled = "Enabled"; + public const string Disabled = "Disabled"; + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/QueryPerformanceInsightResetDataResult.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/QueryPerformanceInsightResetDataResult.cs new file mode 100644 index 000000000000..b03a3f54338b --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/QueryPerformanceInsightResetDataResult.cs @@ -0,0 +1,63 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Result of Query Performance Insight data reset. + /// + public partial class QueryPerformanceInsightResetDataResult + { + /// + /// Initializes a new instance of the + /// QueryPerformanceInsightResetDataResult class. + /// + public QueryPerformanceInsightResetDataResult() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// QueryPerformanceInsightResetDataResult class. + /// + /// Indicates result of the operation. Possible + /// values include: 'Succeeded', 'Failed' + /// operation message. + public QueryPerformanceInsightResetDataResult(string status = default(string), string message = default(string)) + { + Status = status; + Message = message; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets indicates result of the operation. Possible values + /// include: 'Succeeded', 'Failed' + /// + [JsonProperty(PropertyName = "status")] + public string Status { get; set; } + + /// + /// Gets or sets operation message. + /// + [JsonProperty(PropertyName = "message")] + public string Message { get; set; } + + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/QueryPerformanceInsightResetDataResultState.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/QueryPerformanceInsightResetDataResultState.cs new file mode 100644 index 000000000000..c882ce843b5e --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/QueryPerformanceInsightResetDataResultState.cs @@ -0,0 +1,22 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB.Models +{ + + /// + /// Defines values for QueryPerformanceInsightResetDataResultState. + /// + public static class QueryPerformanceInsightResetDataResultState + { + public const string Succeeded = "Succeeded"; + public const string Failed = "Failed"; + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/QueryStatistic.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/QueryStatistic.cs new file mode 100644 index 000000000000..938680ad239f --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/QueryStatistic.cs @@ -0,0 +1,137 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Represents a Query Statistic. + /// + [Rest.Serialization.JsonTransformation] + public partial class QueryStatistic : ProxyResource + { + /// + /// Initializes a new instance of the QueryStatistic class. + /// + public QueryStatistic() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the QueryStatistic class. + /// + /// Fully qualified resource ID for the resource. Ex - + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + /// The name of the resource + /// The type of the resource. E.g. + /// "Microsoft.Compute/virtualMachines" or + /// "Microsoft.Storage/storageAccounts" + /// Database query identifier. + /// Observation start time. + /// Observation end time. + /// Aggregation function + /// name. + /// The list of database names. + /// Number of query executions in + /// this time interval. + /// Metric name. + /// Metric display name. + /// Metric value. + /// Metric value unit. + public QueryStatistic(string id = default(string), string name = default(string), string type = default(string), string queryId = default(string), System.DateTime? startTime = default(System.DateTime?), System.DateTime? endTime = default(System.DateTime?), string aggregationFunction = default(string), IList databaseNames = default(IList), long? queryExecutionCount = default(long?), string metricName = default(string), string metricDisplayName = default(string), double? metricValue = default(double?), string metricValueUnit = default(string)) + : base(id, name, type) + { + QueryId = queryId; + StartTime = startTime; + EndTime = endTime; + AggregationFunction = aggregationFunction; + DatabaseNames = databaseNames; + QueryExecutionCount = queryExecutionCount; + MetricName = metricName; + MetricDisplayName = metricDisplayName; + MetricValue = metricValue; + MetricValueUnit = metricValueUnit; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets database query identifier. + /// + [JsonProperty(PropertyName = "properties.queryId")] + public string QueryId { get; set; } + + /// + /// Gets or sets observation start time. + /// + [JsonProperty(PropertyName = "properties.startTime")] + public System.DateTime? StartTime { get; set; } + + /// + /// Gets or sets observation end time. + /// + [JsonProperty(PropertyName = "properties.endTime")] + public System.DateTime? EndTime { get; set; } + + /// + /// Gets or sets aggregation function name. + /// + [JsonProperty(PropertyName = "properties.aggregationFunction")] + public string AggregationFunction { get; set; } + + /// + /// Gets or sets the list of database names. + /// + [JsonProperty(PropertyName = "properties.databaseNames")] + public IList DatabaseNames { get; set; } + + /// + /// Gets or sets number of query executions in this time interval. + /// + [JsonProperty(PropertyName = "properties.queryExecutionCount")] + public long? QueryExecutionCount { get; set; } + + /// + /// Gets or sets metric name. + /// + [JsonProperty(PropertyName = "properties.metricName")] + public string MetricName { get; set; } + + /// + /// Gets or sets metric display name. + /// + [JsonProperty(PropertyName = "properties.metricDisplayName")] + public string MetricDisplayName { get; set; } + + /// + /// Gets or sets metric value. + /// + [JsonProperty(PropertyName = "properties.metricValue")] + public double? MetricValue { get; set; } + + /// + /// Gets or sets metric value unit. + /// + [JsonProperty(PropertyName = "properties.metricValueUnit")] + public string MetricValueUnit { get; set; } + + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/QueryText.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/QueryText.cs new file mode 100644 index 000000000000..32e6da30982c --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/QueryText.cs @@ -0,0 +1,70 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Represents a Query Text. + /// + [Rest.Serialization.JsonTransformation] + public partial class QueryText : ProxyResource + { + /// + /// Initializes a new instance of the QueryText class. + /// + public QueryText() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the QueryText class. + /// + /// Fully qualified resource ID for the resource. Ex - + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + /// The name of the resource + /// The type of the resource. E.g. + /// "Microsoft.Compute/virtualMachines" or + /// "Microsoft.Storage/storageAccounts" + /// Query identifier unique to the + /// server. + /// Query text. + public QueryText(string id = default(string), string name = default(string), string type = default(string), string queryId = default(string), string queryTextProperty = default(string)) + : base(id, name, type) + { + QueryId = queryId; + QueryTextProperty = queryTextProperty; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets query identifier unique to the server. + /// + [JsonProperty(PropertyName = "properties.queryId")] + public string QueryId { get; set; } + + /// + /// Gets or sets query text. + /// + [JsonProperty(PropertyName = "properties.queryText")] + public string QueryTextProperty { get; set; } + + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/RecommendationAction.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/RecommendationAction.cs new file mode 100644 index 000000000000..be38678b7ef4 --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/RecommendationAction.cs @@ -0,0 +1,123 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Represents a Recommendation Action. + /// + [Rest.Serialization.JsonTransformation] + public partial class RecommendationAction : ProxyResource + { + /// + /// Initializes a new instance of the RecommendationAction class. + /// + public RecommendationAction() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the RecommendationAction class. + /// + /// Fully qualified resource ID for the resource. Ex - + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + /// The name of the resource + /// The type of the resource. E.g. + /// "Microsoft.Compute/virtualMachines" or + /// "Microsoft.Storage/storageAccounts" + /// Advisor name. + /// Recommendation action session + /// identifier. + /// Recommendation action identifier. + /// Recommendation action creation + /// time. + /// Recommendation action expiration + /// time. + /// Recommendation action reason. + /// Recommendation action + /// type. + /// Recommendation action details. + public RecommendationAction(string id = default(string), string name = default(string), string type = default(string), string advisorName = default(string), string sessionId = default(string), int? actionId = default(int?), System.DateTime? createdTime = default(System.DateTime?), System.DateTime? expirationTime = default(System.DateTime?), string reason = default(string), string recommendationType = default(string), IDictionary details = default(IDictionary)) + : base(id, name, type) + { + AdvisorName = advisorName; + SessionId = sessionId; + ActionId = actionId; + CreatedTime = createdTime; + ExpirationTime = expirationTime; + Reason = reason; + RecommendationType = recommendationType; + Details = details; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets advisor name. + /// + [JsonProperty(PropertyName = "properties.advisorName")] + public string AdvisorName { get; set; } + + /// + /// Gets or sets recommendation action session identifier. + /// + [JsonProperty(PropertyName = "properties.sessionId")] + public string SessionId { get; set; } + + /// + /// Gets or sets recommendation action identifier. + /// + [JsonProperty(PropertyName = "properties.actionId")] + public int? ActionId { get; set; } + + /// + /// Gets or sets recommendation action creation time. + /// + [JsonProperty(PropertyName = "properties.createdTime")] + public System.DateTime? CreatedTime { get; set; } + + /// + /// Gets or sets recommendation action expiration time. + /// + [JsonProperty(PropertyName = "properties.expirationTime")] + public System.DateTime? ExpirationTime { get; set; } + + /// + /// Gets or sets recommendation action reason. + /// + [JsonProperty(PropertyName = "properties.reason")] + public string Reason { get; set; } + + /// + /// Gets or sets recommendation action type. + /// + [JsonProperty(PropertyName = "properties.recommendationType")] + public string RecommendationType { get; set; } + + /// + /// Gets or sets recommendation action details. + /// + [JsonProperty(PropertyName = "properties.details")] + public IDictionary Details { get; set; } + + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/RecommendedActionSessionsOperationStatus.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/RecommendedActionSessionsOperationStatus.cs new file mode 100644 index 000000000000..059e2c69952e --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/RecommendedActionSessionsOperationStatus.cs @@ -0,0 +1,69 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Recommendation action session operation status. + /// + public partial class RecommendedActionSessionsOperationStatus + { + /// + /// Initializes a new instance of the + /// RecommendedActionSessionsOperationStatus class. + /// + public RecommendedActionSessionsOperationStatus() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// RecommendedActionSessionsOperationStatus class. + /// + /// Operation identifier. + /// Operation start time. + /// Operation status. + public RecommendedActionSessionsOperationStatus(string name = default(string), System.DateTime? startTime = default(System.DateTime?), string status = default(string)) + { + Name = name; + StartTime = startTime; + Status = status; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets operation identifier. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Gets or sets operation start time. + /// + [JsonProperty(PropertyName = "startTime")] + public System.DateTime? StartTime { get; set; } + + /// + /// Gets or sets operation status. + /// + [JsonProperty(PropertyName = "status")] + public string Status { get; set; } + + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/RecoverableServerResource.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/RecoverableServerResource.cs new file mode 100644 index 000000000000..d0dd1c1dcf49 --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/RecoverableServerResource.cs @@ -0,0 +1,106 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Linq; + + /// + /// A recoverable server resource. + /// + [Rest.Serialization.JsonTransformation] + public partial class RecoverableServerResource : ProxyResource + { + /// + /// Initializes a new instance of the RecoverableServerResource class. + /// + public RecoverableServerResource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the RecoverableServerResource class. + /// + /// Fully qualified resource ID for the resource. Ex - + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + /// The name of the resource + /// The type of the resource. E.g. + /// "Microsoft.Compute/virtualMachines" or + /// "Microsoft.Storage/storageAccounts" + /// The last available backup + /// date time. + /// The service level + /// objective + /// Edition of the performance tier. + /// vCore associated with the service level + /// objective + /// Hardware generation associated + /// with the service level objective + /// The MariaDB version + public RecoverableServerResource(string id = default(string), string name = default(string), string type = default(string), string lastAvailableBackupDateTime = default(string), string serviceLevelObjective = default(string), string edition = default(string), int? vCore = default(int?), string hardwareGeneration = default(string), string version = default(string)) + : base(id, name, type) + { + LastAvailableBackupDateTime = lastAvailableBackupDateTime; + ServiceLevelObjective = serviceLevelObjective; + Edition = edition; + VCore = vCore; + HardwareGeneration = hardwareGeneration; + Version = version; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the last available backup date time. + /// + [JsonProperty(PropertyName = "properties.lastAvailableBackupDateTime")] + public string LastAvailableBackupDateTime { get; private set; } + + /// + /// Gets the service level objective + /// + [JsonProperty(PropertyName = "properties.serviceLevelObjective")] + public string ServiceLevelObjective { get; private set; } + + /// + /// Gets edition of the performance tier. + /// + [JsonProperty(PropertyName = "properties.edition")] + public string Edition { get; private set; } + + /// + /// Gets vCore associated with the service level objective + /// + [JsonProperty(PropertyName = "properties.vCore")] + public int? VCore { get; private set; } + + /// + /// Gets hardware generation associated with the service level + /// objective + /// + [JsonProperty(PropertyName = "properties.hardwareGeneration")] + public string HardwareGeneration { get; private set; } + + /// + /// Gets the MariaDB version + /// + [JsonProperty(PropertyName = "properties.version")] + public string Version { get; private set; } + + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/Resource.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/Resource.cs new file mode 100644 index 000000000000..b877f202a12a --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/Resource.cs @@ -0,0 +1,79 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Resource + /// + /// + /// Common fields that are returned in the response for all Azure Resource + /// Manager resources + /// + public partial class Resource : IResource + { + /// + /// Initializes a new instance of the Resource class. + /// + public Resource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Resource class. + /// + /// Fully qualified resource ID for the resource. Ex - + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + /// The name of the resource + /// The type of the resource. E.g. + /// "Microsoft.Compute/virtualMachines" or + /// "Microsoft.Storage/storageAccounts" + public Resource(string id = default(string), string name = default(string), string type = default(string)) + { + Id = id; + Name = name; + Type = type; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets fully qualified resource ID for the resource. Ex - + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; private set; } + + /// + /// Gets the name of the resource + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; private set; } + + /// + /// Gets the type of the resource. E.g. + /// "Microsoft.Compute/virtualMachines" or + /// "Microsoft.Storage/storageAccounts" + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; private set; } + + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/Server.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/Server.cs new file mode 100644 index 000000000000..c539119753b0 --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/Server.cs @@ -0,0 +1,226 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Represents a server. + /// + [Rest.Serialization.JsonTransformation] + public partial class Server : TrackedResource + { + /// + /// Initializes a new instance of the Server class. + /// + public Server() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Server class. + /// + /// The geo-location where the resource + /// lives + /// Fully qualified resource ID for the resource. Ex - + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + /// The name of the resource + /// The type of the resource. E.g. + /// "Microsoft.Compute/virtualMachines" or + /// "Microsoft.Storage/storageAccounts" + /// Resource tags. + /// The SKU (pricing tier) of the server. + /// The administrator's login name of + /// a server. Can only be specified when the server is being created + /// (and is required for creation). + /// Server version. Possible values include: + /// '10.2', '10.3' + /// Enable ssl enforcement or not when + /// connect to server. Possible values include: 'Enabled', + /// 'Disabled' + /// Enforce a minimal Tls version for + /// the server. Possible values include: 'TLS1_0', 'TLS1_1', 'TLS1_2', + /// 'TLSEnforcementDisabled' + /// A state of a server that is visible + /// to user. Possible values include: 'Ready', 'Dropping', + /// 'Disabled' + /// The fully qualified domain + /// name of a server. + /// Earliest restore point creation + /// time (ISO8601 format) + /// Storage profile of a server. + /// The replication role of the + /// server. + /// The master server id of a replica + /// server. + /// The maximum number of replicas that a + /// master server can have. + /// Whether or not public network + /// access is allowed for this server. Value is optional but if passed + /// in, must be 'Enabled' or 'Disabled'. Possible values include: + /// 'Enabled', 'Disabled' + /// List of private endpoint + /// connections on a server + public Server(string location, string id = default(string), string name = default(string), string type = default(string), IDictionary tags = default(IDictionary), Sku sku = default(Sku), string administratorLogin = default(string), string version = default(string), SslEnforcementEnum? sslEnforcement = default(SslEnforcementEnum?), string minimalTlsVersion = default(string), string userVisibleState = default(string), string fullyQualifiedDomainName = default(string), System.DateTime? earliestRestoreDate = default(System.DateTime?), StorageProfile storageProfile = default(StorageProfile), string replicationRole = default(string), string masterServerId = default(string), int? replicaCapacity = default(int?), string publicNetworkAccess = default(string), IList privateEndpointConnections = default(IList)) + : base(location, id, name, type, tags) + { + Sku = sku; + AdministratorLogin = administratorLogin; + Version = version; + SslEnforcement = sslEnforcement; + MinimalTlsVersion = minimalTlsVersion; + UserVisibleState = userVisibleState; + FullyQualifiedDomainName = fullyQualifiedDomainName; + EarliestRestoreDate = earliestRestoreDate; + StorageProfile = storageProfile; + ReplicationRole = replicationRole; + MasterServerId = masterServerId; + ReplicaCapacity = replicaCapacity; + PublicNetworkAccess = publicNetworkAccess; + PrivateEndpointConnections = privateEndpointConnections; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the SKU (pricing tier) of the server. + /// + [JsonProperty(PropertyName = "sku")] + public Sku Sku { get; set; } + + /// + /// Gets or sets the administrator's login name of a server. Can only + /// be specified when the server is being created (and is required for + /// creation). + /// + [JsonProperty(PropertyName = "properties.administratorLogin")] + public string AdministratorLogin { get; set; } + + /// + /// Gets or sets server version. Possible values include: '10.2', + /// '10.3' + /// + [JsonProperty(PropertyName = "properties.version")] + public string Version { get; set; } + + /// + /// Gets or sets enable ssl enforcement or not when connect to server. + /// Possible values include: 'Enabled', 'Disabled' + /// + [JsonProperty(PropertyName = "properties.sslEnforcement")] + public SslEnforcementEnum? SslEnforcement { get; set; } + + /// + /// Gets or sets enforce a minimal Tls version for the server. Possible + /// values include: 'TLS1_0', 'TLS1_1', 'TLS1_2', + /// 'TLSEnforcementDisabled' + /// + [JsonProperty(PropertyName = "properties.minimalTlsVersion")] + public string MinimalTlsVersion { get; set; } + + /// + /// Gets or sets a state of a server that is visible to user. Possible + /// values include: 'Ready', 'Dropping', 'Disabled' + /// + [JsonProperty(PropertyName = "properties.userVisibleState")] + public string UserVisibleState { get; set; } + + /// + /// Gets or sets the fully qualified domain name of a server. + /// + [JsonProperty(PropertyName = "properties.fullyQualifiedDomainName")] + public string FullyQualifiedDomainName { get; set; } + + /// + /// Gets or sets earliest restore point creation time (ISO8601 format) + /// + [JsonProperty(PropertyName = "properties.earliestRestoreDate")] + public System.DateTime? EarliestRestoreDate { get; set; } + + /// + /// Gets or sets storage profile of a server. + /// + [JsonProperty(PropertyName = "properties.storageProfile")] + public StorageProfile StorageProfile { get; set; } + + /// + /// Gets or sets the replication role of the server. + /// + [JsonProperty(PropertyName = "properties.replicationRole")] + public string ReplicationRole { get; set; } + + /// + /// Gets or sets the master server id of a replica server. + /// + [JsonProperty(PropertyName = "properties.masterServerId")] + public string MasterServerId { get; set; } + + /// + /// Gets or sets the maximum number of replicas that a master server + /// can have. + /// + [JsonProperty(PropertyName = "properties.replicaCapacity")] + public int? ReplicaCapacity { get; set; } + + /// + /// Gets or sets whether or not public network access is allowed for + /// this server. Value is optional but if passed in, must be 'Enabled' + /// or 'Disabled'. Possible values include: 'Enabled', 'Disabled' + /// + [JsonProperty(PropertyName = "properties.publicNetworkAccess")] + public string PublicNetworkAccess { get; set; } + + /// + /// Gets list of private endpoint connections on a server + /// + [JsonProperty(PropertyName = "properties.privateEndpointConnections")] + public IList PrivateEndpointConnections { get; private set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public override void Validate() + { + base.Validate(); + if (Sku != null) + { + Sku.Validate(); + } + if (ReplicaCapacity < 0) + { + throw new ValidationException(ValidationRules.InclusiveMinimum, "ReplicaCapacity", 0); + } + if (PrivateEndpointConnections != null) + { + foreach (var element in PrivateEndpointConnections) + { + if (element != null) + { + element.Validate(); + } + } + } + } + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/ServerForCreate.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/ServerForCreate.cs new file mode 100644 index 000000000000..c07f30f1300c --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/ServerForCreate.cs @@ -0,0 +1,102 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Represents a server to be created. + /// + public partial class ServerForCreate + { + /// + /// Initializes a new instance of the ServerForCreate class. + /// + public ServerForCreate() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ServerForCreate class. + /// + /// Properties of the server. + /// The location the resource resides + /// in. + /// The SKU (pricing tier) of the server. + /// Application-specific metadata in the form of + /// key-value pairs. + public ServerForCreate(ServerPropertiesForCreate properties, string location, Sku sku = default(Sku), IDictionary tags = default(IDictionary)) + { + Sku = sku; + Properties = properties; + Location = location; + Tags = tags; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the SKU (pricing tier) of the server. + /// + [JsonProperty(PropertyName = "sku")] + public Sku Sku { get; set; } + + /// + /// Gets or sets properties of the server. + /// + [JsonProperty(PropertyName = "properties")] + public ServerPropertiesForCreate Properties { get; set; } + + /// + /// Gets or sets the location the resource resides in. + /// + [JsonProperty(PropertyName = "location")] + public string Location { get; set; } + + /// + /// Gets or sets application-specific metadata in the form of key-value + /// pairs. + /// + [JsonProperty(PropertyName = "tags")] + public IDictionary Tags { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Properties == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Properties"); + } + if (Location == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Location"); + } + if (Sku != null) + { + Sku.Validate(); + } + } + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/ServerPrivateEndpointConnection.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/ServerPrivateEndpointConnection.cs new file mode 100644 index 000000000000..17176522e356 --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/ServerPrivateEndpointConnection.cs @@ -0,0 +1,76 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// A private endpoint connection under a server + /// + public partial class ServerPrivateEndpointConnection + { + /// + /// Initializes a new instance of the ServerPrivateEndpointConnection + /// class. + /// + public ServerPrivateEndpointConnection() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ServerPrivateEndpointConnection + /// class. + /// + /// Resource Id of the private endpoint + /// connection. + /// Private endpoint connection + /// properties + public ServerPrivateEndpointConnection(string id = default(string), ServerPrivateEndpointConnectionProperties properties = default(ServerPrivateEndpointConnectionProperties)) + { + Id = id; + Properties = properties; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets resource Id of the private endpoint connection. + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; private set; } + + /// + /// Gets private endpoint connection properties + /// + [JsonProperty(PropertyName = "properties")] + public ServerPrivateEndpointConnectionProperties Properties { get; private set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Properties != null) + { + Properties.Validate(); + } + } + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/ServerPrivateEndpointConnectionProperties.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/ServerPrivateEndpointConnectionProperties.cs new file mode 100644 index 000000000000..6c075be44181 --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/ServerPrivateEndpointConnectionProperties.cs @@ -0,0 +1,87 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Properties of a private endpoint connection. + /// + public partial class ServerPrivateEndpointConnectionProperties + { + /// + /// Initializes a new instance of the + /// ServerPrivateEndpointConnectionProperties class. + /// + public ServerPrivateEndpointConnectionProperties() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// ServerPrivateEndpointConnectionProperties class. + /// + /// Private endpoint which the connection + /// belongs to. + /// Connection state of + /// the private endpoint connection. + /// State of the private endpoint + /// connection. Possible values include: 'Approving', 'Ready', + /// 'Dropping', 'Failed', 'Rejecting' + public ServerPrivateEndpointConnectionProperties(PrivateEndpointProperty privateEndpoint = default(PrivateEndpointProperty), ServerPrivateLinkServiceConnectionStateProperty privateLinkServiceConnectionState = default(ServerPrivateLinkServiceConnectionStateProperty), string provisioningState = default(string)) + { + PrivateEndpoint = privateEndpoint; + PrivateLinkServiceConnectionState = privateLinkServiceConnectionState; + ProvisioningState = provisioningState; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets private endpoint which the connection belongs to. + /// + [JsonProperty(PropertyName = "privateEndpoint")] + public PrivateEndpointProperty PrivateEndpoint { get; set; } + + /// + /// Gets or sets connection state of the private endpoint connection. + /// + [JsonProperty(PropertyName = "privateLinkServiceConnectionState")] + public ServerPrivateLinkServiceConnectionStateProperty PrivateLinkServiceConnectionState { get; set; } + + /// + /// Gets state of the private endpoint connection. Possible values + /// include: 'Approving', 'Ready', 'Dropping', 'Failed', 'Rejecting' + /// + [JsonProperty(PropertyName = "provisioningState")] + public string ProvisioningState { get; private set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (PrivateLinkServiceConnectionState != null) + { + PrivateLinkServiceConnectionState.Validate(); + } + } + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/ServerPrivateLinkServiceConnectionStateProperty.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/ServerPrivateLinkServiceConnectionStateProperty.cs new file mode 100644 index 000000000000..e9e02a11e31d --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/ServerPrivateLinkServiceConnectionStateProperty.cs @@ -0,0 +1,90 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + public partial class ServerPrivateLinkServiceConnectionStateProperty + { + /// + /// Initializes a new instance of the + /// ServerPrivateLinkServiceConnectionStateProperty class. + /// + public ServerPrivateLinkServiceConnectionStateProperty() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// ServerPrivateLinkServiceConnectionStateProperty class. + /// + /// The private link service connection status. + /// Possible values include: 'Approved', 'Pending', 'Rejected', + /// 'Disconnected' + /// The private link service connection + /// description. + /// The actions required for private link + /// service connection. Possible values include: 'None' + public ServerPrivateLinkServiceConnectionStateProperty(string status, string description, string actionsRequired = default(string)) + { + Status = status; + Description = description; + ActionsRequired = actionsRequired; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the private link service connection status. Possible + /// values include: 'Approved', 'Pending', 'Rejected', 'Disconnected' + /// + [JsonProperty(PropertyName = "status")] + public string Status { get; set; } + + /// + /// Gets or sets the private link service connection description. + /// + [JsonProperty(PropertyName = "description")] + public string Description { get; set; } + + /// + /// Gets the actions required for private link service connection. + /// Possible values include: 'None' + /// + [JsonProperty(PropertyName = "actionsRequired")] + public string ActionsRequired { get; private set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Status == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Status"); + } + if (Description == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Description"); + } + } + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/ServerPropertiesForCreate.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/ServerPropertiesForCreate.cs new file mode 100644 index 000000000000..c5bedcf45455 --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/ServerPropertiesForCreate.cs @@ -0,0 +1,97 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The properties used to create a new server. + /// + public partial class ServerPropertiesForCreate + { + /// + /// Initializes a new instance of the ServerPropertiesForCreate class. + /// + public ServerPropertiesForCreate() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ServerPropertiesForCreate class. + /// + /// Server version. Possible values include: + /// '10.2', '10.3' + /// Enable ssl enforcement or not when + /// connect to server. Possible values include: 'Enabled', + /// 'Disabled' + /// Enforce a minimal Tls version for + /// the server. Possible values include: 'TLS1_0', 'TLS1_1', 'TLS1_2', + /// 'TLSEnforcementDisabled' + /// Whether or not public network + /// access is allowed for this server. Value is optional but if passed + /// in, must be 'Enabled' or 'Disabled'. Possible values include: + /// 'Enabled', 'Disabled' + /// Storage profile of a server. + public ServerPropertiesForCreate(string version = default(string), SslEnforcementEnum? sslEnforcement = default(SslEnforcementEnum?), string minimalTlsVersion = default(string), string publicNetworkAccess = default(string), StorageProfile storageProfile = default(StorageProfile)) + { + Version = version; + SslEnforcement = sslEnforcement; + MinimalTlsVersion = minimalTlsVersion; + PublicNetworkAccess = publicNetworkAccess; + StorageProfile = storageProfile; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets server version. Possible values include: '10.2', + /// '10.3' + /// + [JsonProperty(PropertyName = "version")] + public string Version { get; set; } + + /// + /// Gets or sets enable ssl enforcement or not when connect to server. + /// Possible values include: 'Enabled', 'Disabled' + /// + [JsonProperty(PropertyName = "sslEnforcement")] + public SslEnforcementEnum? SslEnforcement { get; set; } + + /// + /// Gets or sets enforce a minimal Tls version for the server. Possible + /// values include: 'TLS1_0', 'TLS1_1', 'TLS1_2', + /// 'TLSEnforcementDisabled' + /// + [JsonProperty(PropertyName = "minimalTlsVersion")] + public string MinimalTlsVersion { get; set; } + + /// + /// Gets or sets whether or not public network access is allowed for + /// this server. Value is optional but if passed in, must be 'Enabled' + /// or 'Disabled'. Possible values include: 'Enabled', 'Disabled' + /// + [JsonProperty(PropertyName = "publicNetworkAccess")] + public string PublicNetworkAccess { get; set; } + + /// + /// Gets or sets storage profile of a server. + /// + [JsonProperty(PropertyName = "storageProfile")] + public StorageProfile StorageProfile { get; set; } + + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/ServerPropertiesForDefaultCreate.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/ServerPropertiesForDefaultCreate.cs new file mode 100644 index 000000000000..2817a2084e25 --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/ServerPropertiesForDefaultCreate.cs @@ -0,0 +1,99 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// The properties used to create a new server. + /// + [Newtonsoft.Json.JsonObject("Default")] + public partial class ServerPropertiesForDefaultCreate : ServerPropertiesForCreate + { + /// + /// Initializes a new instance of the ServerPropertiesForDefaultCreate + /// class. + /// + public ServerPropertiesForDefaultCreate() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ServerPropertiesForDefaultCreate + /// class. + /// + /// The administrator's login name of + /// a server. Can only be specified when the server is being created + /// (and is required for creation). + /// The password of the + /// administrator login. + /// Server version. Possible values include: + /// '10.2', '10.3' + /// Enable ssl enforcement or not when + /// connect to server. Possible values include: 'Enabled', + /// 'Disabled' + /// Enforce a minimal Tls version for + /// the server. Possible values include: 'TLS1_0', 'TLS1_1', 'TLS1_2', + /// 'TLSEnforcementDisabled' + /// Whether or not public network + /// access is allowed for this server. Value is optional but if passed + /// in, must be 'Enabled' or 'Disabled'. Possible values include: + /// 'Enabled', 'Disabled' + /// Storage profile of a server. + public ServerPropertiesForDefaultCreate(string administratorLogin, string administratorLoginPassword, string version = default(string), SslEnforcementEnum? sslEnforcement = default(SslEnforcementEnum?), string minimalTlsVersion = default(string), string publicNetworkAccess = default(string), StorageProfile storageProfile = default(StorageProfile)) + : base(version, sslEnforcement, minimalTlsVersion, publicNetworkAccess, storageProfile) + { + AdministratorLogin = administratorLogin; + AdministratorLoginPassword = administratorLoginPassword; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the administrator's login name of a server. Can only + /// be specified when the server is being created (and is required for + /// creation). + /// + [JsonProperty(PropertyName = "administratorLogin")] + public string AdministratorLogin { get; set; } + + /// + /// Gets or sets the password of the administrator login. + /// + [JsonProperty(PropertyName = "administratorLoginPassword")] + public string AdministratorLoginPassword { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (AdministratorLogin == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "AdministratorLogin"); + } + if (AdministratorLoginPassword == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "AdministratorLoginPassword"); + } + } + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/ServerPropertiesForGeoRestore.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/ServerPropertiesForGeoRestore.cs new file mode 100644 index 000000000000..b33d96bcf7ac --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/ServerPropertiesForGeoRestore.cs @@ -0,0 +1,84 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// The properties used to create a new server by restoring to a different + /// region from a geo replicated backup. + /// + [Newtonsoft.Json.JsonObject("GeoRestore")] + public partial class ServerPropertiesForGeoRestore : ServerPropertiesForCreate + { + /// + /// Initializes a new instance of the ServerPropertiesForGeoRestore + /// class. + /// + public ServerPropertiesForGeoRestore() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ServerPropertiesForGeoRestore + /// class. + /// + /// The source server id to restore + /// from. + /// Server version. Possible values include: + /// '10.2', '10.3' + /// Enable ssl enforcement or not when + /// connect to server. Possible values include: 'Enabled', + /// 'Disabled' + /// Enforce a minimal Tls version for + /// the server. Possible values include: 'TLS1_0', 'TLS1_1', 'TLS1_2', + /// 'TLSEnforcementDisabled' + /// Whether or not public network + /// access is allowed for this server. Value is optional but if passed + /// in, must be 'Enabled' or 'Disabled'. Possible values include: + /// 'Enabled', 'Disabled' + /// Storage profile of a server. + public ServerPropertiesForGeoRestore(string sourceServerId, string version = default(string), SslEnforcementEnum? sslEnforcement = default(SslEnforcementEnum?), string minimalTlsVersion = default(string), string publicNetworkAccess = default(string), StorageProfile storageProfile = default(StorageProfile)) + : base(version, sslEnforcement, minimalTlsVersion, publicNetworkAccess, storageProfile) + { + SourceServerId = sourceServerId; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the source server id to restore from. + /// + [JsonProperty(PropertyName = "sourceServerId")] + public string SourceServerId { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (SourceServerId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "SourceServerId"); + } + } + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/ServerPropertiesForReplica.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/ServerPropertiesForReplica.cs new file mode 100644 index 000000000000..3f6ed1485f3a --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/ServerPropertiesForReplica.cs @@ -0,0 +1,81 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// The properties to create a new replica. + /// + [Newtonsoft.Json.JsonObject("Replica")] + public partial class ServerPropertiesForReplica : ServerPropertiesForCreate + { + /// + /// Initializes a new instance of the ServerPropertiesForReplica class. + /// + public ServerPropertiesForReplica() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ServerPropertiesForReplica class. + /// + /// The master server id to create replica + /// from. + /// Server version. Possible values include: + /// '10.2', '10.3' + /// Enable ssl enforcement or not when + /// connect to server. Possible values include: 'Enabled', + /// 'Disabled' + /// Enforce a minimal Tls version for + /// the server. Possible values include: 'TLS1_0', 'TLS1_1', 'TLS1_2', + /// 'TLSEnforcementDisabled' + /// Whether or not public network + /// access is allowed for this server. Value is optional but if passed + /// in, must be 'Enabled' or 'Disabled'. Possible values include: + /// 'Enabled', 'Disabled' + /// Storage profile of a server. + public ServerPropertiesForReplica(string sourceServerId, string version = default(string), SslEnforcementEnum? sslEnforcement = default(SslEnforcementEnum?), string minimalTlsVersion = default(string), string publicNetworkAccess = default(string), StorageProfile storageProfile = default(StorageProfile)) + : base(version, sslEnforcement, minimalTlsVersion, publicNetworkAccess, storageProfile) + { + SourceServerId = sourceServerId; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the master server id to create replica from. + /// + [JsonProperty(PropertyName = "sourceServerId")] + public string SourceServerId { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (SourceServerId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "SourceServerId"); + } + } + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/ServerPropertiesForRestore.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/ServerPropertiesForRestore.cs new file mode 100644 index 000000000000..406a495fdfc8 --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/ServerPropertiesForRestore.cs @@ -0,0 +1,91 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// The properties used to create a new server by restoring from a backup. + /// + [Newtonsoft.Json.JsonObject("PointInTimeRestore")] + public partial class ServerPropertiesForRestore : ServerPropertiesForCreate + { + /// + /// Initializes a new instance of the ServerPropertiesForRestore class. + /// + public ServerPropertiesForRestore() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ServerPropertiesForRestore class. + /// + /// The source server id to restore + /// from. + /// Restore point creation time + /// (ISO8601 format), specifying the time to restore from. + /// Server version. Possible values include: + /// '10.2', '10.3' + /// Enable ssl enforcement or not when + /// connect to server. Possible values include: 'Enabled', + /// 'Disabled' + /// Enforce a minimal Tls version for + /// the server. Possible values include: 'TLS1_0', 'TLS1_1', 'TLS1_2', + /// 'TLSEnforcementDisabled' + /// Whether or not public network + /// access is allowed for this server. Value is optional but if passed + /// in, must be 'Enabled' or 'Disabled'. Possible values include: + /// 'Enabled', 'Disabled' + /// Storage profile of a server. + public ServerPropertiesForRestore(string sourceServerId, System.DateTime restorePointInTime, string version = default(string), SslEnforcementEnum? sslEnforcement = default(SslEnforcementEnum?), string minimalTlsVersion = default(string), string publicNetworkAccess = default(string), StorageProfile storageProfile = default(StorageProfile)) + : base(version, sslEnforcement, minimalTlsVersion, publicNetworkAccess, storageProfile) + { + SourceServerId = sourceServerId; + RestorePointInTime = restorePointInTime; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the source server id to restore from. + /// + [JsonProperty(PropertyName = "sourceServerId")] + public string SourceServerId { get; set; } + + /// + /// Gets or sets restore point creation time (ISO8601 format), + /// specifying the time to restore from. + /// + [JsonProperty(PropertyName = "restorePointInTime")] + public System.DateTime RestorePointInTime { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (SourceServerId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "SourceServerId"); + } + } + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/ServerSecurityAlertPolicy.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/ServerSecurityAlertPolicy.cs new file mode 100644 index 000000000000..9bf3066e0af9 --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/ServerSecurityAlertPolicy.cs @@ -0,0 +1,139 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// A server security alert policy. + /// + [Rest.Serialization.JsonTransformation] + public partial class ServerSecurityAlertPolicy : ProxyResource + { + /// + /// Initializes a new instance of the ServerSecurityAlertPolicy class. + /// + public ServerSecurityAlertPolicy() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ServerSecurityAlertPolicy class. + /// + /// Specifies the state of the policy, whether it + /// is enabled or disabled. Possible values include: 'Enabled', + /// 'Disabled' + /// Fully qualified resource ID for the resource. Ex - + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + /// The name of the resource + /// The type of the resource. E.g. + /// "Microsoft.Compute/virtualMachines" or + /// "Microsoft.Storage/storageAccounts" + /// Specifies an array of alerts that are + /// disabled. Allowed values are: Sql_Injection, + /// Sql_Injection_Vulnerability, Access_Anomaly + /// Specifies an array of e-mail addresses + /// to which the alert is sent. + /// Specifies that the alert is sent + /// to the account administrators. + /// Specifies the blob storage endpoint + /// (e.g. https://MyAccount.blob.core.windows.net). This blob storage + /// will hold all Threat Detection audit logs. + /// Specifies the identifier key + /// of the Threat Detection audit storage account. + /// Specifies the number of days to keep in + /// the Threat Detection audit logs. + public ServerSecurityAlertPolicy(ServerSecurityAlertPolicyState state, string id = default(string), string name = default(string), string type = default(string), IList disabledAlerts = default(IList), IList emailAddresses = default(IList), bool? emailAccountAdmins = default(bool?), string storageEndpoint = default(string), string storageAccountAccessKey = default(string), int? retentionDays = default(int?)) + : base(id, name, type) + { + State = state; + DisabledAlerts = disabledAlerts; + EmailAddresses = emailAddresses; + EmailAccountAdmins = emailAccountAdmins; + StorageEndpoint = storageEndpoint; + StorageAccountAccessKey = storageAccountAccessKey; + RetentionDays = retentionDays; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets specifies the state of the policy, whether it is + /// enabled or disabled. Possible values include: 'Enabled', 'Disabled' + /// + [JsonProperty(PropertyName = "properties.state")] + public ServerSecurityAlertPolicyState State { get; set; } + + /// + /// Gets or sets specifies an array of alerts that are disabled. + /// Allowed values are: Sql_Injection, Sql_Injection_Vulnerability, + /// Access_Anomaly + /// + [JsonProperty(PropertyName = "properties.disabledAlerts")] + public IList DisabledAlerts { get; set; } + + /// + /// Gets or sets specifies an array of e-mail addresses to which the + /// alert is sent. + /// + [JsonProperty(PropertyName = "properties.emailAddresses")] + public IList EmailAddresses { get; set; } + + /// + /// Gets or sets specifies that the alert is sent to the account + /// administrators. + /// + [JsonProperty(PropertyName = "properties.emailAccountAdmins")] + public bool? EmailAccountAdmins { get; set; } + + /// + /// Gets or sets specifies the blob storage endpoint (e.g. + /// https://MyAccount.blob.core.windows.net). This blob storage will + /// hold all Threat Detection audit logs. + /// + [JsonProperty(PropertyName = "properties.storageEndpoint")] + public string StorageEndpoint { get; set; } + + /// + /// Gets or sets specifies the identifier key of the Threat Detection + /// audit storage account. + /// + [JsonProperty(PropertyName = "properties.storageAccountAccessKey")] + public string StorageAccountAccessKey { get; set; } + + /// + /// Gets or sets specifies the number of days to keep in the Threat + /// Detection audit logs. + /// + [JsonProperty(PropertyName = "properties.retentionDays")] + public int? RetentionDays { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + } + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/ServerSecurityAlertPolicyState.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/ServerSecurityAlertPolicyState.cs new file mode 100644 index 000000000000..28add49bd807 --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/ServerSecurityAlertPolicyState.cs @@ -0,0 +1,60 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB.Models +{ + using Newtonsoft.Json; + using Newtonsoft.Json.Converters; + using System.Runtime; + using System.Runtime.Serialization; + + /// + /// Defines values for ServerSecurityAlertPolicyState. + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum ServerSecurityAlertPolicyState + { + [EnumMember(Value = "Enabled")] + Enabled, + [EnumMember(Value = "Disabled")] + Disabled + } + internal static class ServerSecurityAlertPolicyStateEnumExtension + { + internal static string ToSerializedValue(this ServerSecurityAlertPolicyState? value) + { + return value == null ? null : ((ServerSecurityAlertPolicyState)value).ToSerializedValue(); + } + + internal static string ToSerializedValue(this ServerSecurityAlertPolicyState value) + { + switch( value ) + { + case ServerSecurityAlertPolicyState.Enabled: + return "Enabled"; + case ServerSecurityAlertPolicyState.Disabled: + return "Disabled"; + } + return null; + } + + internal static ServerSecurityAlertPolicyState? ParseServerSecurityAlertPolicyState(this string value) + { + switch( value ) + { + case "Enabled": + return ServerSecurityAlertPolicyState.Enabled; + case "Disabled": + return ServerSecurityAlertPolicyState.Disabled; + } + return null; + } + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/ServerState.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/ServerState.cs new file mode 100644 index 000000000000..33a403252b42 --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/ServerState.cs @@ -0,0 +1,23 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB.Models +{ + + /// + /// Defines values for ServerState. + /// + public static class ServerState + { + public const string Ready = "Ready"; + public const string Dropping = "Dropping"; + public const string Disabled = "Disabled"; + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/ServerUpdateParameters.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/ServerUpdateParameters.cs new file mode 100644 index 000000000000..0d588e4becae --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/ServerUpdateParameters.cs @@ -0,0 +1,151 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Parameters allowed to update for a server. + /// + [Rest.Serialization.JsonTransformation] + public partial class ServerUpdateParameters + { + /// + /// Initializes a new instance of the ServerUpdateParameters class. + /// + public ServerUpdateParameters() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ServerUpdateParameters class. + /// + /// The SKU (pricing tier) of the server. + /// Storage profile of a server. + /// The password of the + /// administrator login. + /// The version of a server. Possible values + /// include: '10.2', '10.3' + /// Enable ssl enforcement or not when + /// connect to server. Possible values include: 'Enabled', + /// 'Disabled' + /// Enforce a minimal Tls version for + /// the server. Possible values include: 'TLS1_0', 'TLS1_1', 'TLS1_2', + /// 'TLSEnforcementDisabled' + /// Whether or not public network + /// access is allowed for this server. Value is optional but if passed + /// in, must be 'Enabled' or 'Disabled'. Possible values include: + /// 'Enabled', 'Disabled' + /// The replication role of the + /// server. + /// Application-specific metadata in the form of + /// key-value pairs. + public ServerUpdateParameters(Sku sku = default(Sku), StorageProfile storageProfile = default(StorageProfile), string administratorLoginPassword = default(string), string version = default(string), SslEnforcementEnum? sslEnforcement = default(SslEnforcementEnum?), string minimalTlsVersion = default(string), string publicNetworkAccess = default(string), string replicationRole = default(string), IDictionary tags = default(IDictionary)) + { + Sku = sku; + StorageProfile = storageProfile; + AdministratorLoginPassword = administratorLoginPassword; + Version = version; + SslEnforcement = sslEnforcement; + MinimalTlsVersion = minimalTlsVersion; + PublicNetworkAccess = publicNetworkAccess; + ReplicationRole = replicationRole; + Tags = tags; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the SKU (pricing tier) of the server. + /// + [JsonProperty(PropertyName = "sku")] + public Sku Sku { get; set; } + + /// + /// Gets or sets storage profile of a server. + /// + [JsonProperty(PropertyName = "properties.storageProfile")] + public StorageProfile StorageProfile { get; set; } + + /// + /// Gets or sets the password of the administrator login. + /// + [JsonProperty(PropertyName = "properties.administratorLoginPassword")] + public string AdministratorLoginPassword { get; set; } + + /// + /// Gets or sets the version of a server. Possible values include: + /// '10.2', '10.3' + /// + [JsonProperty(PropertyName = "properties.version")] + public string Version { get; set; } + + /// + /// Gets or sets enable ssl enforcement or not when connect to server. + /// Possible values include: 'Enabled', 'Disabled' + /// + [JsonProperty(PropertyName = "properties.sslEnforcement")] + public SslEnforcementEnum? SslEnforcement { get; set; } + + /// + /// Gets or sets enforce a minimal Tls version for the server. Possible + /// values include: 'TLS1_0', 'TLS1_1', 'TLS1_2', + /// 'TLSEnforcementDisabled' + /// + [JsonProperty(PropertyName = "properties.minimalTlsVersion")] + public string MinimalTlsVersion { get; set; } + + /// + /// Gets or sets whether or not public network access is allowed for + /// this server. Value is optional but if passed in, must be 'Enabled' + /// or 'Disabled'. Possible values include: 'Enabled', 'Disabled' + /// + [JsonProperty(PropertyName = "properties.publicNetworkAccess")] + public string PublicNetworkAccess { get; set; } + + /// + /// Gets or sets the replication role of the server. + /// + [JsonProperty(PropertyName = "properties.replicationRole")] + public string ReplicationRole { get; set; } + + /// + /// Gets or sets application-specific metadata in the form of key-value + /// pairs. + /// + [JsonProperty(PropertyName = "tags")] + public IDictionary Tags { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Sku != null) + { + Sku.Validate(); + } + } + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/ServerVersion.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/ServerVersion.cs new file mode 100644 index 000000000000..9b288d37cf32 --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/ServerVersion.cs @@ -0,0 +1,22 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB.Models +{ + + /// + /// Defines values for ServerVersion. + /// + public static class ServerVersion + { + public const string OneZeroFullStopTwo = "10.2"; + public const string OneZeroFullStopThree = "10.3"; + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/Sku.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/Sku.cs new file mode 100644 index 000000000000..0b7f1933c735 --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/Sku.cs @@ -0,0 +1,110 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Billing information related properties of a server. + /// + public partial class Sku + { + /// + /// Initializes a new instance of the Sku class. + /// + public Sku() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Sku class. + /// + /// The name of the sku, typically, tier + family + + /// cores, e.g. B_Gen4_1, GP_Gen5_8. + /// The tier of the particular SKU, e.g. Basic. + /// Possible values include: 'Basic', 'GeneralPurpose', + /// 'MemoryOptimized' + /// The scale up/out capacity, representing + /// server's compute units. + /// The size code, to be interpreted by resource as + /// appropriate. + /// The family of hardware. + public Sku(string name, string tier = default(string), int? capacity = default(int?), string size = default(string), string family = default(string)) + { + Name = name; + Tier = tier; + Capacity = capacity; + Size = size; + Family = family; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the name of the sku, typically, tier + family + cores, + /// e.g. B_Gen4_1, GP_Gen5_8. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Gets or sets the tier of the particular SKU, e.g. Basic. Possible + /// values include: 'Basic', 'GeneralPurpose', 'MemoryOptimized' + /// + [JsonProperty(PropertyName = "tier")] + public string Tier { get; set; } + + /// + /// Gets or sets the scale up/out capacity, representing server's + /// compute units. + /// + [JsonProperty(PropertyName = "capacity")] + public int? Capacity { get; set; } + + /// + /// Gets or sets the size code, to be interpreted by resource as + /// appropriate. + /// + [JsonProperty(PropertyName = "size")] + public string Size { get; set; } + + /// + /// Gets or sets the family of hardware. + /// + [JsonProperty(PropertyName = "family")] + public string Family { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Name == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Name"); + } + if (Capacity < 0) + { + throw new ValidationException(ValidationRules.InclusiveMinimum, "Capacity", 0); + } + } + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/SkuTier.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/SkuTier.cs new file mode 100644 index 000000000000..5b192a700292 --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/SkuTier.cs @@ -0,0 +1,23 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB.Models +{ + + /// + /// Defines values for SkuTier. + /// + public static class SkuTier + { + public const string Basic = "Basic"; + public const string GeneralPurpose = "GeneralPurpose"; + public const string MemoryOptimized = "MemoryOptimized"; + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/SslEnforcementEnum.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/SslEnforcementEnum.cs new file mode 100644 index 000000000000..ce8f91aa8f66 --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/SslEnforcementEnum.cs @@ -0,0 +1,60 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB.Models +{ + using Newtonsoft.Json; + using Newtonsoft.Json.Converters; + using System.Runtime; + using System.Runtime.Serialization; + + /// + /// Defines values for SslEnforcementEnum. + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum SslEnforcementEnum + { + [EnumMember(Value = "Enabled")] + Enabled, + [EnumMember(Value = "Disabled")] + Disabled + } + internal static class SslEnforcementEnumEnumExtension + { + internal static string ToSerializedValue(this SslEnforcementEnum? value) + { + return value == null ? null : ((SslEnforcementEnum)value).ToSerializedValue(); + } + + internal static string ToSerializedValue(this SslEnforcementEnum value) + { + switch( value ) + { + case SslEnforcementEnum.Enabled: + return "Enabled"; + case SslEnforcementEnum.Disabled: + return "Disabled"; + } + return null; + } + + internal static SslEnforcementEnum? ParseSslEnforcementEnum(this string value) + { + switch( value ) + { + case "Enabled": + return SslEnforcementEnum.Enabled; + case "Disabled": + return SslEnforcementEnum.Disabled; + } + return null; + } + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/StorageAutogrow.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/StorageAutogrow.cs new file mode 100644 index 000000000000..e4396b6c4ef1 --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/StorageAutogrow.cs @@ -0,0 +1,22 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB.Models +{ + + /// + /// Defines values for StorageAutogrow. + /// + public static class StorageAutogrow + { + public const string Enabled = "Enabled"; + public const string Disabled = "Disabled"; + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/StorageProfile.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/StorageProfile.cs new file mode 100644 index 000000000000..5d20efeab113 --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/StorageProfile.cs @@ -0,0 +1,81 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Storage Profile properties of a server + /// + public partial class StorageProfile + { + /// + /// Initializes a new instance of the StorageProfile class. + /// + public StorageProfile() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the StorageProfile class. + /// + /// Backup retention days for the + /// server. + /// Enable Geo-redundant or not for + /// server backup. Possible values include: 'Enabled', + /// 'Disabled' + /// Max storage allowed for a server. + /// Enable Storage Auto Grow. Possible + /// values include: 'Enabled', 'Disabled' + public StorageProfile(int? backupRetentionDays = default(int?), string geoRedundantBackup = default(string), int? storageMB = default(int?), string storageAutogrow = default(string)) + { + BackupRetentionDays = backupRetentionDays; + GeoRedundantBackup = geoRedundantBackup; + StorageMB = storageMB; + StorageAutogrow = storageAutogrow; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets backup retention days for the server. + /// + [JsonProperty(PropertyName = "backupRetentionDays")] + public int? BackupRetentionDays { get; set; } + + /// + /// Gets or sets enable Geo-redundant or not for server backup. + /// Possible values include: 'Enabled', 'Disabled' + /// + [JsonProperty(PropertyName = "geoRedundantBackup")] + public string GeoRedundantBackup { get; set; } + + /// + /// Gets or sets max storage allowed for a server. + /// + [JsonProperty(PropertyName = "storageMB")] + public int? StorageMB { get; set; } + + /// + /// Gets or sets enable Storage Auto Grow. Possible values include: + /// 'Enabled', 'Disabled' + /// + [JsonProperty(PropertyName = "storageAutogrow")] + public string StorageAutogrow { get; set; } + + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/TagsObject.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/TagsObject.cs new file mode 100644 index 000000000000..c5d81681ba5f --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/TagsObject.cs @@ -0,0 +1,53 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Tags object for patch operations. + /// + public partial class TagsObject + { + /// + /// Initializes a new instance of the TagsObject class. + /// + public TagsObject() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the TagsObject class. + /// + /// Resource tags. + public TagsObject(IDictionary tags = default(IDictionary)) + { + Tags = tags; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets resource tags. + /// + [JsonProperty(PropertyName = "tags")] + public IDictionary Tags { get; set; } + + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/TopQueryStatisticsInput.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/TopQueryStatisticsInput.cs new file mode 100644 index 000000000000..f9f78c4b6fd8 --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/TopQueryStatisticsInput.cs @@ -0,0 +1,118 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Input to get top query statistics + /// + [Rest.Serialization.JsonTransformation] + public partial class TopQueryStatisticsInput + { + /// + /// Initializes a new instance of the TopQueryStatisticsInput class. + /// + public TopQueryStatisticsInput() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the TopQueryStatisticsInput class. + /// + /// Max number of top queries to + /// return. + /// Aggregation function + /// name. + /// Observed metric name. + /// Observation start time. + /// Observation end time. + /// Aggregation interval type in ISO + /// 8601 format. + public TopQueryStatisticsInput(int numberOfTopQueries, string aggregationFunction, string observedMetric, System.DateTime observationStartTime, System.DateTime observationEndTime, string aggregationWindow) + { + NumberOfTopQueries = numberOfTopQueries; + AggregationFunction = aggregationFunction; + ObservedMetric = observedMetric; + ObservationStartTime = observationStartTime; + ObservationEndTime = observationEndTime; + AggregationWindow = aggregationWindow; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets max number of top queries to return. + /// + [JsonProperty(PropertyName = "properties.numberOfTopQueries")] + public int NumberOfTopQueries { get; set; } + + /// + /// Gets or sets aggregation function name. + /// + [JsonProperty(PropertyName = "properties.aggregationFunction")] + public string AggregationFunction { get; set; } + + /// + /// Gets or sets observed metric name. + /// + [JsonProperty(PropertyName = "properties.observedMetric")] + public string ObservedMetric { get; set; } + + /// + /// Gets or sets observation start time. + /// + [JsonProperty(PropertyName = "properties.observationStartTime")] + public System.DateTime ObservationStartTime { get; set; } + + /// + /// Gets or sets observation end time. + /// + [JsonProperty(PropertyName = "properties.observationEndTime")] + public System.DateTime ObservationEndTime { get; set; } + + /// + /// Gets or sets aggregation interval type in ISO 8601 format. + /// + [JsonProperty(PropertyName = "properties.aggregationWindow")] + public string AggregationWindow { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (AggregationFunction == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "AggregationFunction"); + } + if (ObservedMetric == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "ObservedMetric"); + } + if (AggregationWindow == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "AggregationWindow"); + } + } + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/TrackedResource.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/TrackedResource.cs new file mode 100644 index 000000000000..859528f69cb1 --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/TrackedResource.cs @@ -0,0 +1,87 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Tracked Resource + /// + /// + /// The resource model definition for an Azure Resource Manager tracked top + /// level resource which has 'tags' and a 'location' + /// + public partial class TrackedResource : Resource + { + /// + /// Initializes a new instance of the TrackedResource class. + /// + public TrackedResource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the TrackedResource class. + /// + /// The geo-location where the resource + /// lives + /// Fully qualified resource ID for the resource. Ex - + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + /// The name of the resource + /// The type of the resource. E.g. + /// "Microsoft.Compute/virtualMachines" or + /// "Microsoft.Storage/storageAccounts" + /// Resource tags. + public TrackedResource(string location, string id = default(string), string name = default(string), string type = default(string), IDictionary tags = default(IDictionary)) + : base(id, name, type) + { + Tags = tags; + Location = location; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets resource tags. + /// + [JsonProperty(PropertyName = "tags")] + public IDictionary Tags { get; set; } + + /// + /// Gets or sets the geo-location where the resource lives + /// + [JsonProperty(PropertyName = "location")] + public string Location { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Location == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Location"); + } + } + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/VirtualNetworkRule.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/VirtualNetworkRule.cs new file mode 100644 index 000000000000..882eddcde646 --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/VirtualNetworkRule.cs @@ -0,0 +1,97 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Linq; + + /// + /// A virtual network rule. + /// + [Rest.Serialization.JsonTransformation] + public partial class VirtualNetworkRule : ProxyResource + { + /// + /// Initializes a new instance of the VirtualNetworkRule class. + /// + public VirtualNetworkRule() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the VirtualNetworkRule class. + /// + /// The ARM resource id of the + /// virtual network subnet. + /// Fully qualified resource ID for the resource. Ex - + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + /// The name of the resource + /// The type of the resource. E.g. + /// "Microsoft.Compute/virtualMachines" or + /// "Microsoft.Storage/storageAccounts" + /// Create firewall rule + /// before the virtual network has vnet service endpoint + /// enabled. + /// Virtual Network Rule State. Possible values + /// include: 'Initializing', 'InProgress', 'Ready', 'Deleting', + /// 'Unknown' + public VirtualNetworkRule(string virtualNetworkSubnetId, string id = default(string), string name = default(string), string type = default(string), bool? ignoreMissingVnetServiceEndpoint = default(bool?), string state = default(string)) + : base(id, name, type) + { + VirtualNetworkSubnetId = virtualNetworkSubnetId; + IgnoreMissingVnetServiceEndpoint = ignoreMissingVnetServiceEndpoint; + State = state; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the ARM resource id of the virtual network subnet. + /// + [JsonProperty(PropertyName = "properties.virtualNetworkSubnetId")] + public string VirtualNetworkSubnetId { get; set; } + + /// + /// Gets or sets create firewall rule before the virtual network has + /// vnet service endpoint enabled. + /// + [JsonProperty(PropertyName = "properties.ignoreMissingVnetServiceEndpoint")] + public bool? IgnoreMissingVnetServiceEndpoint { get; set; } + + /// + /// Gets virtual Network Rule State. Possible values include: + /// 'Initializing', 'InProgress', 'Ready', 'Deleting', 'Unknown' + /// + [JsonProperty(PropertyName = "properties.state")] + public string State { get; private set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (VirtualNetworkSubnetId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "VirtualNetworkSubnetId"); + } + } + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/VirtualNetworkRuleState.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/VirtualNetworkRuleState.cs new file mode 100644 index 000000000000..1d74a78c1305 --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/VirtualNetworkRuleState.cs @@ -0,0 +1,25 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB.Models +{ + + /// + /// Defines values for VirtualNetworkRuleState. + /// + public static class VirtualNetworkRuleState + { + public const string Initializing = "Initializing"; + public const string InProgress = "InProgress"; + public const string Ready = "Ready"; + public const string Deleting = "Deleting"; + public const string Unknown = "Unknown"; + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/WaitStatistic.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/WaitStatistic.cs new file mode 100644 index 000000000000..eb34e046305c --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/WaitStatistic.cs @@ -0,0 +1,128 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Represents a Wait Statistic. + /// + [Rest.Serialization.JsonTransformation] + public partial class WaitStatistic : ProxyResource + { + /// + /// Initializes a new instance of the WaitStatistic class. + /// + public WaitStatistic() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the WaitStatistic class. + /// + /// Fully qualified resource ID for the resource. Ex - + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + /// The name of the resource + /// The type of the resource. E.g. + /// "Microsoft.Compute/virtualMachines" or + /// "Microsoft.Storage/storageAccounts" + /// Observation start time. + /// Observation end time. + /// Wait event name. + /// Wait event type name. + /// Database query identifier. + /// Database Name. + /// Database user identifier. + /// Wait event count observed in this time + /// interval. + /// Total time of wait in milliseconds in + /// this time interval. + public WaitStatistic(string id = default(string), string name = default(string), string type = default(string), System.DateTime? startTime = default(System.DateTime?), System.DateTime? endTime = default(System.DateTime?), string eventName = default(string), string eventTypeName = default(string), long? queryId = default(long?), string databaseName = default(string), long? userId = default(long?), long? count = default(long?), double? totalTimeInMs = default(double?)) + : base(id, name, type) + { + StartTime = startTime; + EndTime = endTime; + EventName = eventName; + EventTypeName = eventTypeName; + QueryId = queryId; + DatabaseName = databaseName; + UserId = userId; + Count = count; + TotalTimeInMs = totalTimeInMs; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets observation start time. + /// + [JsonProperty(PropertyName = "properties.startTime")] + public System.DateTime? StartTime { get; set; } + + /// + /// Gets or sets observation end time. + /// + [JsonProperty(PropertyName = "properties.endTime")] + public System.DateTime? EndTime { get; set; } + + /// + /// Gets or sets wait event name. + /// + [JsonProperty(PropertyName = "properties.eventName")] + public string EventName { get; set; } + + /// + /// Gets or sets wait event type name. + /// + [JsonProperty(PropertyName = "properties.eventTypeName")] + public string EventTypeName { get; set; } + + /// + /// Gets or sets database query identifier. + /// + [JsonProperty(PropertyName = "properties.queryId")] + public long? QueryId { get; set; } + + /// + /// Gets or sets database Name. + /// + [JsonProperty(PropertyName = "properties.databaseName")] + public string DatabaseName { get; set; } + + /// + /// Gets or sets database user identifier. + /// + [JsonProperty(PropertyName = "properties.userId")] + public long? UserId { get; set; } + + /// + /// Gets or sets wait event count observed in this time interval. + /// + [JsonProperty(PropertyName = "properties.count")] + public long? Count { get; set; } + + /// + /// Gets or sets total time of wait in milliseconds in this time + /// interval. + /// + [JsonProperty(PropertyName = "properties.totalTimeInMs")] + public double? TotalTimeInMs { get; set; } + + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/WaitStatisticsInput.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/WaitStatisticsInput.cs new file mode 100644 index 000000000000..93caeab74870 --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Models/WaitStatisticsInput.cs @@ -0,0 +1,84 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Input to get wait statistics + /// + [Rest.Serialization.JsonTransformation] + public partial class WaitStatisticsInput + { + /// + /// Initializes a new instance of the WaitStatisticsInput class. + /// + public WaitStatisticsInput() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the WaitStatisticsInput class. + /// + /// Observation start time. + /// Observation end time. + /// Aggregation interval type in ISO + /// 8601 format. + public WaitStatisticsInput(System.DateTime observationStartTime, System.DateTime observationEndTime, string aggregationWindow) + { + ObservationStartTime = observationStartTime; + ObservationEndTime = observationEndTime; + AggregationWindow = aggregationWindow; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets observation start time. + /// + [JsonProperty(PropertyName = "properties.observationStartTime")] + public System.DateTime ObservationStartTime { get; set; } + + /// + /// Gets or sets observation end time. + /// + [JsonProperty(PropertyName = "properties.observationEndTime")] + public System.DateTime ObservationEndTime { get; set; } + + /// + /// Gets or sets aggregation interval type in ISO 8601 format. + /// + [JsonProperty(PropertyName = "properties.aggregationWindow")] + public string AggregationWindow { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (AggregationWindow == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "AggregationWindow"); + } + } + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Operations.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Operations.cs new file mode 100644 index 000000000000..5a1c95d084d2 --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/Operations.cs @@ -0,0 +1,219 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Operations operations. + /// + internal partial class Operations : IServiceOperations, IOperations + { + /// + /// Initializes a new instance of the Operations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal Operations(MariaDBManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the MariaDBManagementClient + /// + public MariaDBManagementClient Client { get; private set; } + + /// + /// Lists all of the available REST API operations. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + string apiVersion = "2018-06-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.DBforMariaDB/operations").ToString(); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/OperationsExtensions.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/OperationsExtensions.cs new file mode 100644 index 000000000000..dc4b9ae40e2d --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/OperationsExtensions.cs @@ -0,0 +1,53 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for Operations. + /// + public static partial class OperationsExtensions + { + /// + /// Lists all of the available REST API operations. + /// + /// + /// The operations group for this extension method. + /// + public static OperationListResult List(this IOperations operations) + { + return operations.ListAsync().GetAwaiter().GetResult(); + } + + /// + /// Lists all of the available REST API operations. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The cancellation token. + /// + public static async Task ListAsync(this IOperations operations, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/PrivateEndpointConnectionsOperations.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/PrivateEndpointConnectionsOperations.cs new file mode 100644 index 000000000000..500cc46542e5 --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/PrivateEndpointConnectionsOperations.cs @@ -0,0 +1,1415 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// PrivateEndpointConnectionsOperations operations. + /// + internal partial class PrivateEndpointConnectionsOperations : IServiceOperations, IPrivateEndpointConnectionsOperations + { + /// + /// Initializes a new instance of the PrivateEndpointConnectionsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal PrivateEndpointConnectionsOperations(MariaDBManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the MariaDBManagementClient + /// + public MariaDBManagementClient Client { get; private set; } + + /// + /// Gets a private endpoint connection. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The name of the private endpoint connection. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetWithHttpMessagesAsync(string resourceGroupName, string serverName, string privateEndpointConnectionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (serverName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "serverName"); + } + if (privateEndpointConnectionName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "privateEndpointConnectionName"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + string apiVersion = "2018-06-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("serverName", serverName); + tracingParameters.Add("privateEndpointConnectionName", privateEndpointConnectionName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMariaDB/servers/{serverName}/privateEndpointConnections/{privateEndpointConnectionName}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{serverName}", System.Uri.EscapeDataString(serverName)); + _url = _url.Replace("{privateEndpointConnectionName}", System.Uri.EscapeDataString(privateEndpointConnectionName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Approve or reject a private endpoint connection with a given name. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// + /// + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string serverName, string privateEndpointConnectionName, PrivateEndpointConnection parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, serverName, privateEndpointConnectionName, parameters, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Deletes a private endpoint connection with a given name. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task DeleteWithHttpMessagesAsync(string resourceGroupName, string serverName, string privateEndpointConnectionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginDeleteWithHttpMessagesAsync(resourceGroupName, serverName, privateEndpointConnectionName, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Updates tags on private endpoint connection. + /// + /// + /// Updates private endpoint connection with the specified tags. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// + /// + /// Parameters supplied to the Update private endpoint connection Tags + /// operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> UpdateTagsWithHttpMessagesAsync(string resourceGroupName, string serverName, string privateEndpointConnectionName, TagsObject parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginUpdateTagsWithHttpMessagesAsync(resourceGroupName, serverName, privateEndpointConnectionName, parameters, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets all private endpoint connections on a server. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListByServerWithHttpMessagesAsync(string resourceGroupName, string serverName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (serverName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "serverName"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + string apiVersion = "2018-06-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("serverName", serverName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByServer", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMariaDB/servers/{serverName}/privateEndpointConnections").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{serverName}", System.Uri.EscapeDataString(serverName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Approve or reject a private endpoint connection with a given name. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// + /// + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> BeginCreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string serverName, string privateEndpointConnectionName, PrivateEndpointConnection parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (serverName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "serverName"); + } + if (privateEndpointConnectionName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "privateEndpointConnectionName"); + } + if (parameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); + } + if (parameters != null) + { + parameters.Validate(); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + string apiVersion = "2018-06-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("serverName", serverName); + tracingParameters.Add("privateEndpointConnectionName", privateEndpointConnectionName); + tracingParameters.Add("parameters", parameters); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginCreateOrUpdate", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMariaDB/servers/{serverName}/privateEndpointConnections/{privateEndpointConnectionName}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{serverName}", System.Uri.EscapeDataString(serverName)); + _url = _url.Replace("{privateEndpointConnectionName}", System.Uri.EscapeDataString(privateEndpointConnectionName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PUT"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(parameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 202) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Deletes a private endpoint connection with a given name. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string serverName, string privateEndpointConnectionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (serverName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "serverName"); + } + if (privateEndpointConnectionName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "privateEndpointConnectionName"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + string apiVersion = "2018-06-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("serverName", serverName); + tracingParameters.Add("privateEndpointConnectionName", privateEndpointConnectionName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginDelete", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMariaDB/servers/{serverName}/privateEndpointConnections/{privateEndpointConnectionName}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{serverName}", System.Uri.EscapeDataString(serverName)); + _url = _url.Replace("{privateEndpointConnectionName}", System.Uri.EscapeDataString(privateEndpointConnectionName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("DELETE"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 202 && (int)_statusCode != 204) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Updates tags on private endpoint connection. + /// + /// + /// Updates private endpoint connection with the specified tags. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// + /// + /// Parameters supplied to the Update private endpoint connection Tags + /// operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> BeginUpdateTagsWithHttpMessagesAsync(string resourceGroupName, string serverName, string privateEndpointConnectionName, TagsObject parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (serverName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "serverName"); + } + if (privateEndpointConnectionName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "privateEndpointConnectionName"); + } + if (parameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); + } + string apiVersion = "2018-06-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("serverName", serverName); + tracingParameters.Add("privateEndpointConnectionName", privateEndpointConnectionName); + tracingParameters.Add("parameters", parameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginUpdateTags", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMariaDB/servers/{serverName}/privateEndpointConnections/{privateEndpointConnectionName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{serverName}", System.Uri.EscapeDataString(serverName)); + _url = _url.Replace("{privateEndpointConnectionName}", System.Uri.EscapeDataString(privateEndpointConnectionName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PATCH"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(parameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Gets all private endpoint connections on a server. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListByServerNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByServerNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/PrivateEndpointConnectionsOperationsExtensions.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/PrivateEndpointConnectionsOperationsExtensions.cs new file mode 100644 index 000000000000..135dceb85060 --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/PrivateEndpointConnectionsOperationsExtensions.cs @@ -0,0 +1,439 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for PrivateEndpointConnectionsOperations. + /// + public static partial class PrivateEndpointConnectionsOperationsExtensions + { + /// + /// Gets a private endpoint connection. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The name of the private endpoint connection. + /// + public static PrivateEndpointConnection Get(this IPrivateEndpointConnectionsOperations operations, string resourceGroupName, string serverName, string privateEndpointConnectionName) + { + return operations.GetAsync(resourceGroupName, serverName, privateEndpointConnectionName).GetAwaiter().GetResult(); + } + + /// + /// Gets a private endpoint connection. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The name of the private endpoint connection. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IPrivateEndpointConnectionsOperations operations, string resourceGroupName, string serverName, string privateEndpointConnectionName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, serverName, privateEndpointConnectionName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Approve or reject a private endpoint connection with a given name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// + /// + /// + public static PrivateEndpointConnection CreateOrUpdate(this IPrivateEndpointConnectionsOperations operations, string resourceGroupName, string serverName, string privateEndpointConnectionName, PrivateEndpointConnection parameters) + { + return operations.CreateOrUpdateAsync(resourceGroupName, serverName, privateEndpointConnectionName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Approve or reject a private endpoint connection with a given name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// + /// + /// + /// + /// The cancellation token. + /// + public static async Task CreateOrUpdateAsync(this IPrivateEndpointConnectionsOperations operations, string resourceGroupName, string serverName, string privateEndpointConnectionName, PrivateEndpointConnection parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, serverName, privateEndpointConnectionName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes a private endpoint connection with a given name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// + public static void Delete(this IPrivateEndpointConnectionsOperations operations, string resourceGroupName, string serverName, string privateEndpointConnectionName) + { + operations.DeleteAsync(resourceGroupName, serverName, privateEndpointConnectionName).GetAwaiter().GetResult(); + } + + /// + /// Deletes a private endpoint connection with a given name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this IPrivateEndpointConnectionsOperations operations, string resourceGroupName, string serverName, string privateEndpointConnectionName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, serverName, privateEndpointConnectionName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Updates tags on private endpoint connection. + /// + /// + /// Updates private endpoint connection with the specified tags. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// + /// + /// Parameters supplied to the Update private endpoint connection Tags + /// operation. + /// + public static PrivateEndpointConnection UpdateTags(this IPrivateEndpointConnectionsOperations operations, string resourceGroupName, string serverName, string privateEndpointConnectionName, TagsObject parameters) + { + return operations.UpdateTagsAsync(resourceGroupName, serverName, privateEndpointConnectionName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Updates tags on private endpoint connection. + /// + /// + /// Updates private endpoint connection with the specified tags. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// + /// + /// Parameters supplied to the Update private endpoint connection Tags + /// operation. + /// + /// + /// The cancellation token. + /// + public static async Task UpdateTagsAsync(this IPrivateEndpointConnectionsOperations operations, string resourceGroupName, string serverName, string privateEndpointConnectionName, TagsObject parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.UpdateTagsWithHttpMessagesAsync(resourceGroupName, serverName, privateEndpointConnectionName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets all private endpoint connections on a server. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + public static IPage ListByServer(this IPrivateEndpointConnectionsOperations operations, string resourceGroupName, string serverName) + { + return operations.ListByServerAsync(resourceGroupName, serverName).GetAwaiter().GetResult(); + } + + /// + /// Gets all private endpoint connections on a server. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByServerAsync(this IPrivateEndpointConnectionsOperations operations, string resourceGroupName, string serverName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByServerWithHttpMessagesAsync(resourceGroupName, serverName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Approve or reject a private endpoint connection with a given name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// + /// + /// + public static PrivateEndpointConnection BeginCreateOrUpdate(this IPrivateEndpointConnectionsOperations operations, string resourceGroupName, string serverName, string privateEndpointConnectionName, PrivateEndpointConnection parameters) + { + return operations.BeginCreateOrUpdateAsync(resourceGroupName, serverName, privateEndpointConnectionName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Approve or reject a private endpoint connection with a given name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// + /// + /// + /// + /// The cancellation token. + /// + public static async Task BeginCreateOrUpdateAsync(this IPrivateEndpointConnectionsOperations operations, string resourceGroupName, string serverName, string privateEndpointConnectionName, PrivateEndpointConnection parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, serverName, privateEndpointConnectionName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes a private endpoint connection with a given name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// + public static void BeginDelete(this IPrivateEndpointConnectionsOperations operations, string resourceGroupName, string serverName, string privateEndpointConnectionName) + { + operations.BeginDeleteAsync(resourceGroupName, serverName, privateEndpointConnectionName).GetAwaiter().GetResult(); + } + + /// + /// Deletes a private endpoint connection with a given name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// + /// + /// The cancellation token. + /// + public static async Task BeginDeleteAsync(this IPrivateEndpointConnectionsOperations operations, string resourceGroupName, string serverName, string privateEndpointConnectionName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.BeginDeleteWithHttpMessagesAsync(resourceGroupName, serverName, privateEndpointConnectionName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Updates tags on private endpoint connection. + /// + /// + /// Updates private endpoint connection with the specified tags. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// + /// + /// Parameters supplied to the Update private endpoint connection Tags + /// operation. + /// + public static PrivateEndpointConnection BeginUpdateTags(this IPrivateEndpointConnectionsOperations operations, string resourceGroupName, string serverName, string privateEndpointConnectionName, TagsObject parameters) + { + return operations.BeginUpdateTagsAsync(resourceGroupName, serverName, privateEndpointConnectionName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Updates tags on private endpoint connection. + /// + /// + /// Updates private endpoint connection with the specified tags. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// + /// + /// Parameters supplied to the Update private endpoint connection Tags + /// operation. + /// + /// + /// The cancellation token. + /// + public static async Task BeginUpdateTagsAsync(this IPrivateEndpointConnectionsOperations operations, string resourceGroupName, string serverName, string privateEndpointConnectionName, TagsObject parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginUpdateTagsWithHttpMessagesAsync(resourceGroupName, serverName, privateEndpointConnectionName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets all private endpoint connections on a server. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListByServerNext(this IPrivateEndpointConnectionsOperations operations, string nextPageLink) + { + return operations.ListByServerNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Gets all private endpoint connections on a server. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByServerNextAsync(this IPrivateEndpointConnectionsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByServerNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/PrivateLinkResourcesOperations.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/PrivateLinkResourcesOperations.cs new file mode 100644 index 000000000000..4a5b22606a37 --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/PrivateLinkResourcesOperations.cs @@ -0,0 +1,660 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// PrivateLinkResourcesOperations operations. + /// + internal partial class PrivateLinkResourcesOperations : IServiceOperations, IPrivateLinkResourcesOperations + { + /// + /// Initializes a new instance of the PrivateLinkResourcesOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal PrivateLinkResourcesOperations(MariaDBManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the MariaDBManagementClient + /// + public MariaDBManagementClient Client { get; private set; } + + /// + /// Gets the private link resources for MariaDB server. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListByServerWithHttpMessagesAsync(string resourceGroupName, string serverName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (serverName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "serverName"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + string apiVersion = "2018-06-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("serverName", serverName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByServer", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMariaDB/servers/{serverName}/privateLinkResources").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{serverName}", System.Uri.EscapeDataString(serverName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Gets a private link resource for MariaDB server. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The name of the private link resource. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetWithHttpMessagesAsync(string resourceGroupName, string serverName, string groupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (serverName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "serverName"); + } + if (groupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "groupName"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + string apiVersion = "2018-06-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("serverName", serverName); + tracingParameters.Add("groupName", groupName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMariaDB/servers/{serverName}/privateLinkResources/{groupName}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{serverName}", System.Uri.EscapeDataString(serverName)); + _url = _url.Replace("{groupName}", System.Uri.EscapeDataString(groupName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Gets the private link resources for MariaDB server. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListByServerNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByServerNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/PrivateLinkResourcesOperationsExtensions.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/PrivateLinkResourcesOperationsExtensions.cs new file mode 100644 index 000000000000..62f03f84e568 --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/PrivateLinkResourcesOperationsExtensions.cs @@ -0,0 +1,145 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for PrivateLinkResourcesOperations. + /// + public static partial class PrivateLinkResourcesOperationsExtensions + { + /// + /// Gets the private link resources for MariaDB server. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + public static IPage ListByServer(this IPrivateLinkResourcesOperations operations, string resourceGroupName, string serverName) + { + return operations.ListByServerAsync(resourceGroupName, serverName).GetAwaiter().GetResult(); + } + + /// + /// Gets the private link resources for MariaDB server. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByServerAsync(this IPrivateLinkResourcesOperations operations, string resourceGroupName, string serverName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByServerWithHttpMessagesAsync(resourceGroupName, serverName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets a private link resource for MariaDB server. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The name of the private link resource. + /// + public static PrivateLinkResource Get(this IPrivateLinkResourcesOperations operations, string resourceGroupName, string serverName, string groupName) + { + return operations.GetAsync(resourceGroupName, serverName, groupName).GetAwaiter().GetResult(); + } + + /// + /// Gets a private link resource for MariaDB server. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The name of the private link resource. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IPrivateLinkResourcesOperations operations, string resourceGroupName, string serverName, string groupName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, serverName, groupName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets the private link resources for MariaDB server. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListByServerNext(this IPrivateLinkResourcesOperations operations, string nextPageLink) + { + return operations.ListByServerNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Gets the private link resources for MariaDB server. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByServerNextAsync(this IPrivateLinkResourcesOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByServerNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/QueryTextsOperations.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/QueryTextsOperations.cs new file mode 100644 index 000000000000..66be613c6733 --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/QueryTextsOperations.cs @@ -0,0 +1,682 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// QueryTextsOperations operations. + /// + internal partial class QueryTextsOperations : IServiceOperations, IQueryTextsOperations + { + /// + /// Initializes a new instance of the QueryTextsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal QueryTextsOperations(MariaDBManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the MariaDBManagementClient + /// + public MariaDBManagementClient Client { get; private set; } + + /// + /// Retrieve the Query-Store query texts for the queryId. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The Query-Store query identifier. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetWithHttpMessagesAsync(string resourceGroupName, string serverName, string queryId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (serverName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "serverName"); + } + if (queryId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "queryId"); + } + string apiVersion = "2018-06-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("serverName", serverName); + tracingParameters.Add("queryId", queryId); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMariaDB/servers/{serverName}/queryTexts/{queryId}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{serverName}", System.Uri.EscapeDataString(serverName)); + _url = _url.Replace("{queryId}", System.Uri.EscapeDataString(queryId)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Retrieve the Query-Store query texts for specified queryIds. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The query identifiers + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListByServerWithHttpMessagesAsync(string resourceGroupName, string serverName, IList queryIds, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (serverName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "serverName"); + } + if (queryIds == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "queryIds"); + } + string apiVersion = "2018-06-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("serverName", serverName); + tracingParameters.Add("queryIds", queryIds); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByServer", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMariaDB/servers/{serverName}/queryTexts").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{serverName}", System.Uri.EscapeDataString(serverName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (queryIds != null) + { + if (queryIds.Count == 0) + { + _queryParameters.Add(string.Format("queryIds={0}", System.Uri.EscapeDataString(string.Empty))); + } + else + { + foreach (var _item in queryIds) + { + _queryParameters.Add(string.Format("queryIds={0}", System.Uri.EscapeDataString("" + _item))); + } + } + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Retrieve the Query-Store query texts for specified queryIds. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListByServerNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByServerNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/QueryTextsOperationsExtensions.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/QueryTextsOperationsExtensions.cs new file mode 100644 index 000000000000..b8eccb93c9f0 --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/QueryTextsOperationsExtensions.cs @@ -0,0 +1,153 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for QueryTextsOperations. + /// + public static partial class QueryTextsOperationsExtensions + { + /// + /// Retrieve the Query-Store query texts for the queryId. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The Query-Store query identifier. + /// + public static QueryText Get(this IQueryTextsOperations operations, string resourceGroupName, string serverName, string queryId) + { + return operations.GetAsync(resourceGroupName, serverName, queryId).GetAwaiter().GetResult(); + } + + /// + /// Retrieve the Query-Store query texts for the queryId. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The Query-Store query identifier. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IQueryTextsOperations operations, string resourceGroupName, string serverName, string queryId, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, serverName, queryId, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Retrieve the Query-Store query texts for specified queryIds. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The query identifiers + /// + public static IPage ListByServer(this IQueryTextsOperations operations, string resourceGroupName, string serverName, IList queryIds) + { + return operations.ListByServerAsync(resourceGroupName, serverName, queryIds).GetAwaiter().GetResult(); + } + + /// + /// Retrieve the Query-Store query texts for specified queryIds. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The query identifiers + /// + /// + /// The cancellation token. + /// + public static async Task> ListByServerAsync(this IQueryTextsOperations operations, string resourceGroupName, string serverName, IList queryIds, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByServerWithHttpMessagesAsync(resourceGroupName, serverName, queryIds, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Retrieve the Query-Store query texts for specified queryIds. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListByServerNext(this IQueryTextsOperations operations, string nextPageLink) + { + return operations.ListByServerNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Retrieve the Query-Store query texts for specified queryIds. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByServerNextAsync(this IQueryTextsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByServerNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/RecommendedActionsOperations.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/RecommendedActionsOperations.cs new file mode 100644 index 000000000000..1013bf0711bc --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/RecommendedActionsOperations.cs @@ -0,0 +1,686 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// RecommendedActionsOperations operations. + /// + internal partial class RecommendedActionsOperations : IServiceOperations, IRecommendedActionsOperations + { + /// + /// Initializes a new instance of the RecommendedActionsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal RecommendedActionsOperations(MariaDBManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the MariaDBManagementClient + /// + public MariaDBManagementClient Client { get; private set; } + + /// + /// Retrieve recommended actions from the advisor. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The advisor name for recommendation action. + /// + /// + /// The recommended action name. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetWithHttpMessagesAsync(string resourceGroupName, string serverName, string advisorName, string recommendedActionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (serverName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "serverName"); + } + if (advisorName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "advisorName"); + } + if (recommendedActionName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "recommendedActionName"); + } + string apiVersion = "2018-06-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("serverName", serverName); + tracingParameters.Add("advisorName", advisorName); + tracingParameters.Add("recommendedActionName", recommendedActionName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMariaDB/servers/{serverName}/advisors/{advisorName}/recommendedActions/{recommendedActionName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{serverName}", System.Uri.EscapeDataString(serverName)); + _url = _url.Replace("{advisorName}", System.Uri.EscapeDataString(advisorName)); + _url = _url.Replace("{recommendedActionName}", System.Uri.EscapeDataString(recommendedActionName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Retrieve recommended actions from the advisor. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The advisor name for recommendation action. + /// + /// + /// The recommendation action session identifier. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListByServerWithHttpMessagesAsync(string resourceGroupName, string serverName, string advisorName, string sessionId = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (serverName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "serverName"); + } + if (advisorName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "advisorName"); + } + string apiVersion = "2018-06-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("serverName", serverName); + tracingParameters.Add("advisorName", advisorName); + tracingParameters.Add("sessionId", sessionId); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByServer", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMariaDB/servers/{serverName}/advisors/{advisorName}/recommendedActions").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{serverName}", System.Uri.EscapeDataString(serverName)); + _url = _url.Replace("{advisorName}", System.Uri.EscapeDataString(advisorName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (sessionId != null) + { + _queryParameters.Add(string.Format("sessionId={0}", System.Uri.EscapeDataString(sessionId))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Retrieve recommended actions from the advisor. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListByServerNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByServerNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/RecommendedActionsOperationsExtensions.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/RecommendedActionsOperationsExtensions.cs new file mode 100644 index 000000000000..0c7c4487d593 --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/RecommendedActionsOperationsExtensions.cs @@ -0,0 +1,163 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for RecommendedActionsOperations. + /// + public static partial class RecommendedActionsOperationsExtensions + { + /// + /// Retrieve recommended actions from the advisor. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The advisor name for recommendation action. + /// + /// + /// The recommended action name. + /// + public static RecommendationAction Get(this IRecommendedActionsOperations operations, string resourceGroupName, string serverName, string advisorName, string recommendedActionName) + { + return operations.GetAsync(resourceGroupName, serverName, advisorName, recommendedActionName).GetAwaiter().GetResult(); + } + + /// + /// Retrieve recommended actions from the advisor. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The advisor name for recommendation action. + /// + /// + /// The recommended action name. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IRecommendedActionsOperations operations, string resourceGroupName, string serverName, string advisorName, string recommendedActionName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, serverName, advisorName, recommendedActionName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Retrieve recommended actions from the advisor. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The advisor name for recommendation action. + /// + /// + /// The recommendation action session identifier. + /// + public static IPage ListByServer(this IRecommendedActionsOperations operations, string resourceGroupName, string serverName, string advisorName, string sessionId = default(string)) + { + return operations.ListByServerAsync(resourceGroupName, serverName, advisorName, sessionId).GetAwaiter().GetResult(); + } + + /// + /// Retrieve recommended actions from the advisor. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The advisor name for recommendation action. + /// + /// + /// The recommendation action session identifier. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByServerAsync(this IRecommendedActionsOperations operations, string resourceGroupName, string serverName, string advisorName, string sessionId = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByServerWithHttpMessagesAsync(resourceGroupName, serverName, advisorName, sessionId, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Retrieve recommended actions from the advisor. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListByServerNext(this IRecommendedActionsOperations operations, string nextPageLink) + { + return operations.ListByServerNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Retrieve recommended actions from the advisor. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByServerNextAsync(this IRecommendedActionsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByServerNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/RecoverableServersOperations.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/RecoverableServersOperations.cs new file mode 100644 index 000000000000..39be86408767 --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/RecoverableServersOperations.cs @@ -0,0 +1,266 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// RecoverableServersOperations operations. + /// + internal partial class RecoverableServersOperations : IServiceOperations, IRecoverableServersOperations + { + /// + /// Initializes a new instance of the RecoverableServersOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal RecoverableServersOperations(MariaDBManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the MariaDBManagementClient + /// + public MariaDBManagementClient Client { get; private set; } + + /// + /// Gets a recoverable MariaDB Server. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetWithHttpMessagesAsync(string resourceGroupName, string serverName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (serverName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "serverName"); + } + string apiVersion = "2018-06-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("serverName", serverName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMariaDB/servers/{serverName}/recoverableServers").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{serverName}", System.Uri.EscapeDataString(serverName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/RecoverableServersOperationsExtensions.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/RecoverableServersOperationsExtensions.cs new file mode 100644 index 000000000000..96e331067ff1 --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/RecoverableServersOperationsExtensions.cs @@ -0,0 +1,65 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for RecoverableServersOperations. + /// + public static partial class RecoverableServersOperationsExtensions + { + /// + /// Gets a recoverable MariaDB Server. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + public static RecoverableServerResource Get(this IRecoverableServersOperations operations, string resourceGroupName, string serverName) + { + return operations.GetAsync(resourceGroupName, serverName).GetAwaiter().GetResult(); + } + + /// + /// Gets a recoverable MariaDB Server. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IRecoverableServersOperations operations, string resourceGroupName, string serverName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, serverName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/ReplicasOperations.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/ReplicasOperations.cs new file mode 100644 index 000000000000..5b2e8706e7e9 --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/ReplicasOperations.cs @@ -0,0 +1,266 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// ReplicasOperations operations. + /// + internal partial class ReplicasOperations : IServiceOperations, IReplicasOperations + { + /// + /// Initializes a new instance of the ReplicasOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal ReplicasOperations(MariaDBManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the MariaDBManagementClient + /// + public MariaDBManagementClient Client { get; private set; } + + /// + /// List all the replicas for a given server. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListByServerWithHttpMessagesAsync(string resourceGroupName, string serverName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (serverName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "serverName"); + } + string apiVersion = "2018-06-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("serverName", serverName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByServer", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMariaDB/servers/{serverName}/replicas").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{serverName}", System.Uri.EscapeDataString(serverName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/ReplicasOperationsExtensions.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/ReplicasOperationsExtensions.cs new file mode 100644 index 000000000000..0dd743b25b83 --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/ReplicasOperationsExtensions.cs @@ -0,0 +1,67 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for ReplicasOperations. + /// + public static partial class ReplicasOperationsExtensions + { + /// + /// List all the replicas for a given server. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + public static IEnumerable ListByServer(this IReplicasOperations operations, string resourceGroupName, string serverName) + { + return operations.ListByServerAsync(resourceGroupName, serverName).GetAwaiter().GetResult(); + } + + /// + /// List all the replicas for a given server. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByServerAsync(this IReplicasOperations operations, string resourceGroupName, string serverName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByServerWithHttpMessagesAsync(resourceGroupName, serverName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/SdkInfo_MariaDBManagementClient.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/SdkInfo_MariaDBManagementClient.cs new file mode 100644 index 000000000000..a383196e8980 --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/SdkInfo_MariaDBManagementClient.cs @@ -0,0 +1,52 @@ + +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB +{ + using System; + using System.Collections.Generic; + using System.Linq; + + internal static partial class SdkInfo + { + public static IEnumerable> ApiInfo_MariaDBManagementClient + { + get + { + return new Tuple[] + { + new Tuple("DBforMariaDB", "Advisors", "2018-06-01"), + new Tuple("DBforMariaDB", "CheckNameAvailability", "2018-06-01"), + new Tuple("DBforMariaDB", "Configurations", "2018-06-01"), + new Tuple("DBforMariaDB", "CreateRecommendedActionSession", "2018-06-01"), + new Tuple("DBforMariaDB", "Databases", "2018-06-01"), + new Tuple("DBforMariaDB", "FirewallRules", "2018-06-01"), + new Tuple("DBforMariaDB", "LocationBasedPerformanceTier", "2018-06-01"), + new Tuple("DBforMariaDB", "LocationBasedRecommendedActionSessionsOperationStatus", "2018-06-01"), + new Tuple("DBforMariaDB", "LocationBasedRecommendedActionSessionsResult", "2018-06-01"), + new Tuple("DBforMariaDB", "LogFiles", "2018-06-01"), + new Tuple("DBforMariaDB", "Operations", "2018-06-01"), + new Tuple("DBforMariaDB", "PrivateEndpointConnections", "2018-06-01"), + new Tuple("DBforMariaDB", "PrivateLinkResources", "2018-06-01"), + new Tuple("DBforMariaDB", "QueryTexts", "2018-06-01"), + new Tuple("DBforMariaDB", "RecommendedActions", "2018-06-01"), + new Tuple("DBforMariaDB", "RecoverableServers", "2018-06-01"), + new Tuple("DBforMariaDB", "Replicas", "2018-06-01"), + new Tuple("DBforMariaDB", "ResetQueryPerformanceInsightData", "2018-06-01"), + new Tuple("DBforMariaDB", "ServerBasedPerformanceTier", "2018-06-01"), + new Tuple("DBforMariaDB", "ServerParameters", "2018-06-01"), + new Tuple("DBforMariaDB", "ServerSecurityAlertPolicies", "2018-06-01"), + new Tuple("DBforMariaDB", "Servers", "2018-06-01"), + new Tuple("DBforMariaDB", "Servers", "2020-01-01"), + new Tuple("DBforMariaDB", "TopQueryStatistics", "2018-06-01"), + new Tuple("DBforMariaDB", "VirtualNetworkRules", "2018-06-01"), + new Tuple("DBforMariaDB", "WaitStatistics", "2018-06-01"), + }.AsEnumerable(); + } + } + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/ServerBasedPerformanceTierOperations.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/ServerBasedPerformanceTierOperations.cs new file mode 100644 index 000000000000..859655dae23c --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/ServerBasedPerformanceTierOperations.cs @@ -0,0 +1,266 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// ServerBasedPerformanceTierOperations operations. + /// + internal partial class ServerBasedPerformanceTierOperations : IServiceOperations, IServerBasedPerformanceTierOperations + { + /// + /// Initializes a new instance of the ServerBasedPerformanceTierOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal ServerBasedPerformanceTierOperations(MariaDBManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the MariaDBManagementClient + /// + public MariaDBManagementClient Client { get; private set; } + + /// + /// List all the performance tiers for a MariaDB server. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListWithHttpMessagesAsync(string resourceGroupName, string serverName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (serverName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "serverName"); + } + string apiVersion = "2018-06-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("serverName", serverName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMariaDB/servers/{serverName}/performanceTiers").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{serverName}", System.Uri.EscapeDataString(serverName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/ServerBasedPerformanceTierOperationsExtensions.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/ServerBasedPerformanceTierOperationsExtensions.cs new file mode 100644 index 000000000000..2709412d18c9 --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/ServerBasedPerformanceTierOperationsExtensions.cs @@ -0,0 +1,67 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for ServerBasedPerformanceTierOperations. + /// + public static partial class ServerBasedPerformanceTierOperationsExtensions + { + /// + /// List all the performance tiers for a MariaDB server. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + public static IEnumerable List(this IServerBasedPerformanceTierOperations operations, string resourceGroupName, string serverName) + { + return operations.ListAsync(resourceGroupName, serverName).GetAwaiter().GetResult(); + } + + /// + /// List all the performance tiers for a MariaDB server. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAsync(this IServerBasedPerformanceTierOperations operations, string resourceGroupName, string serverName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(resourceGroupName, serverName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/ServerParametersOperations.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/ServerParametersOperations.cs new file mode 100644 index 000000000000..4cb45b18dcf7 --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/ServerParametersOperations.cs @@ -0,0 +1,305 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// ServerParametersOperations operations. + /// + internal partial class ServerParametersOperations : IServiceOperations, IServerParametersOperations + { + /// + /// Initializes a new instance of the ServerParametersOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal ServerParametersOperations(MariaDBManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the MariaDBManagementClient + /// + public MariaDBManagementClient Client { get; private set; } + + /// + /// Update a list of configurations in a given server. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The parameters for updating a list of server configuration. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> ListUpdateConfigurationsWithHttpMessagesAsync(string resourceGroupName, string serverName, ConfigurationListResult value, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginListUpdateConfigurationsWithHttpMessagesAsync(resourceGroupName, serverName, value, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Update a list of configurations in a given server. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The parameters for updating a list of server configuration. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> BeginListUpdateConfigurationsWithHttpMessagesAsync(string resourceGroupName, string serverName, ConfigurationListResult value, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (serverName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "serverName"); + } + if (value == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "value"); + } + string apiVersion = "2018-06-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("serverName", serverName); + tracingParameters.Add("value", value); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginListUpdateConfigurations", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMariaDB/servers/{serverName}/updateConfigurations").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{serverName}", System.Uri.EscapeDataString(serverName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(value != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(value, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 202) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/ServerParametersOperationsExtensions.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/ServerParametersOperationsExtensions.cs new file mode 100644 index 000000000000..6a50fcc9bfde --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/ServerParametersOperationsExtensions.cs @@ -0,0 +1,117 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for ServerParametersOperations. + /// + public static partial class ServerParametersOperationsExtensions + { + /// + /// Update a list of configurations in a given server. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The parameters for updating a list of server configuration. + /// + public static ConfigurationListResult ListUpdateConfigurations(this IServerParametersOperations operations, string resourceGroupName, string serverName, ConfigurationListResult value) + { + return operations.ListUpdateConfigurationsAsync(resourceGroupName, serverName, value).GetAwaiter().GetResult(); + } + + /// + /// Update a list of configurations in a given server. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The parameters for updating a list of server configuration. + /// + /// + /// The cancellation token. + /// + public static async Task ListUpdateConfigurationsAsync(this IServerParametersOperations operations, string resourceGroupName, string serverName, ConfigurationListResult value, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListUpdateConfigurationsWithHttpMessagesAsync(resourceGroupName, serverName, value, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Update a list of configurations in a given server. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The parameters for updating a list of server configuration. + /// + public static ConfigurationListResult BeginListUpdateConfigurations(this IServerParametersOperations operations, string resourceGroupName, string serverName, ConfigurationListResult value) + { + return operations.BeginListUpdateConfigurationsAsync(resourceGroupName, serverName, value).GetAwaiter().GetResult(); + } + + /// + /// Update a list of configurations in a given server. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The parameters for updating a list of server configuration. + /// + /// + /// The cancellation token. + /// + public static async Task BeginListUpdateConfigurationsAsync(this IServerParametersOperations operations, string resourceGroupName, string serverName, ConfigurationListResult value, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginListUpdateConfigurationsWithHttpMessagesAsync(resourceGroupName, serverName, value, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/ServerSecurityAlertPoliciesOperations.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/ServerSecurityAlertPoliciesOperations.cs new file mode 100644 index 000000000000..33fea0a463dc --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/ServerSecurityAlertPoliciesOperations.cs @@ -0,0 +1,912 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// ServerSecurityAlertPoliciesOperations operations. + /// + internal partial class ServerSecurityAlertPoliciesOperations : IServiceOperations, IServerSecurityAlertPoliciesOperations + { + /// + /// Initializes a new instance of the ServerSecurityAlertPoliciesOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal ServerSecurityAlertPoliciesOperations(MariaDBManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the MariaDBManagementClient + /// + public MariaDBManagementClient Client { get; private set; } + + /// + /// Get a server's security alert policy. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetWithHttpMessagesAsync(string resourceGroupName, string serverName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (serverName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "serverName"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + string securityAlertPolicyName = "Default"; + string apiVersion = "2018-06-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("serverName", serverName); + tracingParameters.Add("securityAlertPolicyName", securityAlertPolicyName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMariaDB/servers/{serverName}/securityAlertPolicies/{securityAlertPolicyName}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{serverName}", System.Uri.EscapeDataString(serverName)); + _url = _url.Replace("{securityAlertPolicyName}", System.Uri.EscapeDataString(securityAlertPolicyName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Creates or updates a threat detection policy. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The server security alert policy. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string serverName, ServerSecurityAlertPolicy parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, serverName, parameters, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get the server's threat detection policies. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListByServerWithHttpMessagesAsync(string resourceGroupName, string serverName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (serverName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "serverName"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + string apiVersion = "2018-06-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("serverName", serverName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByServer", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMariaDB/servers/{serverName}/securityAlertPolicies").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{serverName}", System.Uri.EscapeDataString(serverName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Creates or updates a threat detection policy. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The server security alert policy. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> BeginCreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string serverName, ServerSecurityAlertPolicy parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (serverName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "serverName"); + } + if (parameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); + } + if (parameters != null) + { + parameters.Validate(); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + string securityAlertPolicyName = "Default"; + string apiVersion = "2018-06-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("serverName", serverName); + tracingParameters.Add("securityAlertPolicyName", securityAlertPolicyName); + tracingParameters.Add("parameters", parameters); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginCreateOrUpdate", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMariaDB/servers/{serverName}/securityAlertPolicies/{securityAlertPolicyName}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{serverName}", System.Uri.EscapeDataString(serverName)); + _url = _url.Replace("{securityAlertPolicyName}", System.Uri.EscapeDataString(securityAlertPolicyName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PUT"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(parameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 202) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Get the server's threat detection policies. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListByServerNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByServerNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/ServerSecurityAlertPoliciesOperationsExtensions.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/ServerSecurityAlertPoliciesOperationsExtensions.cs new file mode 100644 index 000000000000..b0c7b5473c8e --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/ServerSecurityAlertPoliciesOperationsExtensions.cs @@ -0,0 +1,231 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for ServerSecurityAlertPoliciesOperations. + /// + public static partial class ServerSecurityAlertPoliciesOperationsExtensions + { + /// + /// Get a server's security alert policy. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + public static ServerSecurityAlertPolicy Get(this IServerSecurityAlertPoliciesOperations operations, string resourceGroupName, string serverName) + { + return operations.GetAsync(resourceGroupName, serverName).GetAwaiter().GetResult(); + } + + /// + /// Get a server's security alert policy. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IServerSecurityAlertPoliciesOperations operations, string resourceGroupName, string serverName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, serverName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Creates or updates a threat detection policy. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The server security alert policy. + /// + public static ServerSecurityAlertPolicy CreateOrUpdate(this IServerSecurityAlertPoliciesOperations operations, string resourceGroupName, string serverName, ServerSecurityAlertPolicy parameters) + { + return operations.CreateOrUpdateAsync(resourceGroupName, serverName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Creates or updates a threat detection policy. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The server security alert policy. + /// + /// + /// The cancellation token. + /// + public static async Task CreateOrUpdateAsync(this IServerSecurityAlertPoliciesOperations operations, string resourceGroupName, string serverName, ServerSecurityAlertPolicy parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, serverName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get the server's threat detection policies. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + public static IPage ListByServer(this IServerSecurityAlertPoliciesOperations operations, string resourceGroupName, string serverName) + { + return operations.ListByServerAsync(resourceGroupName, serverName).GetAwaiter().GetResult(); + } + + /// + /// Get the server's threat detection policies. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByServerAsync(this IServerSecurityAlertPoliciesOperations operations, string resourceGroupName, string serverName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByServerWithHttpMessagesAsync(resourceGroupName, serverName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Creates or updates a threat detection policy. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The server security alert policy. + /// + public static ServerSecurityAlertPolicy BeginCreateOrUpdate(this IServerSecurityAlertPoliciesOperations operations, string resourceGroupName, string serverName, ServerSecurityAlertPolicy parameters) + { + return operations.BeginCreateOrUpdateAsync(resourceGroupName, serverName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Creates or updates a threat detection policy. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The server security alert policy. + /// + /// + /// The cancellation token. + /// + public static async Task BeginCreateOrUpdateAsync(this IServerSecurityAlertPoliciesOperations operations, string resourceGroupName, string serverName, ServerSecurityAlertPolicy parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, serverName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get the server's threat detection policies. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListByServerNext(this IServerSecurityAlertPoliciesOperations operations, string nextPageLink) + { + return operations.ListByServerNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Get the server's threat detection policies. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByServerNextAsync(this IServerSecurityAlertPoliciesOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByServerNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/ServersOperations.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/ServersOperations.cs new file mode 100644 index 000000000000..01f0a9fcb729 --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/ServersOperations.cs @@ -0,0 +1,2032 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// ServersOperations operations. + /// + internal partial class ServersOperations : IServiceOperations, IServersOperations + { + /// + /// Initializes a new instance of the ServersOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal ServersOperations(MariaDBManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the MariaDBManagementClient + /// + public MariaDBManagementClient Client { get; private set; } + + /// + /// Creates a new server or updates an existing server. The update action will + /// overwrite the existing server. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The required parameters for creating or updating a server. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> CreateWithHttpMessagesAsync(string resourceGroupName, string serverName, ServerForCreate parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginCreateWithHttpMessagesAsync(resourceGroupName, serverName, parameters, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Updates an existing server. The request body can contain one to many of the + /// properties present in the normal server definition. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The required parameters for updating a server. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> UpdateWithHttpMessagesAsync(string resourceGroupName, string serverName, ServerUpdateParameters parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginUpdateWithHttpMessagesAsync(resourceGroupName, serverName, parameters, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Deletes a server. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task DeleteWithHttpMessagesAsync(string resourceGroupName, string serverName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginDeleteWithHttpMessagesAsync(resourceGroupName, serverName, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets information about a server. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetWithHttpMessagesAsync(string resourceGroupName, string serverName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (serverName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "serverName"); + } + string apiVersion = "2018-06-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("serverName", serverName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMariaDB/servers/{serverName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{serverName}", System.Uri.EscapeDataString(serverName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// List all the servers in a given resource group. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListByResourceGroupWithHttpMessagesAsync(string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + string apiVersion = "2018-06-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByResourceGroup", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMariaDB/servers").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// List all the servers in a given subscription. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + string apiVersion = "2018-06-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.DBforMariaDB/servers").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Restarts a server. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task RestartWithHttpMessagesAsync(string resourceGroupName, string serverName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginRestartWithHttpMessagesAsync(resourceGroupName, serverName, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Starts a stopped server. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task StartWithHttpMessagesAsync(string resourceGroupName, string serverName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginStartWithHttpMessagesAsync(resourceGroupName, serverName, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Stops a running server. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task StopWithHttpMessagesAsync(string resourceGroupName, string serverName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginStopWithHttpMessagesAsync(resourceGroupName, serverName, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Creates a new server or updates an existing server. The update action will + /// overwrite the existing server. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The required parameters for creating or updating a server. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> BeginCreateWithHttpMessagesAsync(string resourceGroupName, string serverName, ServerForCreate parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (serverName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "serverName"); + } + if (parameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); + } + if (parameters != null) + { + parameters.Validate(); + } + string apiVersion = "2018-06-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("serverName", serverName); + tracingParameters.Add("parameters", parameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginCreate", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMariaDB/servers/{serverName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{serverName}", System.Uri.EscapeDataString(serverName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PUT"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(parameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 201 && (int)_statusCode != 202) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + // Deserialize Response + if ((int)_statusCode == 201) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Updates an existing server. The request body can contain one to many of the + /// properties present in the normal server definition. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The required parameters for updating a server. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> BeginUpdateWithHttpMessagesAsync(string resourceGroupName, string serverName, ServerUpdateParameters parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (serverName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "serverName"); + } + if (parameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); + } + string apiVersion = "2018-06-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("serverName", serverName); + tracingParameters.Add("parameters", parameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginUpdate", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMariaDB/servers/{serverName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{serverName}", System.Uri.EscapeDataString(serverName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PATCH"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(parameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 202) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Deletes a server. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string serverName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (serverName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "serverName"); + } + string apiVersion = "2018-06-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("serverName", serverName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginDelete", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMariaDB/servers/{serverName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{serverName}", System.Uri.EscapeDataString(serverName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("DELETE"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 202 && (int)_statusCode != 204) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Restarts a server. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task BeginRestartWithHttpMessagesAsync(string resourceGroupName, string serverName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (serverName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "serverName"); + } + string apiVersion = "2018-06-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("serverName", serverName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginRestart", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMariaDB/servers/{serverName}/restart").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{serverName}", System.Uri.EscapeDataString(serverName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 202) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Starts a stopped server. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task BeginStartWithHttpMessagesAsync(string resourceGroupName, string serverName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (serverName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "serverName"); + } + string apiVersion = "2020-01-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("serverName", serverName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginStart", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMariaDB/servers/{serverName}/start").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{serverName}", System.Uri.EscapeDataString(serverName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 202) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Stops a running server. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task BeginStopWithHttpMessagesAsync(string resourceGroupName, string serverName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (serverName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "serverName"); + } + string apiVersion = "2020-01-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("serverName", serverName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginStop", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMariaDB/servers/{serverName}/stop").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{serverName}", System.Uri.EscapeDataString(serverName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 202) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/ServersOperationsExtensions.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/ServersOperationsExtensions.cs new file mode 100644 index 000000000000..0b979e9b2f4c --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/ServersOperationsExtensions.cs @@ -0,0 +1,617 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for ServersOperations. + /// + public static partial class ServersOperationsExtensions + { + /// + /// Creates a new server or updates an existing server. The update action will + /// overwrite the existing server. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The required parameters for creating or updating a server. + /// + public static Server Create(this IServersOperations operations, string resourceGroupName, string serverName, ServerForCreate parameters) + { + return operations.CreateAsync(resourceGroupName, serverName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Creates a new server or updates an existing server. The update action will + /// overwrite the existing server. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The required parameters for creating or updating a server. + /// + /// + /// The cancellation token. + /// + public static async Task CreateAsync(this IServersOperations operations, string resourceGroupName, string serverName, ServerForCreate parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateWithHttpMessagesAsync(resourceGroupName, serverName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Updates an existing server. The request body can contain one to many of the + /// properties present in the normal server definition. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The required parameters for updating a server. + /// + public static Server Update(this IServersOperations operations, string resourceGroupName, string serverName, ServerUpdateParameters parameters) + { + return operations.UpdateAsync(resourceGroupName, serverName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Updates an existing server. The request body can contain one to many of the + /// properties present in the normal server definition. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The required parameters for updating a server. + /// + /// + /// The cancellation token. + /// + public static async Task UpdateAsync(this IServersOperations operations, string resourceGroupName, string serverName, ServerUpdateParameters parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.UpdateWithHttpMessagesAsync(resourceGroupName, serverName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes a server. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + public static void Delete(this IServersOperations operations, string resourceGroupName, string serverName) + { + operations.DeleteAsync(resourceGroupName, serverName).GetAwaiter().GetResult(); + } + + /// + /// Deletes a server. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this IServersOperations operations, string resourceGroupName, string serverName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, serverName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Gets information about a server. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + public static Server Get(this IServersOperations operations, string resourceGroupName, string serverName) + { + return operations.GetAsync(resourceGroupName, serverName).GetAwaiter().GetResult(); + } + + /// + /// Gets information about a server. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IServersOperations operations, string resourceGroupName, string serverName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, serverName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// List all the servers in a given resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + public static IEnumerable ListByResourceGroup(this IServersOperations operations, string resourceGroupName) + { + return operations.ListByResourceGroupAsync(resourceGroupName).GetAwaiter().GetResult(); + } + + /// + /// List all the servers in a given resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByResourceGroupAsync(this IServersOperations operations, string resourceGroupName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByResourceGroupWithHttpMessagesAsync(resourceGroupName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// List all the servers in a given subscription. + /// + /// + /// The operations group for this extension method. + /// + public static IEnumerable List(this IServersOperations operations) + { + return operations.ListAsync().GetAwaiter().GetResult(); + } + + /// + /// List all the servers in a given subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAsync(this IServersOperations operations, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Restarts a server. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + public static void Restart(this IServersOperations operations, string resourceGroupName, string serverName) + { + operations.RestartAsync(resourceGroupName, serverName).GetAwaiter().GetResult(); + } + + /// + /// Restarts a server. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The cancellation token. + /// + public static async Task RestartAsync(this IServersOperations operations, string resourceGroupName, string serverName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.RestartWithHttpMessagesAsync(resourceGroupName, serverName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Starts a stopped server. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + public static void Start(this IServersOperations operations, string resourceGroupName, string serverName) + { + operations.StartAsync(resourceGroupName, serverName).GetAwaiter().GetResult(); + } + + /// + /// Starts a stopped server. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The cancellation token. + /// + public static async Task StartAsync(this IServersOperations operations, string resourceGroupName, string serverName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.StartWithHttpMessagesAsync(resourceGroupName, serverName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Stops a running server. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + public static void Stop(this IServersOperations operations, string resourceGroupName, string serverName) + { + operations.StopAsync(resourceGroupName, serverName).GetAwaiter().GetResult(); + } + + /// + /// Stops a running server. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The cancellation token. + /// + public static async Task StopAsync(this IServersOperations operations, string resourceGroupName, string serverName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.StopWithHttpMessagesAsync(resourceGroupName, serverName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Creates a new server or updates an existing server. The update action will + /// overwrite the existing server. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The required parameters for creating or updating a server. + /// + public static Server BeginCreate(this IServersOperations operations, string resourceGroupName, string serverName, ServerForCreate parameters) + { + return operations.BeginCreateAsync(resourceGroupName, serverName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Creates a new server or updates an existing server. The update action will + /// overwrite the existing server. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The required parameters for creating or updating a server. + /// + /// + /// The cancellation token. + /// + public static async Task BeginCreateAsync(this IServersOperations operations, string resourceGroupName, string serverName, ServerForCreate parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginCreateWithHttpMessagesAsync(resourceGroupName, serverName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Updates an existing server. The request body can contain one to many of the + /// properties present in the normal server definition. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The required parameters for updating a server. + /// + public static Server BeginUpdate(this IServersOperations operations, string resourceGroupName, string serverName, ServerUpdateParameters parameters) + { + return operations.BeginUpdateAsync(resourceGroupName, serverName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Updates an existing server. The request body can contain one to many of the + /// properties present in the normal server definition. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The required parameters for updating a server. + /// + /// + /// The cancellation token. + /// + public static async Task BeginUpdateAsync(this IServersOperations operations, string resourceGroupName, string serverName, ServerUpdateParameters parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginUpdateWithHttpMessagesAsync(resourceGroupName, serverName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes a server. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + public static void BeginDelete(this IServersOperations operations, string resourceGroupName, string serverName) + { + operations.BeginDeleteAsync(resourceGroupName, serverName).GetAwaiter().GetResult(); + } + + /// + /// Deletes a server. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The cancellation token. + /// + public static async Task BeginDeleteAsync(this IServersOperations operations, string resourceGroupName, string serverName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.BeginDeleteWithHttpMessagesAsync(resourceGroupName, serverName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Restarts a server. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + public static void BeginRestart(this IServersOperations operations, string resourceGroupName, string serverName) + { + operations.BeginRestartAsync(resourceGroupName, serverName).GetAwaiter().GetResult(); + } + + /// + /// Restarts a server. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The cancellation token. + /// + public static async Task BeginRestartAsync(this IServersOperations operations, string resourceGroupName, string serverName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.BeginRestartWithHttpMessagesAsync(resourceGroupName, serverName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Starts a stopped server. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + public static void BeginStart(this IServersOperations operations, string resourceGroupName, string serverName) + { + operations.BeginStartAsync(resourceGroupName, serverName).GetAwaiter().GetResult(); + } + + /// + /// Starts a stopped server. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The cancellation token. + /// + public static async Task BeginStartAsync(this IServersOperations operations, string resourceGroupName, string serverName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.BeginStartWithHttpMessagesAsync(resourceGroupName, serverName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Stops a running server. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + public static void BeginStop(this IServersOperations operations, string resourceGroupName, string serverName) + { + operations.BeginStopAsync(resourceGroupName, serverName).GetAwaiter().GetResult(); + } + + /// + /// Stops a running server. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The cancellation token. + /// + public static async Task BeginStopAsync(this IServersOperations operations, string resourceGroupName, string serverName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.BeginStopWithHttpMessagesAsync(resourceGroupName, serverName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/TopQueryStatisticsOperations.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/TopQueryStatisticsOperations.cs new file mode 100644 index 000000000000..bd4cd94a9eac --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/TopQueryStatisticsOperations.cs @@ -0,0 +1,678 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// TopQueryStatisticsOperations operations. + /// + internal partial class TopQueryStatisticsOperations : IServiceOperations, ITopQueryStatisticsOperations + { + /// + /// Initializes a new instance of the TopQueryStatisticsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal TopQueryStatisticsOperations(MariaDBManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the MariaDBManagementClient + /// + public MariaDBManagementClient Client { get; private set; } + + /// + /// Retrieve the query statistic for specified identifier. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The Query Statistic identifier. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetWithHttpMessagesAsync(string resourceGroupName, string serverName, string queryStatisticId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (serverName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "serverName"); + } + if (queryStatisticId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "queryStatisticId"); + } + string apiVersion = "2018-06-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("serverName", serverName); + tracingParameters.Add("queryStatisticId", queryStatisticId); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMariaDB/servers/{serverName}/topQueryStatistics/{queryStatisticId}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{serverName}", System.Uri.EscapeDataString(serverName)); + _url = _url.Replace("{queryStatisticId}", System.Uri.EscapeDataString(queryStatisticId)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Retrieve the Query-Store top queries for specified metric and aggregation. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The required parameters for retrieving top query statistics. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListByServerWithHttpMessagesAsync(string resourceGroupName, string serverName, TopQueryStatisticsInput parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (serverName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "serverName"); + } + if (parameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); + } + if (parameters != null) + { + parameters.Validate(); + } + string apiVersion = "2018-06-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("serverName", serverName); + tracingParameters.Add("parameters", parameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByServer", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMariaDB/servers/{serverName}/topQueryStatistics").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{serverName}", System.Uri.EscapeDataString(serverName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(parameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Retrieve the Query-Store top queries for specified metric and aggregation. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListByServerNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByServerNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/TopQueryStatisticsOperationsExtensions.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/TopQueryStatisticsOperationsExtensions.cs new file mode 100644 index 000000000000..41edd5e3c8f6 --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/TopQueryStatisticsOperationsExtensions.cs @@ -0,0 +1,151 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for TopQueryStatisticsOperations. + /// + public static partial class TopQueryStatisticsOperationsExtensions + { + /// + /// Retrieve the query statistic for specified identifier. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The Query Statistic identifier. + /// + public static QueryStatistic Get(this ITopQueryStatisticsOperations operations, string resourceGroupName, string serverName, string queryStatisticId) + { + return operations.GetAsync(resourceGroupName, serverName, queryStatisticId).GetAwaiter().GetResult(); + } + + /// + /// Retrieve the query statistic for specified identifier. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The Query Statistic identifier. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this ITopQueryStatisticsOperations operations, string resourceGroupName, string serverName, string queryStatisticId, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, serverName, queryStatisticId, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Retrieve the Query-Store top queries for specified metric and aggregation. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The required parameters for retrieving top query statistics. + /// + public static IPage ListByServer(this ITopQueryStatisticsOperations operations, string resourceGroupName, string serverName, TopQueryStatisticsInput parameters) + { + return operations.ListByServerAsync(resourceGroupName, serverName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Retrieve the Query-Store top queries for specified metric and aggregation. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The required parameters for retrieving top query statistics. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByServerAsync(this ITopQueryStatisticsOperations operations, string resourceGroupName, string serverName, TopQueryStatisticsInput parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByServerWithHttpMessagesAsync(resourceGroupName, serverName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Retrieve the Query-Store top queries for specified metric and aggregation. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListByServerNext(this ITopQueryStatisticsOperations operations, string nextPageLink) + { + return operations.ListByServerNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Retrieve the Query-Store top queries for specified metric and aggregation. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByServerNextAsync(this ITopQueryStatisticsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByServerNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/VirtualNetworkRulesOperations.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/VirtualNetworkRulesOperations.cs new file mode 100644 index 000000000000..081891bfb420 --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/VirtualNetworkRulesOperations.cs @@ -0,0 +1,1170 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// VirtualNetworkRulesOperations operations. + /// + internal partial class VirtualNetworkRulesOperations : IServiceOperations, IVirtualNetworkRulesOperations + { + /// + /// Initializes a new instance of the VirtualNetworkRulesOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal VirtualNetworkRulesOperations(MariaDBManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the MariaDBManagementClient + /// + public MariaDBManagementClient Client { get; private set; } + + /// + /// Gets a virtual network rule. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The name of the virtual network rule. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetWithHttpMessagesAsync(string resourceGroupName, string serverName, string virtualNetworkRuleName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (serverName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "serverName"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + if (virtualNetworkRuleName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "virtualNetworkRuleName"); + } + string apiVersion = "2018-06-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("serverName", serverName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("virtualNetworkRuleName", virtualNetworkRuleName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMariaDB/servers/{serverName}/virtualNetworkRules/{virtualNetworkRuleName}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{serverName}", System.Uri.EscapeDataString(serverName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{virtualNetworkRuleName}", System.Uri.EscapeDataString(virtualNetworkRuleName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Creates or updates an existing virtual network rule. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The name of the virtual network rule. + /// + /// + /// The requested virtual Network Rule Resource state. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string serverName, string virtualNetworkRuleName, VirtualNetworkRule parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, serverName, virtualNetworkRuleName, parameters, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Deletes the virtual network rule with the given name. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The name of the virtual network rule. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task DeleteWithHttpMessagesAsync(string resourceGroupName, string serverName, string virtualNetworkRuleName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginDeleteWithHttpMessagesAsync(resourceGroupName, serverName, virtualNetworkRuleName, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets a list of virtual network rules in a server. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListByServerWithHttpMessagesAsync(string resourceGroupName, string serverName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (serverName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "serverName"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + string apiVersion = "2018-06-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("serverName", serverName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByServer", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMariaDB/servers/{serverName}/virtualNetworkRules").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{serverName}", System.Uri.EscapeDataString(serverName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Creates or updates an existing virtual network rule. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The name of the virtual network rule. + /// + /// + /// The requested virtual Network Rule Resource state. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> BeginCreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string serverName, string virtualNetworkRuleName, VirtualNetworkRule parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (serverName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "serverName"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + if (virtualNetworkRuleName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "virtualNetworkRuleName"); + } + if (parameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); + } + if (parameters != null) + { + parameters.Validate(); + } + string apiVersion = "2018-06-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("serverName", serverName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("virtualNetworkRuleName", virtualNetworkRuleName); + tracingParameters.Add("parameters", parameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginCreateOrUpdate", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMariaDB/servers/{serverName}/virtualNetworkRules/{virtualNetworkRuleName}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{serverName}", System.Uri.EscapeDataString(serverName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{virtualNetworkRuleName}", System.Uri.EscapeDataString(virtualNetworkRuleName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PUT"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(parameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 201 && (int)_statusCode != 202) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + // Deserialize Response + if ((int)_statusCode == 201) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Deletes the virtual network rule with the given name. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The name of the virtual network rule. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string serverName, string virtualNetworkRuleName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (serverName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "serverName"); + } + if (virtualNetworkRuleName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "virtualNetworkRuleName"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + string apiVersion = "2018-06-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("serverName", serverName); + tracingParameters.Add("virtualNetworkRuleName", virtualNetworkRuleName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginDelete", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMariaDB/servers/{serverName}/virtualNetworkRules/{virtualNetworkRuleName}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{serverName}", System.Uri.EscapeDataString(serverName)); + _url = _url.Replace("{virtualNetworkRuleName}", System.Uri.EscapeDataString(virtualNetworkRuleName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("DELETE"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 202 && (int)_statusCode != 204) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Gets a list of virtual network rules in a server. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListByServerNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByServerNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/VirtualNetworkRulesOperationsExtensions.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/VirtualNetworkRulesOperationsExtensions.cs new file mode 100644 index 000000000000..c677f19e6a5c --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/VirtualNetworkRulesOperationsExtensions.cs @@ -0,0 +1,335 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for VirtualNetworkRulesOperations. + /// + public static partial class VirtualNetworkRulesOperationsExtensions + { + /// + /// Gets a virtual network rule. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The name of the virtual network rule. + /// + public static VirtualNetworkRule Get(this IVirtualNetworkRulesOperations operations, string resourceGroupName, string serverName, string virtualNetworkRuleName) + { + return operations.GetAsync(resourceGroupName, serverName, virtualNetworkRuleName).GetAwaiter().GetResult(); + } + + /// + /// Gets a virtual network rule. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The name of the virtual network rule. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IVirtualNetworkRulesOperations operations, string resourceGroupName, string serverName, string virtualNetworkRuleName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, serverName, virtualNetworkRuleName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Creates or updates an existing virtual network rule. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The name of the virtual network rule. + /// + /// + /// The requested virtual Network Rule Resource state. + /// + public static VirtualNetworkRule CreateOrUpdate(this IVirtualNetworkRulesOperations operations, string resourceGroupName, string serverName, string virtualNetworkRuleName, VirtualNetworkRule parameters) + { + return operations.CreateOrUpdateAsync(resourceGroupName, serverName, virtualNetworkRuleName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Creates or updates an existing virtual network rule. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The name of the virtual network rule. + /// + /// + /// The requested virtual Network Rule Resource state. + /// + /// + /// The cancellation token. + /// + public static async Task CreateOrUpdateAsync(this IVirtualNetworkRulesOperations operations, string resourceGroupName, string serverName, string virtualNetworkRuleName, VirtualNetworkRule parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, serverName, virtualNetworkRuleName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes the virtual network rule with the given name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The name of the virtual network rule. + /// + public static void Delete(this IVirtualNetworkRulesOperations operations, string resourceGroupName, string serverName, string virtualNetworkRuleName) + { + operations.DeleteAsync(resourceGroupName, serverName, virtualNetworkRuleName).GetAwaiter().GetResult(); + } + + /// + /// Deletes the virtual network rule with the given name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The name of the virtual network rule. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this IVirtualNetworkRulesOperations operations, string resourceGroupName, string serverName, string virtualNetworkRuleName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, serverName, virtualNetworkRuleName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Gets a list of virtual network rules in a server. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + public static IPage ListByServer(this IVirtualNetworkRulesOperations operations, string resourceGroupName, string serverName) + { + return operations.ListByServerAsync(resourceGroupName, serverName).GetAwaiter().GetResult(); + } + + /// + /// Gets a list of virtual network rules in a server. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByServerAsync(this IVirtualNetworkRulesOperations operations, string resourceGroupName, string serverName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByServerWithHttpMessagesAsync(resourceGroupName, serverName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Creates or updates an existing virtual network rule. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The name of the virtual network rule. + /// + /// + /// The requested virtual Network Rule Resource state. + /// + public static VirtualNetworkRule BeginCreateOrUpdate(this IVirtualNetworkRulesOperations operations, string resourceGroupName, string serverName, string virtualNetworkRuleName, VirtualNetworkRule parameters) + { + return operations.BeginCreateOrUpdateAsync(resourceGroupName, serverName, virtualNetworkRuleName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Creates or updates an existing virtual network rule. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The name of the virtual network rule. + /// + /// + /// The requested virtual Network Rule Resource state. + /// + /// + /// The cancellation token. + /// + public static async Task BeginCreateOrUpdateAsync(this IVirtualNetworkRulesOperations operations, string resourceGroupName, string serverName, string virtualNetworkRuleName, VirtualNetworkRule parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, serverName, virtualNetworkRuleName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes the virtual network rule with the given name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The name of the virtual network rule. + /// + public static void BeginDelete(this IVirtualNetworkRulesOperations operations, string resourceGroupName, string serverName, string virtualNetworkRuleName) + { + operations.BeginDeleteAsync(resourceGroupName, serverName, virtualNetworkRuleName).GetAwaiter().GetResult(); + } + + /// + /// Deletes the virtual network rule with the given name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The name of the virtual network rule. + /// + /// + /// The cancellation token. + /// + public static async Task BeginDeleteAsync(this IVirtualNetworkRulesOperations operations, string resourceGroupName, string serverName, string virtualNetworkRuleName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.BeginDeleteWithHttpMessagesAsync(resourceGroupName, serverName, virtualNetworkRuleName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Gets a list of virtual network rules in a server. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListByServerNext(this IVirtualNetworkRulesOperations operations, string nextPageLink) + { + return operations.ListByServerNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Gets a list of virtual network rules in a server. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByServerNextAsync(this IVirtualNetworkRulesOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByServerNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/WaitStatisticsOperations.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/WaitStatisticsOperations.cs new file mode 100644 index 000000000000..6fbb977b930c --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/WaitStatisticsOperations.cs @@ -0,0 +1,678 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// WaitStatisticsOperations operations. + /// + internal partial class WaitStatisticsOperations : IServiceOperations, IWaitStatisticsOperations + { + /// + /// Initializes a new instance of the WaitStatisticsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal WaitStatisticsOperations(MariaDBManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the MariaDBManagementClient + /// + public MariaDBManagementClient Client { get; private set; } + + /// + /// Retrieve wait statistics for specified identifier. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The Wait Statistic identifier. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetWithHttpMessagesAsync(string resourceGroupName, string serverName, string waitStatisticsId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (serverName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "serverName"); + } + if (waitStatisticsId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "waitStatisticsId"); + } + string apiVersion = "2018-06-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("serverName", serverName); + tracingParameters.Add("waitStatisticsId", waitStatisticsId); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMariaDB/servers/{serverName}/waitStatistics/{waitStatisticsId}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{serverName}", System.Uri.EscapeDataString(serverName)); + _url = _url.Replace("{waitStatisticsId}", System.Uri.EscapeDataString(waitStatisticsId)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Retrieve wait statistics for specified aggregation window. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The required parameters for retrieving wait statistics. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListByServerWithHttpMessagesAsync(string resourceGroupName, string serverName, WaitStatisticsInput parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (serverName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "serverName"); + } + if (parameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); + } + if (parameters != null) + { + parameters.Validate(); + } + string apiVersion = "2018-06-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("serverName", serverName); + tracingParameters.Add("parameters", parameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByServer", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMariaDB/servers/{serverName}/waitStatistics").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{serverName}", System.Uri.EscapeDataString(serverName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(parameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Retrieve wait statistics for specified aggregation window. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListByServerNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByServerNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/WaitStatisticsOperationsExtensions.cs b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/WaitStatisticsOperationsExtensions.cs new file mode 100644 index 000000000000..661f16fd98b9 --- /dev/null +++ b/sdk/mariadb/Microsoft.Azure.Management.MariaDB/src/Generated/WaitStatisticsOperationsExtensions.cs @@ -0,0 +1,151 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.MariaDB +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for WaitStatisticsOperations. + /// + public static partial class WaitStatisticsOperationsExtensions + { + /// + /// Retrieve wait statistics for specified identifier. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The Wait Statistic identifier. + /// + public static WaitStatistic Get(this IWaitStatisticsOperations operations, string resourceGroupName, string serverName, string waitStatisticsId) + { + return operations.GetAsync(resourceGroupName, serverName, waitStatisticsId).GetAwaiter().GetResult(); + } + + /// + /// Retrieve wait statistics for specified identifier. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The Wait Statistic identifier. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IWaitStatisticsOperations operations, string resourceGroupName, string serverName, string waitStatisticsId, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, serverName, waitStatisticsId, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Retrieve wait statistics for specified aggregation window. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The required parameters for retrieving wait statistics. + /// + public static IPage ListByServer(this IWaitStatisticsOperations operations, string resourceGroupName, string serverName, WaitStatisticsInput parameters) + { + return operations.ListByServerAsync(resourceGroupName, serverName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Retrieve wait statistics for specified aggregation window. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the server. + /// + /// + /// The required parameters for retrieving wait statistics. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByServerAsync(this IWaitStatisticsOperations operations, string resourceGroupName, string serverName, WaitStatisticsInput parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByServerWithHttpMessagesAsync(resourceGroupName, serverName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Retrieve wait statistics for specified aggregation window. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListByServerNext(this IWaitStatisticsOperations operations, string nextPageLink) + { + return operations.ListByServerNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Retrieve wait statistics for specified aggregation window. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByServerNextAsync(this IWaitStatisticsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByServerNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +}