From 3d588c0c878e355474cc1ae6ae94ed05b227d52d Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Tue, 25 Jan 2022 08:50:58 +0000 Subject: [PATCH] CodeGen from PR 17486 in Azure/azure-rest-api-specs Merge b39460fc3393d5c1176bb41afb3d3c653b102669 into 80e0bf225d3bb42a87d04696481b5c5ec4bef08a --- .../src/Generated/AuthorizationOperations.cs | 397 + .../AuthorizationOperationsExtensions.cs | 87 + .../DataPolicyManifestsOperations.cs | 604 + ...DataPolicyManifestsOperationsExtensions.cs | 175 + .../src/Generated/DeploymentOperations.cs | 3100 +++++ .../DeploymentOperationsExtensions.cs | 631 + .../src/Generated/DeploymentScriptsClient.cs | 363 + .../Generated/DeploymentScriptsOperations.cs | 2095 +++ .../DeploymentScriptsOperationsExtensions.cs | 462 + .../src/Generated/DeploymentsOperations.cs | 11093 ++++++++++++++++ .../DeploymentsOperationsExtensions.cs | 3137 +++++ .../src/Generated/FeatureClient.cs | 699 + .../src/Generated/FeatureClientExtensions.cs | 87 + .../src/Generated/FeaturesOperations.cs | 1322 ++ .../Generated/FeaturesOperationsExtensions.cs | 283 + .../src/Generated/IAuthorizationOperations.cs | 70 + .../IDataPolicyManifestsOperations.cs | 119 + .../src/Generated/IDeploymentOperations.cs | 405 + .../src/Generated/IDeploymentScriptsClient.cs | 79 + .../Generated/IDeploymentScriptsOperations.cs | 300 + .../src/Generated/IDeploymentsOperations.cs | 1908 +++ .../src/Generated/IFeatureClient.cs | 111 + .../src/Generated/IFeaturesOperations.cs | 191 + .../src/Generated/IManagementLinkClient.cs | 88 + .../src/Generated/IManagementLockClient.cs | 84 + .../Generated/IManagementLocksOperations.cs | 615 + .../src/Generated/IOperations.cs | 68 + .../Generated/IPolicyAssignmentsOperations.cs | 738 + .../src/Generated/IPolicyClient.cs | 92 + .../Generated/IPolicyDefinitionsOperations.cs | 483 + .../Generated/IPolicyExemptionsOperations.cs | 523 + .../IPolicySetDefinitionsOperations.cs | 477 + .../IProviderResourceTypesOperations.cs | 53 + .../src/Generated/IProvidersOperations.cs | 264 + .../Generated/IResourceGroupsOperations.cs | 284 + .../src/Generated/IResourceLinksOperations.cs | 197 + .../Generated/IResourceManagementClient.cs | 113 + .../src/Generated/IResourcesOperations.cs | 775 ++ .../src/Generated/ISubscriptionClient.cs | 103 + ...scriptionFeatureRegistrationsOperations.cs | 189 + .../src/Generated/ISubscriptionsOperations.cs | 145 + .../src/Generated/ITagsOperations.cs | 299 + .../ITemplateSpecVersionsOperations.cs | 192 + .../src/Generated/ITemplateSpecsClient.cs | 84 + .../src/Generated/ITemplateSpecsOperations.cs | 228 + .../src/Generated/ITenantsOperations.cs | 68 + .../src/Generated/ManagementLinkClient.cs | 369 + .../src/Generated/ManagementLockClient.cs | 367 + .../Generated/ManagementLocksOperations.cs | 4230 ++++++ .../ManagementLocksOperationsExtensions.cs | 996 ++ .../src/Generated/Models/Alias.cs | 99 + .../src/Generated/Models/AliasPath.cs | 79 + .../Generated/Models/AliasPathAttributes.cs | 29 + .../src/Generated/Models/AliasPathMetadata.cs | 63 + .../Generated/Models/AliasPathTokenType.cs | 52 + .../src/Generated/Models/AliasPattern.cs | 69 + .../src/Generated/Models/AliasPatternType.cs | 66 + .../src/Generated/Models/AliasType.cs | 75 + .../src/Generated/Models/ApiProfile.cs | 56 + .../Generated/Models/AuthorizationProfile.cs | 83 + .../Generated/Models/AvailabilityZonePeers.cs | 61 + .../src/Generated/Models/AzureCliScript.cs | 244 + .../Generated/Models/AzurePowerShellScript.cs | 244 + .../src/Generated/Models/AzureResourceBase.cs | 80 + .../src/Generated/Models/BasicDependency.cs | 67 + .../src/Generated/Models/ChangeType.cs | 123 + .../Models/CheckResourceNameResult.cs | 70 + .../Generated/Models/CheckZonePeersRequest.cs | 62 + .../Generated/Models/CheckZonePeersResult.cs | 70 + .../src/Generated/Models/CleanupOptions.cs | 23 + .../Models/ContainerConfiguration.cs | 98 + .../src/Generated/Models/CreatedByType.cs | 24 + .../src/Generated/Models/DataEffect.cs | 59 + ...anifestCustomResourceFunctionDefinition.cs | 93 + .../Generated/Models/DataPolicyManifest.cs | 151 + .../src/Generated/Models/DebugSetting.cs | 65 + .../src/Generated/Models/Dependency.cs | 77 + .../src/Generated/Models/Deployment.cs | 88 + .../Models/DeploymentExportResult.cs | 51 + .../Generated/Models/DeploymentExtended.cs | 108 + .../Models/DeploymentExtendedFilter.cs | 51 + .../src/Generated/Models/DeploymentMode.cs | 60 + .../Generated/Models/DeploymentOperation.cs | 67 + .../Models/DeploymentOperationProperties.cs | 142 + .../Generated/Models/DeploymentProperties.cs | 168 + .../Models/DeploymentPropertiesExtended.cs | 218 + .../src/Generated/Models/DeploymentScript.cs | 103 + .../Models/DeploymentScriptUpdateParameter.cs | 60 + .../Models/DeploymentScriptsError.cs | 49 + .../Models/DeploymentScriptsErrorException.cs | 62 + .../Models/DeploymentValidateResult.cs | 73 + .../src/Generated/Models/DeploymentWhatIf.cs | 78 + .../Models/DeploymentWhatIfProperties.cs | 97 + .../Models/DeploymentWhatIfSettings.cs | 54 + ...entsWhatIfAtManagementGroupScopeHeaders.cs | 63 + ...oymentsWhatIfAtSubscriptionScopeHeaders.cs | 63 + .../DeploymentsWhatIfAtTenantScopeHeaders.cs | 63 + .../Models/DeploymentsWhatIfHeaders.cs | 61 + .../src/Generated/Models/EnforcementMode.cs | 29 + .../Generated/Models/EnvironmentVariable.cs | 83 + .../Generated/Models/ErrorAdditionalInfo.cs | 59 + .../src/Generated/Models/ErrorDefinition.cs | 71 + .../src/Generated/Models/ErrorDetail.cs | 85 + .../src/Generated/Models/ErrorResponse.cs | 90 + .../Models/ErrorResponseException.cs | 62 + .../src/Generated/Models/ExemptionCategory.cs | 30 + .../Generated/Models/ExportTemplateRequest.cs | 71 + .../Models/ExpressionEvaluationOptions.cs | 58 + .../ExpressionEvaluationOptionsScopeType.cs | 23 + .../src/Generated/Models/ExtendedLocation.cs | 61 + .../Generated/Models/ExtendedLocationType.cs | 21 + .../src/Generated/Models/FeatureProperties.cs | 53 + .../src/Generated/Models/FeatureResult.cs | 76 + .../src/Generated/Models/Filter.cs | 54 + .../src/Generated/Models/GenericResource.cs | 118 + .../Models/GenericResourceExpanded.cs | 100 + .../Generated/Models/GenericResourceFilter.cs | 67 + .../src/Generated/Models/HttpMessage.cs | 51 + .../src/Generated/Models/Identity.cs | 88 + .../IdentityUserAssignedIdentitiesValue.cs | 60 + .../Models/LinkedTemplateArtifact.cs | 79 + .../src/Generated/Models/Location.cs | 107 + .../src/Generated/Models/LocationMetadata.cs | 117 + .../src/Generated/Models/LocationType.cs | 60 + .../src/Generated/Models/LockLevel.cs | 23 + .../src/Generated/Models/ManagedByTenant.cs | 52 + .../Models/ManagedServiceIdentity.cs | 75 + .../Models/ManagedServiceIdentityType.cs | 21 + .../Generated/Models/ManagementLockObject.cs | 128 + .../Generated/Models/ManagementLockOwner.cs | 52 + .../Generated/Models/NonComplianceMessage.cs | 88 + .../src/Generated/Models/OnErrorDeployment.cs | 64 + .../Models/OnErrorDeploymentExtended.cs | 73 + .../Generated/Models/OnErrorDeploymentType.cs | 60 + .../src/Generated/Models/Operation.cs | 61 + .../src/Generated/Models/OperationDisplay.cs | 79 + .../Generated/Models/OperationListResult.cs | 65 + .../src/Generated/Models/Page.cs | 53 + .../src/Generated/Models/Page1.cs | 53 + .../src/Generated/Models/PairedRegion.cs | 70 + .../Models/ParameterDefinitionsValue.cs | 84 + .../ParameterDefinitionsValueMetadata.cs | 101 + .../src/Generated/Models/ParameterType.cs | 27 + .../Generated/Models/ParameterValuesValue.cs | 51 + .../src/Generated/Models/ParametersLink.cs | 75 + .../src/Generated/Models/Peers.cs | 59 + .../src/Generated/Models/Permission.cs | 77 + .../src/Generated/Models/Plan.cs | 83 + .../src/Generated/Models/PolicyAssignment.cs | 190 + .../Models/PolicyAssignmentUpdate.cs | 60 + .../src/Generated/Models/PolicyDefinition.cs | 154 + .../Generated/Models/PolicyDefinitionGroup.cs | 99 + .../Models/PolicyDefinitionReference.cs | 100 + .../src/Generated/Models/PolicyExemption.cs | 175 + .../Generated/Models/PolicySetDefinition.cs | 189 + .../src/Generated/Models/PolicyType.cs | 24 + .../Generated/Models/PropertyChangeType.cs | 98 + .../src/Generated/Models/Provider.cs | 101 + .../ProviderAuthorizationConsentState.cs | 24 + .../Models/ProviderConsentDefinition.cs | 53 + .../Models/ProviderExtendedLocation.cs | 70 + .../Generated/Models/ProviderPermission.cs | 80 + .../Models/ProviderPermissionListResult.cs | 64 + .../Models/ProviderRegistrationRequest.cs | 54 + .../Generated/Models/ProviderResourceType.cs | 131 + .../Models/ProviderResourceTypeListResult.cs | 64 + .../Generated/Models/ProvisioningOperation.cs | 139 + .../src/Generated/Models/ProvisioningState.cs | 32 + .../src/Generated/Models/ProxyResource.cs | 69 + .../src/Generated/Models/RegionCategory.cs | 23 + .../src/Generated/Models/RegionType.cs | 22 + .../src/Generated/Models/Resource.cs | 95 + .../src/Generated/Models/ResourceGroup.cs | 122 + .../Models/ResourceGroupExportResult.cs | 59 + .../Generated/Models/ResourceGroupFilter.cs | 59 + .../Models/ResourceGroupPatchable.cs | 79 + .../Models/ResourceGroupProperties.cs | 51 + .../Generated/Models/ResourceIdentityType.cs | 72 + .../src/Generated/Models/ResourceLink.cs | 91 + .../Generated/Models/ResourceLinkFilter.cs | 65 + .../Models/ResourceLinkProperties.cs | 84 + .../src/Generated/Models/ResourceName.cs | 77 + .../Generated/Models/ResourceNameStatus.cs | 22 + ...ourceProviderOperationDisplayProperties.cs | 85 + .../src/Generated/Models/ResourceReference.cs | 51 + .../Generated/Models/ResourceTypeAliases.cs | 61 + .../src/Generated/Models/ResourcesMoveInfo.cs | 62 + .../src/Generated/Models/RoleDefinition.cs | 85 + .../src/Generated/Models/ScopedDeployment.cs | 92 + .../Models/ScopedDeploymentWhatIf.cs | 82 + .../src/Generated/Models/ScriptLog.cs | 59 + .../src/Generated/Models/ScriptLogsList.cs | 53 + .../Models/ScriptProvisioningState.cs | 26 + .../src/Generated/Models/ScriptStatus.cs | 93 + .../src/Generated/Models/Sku.cs | 91 + .../src/Generated/Models/SpendingLimit.cs | 66 + .../src/Generated/Models/StatusMessage.cs | 59 + .../Models/StorageAccountConfiguration.cs | 63 + .../src/Generated/Models/SubResource.cs | 53 + .../src/Generated/Models/Subscription.cs | 133 + .../Models/SubscriptionFeatureRegistration.cs | 68 + ...criptionFeatureRegistrationApprovalType.cs | 23 + ...bscriptionFeatureRegistrationProperties.cs | 189 + .../SubscriptionFeatureRegistrationState.cs | 27 + .../Generated/Models/SubscriptionPolicies.cs | 75 + .../src/Generated/Models/SubscriptionState.cs | 78 + .../src/Generated/Models/SystemData.cs | 103 + .../src/Generated/Models/TagCount.cs | 59 + .../src/Generated/Models/TagDetails.cs | 83 + .../src/Generated/Models/TagValue.cs | 69 + .../src/Generated/Models/Tags.cs | 51 + .../Generated/Models/TagsPatchOperation.cs | 35 + .../src/Generated/Models/TagsPatchResource.cs | 61 + .../src/Generated/Models/TagsResource.cs | 90 + .../src/Generated/Models/TargetResource.cs | 67 + .../Generated/Models/TemplateHashResult.cs | 61 + .../src/Generated/Models/TemplateLink.cs | 101 + .../src/Generated/Models/TemplateSpec.cs | 142 + .../Models/TemplateSpecExpandKind.cs | 24 + .../Models/TemplateSpecUpdateModel.cs | 61 + .../Generated/Models/TemplateSpecVersion.cs | 151 + .../Models/TemplateSpecVersionInfo.cs | 70 + .../Models/TemplateSpecVersionUpdateModel.cs | 63 + .../Generated/Models/TemplateSpecsError.cs | 49 + .../Models/TemplateSpecsErrorException.cs | 62 + .../src/Generated/Models/TenantCategory.cs | 66 + .../Generated/Models/TenantIdDescription.cs | 137 + .../Generated/Models/UserAssignedIdentity.cs | 62 + .../src/Generated/Models/WhatIfChange.cs | 130 + .../Generated/Models/WhatIfOperationResult.cs | 75 + .../Generated/Models/WhatIfPropertyChange.cs | 116 + .../Generated/Models/WhatIfResultFormat.cs | 60 + .../src/Generated/Models/ZoneMapping.cs | 56 + .../src/Generated/Operations.cs | 400 + .../src/Generated/OperationsExtensions.cs | 87 + .../Generated/PolicyAssignmentsOperations.cs | 3428 +++++ .../PolicyAssignmentsOperationsExtensions.cs | 1242 ++ .../src/Generated/PolicyClient.cs | 375 + .../Generated/PolicyDefinitionsOperations.cs | 2590 ++++ .../PolicyDefinitionsOperationsExtensions.cs | 787 ++ .../Generated/PolicyExemptionsOperations.cs | 2353 ++++ .../PolicyExemptionsOperationsExtensions.cs | 864 ++ .../PolicySetDefinitionsOperations.cs | 2628 ++++ ...olicySetDefinitionsOperationsExtensions.cs | 775 ++ .../ProviderResourceTypesOperations.cs | 250 + ...oviderResourceTypesOperationsExtensions.cs | 67 + .../src/Generated/ProvidersOperations.cs | 1912 +++ .../ProvidersOperationsExtensions.cs | 402 + .../src/Generated/ResourceGroupsOperations.cs | 1722 +++ .../ResourceGroupsOperationsExtensions.cs | 438 + .../src/Generated/ResourceLinksOperations.cs | 1356 ++ .../ResourceLinksOperationsExtensions.cs | 293 + .../src/Generated/ResourceManagementClient.cs | 402 + .../src/Generated/ResourcesOperations.cs | 3639 +++++ .../ResourcesOperationsExtensions.cs | 1308 ++ .../SdkInfo_DeploymentScriptsClient.cs | 27 + .../src/Generated/SdkInfo_FeatureClient.cs | 29 + .../Generated/SdkInfo_ManagementLinkClient.cs | 29 + .../Generated/SdkInfo_ManagementLockClient.cs | 28 + .../src/Generated/SdkInfo_PolicyClient.cs | 36 + .../SdkInfo_ResourceManagementClient.cs | 39 + .../Generated/SdkInfo_SubscriptionClient.cs | 30 + .../Generated/SdkInfo_TemplateSpecsClient.cs | 28 + .../src/Generated/SubscriptionClient.cs | 555 + .../Generated/SubscriptionClientExtensions.cs | 67 + ...scriptionFeatureRegistrationsOperations.cs | 1313 ++ ...eatureRegistrationsOperationsExtensions.cs | 282 + .../src/Generated/SubscriptionsOperations.cs | 968 ++ .../SubscriptionsOperationsExtensions.cs | 213 + .../src/Generated/TagsOperations.cs | 1950 +++ .../src/Generated/TagsOperationsExtensions.cs | 466 + .../TemplateSpecVersionsOperations.cs | 1449 ++ ...emplateSpecVersionsOperationsExtensions.cs | 294 + .../src/Generated/TemplateSpecsClient.cs | 367 + .../src/Generated/TemplateSpecsOperations.cs | 1697 +++ .../TemplateSpecsOperationsExtensions.cs | 350 + .../src/Generated/TenantsOperations.cs | 400 + .../Generated/TenantsOperationsExtensions.cs | 87 + 278 files changed, 91941 insertions(+) create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/AuthorizationOperations.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/AuthorizationOperationsExtensions.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/DataPolicyManifestsOperations.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/DataPolicyManifestsOperationsExtensions.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/DeploymentOperations.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/DeploymentOperationsExtensions.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/DeploymentScriptsClient.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/DeploymentScriptsOperations.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/DeploymentScriptsOperationsExtensions.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/DeploymentsOperations.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/DeploymentsOperationsExtensions.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/FeatureClient.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/FeatureClientExtensions.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/FeaturesOperations.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/FeaturesOperationsExtensions.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/IAuthorizationOperations.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/IDataPolicyManifestsOperations.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/IDeploymentOperations.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/IDeploymentScriptsClient.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/IDeploymentScriptsOperations.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/IDeploymentsOperations.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/IFeatureClient.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/IFeaturesOperations.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/IManagementLinkClient.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/IManagementLockClient.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/IManagementLocksOperations.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/IOperations.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/IPolicyAssignmentsOperations.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/IPolicyClient.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/IPolicyDefinitionsOperations.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/IPolicyExemptionsOperations.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/IPolicySetDefinitionsOperations.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/IProviderResourceTypesOperations.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/IProvidersOperations.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/IResourceGroupsOperations.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/IResourceLinksOperations.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/IResourceManagementClient.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/IResourcesOperations.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/ISubscriptionClient.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/ISubscriptionFeatureRegistrationsOperations.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/ISubscriptionsOperations.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/ITagsOperations.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/ITemplateSpecVersionsOperations.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/ITemplateSpecsClient.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/ITemplateSpecsOperations.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/ITenantsOperations.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/ManagementLinkClient.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/ManagementLockClient.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/ManagementLocksOperations.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/ManagementLocksOperationsExtensions.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/Alias.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/AliasPath.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/AliasPathAttributes.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/AliasPathMetadata.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/AliasPathTokenType.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/AliasPattern.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/AliasPatternType.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/AliasType.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ApiProfile.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/AuthorizationProfile.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/AvailabilityZonePeers.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/AzureCliScript.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/AzurePowerShellScript.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/AzureResourceBase.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/BasicDependency.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ChangeType.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/CheckResourceNameResult.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/CheckZonePeersRequest.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/CheckZonePeersResult.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/CleanupOptions.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ContainerConfiguration.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/CreatedByType.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/DataEffect.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/DataManifestCustomResourceFunctionDefinition.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/DataPolicyManifest.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/DebugSetting.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/Dependency.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/Deployment.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/DeploymentExportResult.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/DeploymentExtended.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/DeploymentExtendedFilter.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/DeploymentMode.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/DeploymentOperation.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/DeploymentOperationProperties.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/DeploymentProperties.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/DeploymentPropertiesExtended.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/DeploymentScript.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/DeploymentScriptUpdateParameter.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/DeploymentScriptsError.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/DeploymentScriptsErrorException.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/DeploymentValidateResult.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/DeploymentWhatIf.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/DeploymentWhatIfProperties.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/DeploymentWhatIfSettings.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/DeploymentsWhatIfAtManagementGroupScopeHeaders.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/DeploymentsWhatIfAtSubscriptionScopeHeaders.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/DeploymentsWhatIfAtTenantScopeHeaders.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/DeploymentsWhatIfHeaders.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/EnforcementMode.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/EnvironmentVariable.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ErrorAdditionalInfo.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ErrorDefinition.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ErrorDetail.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ErrorResponse.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ErrorResponseException.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ExemptionCategory.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ExportTemplateRequest.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ExpressionEvaluationOptions.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ExpressionEvaluationOptionsScopeType.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ExtendedLocation.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ExtendedLocationType.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/FeatureProperties.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/FeatureResult.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/Filter.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/GenericResource.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/GenericResourceExpanded.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/GenericResourceFilter.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/HttpMessage.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/Identity.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/IdentityUserAssignedIdentitiesValue.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/LinkedTemplateArtifact.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/Location.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/LocationMetadata.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/LocationType.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/LockLevel.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ManagedByTenant.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ManagedServiceIdentity.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ManagedServiceIdentityType.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ManagementLockObject.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ManagementLockOwner.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/NonComplianceMessage.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/OnErrorDeployment.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/OnErrorDeploymentExtended.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/OnErrorDeploymentType.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/Operation.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/OperationDisplay.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/OperationListResult.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/Page.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/Page1.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/PairedRegion.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ParameterDefinitionsValue.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ParameterDefinitionsValueMetadata.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ParameterType.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ParameterValuesValue.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ParametersLink.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/Peers.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/Permission.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/Plan.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/PolicyAssignment.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/PolicyAssignmentUpdate.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/PolicyDefinition.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/PolicyDefinitionGroup.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/PolicyDefinitionReference.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/PolicyExemption.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/PolicySetDefinition.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/PolicyType.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/PropertyChangeType.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/Provider.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ProviderAuthorizationConsentState.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ProviderConsentDefinition.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ProviderExtendedLocation.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ProviderPermission.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ProviderPermissionListResult.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ProviderRegistrationRequest.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ProviderResourceType.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ProviderResourceTypeListResult.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ProvisioningOperation.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ProvisioningState.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ProxyResource.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/RegionCategory.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/RegionType.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/Resource.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ResourceGroup.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ResourceGroupExportResult.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ResourceGroupFilter.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ResourceGroupPatchable.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ResourceGroupProperties.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ResourceIdentityType.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ResourceLink.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ResourceLinkFilter.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ResourceLinkProperties.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ResourceName.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ResourceNameStatus.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ResourceProviderOperationDisplayProperties.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ResourceReference.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ResourceTypeAliases.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ResourcesMoveInfo.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/RoleDefinition.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ScopedDeployment.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ScopedDeploymentWhatIf.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ScriptLog.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ScriptLogsList.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ScriptProvisioningState.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ScriptStatus.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/Sku.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/SpendingLimit.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/StatusMessage.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/StorageAccountConfiguration.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/SubResource.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/Subscription.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/SubscriptionFeatureRegistration.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/SubscriptionFeatureRegistrationApprovalType.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/SubscriptionFeatureRegistrationProperties.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/SubscriptionFeatureRegistrationState.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/SubscriptionPolicies.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/SubscriptionState.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/SystemData.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/TagCount.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/TagDetails.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/TagValue.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/Tags.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/TagsPatchOperation.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/TagsPatchResource.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/TagsResource.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/TargetResource.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/TemplateHashResult.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/TemplateLink.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/TemplateSpec.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/TemplateSpecExpandKind.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/TemplateSpecUpdateModel.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/TemplateSpecVersion.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/TemplateSpecVersionInfo.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/TemplateSpecVersionUpdateModel.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/TemplateSpecsError.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/TemplateSpecsErrorException.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/TenantCategory.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/TenantIdDescription.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/UserAssignedIdentity.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/WhatIfChange.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/WhatIfOperationResult.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/WhatIfPropertyChange.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/WhatIfResultFormat.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ZoneMapping.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Operations.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/OperationsExtensions.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/PolicyAssignmentsOperations.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/PolicyAssignmentsOperationsExtensions.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/PolicyClient.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/PolicyDefinitionsOperations.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/PolicyDefinitionsOperationsExtensions.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/PolicyExemptionsOperations.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/PolicyExemptionsOperationsExtensions.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/PolicySetDefinitionsOperations.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/PolicySetDefinitionsOperationsExtensions.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/ProviderResourceTypesOperations.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/ProviderResourceTypesOperationsExtensions.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/ProvidersOperations.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/ProvidersOperationsExtensions.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/ResourceGroupsOperations.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/ResourceGroupsOperationsExtensions.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/ResourceLinksOperations.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/ResourceLinksOperationsExtensions.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/ResourceManagementClient.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/ResourcesOperations.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/ResourcesOperationsExtensions.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/SdkInfo_DeploymentScriptsClient.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/SdkInfo_FeatureClient.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/SdkInfo_ManagementLinkClient.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/SdkInfo_ManagementLockClient.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/SdkInfo_PolicyClient.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/SdkInfo_ResourceManagementClient.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/SdkInfo_SubscriptionClient.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/SdkInfo_TemplateSpecsClient.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/SubscriptionClient.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/SubscriptionClientExtensions.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/SubscriptionFeatureRegistrationsOperations.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/SubscriptionFeatureRegistrationsOperationsExtensions.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/SubscriptionsOperations.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/SubscriptionsOperationsExtensions.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/TagsOperations.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/TagsOperationsExtensions.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/TemplateSpecVersionsOperations.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/TemplateSpecVersionsOperationsExtensions.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/TemplateSpecsClient.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/TemplateSpecsOperations.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/TemplateSpecsOperationsExtensions.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/TenantsOperations.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/TenantsOperationsExtensions.cs diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/AuthorizationOperations.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/AuthorizationOperations.cs new file mode 100644 index 0000000000000..9b888df5fe72d --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/AuthorizationOperations.cs @@ -0,0 +1,397 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager +{ + 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; + + /// + /// AuthorizationOperations operations. + /// + internal partial class AuthorizationOperations : IServiceOperations, IAuthorizationOperations + { + /// + /// Initializes a new instance of the AuthorizationOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal AuthorizationOperations(ManagementLockClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the ManagementLockClient + /// + public ManagementLockClient Client { get; private set; } + + /// + /// Lists all of the available Microsoft.Authorization 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.Authorization/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; + } + + /// + /// Lists all of the available Microsoft.Authorization REST API operations. + /// + /// + /// 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; + } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/AuthorizationOperationsExtensions.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/AuthorizationOperationsExtensions.cs new file mode 100644 index 0000000000000..e9bfdaf75844f --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/AuthorizationOperationsExtensions.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.ResourceManager +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for AuthorizationOperations. + /// + public static partial class AuthorizationOperationsExtensions + { + /// + /// Lists all of the available Microsoft.Authorization REST API operations. + /// + /// + /// The operations group for this extension method. + /// + public static IPage List(this IAuthorizationOperations operations) + { + return operations.ListAsync().GetAwaiter().GetResult(); + } + + /// + /// Lists all of the available Microsoft.Authorization REST API operations. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAsync(this IAuthorizationOperations operations, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Lists all of the available Microsoft.Authorization REST API operations. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListNext(this IAuthorizationOperations operations, string nextPageLink) + { + return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Lists all of the available Microsoft.Authorization REST API operations. + /// + /// + /// 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 IAuthorizationOperations 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/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/DataPolicyManifestsOperations.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/DataPolicyManifestsOperations.cs new file mode 100644 index 0000000000000..ed80f674c1042 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/DataPolicyManifestsOperations.cs @@ -0,0 +1,604 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager +{ + 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; + + /// + /// DataPolicyManifestsOperations operations. + /// + internal partial class DataPolicyManifestsOperations : IServiceOperations, IDataPolicyManifestsOperations + { + /// + /// Initializes a new instance of the DataPolicyManifestsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal DataPolicyManifestsOperations(PolicyClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the PolicyClient + /// + public PolicyClient Client { get; private set; } + + /// + /// Retrieves a data policy manifest. + /// + /// + /// This operation retrieves the data policy manifest with the given policy + /// mode. + /// + /// + /// The policy mode of the data policy manifest to get. + /// + /// + /// 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> GetByPolicyModeWithHttpMessagesAsync(string policyMode, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (policyMode == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "policyMode"); + } + string apiVersion = "2020-09-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("policyMode", policyMode); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetByPolicyMode", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Authorization/dataPolicyManifests/{policyMode}").ToString(); + _url = _url.Replace("{policyMode}", System.Uri.EscapeDataString(policyMode)); + 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; + } + + /// + /// Retrieves data policy manifests + /// + /// + /// This operation retrieves a list of all the data policy manifests that match + /// the optional given $filter. Valid values for $filter are: + /// "$filter=namespace eq '{0}'". If $filter is not provided, the unfiltered + /// list includes all data policy manifests for data resource types. If + /// $filter=namespace is provided, the returned list only includes all data + /// policy manifests that have a namespace matching the provided value. + /// + /// + /// The filter to apply on the operation. Valid values for $filter are: + /// "namespace eq '{value}'". If $filter is not provided, no filtering is + /// performed. If $filter=namespace eq '{value}' is provided, the returned list + /// only includes all data policy manifests that have a namespace matching the + /// provided value. + /// + /// + /// 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(string filter = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + string apiVersion = "2020-09-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("filter", filter); + 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.Authorization/dataPolicyManifests").ToString(); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (filter != null) + { + _queryParameters.Add(string.Format("$filter={0}", filter)); + } + 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; + } + + /// + /// Retrieves data policy manifests + /// + /// + /// This operation retrieves a list of all the data policy manifests that match + /// the optional given $filter. Valid values for $filter are: + /// "$filter=namespace eq '{0}'". If $filter is not provided, the unfiltered + /// list includes all data policy manifests for data resource types. If + /// $filter=namespace is provided, the returned list only includes all data + /// policy manifests that have a namespace matching the provided value. + /// + /// + /// 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 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/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/DataPolicyManifestsOperationsExtensions.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/DataPolicyManifestsOperationsExtensions.cs new file mode 100644 index 0000000000000..d889e99596e76 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/DataPolicyManifestsOperationsExtensions.cs @@ -0,0 +1,175 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for DataPolicyManifestsOperations. + /// + public static partial class DataPolicyManifestsOperationsExtensions + { + /// + /// Retrieves a data policy manifest. + /// + /// + /// This operation retrieves the data policy manifest with the given policy + /// mode. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The policy mode of the data policy manifest to get. + /// + public static DataPolicyManifest GetByPolicyMode(this IDataPolicyManifestsOperations operations, string policyMode) + { + return operations.GetByPolicyModeAsync(policyMode).GetAwaiter().GetResult(); + } + + /// + /// Retrieves a data policy manifest. + /// + /// + /// This operation retrieves the data policy manifest with the given policy + /// mode. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The policy mode of the data policy manifest to get. + /// + /// + /// The cancellation token. + /// + public static async Task GetByPolicyModeAsync(this IDataPolicyManifestsOperations operations, string policyMode, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetByPolicyModeWithHttpMessagesAsync(policyMode, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Retrieves data policy manifests + /// + /// + /// This operation retrieves a list of all the data policy manifests that match + /// the optional given $filter. Valid values for $filter are: + /// "$filter=namespace eq '{0}'". If $filter is not provided, the unfiltered + /// list includes all data policy manifests for data resource types. If + /// $filter=namespace is provided, the returned list only includes all data + /// policy manifests that have a namespace matching the provided value. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The filter to apply on the operation. Valid values for $filter are: + /// "namespace eq '{value}'". If $filter is not provided, no filtering is + /// performed. If $filter=namespace eq '{value}' is provided, the returned list + /// only includes all data policy manifests that have a namespace matching the + /// provided value. + /// + public static IPage List(this IDataPolicyManifestsOperations operations, string filter = default(string)) + { + return operations.ListAsync(filter).GetAwaiter().GetResult(); + } + + /// + /// Retrieves data policy manifests + /// + /// + /// This operation retrieves a list of all the data policy manifests that match + /// the optional given $filter. Valid values for $filter are: + /// "$filter=namespace eq '{0}'". If $filter is not provided, the unfiltered + /// list includes all data policy manifests for data resource types. If + /// $filter=namespace is provided, the returned list only includes all data + /// policy manifests that have a namespace matching the provided value. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The filter to apply on the operation. Valid values for $filter are: + /// "namespace eq '{value}'". If $filter is not provided, no filtering is + /// performed. If $filter=namespace eq '{value}' is provided, the returned list + /// only includes all data policy manifests that have a namespace matching the + /// provided value. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAsync(this IDataPolicyManifestsOperations operations, string filter = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(filter, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Retrieves data policy manifests + /// + /// + /// This operation retrieves a list of all the data policy manifests that match + /// the optional given $filter. Valid values for $filter are: + /// "$filter=namespace eq '{0}'". If $filter is not provided, the unfiltered + /// list includes all data policy manifests for data resource types. If + /// $filter=namespace is provided, the returned list only includes all data + /// policy manifests that have a namespace matching the provided value. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListNext(this IDataPolicyManifestsOperations operations, string nextPageLink) + { + return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Retrieves data policy manifests + /// + /// + /// This operation retrieves a list of all the data policy manifests that match + /// the optional given $filter. Valid values for $filter are: + /// "$filter=namespace eq '{0}'". If $filter is not provided, the unfiltered + /// list includes all data policy manifests for data resource types. If + /// $filter=namespace is provided, the returned list only includes all data + /// policy manifests that have a namespace matching the provided value. + /// + /// + /// 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 IDataPolicyManifestsOperations 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/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/DeploymentOperations.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/DeploymentOperations.cs new file mode 100644 index 0000000000000..e99f83084f905 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/DeploymentOperations.cs @@ -0,0 +1,3100 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager +{ + 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; + + /// + /// DeploymentOperations operations. + /// + internal partial class DeploymentOperations : IServiceOperations, IDeploymentOperations + { + /// + /// Initializes a new instance of the DeploymentOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal DeploymentOperations(ResourceManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the ResourceManagementClient + /// + public ResourceManagementClient Client { get; private set; } + + /// + /// Gets a deployments operation. + /// + /// + /// The resource scope. + /// + /// + /// The name of the deployment. + /// + /// + /// The ID of the operation to get. + /// + /// + /// 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> GetAtScopeWithHttpMessagesAsync(string scope, string deploymentName, string operationId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (scope == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "scope"); + } + if (deploymentName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "deploymentName"); + } + if (deploymentName != null) + { + if (deploymentName.Length > 64) + { + throw new ValidationException(ValidationRules.MaxLength, "deploymentName", 64); + } + if (deploymentName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "deploymentName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(deploymentName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "deploymentName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (operationId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "operationId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("scope", scope); + tracingParameters.Add("deploymentName", deploymentName); + tracingParameters.Add("operationId", operationId); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetAtScope", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}").ToString(); + _url = _url.Replace("{scope}", scope); + _url = _url.Replace("{deploymentName}", System.Uri.EscapeDataString(deploymentName)); + _url = _url.Replace("{operationId}", System.Uri.EscapeDataString(operationId)); + 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 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 deployments operations for a deployment. + /// + /// + /// The resource scope. + /// + /// + /// The name of the deployment. + /// + /// + /// The number of results to return. + /// + /// + /// 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>> ListAtScopeWithHttpMessagesAsync(string scope, string deploymentName, int? top = default(int?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (scope == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "scope"); + } + if (deploymentName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "deploymentName"); + } + if (deploymentName != null) + { + if (deploymentName.Length > 64) + { + throw new ValidationException(ValidationRules.MaxLength, "deploymentName", 64); + } + if (deploymentName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "deploymentName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(deploymentName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "deploymentName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("scope", scope); + tracingParameters.Add("deploymentName", deploymentName); + tracingParameters.Add("top", top); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListAtScope", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations").ToString(); + _url = _url.Replace("{scope}", scope); + _url = _url.Replace("{deploymentName}", System.Uri.EscapeDataString(deploymentName)); + List _queryParameters = new List(); + if (top != null) + { + _queryParameters.Add(string.Format("$top={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(top, Client.SerializationSettings).Trim('"')))); + } + 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 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 deployments operation. + /// + /// + /// The name of the deployment. + /// + /// + /// The ID of the operation to get. + /// + /// + /// 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> GetAtTenantScopeWithHttpMessagesAsync(string deploymentName, string operationId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (deploymentName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "deploymentName"); + } + if (deploymentName != null) + { + if (deploymentName.Length > 64) + { + throw new ValidationException(ValidationRules.MaxLength, "deploymentName", 64); + } + if (deploymentName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "deploymentName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(deploymentName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "deploymentName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (operationId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "operationId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("deploymentName", deploymentName); + tracingParameters.Add("operationId", operationId); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetAtTenantScope", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}").ToString(); + _url = _url.Replace("{deploymentName}", System.Uri.EscapeDataString(deploymentName)); + _url = _url.Replace("{operationId}", System.Uri.EscapeDataString(operationId)); + 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 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 deployments operations for a deployment. + /// + /// + /// The name of the deployment. + /// + /// + /// The number of results to return. + /// + /// + /// 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>> ListAtTenantScopeWithHttpMessagesAsync(string deploymentName, int? top = default(int?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (deploymentName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "deploymentName"); + } + if (deploymentName != null) + { + if (deploymentName.Length > 64) + { + throw new ValidationException(ValidationRules.MaxLength, "deploymentName", 64); + } + if (deploymentName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "deploymentName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(deploymentName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "deploymentName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("deploymentName", deploymentName); + tracingParameters.Add("top", top); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListAtTenantScope", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Resources/deployments/{deploymentName}/operations").ToString(); + _url = _url.Replace("{deploymentName}", System.Uri.EscapeDataString(deploymentName)); + List _queryParameters = new List(); + if (top != null) + { + _queryParameters.Add(string.Format("$top={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(top, Client.SerializationSettings).Trim('"')))); + } + 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 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 deployments operation. + /// + /// + /// The management group ID. + /// + /// + /// The name of the deployment. + /// + /// + /// The ID of the operation to get. + /// + /// + /// 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> GetAtManagementGroupScopeWithHttpMessagesAsync(string groupId, string deploymentName, string operationId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (groupId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "groupId"); + } + if (groupId != null) + { + if (groupId.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "groupId", 90); + } + if (groupId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "groupId", 1); + } + } + if (deploymentName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "deploymentName"); + } + if (deploymentName != null) + { + if (deploymentName.Length > 64) + { + throw new ValidationException(ValidationRules.MaxLength, "deploymentName", 64); + } + if (deploymentName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "deploymentName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(deploymentName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "deploymentName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (operationId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "operationId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("groupId", groupId); + tracingParameters.Add("deploymentName", deploymentName); + tracingParameters.Add("operationId", operationId); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetAtManagementGroupScope", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}").ToString(); + _url = _url.Replace("{groupId}", System.Uri.EscapeDataString(groupId)); + _url = _url.Replace("{deploymentName}", System.Uri.EscapeDataString(deploymentName)); + _url = _url.Replace("{operationId}", System.Uri.EscapeDataString(operationId)); + 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 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 deployments operations for a deployment. + /// + /// + /// The management group ID. + /// + /// + /// The name of the deployment. + /// + /// + /// The number of results to return. + /// + /// + /// 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>> ListAtManagementGroupScopeWithHttpMessagesAsync(string groupId, string deploymentName, int? top = default(int?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (groupId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "groupId"); + } + if (groupId != null) + { + if (groupId.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "groupId", 90); + } + if (groupId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "groupId", 1); + } + } + if (deploymentName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "deploymentName"); + } + if (deploymentName != null) + { + if (deploymentName.Length > 64) + { + throw new ValidationException(ValidationRules.MaxLength, "deploymentName", 64); + } + if (deploymentName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "deploymentName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(deploymentName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "deploymentName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("groupId", groupId); + tracingParameters.Add("deploymentName", deploymentName); + tracingParameters.Add("top", top); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListAtManagementGroupScope", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations").ToString(); + _url = _url.Replace("{groupId}", System.Uri.EscapeDataString(groupId)); + _url = _url.Replace("{deploymentName}", System.Uri.EscapeDataString(deploymentName)); + List _queryParameters = new List(); + if (top != null) + { + _queryParameters.Add(string.Format("$top={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(top, Client.SerializationSettings).Trim('"')))); + } + 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 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 deployments operation. + /// + /// + /// The name of the deployment. + /// + /// + /// The ID of the operation to get. + /// + /// + /// 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> GetAtSubscriptionScopeWithHttpMessagesAsync(string deploymentName, string operationId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (deploymentName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "deploymentName"); + } + if (deploymentName != null) + { + if (deploymentName.Length > 64) + { + throw new ValidationException(ValidationRules.MaxLength, "deploymentName", 64); + } + if (deploymentName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "deploymentName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(deploymentName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "deploymentName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (operationId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "operationId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("deploymentName", deploymentName); + tracingParameters.Add("operationId", operationId); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetAtSubscriptionScope", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}").ToString(); + _url = _url.Replace("{deploymentName}", System.Uri.EscapeDataString(deploymentName)); + _url = _url.Replace("{operationId}", System.Uri.EscapeDataString(operationId)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + 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 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 deployments operations for a deployment. + /// + /// + /// The name of the deployment. + /// + /// + /// The number of results to return. + /// + /// + /// 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>> ListAtSubscriptionScopeWithHttpMessagesAsync(string deploymentName, int? top = default(int?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (deploymentName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "deploymentName"); + } + if (deploymentName != null) + { + if (deploymentName.Length > 64) + { + throw new ValidationException(ValidationRules.MaxLength, "deploymentName", 64); + } + if (deploymentName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "deploymentName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(deploymentName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "deploymentName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("deploymentName", deploymentName); + tracingParameters.Add("top", top); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListAtSubscriptionScope", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations").ToString(); + _url = _url.Replace("{deploymentName}", System.Uri.EscapeDataString(deploymentName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (top != null) + { + _queryParameters.Add(string.Format("$top={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(top, Client.SerializationSettings).Trim('"')))); + } + 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 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 deployments operation. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the deployment. + /// + /// + /// The ID of the operation to get. + /// + /// + /// 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 deploymentName, string operationId, 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 (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (deploymentName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "deploymentName"); + } + if (deploymentName != null) + { + if (deploymentName.Length > 64) + { + throw new ValidationException(ValidationRules.MaxLength, "deploymentName", 64); + } + if (deploymentName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "deploymentName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(deploymentName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "deploymentName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (operationId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "operationId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("deploymentName", deploymentName); + 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}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{deploymentName}", System.Uri.EscapeDataString(deploymentName)); + _url = _url.Replace("{operationId}", System.Uri.EscapeDataString(operationId)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + 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 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 deployments operations for a deployment. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the deployment. + /// + /// + /// The number of results to return. + /// + /// + /// 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 deploymentName, int? top = default(int?), 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 (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (deploymentName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "deploymentName"); + } + if (deploymentName != null) + { + if (deploymentName.Length > 64) + { + throw new ValidationException(ValidationRules.MaxLength, "deploymentName", 64); + } + if (deploymentName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "deploymentName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(deploymentName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "deploymentName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("deploymentName", deploymentName); + tracingParameters.Add("top", top); + 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}/deployments/{deploymentName}/operations").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{deploymentName}", System.Uri.EscapeDataString(deploymentName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (top != null) + { + _queryParameters.Add(string.Format("$top={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(top, Client.SerializationSettings).Trim('"')))); + } + 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 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 deployments operations for a deployment. + /// + /// + /// 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>> ListAtScopeNextWithHttpMessagesAsync(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, "ListAtScopeNext", 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; + } + + /// + /// Gets all deployments operations for a deployment. + /// + /// + /// 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>> ListAtTenantScopeNextWithHttpMessagesAsync(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, "ListAtTenantScopeNext", 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; + } + + /// + /// Gets all deployments operations for a deployment. + /// + /// + /// 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>> ListAtManagementGroupScopeNextWithHttpMessagesAsync(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, "ListAtManagementGroupScopeNext", 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; + } + + /// + /// Gets all deployments operations for a deployment. + /// + /// + /// 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>> ListAtSubscriptionScopeNextWithHttpMessagesAsync(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, "ListAtSubscriptionScopeNext", 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; + } + + /// + /// Gets all deployments operations for a deployment. + /// + /// + /// 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 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/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/DeploymentOperationsExtensions.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/DeploymentOperationsExtensions.cs new file mode 100644 index 0000000000000..8258812a5d371 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/DeploymentOperationsExtensions.cs @@ -0,0 +1,631 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for DeploymentOperations. + /// + public static partial class DeploymentOperationsExtensions + { + /// + /// Gets a deployments operation. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The resource scope. + /// + /// + /// The name of the deployment. + /// + /// + /// The ID of the operation to get. + /// + public static DeploymentOperation GetAtScope(this IDeploymentOperations operations, string scope, string deploymentName, string operationId) + { + return operations.GetAtScopeAsync(scope, deploymentName, operationId).GetAwaiter().GetResult(); + } + + /// + /// Gets a deployments operation. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The resource scope. + /// + /// + /// The name of the deployment. + /// + /// + /// The ID of the operation to get. + /// + /// + /// The cancellation token. + /// + public static async Task GetAtScopeAsync(this IDeploymentOperations operations, string scope, string deploymentName, string operationId, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetAtScopeWithHttpMessagesAsync(scope, deploymentName, operationId, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets all deployments operations for a deployment. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The resource scope. + /// + /// + /// The name of the deployment. + /// + /// + /// The number of results to return. + /// + public static IPage ListAtScope(this IDeploymentOperations operations, string scope, string deploymentName, int? top = default(int?)) + { + return operations.ListAtScopeAsync(scope, deploymentName, top).GetAwaiter().GetResult(); + } + + /// + /// Gets all deployments operations for a deployment. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The resource scope. + /// + /// + /// The name of the deployment. + /// + /// + /// The number of results to return. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAtScopeAsync(this IDeploymentOperations operations, string scope, string deploymentName, int? top = default(int?), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListAtScopeWithHttpMessagesAsync(scope, deploymentName, top, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets a deployments operation. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the deployment. + /// + /// + /// The ID of the operation to get. + /// + public static DeploymentOperation GetAtTenantScope(this IDeploymentOperations operations, string deploymentName, string operationId) + { + return operations.GetAtTenantScopeAsync(deploymentName, operationId).GetAwaiter().GetResult(); + } + + /// + /// Gets a deployments operation. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the deployment. + /// + /// + /// The ID of the operation to get. + /// + /// + /// The cancellation token. + /// + public static async Task GetAtTenantScopeAsync(this IDeploymentOperations operations, string deploymentName, string operationId, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetAtTenantScopeWithHttpMessagesAsync(deploymentName, operationId, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets all deployments operations for a deployment. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the deployment. + /// + /// + /// The number of results to return. + /// + public static IPage ListAtTenantScope(this IDeploymentOperations operations, string deploymentName, int? top = default(int?)) + { + return operations.ListAtTenantScopeAsync(deploymentName, top).GetAwaiter().GetResult(); + } + + /// + /// Gets all deployments operations for a deployment. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the deployment. + /// + /// + /// The number of results to return. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAtTenantScopeAsync(this IDeploymentOperations operations, string deploymentName, int? top = default(int?), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListAtTenantScopeWithHttpMessagesAsync(deploymentName, top, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets a deployments operation. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The management group ID. + /// + /// + /// The name of the deployment. + /// + /// + /// The ID of the operation to get. + /// + public static DeploymentOperation GetAtManagementGroupScope(this IDeploymentOperations operations, string groupId, string deploymentName, string operationId) + { + return operations.GetAtManagementGroupScopeAsync(groupId, deploymentName, operationId).GetAwaiter().GetResult(); + } + + /// + /// Gets a deployments operation. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The management group ID. + /// + /// + /// The name of the deployment. + /// + /// + /// The ID of the operation to get. + /// + /// + /// The cancellation token. + /// + public static async Task GetAtManagementGroupScopeAsync(this IDeploymentOperations operations, string groupId, string deploymentName, string operationId, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetAtManagementGroupScopeWithHttpMessagesAsync(groupId, deploymentName, operationId, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets all deployments operations for a deployment. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The management group ID. + /// + /// + /// The name of the deployment. + /// + /// + /// The number of results to return. + /// + public static IPage ListAtManagementGroupScope(this IDeploymentOperations operations, string groupId, string deploymentName, int? top = default(int?)) + { + return operations.ListAtManagementGroupScopeAsync(groupId, deploymentName, top).GetAwaiter().GetResult(); + } + + /// + /// Gets all deployments operations for a deployment. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The management group ID. + /// + /// + /// The name of the deployment. + /// + /// + /// The number of results to return. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAtManagementGroupScopeAsync(this IDeploymentOperations operations, string groupId, string deploymentName, int? top = default(int?), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListAtManagementGroupScopeWithHttpMessagesAsync(groupId, deploymentName, top, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets a deployments operation. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the deployment. + /// + /// + /// The ID of the operation to get. + /// + public static DeploymentOperation GetAtSubscriptionScope(this IDeploymentOperations operations, string deploymentName, string operationId) + { + return operations.GetAtSubscriptionScopeAsync(deploymentName, operationId).GetAwaiter().GetResult(); + } + + /// + /// Gets a deployments operation. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the deployment. + /// + /// + /// The ID of the operation to get. + /// + /// + /// The cancellation token. + /// + public static async Task GetAtSubscriptionScopeAsync(this IDeploymentOperations operations, string deploymentName, string operationId, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetAtSubscriptionScopeWithHttpMessagesAsync(deploymentName, operationId, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets all deployments operations for a deployment. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the deployment. + /// + /// + /// The number of results to return. + /// + public static IPage ListAtSubscriptionScope(this IDeploymentOperations operations, string deploymentName, int? top = default(int?)) + { + return operations.ListAtSubscriptionScopeAsync(deploymentName, top).GetAwaiter().GetResult(); + } + + /// + /// Gets all deployments operations for a deployment. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the deployment. + /// + /// + /// The number of results to return. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAtSubscriptionScopeAsync(this IDeploymentOperations operations, string deploymentName, int? top = default(int?), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListAtSubscriptionScopeWithHttpMessagesAsync(deploymentName, top, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets a deployments operation. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the deployment. + /// + /// + /// The ID of the operation to get. + /// + public static DeploymentOperation Get(this IDeploymentOperations operations, string resourceGroupName, string deploymentName, string operationId) + { + return operations.GetAsync(resourceGroupName, deploymentName, operationId).GetAwaiter().GetResult(); + } + + /// + /// Gets a deployments operation. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the deployment. + /// + /// + /// The ID of the operation to get. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IDeploymentOperations operations, string resourceGroupName, string deploymentName, string operationId, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, deploymentName, operationId, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets all deployments operations for a deployment. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the deployment. + /// + /// + /// The number of results to return. + /// + public static IPage List(this IDeploymentOperations operations, string resourceGroupName, string deploymentName, int? top = default(int?)) + { + return operations.ListAsync(resourceGroupName, deploymentName, top).GetAwaiter().GetResult(); + } + + /// + /// Gets all deployments operations for a deployment. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the deployment. + /// + /// + /// The number of results to return. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAsync(this IDeploymentOperations operations, string resourceGroupName, string deploymentName, int? top = default(int?), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(resourceGroupName, deploymentName, top, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets all deployments operations for a deployment. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListAtScopeNext(this IDeploymentOperations operations, string nextPageLink) + { + return operations.ListAtScopeNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Gets all deployments operations for a deployment. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAtScopeNextAsync(this IDeploymentOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListAtScopeNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets all deployments operations for a deployment. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListAtTenantScopeNext(this IDeploymentOperations operations, string nextPageLink) + { + return operations.ListAtTenantScopeNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Gets all deployments operations for a deployment. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAtTenantScopeNextAsync(this IDeploymentOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListAtTenantScopeNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets all deployments operations for a deployment. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListAtManagementGroupScopeNext(this IDeploymentOperations operations, string nextPageLink) + { + return operations.ListAtManagementGroupScopeNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Gets all deployments operations for a deployment. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAtManagementGroupScopeNextAsync(this IDeploymentOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListAtManagementGroupScopeNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets all deployments operations for a deployment. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListAtSubscriptionScopeNext(this IDeploymentOperations operations, string nextPageLink) + { + return operations.ListAtSubscriptionScopeNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Gets all deployments operations for a deployment. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAtSubscriptionScopeNextAsync(this IDeploymentOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListAtSubscriptionScopeNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets all deployments operations for a deployment. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListNext(this IDeploymentOperations operations, string nextPageLink) + { + return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Gets all deployments operations for a deployment. + /// + /// + /// 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 IDeploymentOperations 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/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/DeploymentScriptsClient.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/DeploymentScriptsClient.cs new file mode 100644 index 0000000000000..b1e7a13ec5211 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/DeploymentScriptsClient.cs @@ -0,0 +1,363 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager +{ + 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; + + /// + /// The APIs listed in this specification can be used to manage Deployment + /// Scripts resource through the Azure Resource Manager. + /// + public partial class DeploymentScriptsClient : ServiceClient, IDeploymentScriptsClient, 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; } + + /// + /// Subscription Id which forms part of the URI for every service call. + /// + public string SubscriptionId { get; set; } + + /// + /// Client Api version. + /// + 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 IDeploymentScriptsOperations. + /// + public virtual IDeploymentScriptsOperations DeploymentScripts { get; private set; } + + /// + /// Initializes a new instance of the DeploymentScriptsClient class. + /// + /// + /// HttpClient to be used + /// + /// + /// True: will dispose the provided httpClient on calling DeploymentScriptsClient.Dispose(). False: will not dispose provided httpClient + protected DeploymentScriptsClient(HttpClient httpClient, bool disposeHttpClient) : base(httpClient, disposeHttpClient) + { + Initialize(); + } + + /// + /// Initializes a new instance of the DeploymentScriptsClient class. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + protected DeploymentScriptsClient(params DelegatingHandler[] handlers) : base(handlers) + { + Initialize(); + } + + /// + /// Initializes a new instance of the DeploymentScriptsClient class. + /// + /// + /// Optional. The http client handler used to handle http transport. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + protected DeploymentScriptsClient(HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : base(rootHandler, handlers) + { + Initialize(); + } + + /// + /// Initializes a new instance of the DeploymentScriptsClient 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 DeploymentScriptsClient(System.Uri baseUri, params DelegatingHandler[] handlers) : this(handlers) + { + if (baseUri == null) + { + throw new System.ArgumentNullException("baseUri"); + } + BaseUri = baseUri; + } + + /// + /// Initializes a new instance of the DeploymentScriptsClient 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 DeploymentScriptsClient(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 DeploymentScriptsClient 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 DeploymentScriptsClient(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 DeploymentScriptsClient class. + /// + /// + /// Required. Credentials needed for the client to connect to Azure. + /// + /// + /// HttpClient to be used + /// + /// + /// True: will dispose the provided httpClient on calling DeploymentScriptsClient.Dispose(). False: will not dispose provided httpClient + /// + /// Thrown when a required parameter is null + /// + public DeploymentScriptsClient(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 DeploymentScriptsClient 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 DeploymentScriptsClient(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 DeploymentScriptsClient 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 DeploymentScriptsClient(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 DeploymentScriptsClient 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 DeploymentScriptsClient(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() + { + DeploymentScripts = new DeploymentScriptsOperations(this); + BaseUri = new System.Uri("https://management.azure.com"); + ApiVersion = "2020-10-01"; + 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("kind")); + DeserializationSettings.Converters.Add(new PolymorphicDeserializeJsonConverter("kind")); + CustomInitialize(); + DeserializationSettings.Converters.Add(new TransformationJsonConverter()); + DeserializationSettings.Converters.Add(new CloudErrorJsonConverter()); + } + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/DeploymentScriptsOperations.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/DeploymentScriptsOperations.cs new file mode 100644 index 0000000000000..122afdc920c3f --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/DeploymentScriptsOperations.cs @@ -0,0 +1,2095 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager +{ + 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; + + /// + /// DeploymentScriptsOperations operations. + /// + internal partial class DeploymentScriptsOperations : IServiceOperations, IDeploymentScriptsOperations + { + /// + /// Initializes a new instance of the DeploymentScriptsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal DeploymentScriptsOperations(DeploymentScriptsClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the DeploymentScriptsClient + /// + public DeploymentScriptsClient Client { get; private set; } + + /// + /// Creates a deployment script. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Name of the deployment script. + /// + /// + /// Deployment script supplied to the operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> CreateWithHttpMessagesAsync(string resourceGroupName, string scriptName, DeploymentScript deploymentScript, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginCreateWithHttpMessagesAsync(resourceGroupName, scriptName, deploymentScript, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Updates deployment script tags with specified values. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Name of the deployment script. + /// + /// + /// Deployment script resource with the tags to be updated. + /// + /// + /// 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> UpdateWithHttpMessagesAsync(string resourceGroupName, string scriptName, DeploymentScriptUpdateParameter deploymentScript = default(DeploymentScriptUpdateParameter), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + 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 (scriptName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "scriptName"); + } + if (scriptName != null) + { + if (scriptName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "scriptName", 90); + } + if (scriptName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "scriptName", 1); + } + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("scriptName", scriptName); + tracingParameters.Add("deploymentScript", deploymentScript); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Update", 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.Resources/deploymentScripts/{scriptName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{scriptName}", System.Uri.EscapeDataString(scriptName)); + 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(deploymentScript != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(deploymentScript, 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 DeploymentScriptsErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + DeploymentScriptsError _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 deployment script with a given name. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Name of the deployment script. + /// + /// + /// 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 scriptName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + 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 (scriptName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "scriptName"); + } + if (scriptName != null) + { + if (scriptName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "scriptName", 90); + } + if (scriptName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "scriptName", 1); + } + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("scriptName", scriptName); + 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.Resources/deploymentScripts/{scriptName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{scriptName}", System.Uri.EscapeDataString(scriptName)); + 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 DeploymentScriptsErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + DeploymentScriptsError _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 deployment script. When operation completes, status code 200 + /// returned without content. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Name of the deployment script. + /// + /// + /// 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 DeleteWithHttpMessagesAsync(string resourceGroupName, string scriptName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + 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 (scriptName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "scriptName"); + } + if (scriptName != null) + { + if (scriptName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "scriptName", 90); + } + if (scriptName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "scriptName", 1); + } + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("scriptName", scriptName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Delete", 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.Resources/deploymentScripts/{scriptName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{scriptName}", System.Uri.EscapeDataString(scriptName)); + 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 != 204) + { + var ex = new DeploymentScriptsErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + DeploymentScriptsError _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(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Lists all deployment scripts for 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>> ListBySubscriptionWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // 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, "ListBySubscription", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Resources/deploymentScripts").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + 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 DeploymentScriptsErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + DeploymentScriptsError _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 deployment script logs for a given deployment script name. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Name of the deployment script. + /// + /// + /// 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> GetLogsWithHttpMessagesAsync(string resourceGroupName, string scriptName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + 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 (scriptName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "scriptName"); + } + if (scriptName != null) + { + if (scriptName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "scriptName", 90); + } + if (scriptName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "scriptName", 1); + } + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("scriptName", scriptName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetLogs", 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.Resources/deploymentScripts/{scriptName}/logs").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{scriptName}", System.Uri.EscapeDataString(scriptName)); + 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 DeploymentScriptsErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + DeploymentScriptsError _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 deployment script logs for a given deployment script name. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Name of the deployment script. + /// + /// + /// The number of lines to show from the tail of the deployment script log. + /// Valid value is a positive number up to 1000. If 'tail' is not provided, all + /// available logs are shown up to container instance log capacity of 4mb. + /// + /// + /// 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> GetLogsDefaultWithHttpMessagesAsync(string resourceGroupName, string scriptName, int? tail = default(int?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + 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 (scriptName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "scriptName"); + } + if (scriptName != null) + { + if (scriptName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "scriptName", 90); + } + if (scriptName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "scriptName", 1); + } + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("scriptName", scriptName); + tracingParameters.Add("tail", tail); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetLogsDefault", 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.Resources/deploymentScripts/{scriptName}/logs/default").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{scriptName}", System.Uri.EscapeDataString(scriptName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (tail != null) + { + _queryParameters.Add(string.Format("tail={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(tail, Client.SerializationSettings).Trim('"')))); + } + 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 DeploymentScriptsErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + DeploymentScriptsError _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 deployments scripts. + /// + /// + /// 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 (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 (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // 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.Resources/deploymentScripts").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _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 DeploymentScriptsErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + DeploymentScriptsError _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 deployment script. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Name of the deployment script. + /// + /// + /// Deployment script supplied to the 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> BeginCreateWithHttpMessagesAsync(string resourceGroupName, string scriptName, DeploymentScript deploymentScript, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + 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 (scriptName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "scriptName"); + } + if (scriptName != null) + { + if (scriptName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "scriptName", 90); + } + if (scriptName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "scriptName", 1); + } + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (deploymentScript == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "deploymentScript"); + } + if (deploymentScript != null) + { + deploymentScript.Validate(); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("scriptName", scriptName); + tracingParameters.Add("deploymentScript", deploymentScript); + 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.Resources/deploymentScripts/{scriptName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{scriptName}", System.Uri.EscapeDataString(scriptName)); + 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(deploymentScript != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(deploymentScript, 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 DeploymentScriptsErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + DeploymentScriptsError _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); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Lists all deployment scripts for a given 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>> ListBySubscriptionNextWithHttpMessagesAsync(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, "ListBySubscriptionNext", 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 DeploymentScriptsErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + DeploymentScriptsError _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 deployments scripts. + /// + /// + /// 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 DeploymentScriptsErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + DeploymentScriptsError _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/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/DeploymentScriptsOperationsExtensions.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/DeploymentScriptsOperationsExtensions.cs new file mode 100644 index 0000000000000..f9a22328b2403 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/DeploymentScriptsOperationsExtensions.cs @@ -0,0 +1,462 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for DeploymentScriptsOperations. + /// + public static partial class DeploymentScriptsOperationsExtensions + { + /// + /// Creates a deployment script. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Name of the deployment script. + /// + /// + /// Deployment script supplied to the operation. + /// + public static DeploymentScript Create(this IDeploymentScriptsOperations operations, string resourceGroupName, string scriptName, DeploymentScript deploymentScript) + { + return operations.CreateAsync(resourceGroupName, scriptName, deploymentScript).GetAwaiter().GetResult(); + } + + /// + /// Creates a deployment script. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Name of the deployment script. + /// + /// + /// Deployment script supplied to the operation. + /// + /// + /// The cancellation token. + /// + public static async Task CreateAsync(this IDeploymentScriptsOperations operations, string resourceGroupName, string scriptName, DeploymentScript deploymentScript, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateWithHttpMessagesAsync(resourceGroupName, scriptName, deploymentScript, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Updates deployment script tags with specified values. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Name of the deployment script. + /// + /// + /// Deployment script resource with the tags to be updated. + /// + public static DeploymentScript Update(this IDeploymentScriptsOperations operations, string resourceGroupName, string scriptName, DeploymentScriptUpdateParameter deploymentScript = default(DeploymentScriptUpdateParameter)) + { + return operations.UpdateAsync(resourceGroupName, scriptName, deploymentScript).GetAwaiter().GetResult(); + } + + /// + /// Updates deployment script tags with specified values. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Name of the deployment script. + /// + /// + /// Deployment script resource with the tags to be updated. + /// + /// + /// The cancellation token. + /// + public static async Task UpdateAsync(this IDeploymentScriptsOperations operations, string resourceGroupName, string scriptName, DeploymentScriptUpdateParameter deploymentScript = default(DeploymentScriptUpdateParameter), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.UpdateWithHttpMessagesAsync(resourceGroupName, scriptName, deploymentScript, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets a deployment script with a given name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Name of the deployment script. + /// + public static DeploymentScript Get(this IDeploymentScriptsOperations operations, string resourceGroupName, string scriptName) + { + return operations.GetAsync(resourceGroupName, scriptName).GetAwaiter().GetResult(); + } + + /// + /// Gets a deployment script with a given name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Name of the deployment script. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IDeploymentScriptsOperations operations, string resourceGroupName, string scriptName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, scriptName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes a deployment script. When operation completes, status code 200 + /// returned without content. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Name of the deployment script. + /// + public static void Delete(this IDeploymentScriptsOperations operations, string resourceGroupName, string scriptName) + { + operations.DeleteAsync(resourceGroupName, scriptName).GetAwaiter().GetResult(); + } + + /// + /// Deletes a deployment script. When operation completes, status code 200 + /// returned without content. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Name of the deployment script. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this IDeploymentScriptsOperations operations, string resourceGroupName, string scriptName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, scriptName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Lists all deployment scripts for a given subscription. + /// + /// + /// The operations group for this extension method. + /// + public static IPage ListBySubscription(this IDeploymentScriptsOperations operations) + { + return operations.ListBySubscriptionAsync().GetAwaiter().GetResult(); + } + + /// + /// Lists all deployment scripts for a given subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The cancellation token. + /// + public static async Task> ListBySubscriptionAsync(this IDeploymentScriptsOperations operations, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListBySubscriptionWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets deployment script logs for a given deployment script name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Name of the deployment script. + /// + public static ScriptLogsList GetLogs(this IDeploymentScriptsOperations operations, string resourceGroupName, string scriptName) + { + return operations.GetLogsAsync(resourceGroupName, scriptName).GetAwaiter().GetResult(); + } + + /// + /// Gets deployment script logs for a given deployment script name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Name of the deployment script. + /// + /// + /// The cancellation token. + /// + public static async Task GetLogsAsync(this IDeploymentScriptsOperations operations, string resourceGroupName, string scriptName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetLogsWithHttpMessagesAsync(resourceGroupName, scriptName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets deployment script logs for a given deployment script name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Name of the deployment script. + /// + /// + /// The number of lines to show from the tail of the deployment script log. + /// Valid value is a positive number up to 1000. If 'tail' is not provided, all + /// available logs are shown up to container instance log capacity of 4mb. + /// + public static ScriptLog GetLogsDefault(this IDeploymentScriptsOperations operations, string resourceGroupName, string scriptName, int? tail = default(int?)) + { + return operations.GetLogsDefaultAsync(resourceGroupName, scriptName, tail).GetAwaiter().GetResult(); + } + + /// + /// Gets deployment script logs for a given deployment script name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Name of the deployment script. + /// + /// + /// The number of lines to show from the tail of the deployment script log. + /// Valid value is a positive number up to 1000. If 'tail' is not provided, all + /// available logs are shown up to container instance log capacity of 4mb. + /// + /// + /// The cancellation token. + /// + public static async Task GetLogsDefaultAsync(this IDeploymentScriptsOperations operations, string resourceGroupName, string scriptName, int? tail = default(int?), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetLogsDefaultWithHttpMessagesAsync(resourceGroupName, scriptName, tail, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Lists deployments scripts. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + public static IPage ListByResourceGroup(this IDeploymentScriptsOperations operations, string resourceGroupName) + { + return operations.ListByResourceGroupAsync(resourceGroupName).GetAwaiter().GetResult(); + } + + /// + /// Lists deployments scripts. + /// + /// + /// 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 IDeploymentScriptsOperations operations, string resourceGroupName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByResourceGroupWithHttpMessagesAsync(resourceGroupName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Creates a deployment script. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Name of the deployment script. + /// + /// + /// Deployment script supplied to the operation. + /// + public static DeploymentScript BeginCreate(this IDeploymentScriptsOperations operations, string resourceGroupName, string scriptName, DeploymentScript deploymentScript) + { + return operations.BeginCreateAsync(resourceGroupName, scriptName, deploymentScript).GetAwaiter().GetResult(); + } + + /// + /// Creates a deployment script. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Name of the deployment script. + /// + /// + /// Deployment script supplied to the operation. + /// + /// + /// The cancellation token. + /// + public static async Task BeginCreateAsync(this IDeploymentScriptsOperations operations, string resourceGroupName, string scriptName, DeploymentScript deploymentScript, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginCreateWithHttpMessagesAsync(resourceGroupName, scriptName, deploymentScript, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Lists all deployment scripts for a given subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListBySubscriptionNext(this IDeploymentScriptsOperations operations, string nextPageLink) + { + return operations.ListBySubscriptionNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Lists all deployment scripts for a given 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> ListBySubscriptionNextAsync(this IDeploymentScriptsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListBySubscriptionNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Lists deployments scripts. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListByResourceGroupNext(this IDeploymentScriptsOperations operations, string nextPageLink) + { + return operations.ListByResourceGroupNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Lists deployments scripts. + /// + /// + /// 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 IDeploymentScriptsOperations 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/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/DeploymentsOperations.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/DeploymentsOperations.cs new file mode 100644 index 0000000000000..264aae05622ef --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/DeploymentsOperations.cs @@ -0,0 +1,11093 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Microsoft.Rest.Azure.OData; + 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; + + /// + /// DeploymentsOperations operations. + /// + internal partial class DeploymentsOperations : IServiceOperations, IDeploymentsOperations + { + /// + /// Initializes a new instance of the DeploymentsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal DeploymentsOperations(ResourceManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the ResourceManagementClient + /// + public ResourceManagementClient Client { get; private set; } + + /// + /// Deletes a deployment from the deployment history. + /// + /// + /// A template deployment that is currently running cannot be deleted. Deleting + /// a template deployment removes the associated deployment operations. This is + /// an asynchronous operation that returns a status of 202 until the template + /// deployment is successfully deleted. The Location response header contains + /// the URI that is used to obtain the status of the process. While the process + /// is running, a call to the URI in the Location header returns a status of + /// 202. When the process finishes, the URI in the Location header returns a + /// status of 204 on success. If the asynchronous request failed, the URI in + /// the Location header returns an error-level status code. + /// + /// + /// The resource scope. + /// + /// + /// The name of the deployment. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task DeleteAtScopeWithHttpMessagesAsync(string scope, string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginDeleteAtScopeWithHttpMessagesAsync(scope, deploymentName, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Checks whether the deployment exists. + /// + /// + /// The resource scope. + /// + /// + /// The name of the deployment. + /// + /// + /// 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> CheckExistenceAtScopeWithHttpMessagesAsync(string scope, string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (scope == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "scope"); + } + if (deploymentName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "deploymentName"); + } + if (deploymentName != null) + { + if (deploymentName.Length > 64) + { + throw new ValidationException(ValidationRules.MaxLength, "deploymentName", 64); + } + if (deploymentName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "deploymentName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(deploymentName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "deploymentName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("scope", scope); + tracingParameters.Add("deploymentName", deploymentName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "CheckExistenceAtScope", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{scope}/providers/Microsoft.Resources/deployments/{deploymentName}").ToString(); + _url = _url.Replace("{scope}", scope); + _url = _url.Replace("{deploymentName}", System.Uri.EscapeDataString(deploymentName)); + 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("HEAD"); + _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, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 204 && (int)_statusCode != 404) + { + 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; + _result.Body = _statusCode == System.Net.HttpStatusCode.NoContent; + 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; + } + + /// + /// Deploys resources at a given scope. + /// + /// + /// You can provide the template and parameters directly in the request or link + /// to JSON files. + /// + /// + /// The resource scope. + /// + /// + /// The name of the deployment. + /// + /// + /// Additional parameters supplied to the operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> CreateOrUpdateAtScopeWithHttpMessagesAsync(string scope, string deploymentName, Deployment parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginCreateOrUpdateAtScopeWithHttpMessagesAsync(scope, deploymentName, parameters, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets a deployment. + /// + /// + /// The resource scope. + /// + /// + /// The name of the deployment. + /// + /// + /// 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> GetAtScopeWithHttpMessagesAsync(string scope, string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (scope == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "scope"); + } + if (deploymentName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "deploymentName"); + } + if (deploymentName != null) + { + if (deploymentName.Length > 64) + { + throw new ValidationException(ValidationRules.MaxLength, "deploymentName", 64); + } + if (deploymentName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "deploymentName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(deploymentName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "deploymentName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("scope", scope); + tracingParameters.Add("deploymentName", deploymentName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetAtScope", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{scope}/providers/Microsoft.Resources/deployments/{deploymentName}").ToString(); + _url = _url.Replace("{scope}", scope); + _url = _url.Replace("{deploymentName}", System.Uri.EscapeDataString(deploymentName)); + 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 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; + } + + /// + /// Cancels a currently running template deployment. + /// + /// + /// You can cancel a deployment only if the provisioningState is Accepted or + /// Running. After the deployment is canceled, the provisioningState is set to + /// Canceled. Canceling a template deployment stops the currently running + /// template deployment and leaves the resources partially deployed. + /// + /// + /// The resource scope. + /// + /// + /// The name of the deployment. + /// + /// + /// 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 CancelAtScopeWithHttpMessagesAsync(string scope, string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (scope == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "scope"); + } + if (deploymentName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "deploymentName"); + } + if (deploymentName != null) + { + if (deploymentName.Length > 64) + { + throw new ValidationException(ValidationRules.MaxLength, "deploymentName", 64); + } + if (deploymentName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "deploymentName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(deploymentName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "deploymentName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("scope", scope); + tracingParameters.Add("deploymentName", deploymentName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "CancelAtScope", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel").ToString(); + _url = _url.Replace("{scope}", scope); + _url = _url.Replace("{deploymentName}", System.Uri.EscapeDataString(deploymentName)); + 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 != 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; + } + + /// + /// Validates whether the specified template is syntactically correct and will + /// be accepted by Azure Resource Manager.. + /// + /// + /// The resource scope. + /// + /// + /// The name of the deployment. + /// + /// + /// Parameters to validate. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> ValidateAtScopeWithHttpMessagesAsync(string scope, string deploymentName, Deployment parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginValidateAtScopeWithHttpMessagesAsync(scope, deploymentName, parameters, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Exports the template used for specified deployment. + /// + /// + /// The resource scope. + /// + /// + /// The name of the deployment. + /// + /// + /// 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> ExportTemplateAtScopeWithHttpMessagesAsync(string scope, string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (scope == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "scope"); + } + if (deploymentName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "deploymentName"); + } + if (deploymentName != null) + { + if (deploymentName.Length > 64) + { + throw new ValidationException(ValidationRules.MaxLength, "deploymentName", 64); + } + if (deploymentName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "deploymentName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(deploymentName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "deploymentName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("scope", scope); + tracingParameters.Add("deploymentName", deploymentName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ExportTemplateAtScope", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate").ToString(); + _url = _url.Replace("{scope}", scope); + _url = _url.Replace("{deploymentName}", System.Uri.EscapeDataString(deploymentName)); + 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) + { + 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 all the deployments at the given scope. + /// + /// + /// The resource scope. + /// + /// + /// OData parameters to apply to the 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>> ListAtScopeWithHttpMessagesAsync(string scope, ODataQuery odataQuery = default(ODataQuery), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (scope == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "scope"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("odataQuery", odataQuery); + tracingParameters.Add("scope", scope); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListAtScope", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{scope}/providers/Microsoft.Resources/deployments/").ToString(); + _url = _url.Replace("{scope}", scope); + List _queryParameters = new List(); + if (odataQuery != null) + { + var _odataFilter = odataQuery.ToString(); + if (!string.IsNullOrEmpty(_odataFilter)) + { + _queryParameters.Add(_odataFilter); + } + } + 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 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 deployment from the deployment history. + /// + /// + /// A template deployment that is currently running cannot be deleted. Deleting + /// a template deployment removes the associated deployment operations. This is + /// an asynchronous operation that returns a status of 202 until the template + /// deployment is successfully deleted. The Location response header contains + /// the URI that is used to obtain the status of the process. While the process + /// is running, a call to the URI in the Location header returns a status of + /// 202. When the process finishes, the URI in the Location header returns a + /// status of 204 on success. If the asynchronous request failed, the URI in + /// the Location header returns an error-level status code. + /// + /// + /// The name of the deployment. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task DeleteAtTenantScopeWithHttpMessagesAsync(string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginDeleteAtTenantScopeWithHttpMessagesAsync(deploymentName, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Checks whether the deployment exists. + /// + /// + /// The name of the deployment. + /// + /// + /// 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> CheckExistenceAtTenantScopeWithHttpMessagesAsync(string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (deploymentName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "deploymentName"); + } + if (deploymentName != null) + { + if (deploymentName.Length > 64) + { + throw new ValidationException(ValidationRules.MaxLength, "deploymentName", 64); + } + if (deploymentName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "deploymentName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(deploymentName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "deploymentName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("deploymentName", deploymentName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "CheckExistenceAtTenantScope", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Resources/deployments/{deploymentName}").ToString(); + _url = _url.Replace("{deploymentName}", System.Uri.EscapeDataString(deploymentName)); + 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("HEAD"); + _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, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 204 && (int)_statusCode != 404) + { + 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; + _result.Body = _statusCode == System.Net.HttpStatusCode.NoContent; + 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; + } + + /// + /// Deploys resources at tenant scope. + /// + /// + /// You can provide the template and parameters directly in the request or link + /// to JSON files. + /// + /// + /// The name of the deployment. + /// + /// + /// Additional parameters supplied to the operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> CreateOrUpdateAtTenantScopeWithHttpMessagesAsync(string deploymentName, ScopedDeployment parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginCreateOrUpdateAtTenantScopeWithHttpMessagesAsync(deploymentName, parameters, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets a deployment. + /// + /// + /// The name of the deployment. + /// + /// + /// 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> GetAtTenantScopeWithHttpMessagesAsync(string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (deploymentName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "deploymentName"); + } + if (deploymentName != null) + { + if (deploymentName.Length > 64) + { + throw new ValidationException(ValidationRules.MaxLength, "deploymentName", 64); + } + if (deploymentName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "deploymentName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(deploymentName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "deploymentName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("deploymentName", deploymentName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetAtTenantScope", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Resources/deployments/{deploymentName}").ToString(); + _url = _url.Replace("{deploymentName}", System.Uri.EscapeDataString(deploymentName)); + 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 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; + } + + /// + /// Cancels a currently running template deployment. + /// + /// + /// You can cancel a deployment only if the provisioningState is Accepted or + /// Running. After the deployment is canceled, the provisioningState is set to + /// Canceled. Canceling a template deployment stops the currently running + /// template deployment and leaves the resources partially deployed. + /// + /// + /// The name of the deployment. + /// + /// + /// 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 CancelAtTenantScopeWithHttpMessagesAsync(string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (deploymentName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "deploymentName"); + } + if (deploymentName != null) + { + if (deploymentName.Length > 64) + { + throw new ValidationException(ValidationRules.MaxLength, "deploymentName", 64); + } + if (deploymentName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "deploymentName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(deploymentName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "deploymentName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("deploymentName", deploymentName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "CancelAtTenantScope", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Resources/deployments/{deploymentName}/cancel").ToString(); + _url = _url.Replace("{deploymentName}", System.Uri.EscapeDataString(deploymentName)); + 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 != 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; + } + + /// + /// Validates whether the specified template is syntactically correct and will + /// be accepted by Azure Resource Manager.. + /// + /// + /// The name of the deployment. + /// + /// + /// Parameters to validate. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> ValidateAtTenantScopeWithHttpMessagesAsync(string deploymentName, ScopedDeployment parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginValidateAtTenantScopeWithHttpMessagesAsync(deploymentName, parameters, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Returns changes that will be made by the deployment if executed at the + /// scope of the tenant group. + /// + /// + /// The name of the deployment. + /// + /// + /// Parameters to validate. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> WhatIfAtTenantScopeWithHttpMessagesAsync(string deploymentName, ScopedDeploymentWhatIf parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginWhatIfAtTenantScopeWithHttpMessagesAsync(deploymentName, parameters, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Exports the template used for specified deployment. + /// + /// + /// The name of the deployment. + /// + /// + /// 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> ExportTemplateAtTenantScopeWithHttpMessagesAsync(string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (deploymentName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "deploymentName"); + } + if (deploymentName != null) + { + if (deploymentName.Length > 64) + { + throw new ValidationException(ValidationRules.MaxLength, "deploymentName", 64); + } + if (deploymentName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "deploymentName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(deploymentName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "deploymentName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("deploymentName", deploymentName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ExportTemplateAtTenantScope", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate").ToString(); + _url = _url.Replace("{deploymentName}", System.Uri.EscapeDataString(deploymentName)); + 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) + { + 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 all the deployments at the tenant scope. + /// + /// + /// OData parameters to apply to the 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>> ListAtTenantScopeWithHttpMessagesAsync(ODataQuery odataQuery = default(ODataQuery), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("odataQuery", odataQuery); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListAtTenantScope", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Resources/deployments/").ToString(); + List _queryParameters = new List(); + if (odataQuery != null) + { + var _odataFilter = odataQuery.ToString(); + if (!string.IsNullOrEmpty(_odataFilter)) + { + _queryParameters.Add(_odataFilter); + } + } + 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 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 deployment from the deployment history. + /// + /// + /// A template deployment that is currently running cannot be deleted. Deleting + /// a template deployment removes the associated deployment operations. This is + /// an asynchronous operation that returns a status of 202 until the template + /// deployment is successfully deleted. The Location response header contains + /// the URI that is used to obtain the status of the process. While the process + /// is running, a call to the URI in the Location header returns a status of + /// 202. When the process finishes, the URI in the Location header returns a + /// status of 204 on success. If the asynchronous request failed, the URI in + /// the Location header returns an error-level status code. + /// + /// + /// The management group ID. + /// + /// + /// The name of the deployment. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task DeleteAtManagementGroupScopeWithHttpMessagesAsync(string groupId, string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginDeleteAtManagementGroupScopeWithHttpMessagesAsync(groupId, deploymentName, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Checks whether the deployment exists. + /// + /// + /// The management group ID. + /// + /// + /// The name of the deployment. + /// + /// + /// 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> CheckExistenceAtManagementGroupScopeWithHttpMessagesAsync(string groupId, string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (groupId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "groupId"); + } + if (groupId != null) + { + if (groupId.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "groupId", 90); + } + if (groupId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "groupId", 1); + } + } + if (deploymentName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "deploymentName"); + } + if (deploymentName != null) + { + if (deploymentName.Length > 64) + { + throw new ValidationException(ValidationRules.MaxLength, "deploymentName", 64); + } + if (deploymentName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "deploymentName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(deploymentName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "deploymentName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("groupId", groupId); + tracingParameters.Add("deploymentName", deploymentName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "CheckExistenceAtManagementGroupScope", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}").ToString(); + _url = _url.Replace("{groupId}", System.Uri.EscapeDataString(groupId)); + _url = _url.Replace("{deploymentName}", System.Uri.EscapeDataString(deploymentName)); + 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("HEAD"); + _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, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 204 && (int)_statusCode != 404) + { + 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; + _result.Body = _statusCode == System.Net.HttpStatusCode.NoContent; + 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; + } + + /// + /// Deploys resources at management group scope. + /// + /// + /// You can provide the template and parameters directly in the request or link + /// to JSON files. + /// + /// + /// The management group ID. + /// + /// + /// The name of the deployment. + /// + /// + /// Additional parameters supplied to the operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> CreateOrUpdateAtManagementGroupScopeWithHttpMessagesAsync(string groupId, string deploymentName, ScopedDeployment parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginCreateOrUpdateAtManagementGroupScopeWithHttpMessagesAsync(groupId, deploymentName, parameters, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets a deployment. + /// + /// + /// The management group ID. + /// + /// + /// The name of the deployment. + /// + /// + /// 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> GetAtManagementGroupScopeWithHttpMessagesAsync(string groupId, string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (groupId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "groupId"); + } + if (groupId != null) + { + if (groupId.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "groupId", 90); + } + if (groupId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "groupId", 1); + } + } + if (deploymentName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "deploymentName"); + } + if (deploymentName != null) + { + if (deploymentName.Length > 64) + { + throw new ValidationException(ValidationRules.MaxLength, "deploymentName", 64); + } + if (deploymentName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "deploymentName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(deploymentName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "deploymentName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("groupId", groupId); + tracingParameters.Add("deploymentName", deploymentName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetAtManagementGroupScope", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}").ToString(); + _url = _url.Replace("{groupId}", System.Uri.EscapeDataString(groupId)); + _url = _url.Replace("{deploymentName}", System.Uri.EscapeDataString(deploymentName)); + 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 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; + } + + /// + /// Cancels a currently running template deployment. + /// + /// + /// You can cancel a deployment only if the provisioningState is Accepted or + /// Running. After the deployment is canceled, the provisioningState is set to + /// Canceled. Canceling a template deployment stops the currently running + /// template deployment and leaves the resources partially deployed. + /// + /// + /// The management group ID. + /// + /// + /// The name of the deployment. + /// + /// + /// 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 CancelAtManagementGroupScopeWithHttpMessagesAsync(string groupId, string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (groupId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "groupId"); + } + if (groupId != null) + { + if (groupId.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "groupId", 90); + } + if (groupId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "groupId", 1); + } + } + if (deploymentName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "deploymentName"); + } + if (deploymentName != null) + { + if (deploymentName.Length > 64) + { + throw new ValidationException(ValidationRules.MaxLength, "deploymentName", 64); + } + if (deploymentName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "deploymentName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(deploymentName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "deploymentName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("groupId", groupId); + tracingParameters.Add("deploymentName", deploymentName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "CancelAtManagementGroupScope", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel").ToString(); + _url = _url.Replace("{groupId}", System.Uri.EscapeDataString(groupId)); + _url = _url.Replace("{deploymentName}", System.Uri.EscapeDataString(deploymentName)); + 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 != 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; + } + + /// + /// Validates whether the specified template is syntactically correct and will + /// be accepted by Azure Resource Manager.. + /// + /// + /// The management group ID. + /// + /// + /// The name of the deployment. + /// + /// + /// Parameters to validate. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> ValidateAtManagementGroupScopeWithHttpMessagesAsync(string groupId, string deploymentName, ScopedDeployment parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginValidateAtManagementGroupScopeWithHttpMessagesAsync(groupId, deploymentName, parameters, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Returns changes that will be made by the deployment if executed at the + /// scope of the management group. + /// + /// + /// The management group ID. + /// + /// + /// The name of the deployment. + /// + /// + /// Parameters to validate. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> WhatIfAtManagementGroupScopeWithHttpMessagesAsync(string groupId, string deploymentName, ScopedDeploymentWhatIf parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginWhatIfAtManagementGroupScopeWithHttpMessagesAsync(groupId, deploymentName, parameters, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Exports the template used for specified deployment. + /// + /// + /// The management group ID. + /// + /// + /// The name of the deployment. + /// + /// + /// 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> ExportTemplateAtManagementGroupScopeWithHttpMessagesAsync(string groupId, string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (groupId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "groupId"); + } + if (groupId != null) + { + if (groupId.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "groupId", 90); + } + if (groupId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "groupId", 1); + } + } + if (deploymentName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "deploymentName"); + } + if (deploymentName != null) + { + if (deploymentName.Length > 64) + { + throw new ValidationException(ValidationRules.MaxLength, "deploymentName", 64); + } + if (deploymentName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "deploymentName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(deploymentName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "deploymentName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("groupId", groupId); + tracingParameters.Add("deploymentName", deploymentName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ExportTemplateAtManagementGroupScope", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate").ToString(); + _url = _url.Replace("{groupId}", System.Uri.EscapeDataString(groupId)); + _url = _url.Replace("{deploymentName}", System.Uri.EscapeDataString(deploymentName)); + 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) + { + 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 all the deployments for a management group. + /// + /// + /// The management group ID. + /// + /// + /// OData parameters to apply to the 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>> ListAtManagementGroupScopeWithHttpMessagesAsync(string groupId, ODataQuery odataQuery = default(ODataQuery), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (groupId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "groupId"); + } + if (groupId != null) + { + if (groupId.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "groupId", 90); + } + if (groupId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "groupId", 1); + } + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("odataQuery", odataQuery); + tracingParameters.Add("groupId", groupId); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListAtManagementGroupScope", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/").ToString(); + _url = _url.Replace("{groupId}", System.Uri.EscapeDataString(groupId)); + List _queryParameters = new List(); + if (odataQuery != null) + { + var _odataFilter = odataQuery.ToString(); + if (!string.IsNullOrEmpty(_odataFilter)) + { + _queryParameters.Add(_odataFilter); + } + } + 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 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 deployment from the deployment history. + /// + /// + /// A template deployment that is currently running cannot be deleted. Deleting + /// a template deployment removes the associated deployment operations. This is + /// an asynchronous operation that returns a status of 202 until the template + /// deployment is successfully deleted. The Location response header contains + /// the URI that is used to obtain the status of the process. While the process + /// is running, a call to the URI in the Location header returns a status of + /// 202. When the process finishes, the URI in the Location header returns a + /// status of 204 on success. If the asynchronous request failed, the URI in + /// the Location header returns an error-level status code. + /// + /// + /// The name of the deployment. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task DeleteAtSubscriptionScopeWithHttpMessagesAsync(string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginDeleteAtSubscriptionScopeWithHttpMessagesAsync(deploymentName, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Checks whether the deployment exists. + /// + /// + /// The name of the deployment. + /// + /// + /// 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> CheckExistenceAtSubscriptionScopeWithHttpMessagesAsync(string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (deploymentName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "deploymentName"); + } + if (deploymentName != null) + { + if (deploymentName.Length > 64) + { + throw new ValidationException(ValidationRules.MaxLength, "deploymentName", 64); + } + if (deploymentName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "deploymentName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(deploymentName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "deploymentName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("deploymentName", deploymentName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "CheckExistenceAtSubscriptionScope", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}").ToString(); + _url = _url.Replace("{deploymentName}", System.Uri.EscapeDataString(deploymentName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + 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("HEAD"); + _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, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 204 && (int)_statusCode != 404) + { + 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; + _result.Body = _statusCode == System.Net.HttpStatusCode.NoContent; + 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; + } + + /// + /// Deploys resources at subscription scope. + /// + /// + /// You can provide the template and parameters directly in the request or link + /// to JSON files. + /// + /// + /// The name of the deployment. + /// + /// + /// Additional parameters supplied to the operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> CreateOrUpdateAtSubscriptionScopeWithHttpMessagesAsync(string deploymentName, Deployment parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginCreateOrUpdateAtSubscriptionScopeWithHttpMessagesAsync(deploymentName, parameters, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets a deployment. + /// + /// + /// The name of the deployment. + /// + /// + /// 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> GetAtSubscriptionScopeWithHttpMessagesAsync(string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (deploymentName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "deploymentName"); + } + if (deploymentName != null) + { + if (deploymentName.Length > 64) + { + throw new ValidationException(ValidationRules.MaxLength, "deploymentName", 64); + } + if (deploymentName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "deploymentName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(deploymentName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "deploymentName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("deploymentName", deploymentName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetAtSubscriptionScope", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}").ToString(); + _url = _url.Replace("{deploymentName}", System.Uri.EscapeDataString(deploymentName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + 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 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; + } + + /// + /// Cancels a currently running template deployment. + /// + /// + /// You can cancel a deployment only if the provisioningState is Accepted or + /// Running. After the deployment is canceled, the provisioningState is set to + /// Canceled. Canceling a template deployment stops the currently running + /// template deployment and leaves the resources partially deployed. + /// + /// + /// The name of the deployment. + /// + /// + /// 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 CancelAtSubscriptionScopeWithHttpMessagesAsync(string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (deploymentName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "deploymentName"); + } + if (deploymentName != null) + { + if (deploymentName.Length > 64) + { + throw new ValidationException(ValidationRules.MaxLength, "deploymentName", 64); + } + if (deploymentName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "deploymentName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(deploymentName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "deploymentName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("deploymentName", deploymentName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "CancelAtSubscriptionScope", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel").ToString(); + _url = _url.Replace("{deploymentName}", System.Uri.EscapeDataString(deploymentName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + 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 != 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; + } + + /// + /// Validates whether the specified template is syntactically correct and will + /// be accepted by Azure Resource Manager.. + /// + /// + /// The name of the deployment. + /// + /// + /// Parameters to validate. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> ValidateAtSubscriptionScopeWithHttpMessagesAsync(string deploymentName, Deployment parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginValidateAtSubscriptionScopeWithHttpMessagesAsync(deploymentName, parameters, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Returns changes that will be made by the deployment if executed at the + /// scope of the subscription. + /// + /// + /// The name of the deployment. + /// + /// + /// Parameters to What If. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> WhatIfAtSubscriptionScopeWithHttpMessagesAsync(string deploymentName, DeploymentWhatIf parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginWhatIfAtSubscriptionScopeWithHttpMessagesAsync(deploymentName, parameters, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Exports the template used for specified deployment. + /// + /// + /// The name of the deployment. + /// + /// + /// 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> ExportTemplateAtSubscriptionScopeWithHttpMessagesAsync(string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (deploymentName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "deploymentName"); + } + if (deploymentName != null) + { + if (deploymentName.Length > 64) + { + throw new ValidationException(ValidationRules.MaxLength, "deploymentName", 64); + } + if (deploymentName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "deploymentName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(deploymentName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "deploymentName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("deploymentName", deploymentName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ExportTemplateAtSubscriptionScope", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate").ToString(); + _url = _url.Replace("{deploymentName}", System.Uri.EscapeDataString(deploymentName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + 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) + { + 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 all the deployments for a subscription. + /// + /// + /// OData parameters to apply to the 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>> ListAtSubscriptionScopeWithHttpMessagesAsync(ODataQuery odataQuery = default(ODataQuery), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("odataQuery", odataQuery); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListAtSubscriptionScope", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (odataQuery != null) + { + var _odataFilter = odataQuery.ToString(); + if (!string.IsNullOrEmpty(_odataFilter)) + { + _queryParameters.Add(_odataFilter); + } + } + 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 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 deployment from the deployment history. + /// + /// + /// A template deployment that is currently running cannot be deleted. Deleting + /// a template deployment removes the associated deployment operations. + /// Deleting a template deployment does not affect the state of the resource + /// group. This is an asynchronous operation that returns a status of 202 until + /// the template deployment is successfully deleted. The Location response + /// header contains the URI that is used to obtain the status of the process. + /// While the process is running, a call to the URI in the Location header + /// returns a status of 202. When the process finishes, the URI in the Location + /// header returns a status of 204 on success. If the asynchronous request + /// failed, the URI in the Location header returns an error-level status code. + /// + /// + /// The name of the resource group with the deployment to delete. The name is + /// case insensitive. + /// + /// + /// The name of the deployment. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task DeleteWithHttpMessagesAsync(string resourceGroupName, string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginDeleteWithHttpMessagesAsync(resourceGroupName, deploymentName, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Checks whether the deployment exists. + /// + /// + /// The name of the resource group with the deployment to check. The name is + /// case insensitive. + /// + /// + /// The name of the deployment. + /// + /// + /// 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> CheckExistenceWithHttpMessagesAsync(string resourceGroupName, string deploymentName, 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 (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (deploymentName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "deploymentName"); + } + if (deploymentName != null) + { + if (deploymentName.Length > 64) + { + throw new ValidationException(ValidationRules.MaxLength, "deploymentName", 64); + } + if (deploymentName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "deploymentName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(deploymentName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "deploymentName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("deploymentName", deploymentName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "CheckExistence", 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.Resources/deployments/{deploymentName}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{deploymentName}", System.Uri.EscapeDataString(deploymentName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + 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("HEAD"); + _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, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 204 && (int)_statusCode != 404) + { + 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; + _result.Body = _statusCode == System.Net.HttpStatusCode.NoContent; + 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; + } + + /// + /// Deploys resources to a resource group. + /// + /// + /// You can provide the template and parameters directly in the request or link + /// to JSON files. + /// + /// + /// The name of the resource group to deploy the resources to. The name is case + /// insensitive. The resource group must already exist. + /// + /// + /// The name of the deployment. + /// + /// + /// Additional parameters supplied to the operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string deploymentName, Deployment parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, deploymentName, parameters, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets a deployment. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the deployment. + /// + /// + /// 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 deploymentName, 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 (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (deploymentName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "deploymentName"); + } + if (deploymentName != null) + { + if (deploymentName.Length > 64) + { + throw new ValidationException(ValidationRules.MaxLength, "deploymentName", 64); + } + if (deploymentName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "deploymentName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(deploymentName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "deploymentName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("deploymentName", deploymentName); + 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.Resources/deployments/{deploymentName}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{deploymentName}", System.Uri.EscapeDataString(deploymentName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + 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 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; + } + + /// + /// Cancels a currently running template deployment. + /// + /// + /// You can cancel a deployment only if the provisioningState is Accepted or + /// Running. After the deployment is canceled, the provisioningState is set to + /// Canceled. Canceling a template deployment stops the currently running + /// template deployment and leaves the resource group partially deployed. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the deployment. + /// + /// + /// 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 CancelWithHttpMessagesAsync(string resourceGroupName, string deploymentName, 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 (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (deploymentName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "deploymentName"); + } + if (deploymentName != null) + { + if (deploymentName.Length > 64) + { + throw new ValidationException(ValidationRules.MaxLength, "deploymentName", 64); + } + if (deploymentName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "deploymentName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(deploymentName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "deploymentName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("deploymentName", deploymentName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Cancel", 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.Resources/deployments/{deploymentName}/cancel").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{deploymentName}", System.Uri.EscapeDataString(deploymentName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + 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 != 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; + } + + /// + /// Validates whether the specified template is syntactically correct and will + /// be accepted by Azure Resource Manager.. + /// + /// + /// The name of the resource group the template will be deployed to. The name + /// is case insensitive. + /// + /// + /// The name of the deployment. + /// + /// + /// Parameters to validate. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> ValidateWithHttpMessagesAsync(string resourceGroupName, string deploymentName, Deployment parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginValidateWithHttpMessagesAsync(resourceGroupName, deploymentName, parameters, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Returns changes that will be made by the deployment if executed at the + /// scope of the resource group. + /// + /// + /// The name of the resource group the template will be deployed to. The name + /// is case insensitive. + /// + /// + /// The name of the deployment. + /// + /// + /// Parameters to validate. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> WhatIfWithHttpMessagesAsync(string resourceGroupName, string deploymentName, DeploymentWhatIf parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginWhatIfWithHttpMessagesAsync(resourceGroupName, deploymentName, parameters, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Exports the template used for specified deployment. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the deployment. + /// + /// + /// 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> ExportTemplateWithHttpMessagesAsync(string resourceGroupName, string deploymentName, 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 (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (deploymentName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "deploymentName"); + } + if (deploymentName != null) + { + if (deploymentName.Length > 64) + { + throw new ValidationException(ValidationRules.MaxLength, "deploymentName", 64); + } + if (deploymentName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "deploymentName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(deploymentName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "deploymentName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("deploymentName", deploymentName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ExportTemplate", 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.Resources/deployments/{deploymentName}/exportTemplate").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{deploymentName}", System.Uri.EscapeDataString(deploymentName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + 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) + { + 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 all the deployments for a resource group. + /// + /// + /// The name of the resource group with the deployments to get. The name is + /// case insensitive. + /// + /// + /// OData parameters to apply to the 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>> ListByResourceGroupWithHttpMessagesAsync(string resourceGroupName, ODataQuery odataQuery = default(ODataQuery), 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 (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("odataQuery", odataQuery); + 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.Resources/deployments/").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (odataQuery != null) + { + var _odataFilter = odataQuery.ToString(); + if (!string.IsNullOrEmpty(_odataFilter)) + { + _queryParameters.Add(_odataFilter); + } + } + 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 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; + } + + /// + /// Calculate the hash of the given template. + /// + /// + /// The template provided to calculate hash. + /// + /// + /// 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> CalculateTemplateHashWithHttpMessagesAsync(object template, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (template == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "template"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("template", template); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "CalculateTemplateHash", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Resources/calculateTemplateHash").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("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(template != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(template, 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; + } + + /// + /// Deletes a deployment from the deployment history. + /// + /// + /// A template deployment that is currently running cannot be deleted. Deleting + /// a template deployment removes the associated deployment operations. This is + /// an asynchronous operation that returns a status of 202 until the template + /// deployment is successfully deleted. The Location response header contains + /// the URI that is used to obtain the status of the process. While the process + /// is running, a call to the URI in the Location header returns a status of + /// 202. When the process finishes, the URI in the Location header returns a + /// status of 204 on success. If the asynchronous request failed, the URI in + /// the Location header returns an error-level status code. + /// + /// + /// The resource scope. + /// + /// + /// The name of the deployment. + /// + /// + /// 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 BeginDeleteAtScopeWithHttpMessagesAsync(string scope, string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (scope == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "scope"); + } + if (deploymentName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "deploymentName"); + } + if (deploymentName != null) + { + if (deploymentName.Length > 64) + { + throw new ValidationException(ValidationRules.MaxLength, "deploymentName", 64); + } + if (deploymentName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "deploymentName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(deploymentName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "deploymentName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("scope", scope); + tracingParameters.Add("deploymentName", deploymentName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginDeleteAtScope", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{scope}/providers/Microsoft.Resources/deployments/{deploymentName}").ToString(); + _url = _url.Replace("{scope}", scope); + _url = _url.Replace("{deploymentName}", System.Uri.EscapeDataString(deploymentName)); + 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 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; + } + + /// + /// Deploys resources at a given scope. + /// + /// + /// You can provide the template and parameters directly in the request or link + /// to JSON files. + /// + /// + /// The resource scope. + /// + /// + /// The name of the deployment. + /// + /// + /// Additional parameters supplied to the 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> BeginCreateOrUpdateAtScopeWithHttpMessagesAsync(string scope, string deploymentName, Deployment parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (scope == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "scope"); + } + if (deploymentName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "deploymentName"); + } + if (deploymentName != null) + { + if (deploymentName.Length > 64) + { + throw new ValidationException(ValidationRules.MaxLength, "deploymentName", 64); + } + if (deploymentName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "deploymentName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(deploymentName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "deploymentName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (parameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); + } + if (parameters != null) + { + parameters.Validate(); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("scope", scope); + tracingParameters.Add("deploymentName", deploymentName); + tracingParameters.Add("parameters", parameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginCreateOrUpdateAtScope", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{scope}/providers/Microsoft.Resources/deployments/{deploymentName}").ToString(); + _url = _url.Replace("{scope}", scope); + _url = _url.Replace("{deploymentName}", System.Uri.EscapeDataString(deploymentName)); + 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 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; + } + + /// + /// Validates whether the specified template is syntactically correct and will + /// be accepted by Azure Resource Manager.. + /// + /// + /// The resource scope. + /// + /// + /// The name of the deployment. + /// + /// + /// Parameters to validate. + /// + /// + /// 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> BeginValidateAtScopeWithHttpMessagesAsync(string scope, string deploymentName, Deployment parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (scope == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "scope"); + } + if (deploymentName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "deploymentName"); + } + if (deploymentName != null) + { + if (deploymentName.Length > 64) + { + throw new ValidationException(ValidationRules.MaxLength, "deploymentName", 64); + } + if (deploymentName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "deploymentName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(deploymentName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "deploymentName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (parameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); + } + if (parameters != null) + { + parameters.Validate(); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("scope", scope); + tracingParameters.Add("deploymentName", deploymentName); + tracingParameters.Add("parameters", parameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginValidateAtScope", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/validate").ToString(); + _url = _url.Replace("{scope}", scope); + _url = _url.Replace("{deploymentName}", System.Uri.EscapeDataString(deploymentName)); + 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(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 && (int)_statusCode != 400) + { + 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 == 400) + { + _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 deployment from the deployment history. + /// + /// + /// A template deployment that is currently running cannot be deleted. Deleting + /// a template deployment removes the associated deployment operations. This is + /// an asynchronous operation that returns a status of 202 until the template + /// deployment is successfully deleted. The Location response header contains + /// the URI that is used to obtain the status of the process. While the process + /// is running, a call to the URI in the Location header returns a status of + /// 202. When the process finishes, the URI in the Location header returns a + /// status of 204 on success. If the asynchronous request failed, the URI in + /// the Location header returns an error-level status code. + /// + /// + /// The name of the deployment. + /// + /// + /// 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 BeginDeleteAtTenantScopeWithHttpMessagesAsync(string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (deploymentName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "deploymentName"); + } + if (deploymentName != null) + { + if (deploymentName.Length > 64) + { + throw new ValidationException(ValidationRules.MaxLength, "deploymentName", 64); + } + if (deploymentName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "deploymentName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(deploymentName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "deploymentName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("deploymentName", deploymentName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginDeleteAtTenantScope", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Resources/deployments/{deploymentName}").ToString(); + _url = _url.Replace("{deploymentName}", System.Uri.EscapeDataString(deploymentName)); + 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 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; + } + + /// + /// Deploys resources at tenant scope. + /// + /// + /// You can provide the template and parameters directly in the request or link + /// to JSON files. + /// + /// + /// The name of the deployment. + /// + /// + /// Additional parameters supplied to the 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> BeginCreateOrUpdateAtTenantScopeWithHttpMessagesAsync(string deploymentName, ScopedDeployment parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (deploymentName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "deploymentName"); + } + if (deploymentName != null) + { + if (deploymentName.Length > 64) + { + throw new ValidationException(ValidationRules.MaxLength, "deploymentName", 64); + } + if (deploymentName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "deploymentName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(deploymentName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "deploymentName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (parameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); + } + if (parameters != null) + { + parameters.Validate(); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("deploymentName", deploymentName); + tracingParameters.Add("parameters", parameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginCreateOrUpdateAtTenantScope", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Resources/deployments/{deploymentName}").ToString(); + _url = _url.Replace("{deploymentName}", System.Uri.EscapeDataString(deploymentName)); + 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 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; + } + + /// + /// Validates whether the specified template is syntactically correct and will + /// be accepted by Azure Resource Manager.. + /// + /// + /// The name of the deployment. + /// + /// + /// Parameters to validate. + /// + /// + /// 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> BeginValidateAtTenantScopeWithHttpMessagesAsync(string deploymentName, ScopedDeployment parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (deploymentName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "deploymentName"); + } + if (deploymentName != null) + { + if (deploymentName.Length > 64) + { + throw new ValidationException(ValidationRules.MaxLength, "deploymentName", 64); + } + if (deploymentName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "deploymentName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(deploymentName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "deploymentName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (parameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); + } + if (parameters != null) + { + parameters.Validate(); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("deploymentName", deploymentName); + tracingParameters.Add("parameters", parameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginValidateAtTenantScope", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Resources/deployments/{deploymentName}/validate").ToString(); + _url = _url.Replace("{deploymentName}", System.Uri.EscapeDataString(deploymentName)); + 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(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 && (int)_statusCode != 400) + { + 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 == 400) + { + _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; + } + + /// + /// Returns changes that will be made by the deployment if executed at the + /// scope of the tenant group. + /// + /// + /// The name of the deployment. + /// + /// + /// Parameters to validate. + /// + /// + /// 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> BeginWhatIfAtTenantScopeWithHttpMessagesAsync(string deploymentName, ScopedDeploymentWhatIf parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (deploymentName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "deploymentName"); + } + if (deploymentName != null) + { + if (deploymentName.Length > 64) + { + throw new ValidationException(ValidationRules.MaxLength, "deploymentName", 64); + } + if (deploymentName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "deploymentName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(deploymentName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "deploymentName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (parameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); + } + if (parameters != null) + { + parameters.Validate(); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("deploymentName", deploymentName); + tracingParameters.Add("parameters", parameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginWhatIfAtTenantScope", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Resources/deployments/{deploymentName}/whatIf").ToString(); + _url = _url.Replace("{deploymentName}", System.Uri.EscapeDataString(deploymentName)); + 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(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); + } + } + 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 deployment from the deployment history. + /// + /// + /// A template deployment that is currently running cannot be deleted. Deleting + /// a template deployment removes the associated deployment operations. This is + /// an asynchronous operation that returns a status of 202 until the template + /// deployment is successfully deleted. The Location response header contains + /// the URI that is used to obtain the status of the process. While the process + /// is running, a call to the URI in the Location header returns a status of + /// 202. When the process finishes, the URI in the Location header returns a + /// status of 204 on success. If the asynchronous request failed, the URI in + /// the Location header returns an error-level status code. + /// + /// + /// The management group ID. + /// + /// + /// The name of the deployment. + /// + /// + /// 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 BeginDeleteAtManagementGroupScopeWithHttpMessagesAsync(string groupId, string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (groupId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "groupId"); + } + if (groupId != null) + { + if (groupId.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "groupId", 90); + } + if (groupId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "groupId", 1); + } + } + if (deploymentName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "deploymentName"); + } + if (deploymentName != null) + { + if (deploymentName.Length > 64) + { + throw new ValidationException(ValidationRules.MaxLength, "deploymentName", 64); + } + if (deploymentName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "deploymentName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(deploymentName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "deploymentName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("groupId", groupId); + tracingParameters.Add("deploymentName", deploymentName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginDeleteAtManagementGroupScope", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}").ToString(); + _url = _url.Replace("{groupId}", System.Uri.EscapeDataString(groupId)); + _url = _url.Replace("{deploymentName}", System.Uri.EscapeDataString(deploymentName)); + 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 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; + } + + /// + /// Deploys resources at management group scope. + /// + /// + /// You can provide the template and parameters directly in the request or link + /// to JSON files. + /// + /// + /// The management group ID. + /// + /// + /// The name of the deployment. + /// + /// + /// Additional parameters supplied to the 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> BeginCreateOrUpdateAtManagementGroupScopeWithHttpMessagesAsync(string groupId, string deploymentName, ScopedDeployment parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (groupId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "groupId"); + } + if (groupId != null) + { + if (groupId.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "groupId", 90); + } + if (groupId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "groupId", 1); + } + } + if (deploymentName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "deploymentName"); + } + if (deploymentName != null) + { + if (deploymentName.Length > 64) + { + throw new ValidationException(ValidationRules.MaxLength, "deploymentName", 64); + } + if (deploymentName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "deploymentName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(deploymentName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "deploymentName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (parameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); + } + if (parameters != null) + { + parameters.Validate(); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("groupId", groupId); + tracingParameters.Add("deploymentName", deploymentName); + tracingParameters.Add("parameters", parameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginCreateOrUpdateAtManagementGroupScope", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}").ToString(); + _url = _url.Replace("{groupId}", System.Uri.EscapeDataString(groupId)); + _url = _url.Replace("{deploymentName}", System.Uri.EscapeDataString(deploymentName)); + 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 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; + } + + /// + /// Validates whether the specified template is syntactically correct and will + /// be accepted by Azure Resource Manager.. + /// + /// + /// The management group ID. + /// + /// + /// The name of the deployment. + /// + /// + /// Parameters to validate. + /// + /// + /// 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> BeginValidateAtManagementGroupScopeWithHttpMessagesAsync(string groupId, string deploymentName, ScopedDeployment parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (groupId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "groupId"); + } + if (groupId != null) + { + if (groupId.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "groupId", 90); + } + if (groupId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "groupId", 1); + } + } + if (deploymentName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "deploymentName"); + } + if (deploymentName != null) + { + if (deploymentName.Length > 64) + { + throw new ValidationException(ValidationRules.MaxLength, "deploymentName", 64); + } + if (deploymentName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "deploymentName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(deploymentName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "deploymentName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (parameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); + } + if (parameters != null) + { + parameters.Validate(); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("groupId", groupId); + tracingParameters.Add("deploymentName", deploymentName); + tracingParameters.Add("parameters", parameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginValidateAtManagementGroupScope", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate").ToString(); + _url = _url.Replace("{groupId}", System.Uri.EscapeDataString(groupId)); + _url = _url.Replace("{deploymentName}", System.Uri.EscapeDataString(deploymentName)); + 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(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 && (int)_statusCode != 400) + { + 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 == 400) + { + _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; + } + + /// + /// Returns changes that will be made by the deployment if executed at the + /// scope of the management group. + /// + /// + /// The management group ID. + /// + /// + /// The name of the deployment. + /// + /// + /// Parameters to validate. + /// + /// + /// 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> BeginWhatIfAtManagementGroupScopeWithHttpMessagesAsync(string groupId, string deploymentName, ScopedDeploymentWhatIf parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (groupId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "groupId"); + } + if (groupId != null) + { + if (groupId.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "groupId", 90); + } + if (groupId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "groupId", 1); + } + } + if (deploymentName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "deploymentName"); + } + if (deploymentName != null) + { + if (deploymentName.Length > 64) + { + throw new ValidationException(ValidationRules.MaxLength, "deploymentName", 64); + } + if (deploymentName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "deploymentName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(deploymentName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "deploymentName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (parameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); + } + if (parameters != null) + { + parameters.Validate(); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("groupId", groupId); + tracingParameters.Add("deploymentName", deploymentName); + tracingParameters.Add("parameters", parameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginWhatIfAtManagementGroupScope", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf").ToString(); + _url = _url.Replace("{groupId}", System.Uri.EscapeDataString(groupId)); + _url = _url.Replace("{deploymentName}", System.Uri.EscapeDataString(deploymentName)); + 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(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); + } + } + 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 deployment from the deployment history. + /// + /// + /// A template deployment that is currently running cannot be deleted. Deleting + /// a template deployment removes the associated deployment operations. This is + /// an asynchronous operation that returns a status of 202 until the template + /// deployment is successfully deleted. The Location response header contains + /// the URI that is used to obtain the status of the process. While the process + /// is running, a call to the URI in the Location header returns a status of + /// 202. When the process finishes, the URI in the Location header returns a + /// status of 204 on success. If the asynchronous request failed, the URI in + /// the Location header returns an error-level status code. + /// + /// + /// The name of the deployment. + /// + /// + /// 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 BeginDeleteAtSubscriptionScopeWithHttpMessagesAsync(string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (deploymentName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "deploymentName"); + } + if (deploymentName != null) + { + if (deploymentName.Length > 64) + { + throw new ValidationException(ValidationRules.MaxLength, "deploymentName", 64); + } + if (deploymentName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "deploymentName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(deploymentName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "deploymentName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("deploymentName", deploymentName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginDeleteAtSubscriptionScope", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}").ToString(); + _url = _url.Replace("{deploymentName}", System.Uri.EscapeDataString(deploymentName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + 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 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; + } + + /// + /// Deploys resources at subscription scope. + /// + /// + /// You can provide the template and parameters directly in the request or link + /// to JSON files. + /// + /// + /// The name of the deployment. + /// + /// + /// Additional parameters supplied to the 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> BeginCreateOrUpdateAtSubscriptionScopeWithHttpMessagesAsync(string deploymentName, Deployment parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (deploymentName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "deploymentName"); + } + if (deploymentName != null) + { + if (deploymentName.Length > 64) + { + throw new ValidationException(ValidationRules.MaxLength, "deploymentName", 64); + } + if (deploymentName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "deploymentName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(deploymentName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "deploymentName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (parameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); + } + if (parameters != null) + { + parameters.Validate(); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("deploymentName", deploymentName); + tracingParameters.Add("parameters", parameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginCreateOrUpdateAtSubscriptionScope", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}").ToString(); + _url = _url.Replace("{deploymentName}", System.Uri.EscapeDataString(deploymentName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + 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 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; + } + + /// + /// Validates whether the specified template is syntactically correct and will + /// be accepted by Azure Resource Manager.. + /// + /// + /// The name of the deployment. + /// + /// + /// Parameters to validate. + /// + /// + /// 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> BeginValidateAtSubscriptionScopeWithHttpMessagesAsync(string deploymentName, Deployment parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (deploymentName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "deploymentName"); + } + if (deploymentName != null) + { + if (deploymentName.Length > 64) + { + throw new ValidationException(ValidationRules.MaxLength, "deploymentName", 64); + } + if (deploymentName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "deploymentName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(deploymentName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "deploymentName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (parameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); + } + if (parameters != null) + { + parameters.Validate(); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("deploymentName", deploymentName); + tracingParameters.Add("parameters", parameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginValidateAtSubscriptionScope", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate").ToString(); + _url = _url.Replace("{deploymentName}", System.Uri.EscapeDataString(deploymentName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + 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(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 && (int)_statusCode != 400) + { + 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 == 400) + { + _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; + } + + /// + /// Returns changes that will be made by the deployment if executed at the + /// scope of the subscription. + /// + /// + /// The name of the deployment. + /// + /// + /// Parameters to What If. + /// + /// + /// 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> BeginWhatIfAtSubscriptionScopeWithHttpMessagesAsync(string deploymentName, DeploymentWhatIf parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (deploymentName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "deploymentName"); + } + if (deploymentName != null) + { + if (deploymentName.Length > 64) + { + throw new ValidationException(ValidationRules.MaxLength, "deploymentName", 64); + } + if (deploymentName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "deploymentName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(deploymentName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "deploymentName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (parameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); + } + if (parameters != null) + { + parameters.Validate(); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("deploymentName", deploymentName); + tracingParameters.Add("parameters", parameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginWhatIfAtSubscriptionScope", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf").ToString(); + _url = _url.Replace("{deploymentName}", System.Uri.EscapeDataString(deploymentName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + 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(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); + } + } + 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 deployment from the deployment history. + /// + /// + /// A template deployment that is currently running cannot be deleted. Deleting + /// a template deployment removes the associated deployment operations. + /// Deleting a template deployment does not affect the state of the resource + /// group. This is an asynchronous operation that returns a status of 202 until + /// the template deployment is successfully deleted. The Location response + /// header contains the URI that is used to obtain the status of the process. + /// While the process is running, a call to the URI in the Location header + /// returns a status of 202. When the process finishes, the URI in the Location + /// header returns a status of 204 on success. If the asynchronous request + /// failed, the URI in the Location header returns an error-level status code. + /// + /// + /// The name of the resource group with the deployment to delete. The name is + /// case insensitive. + /// + /// + /// The name of the deployment. + /// + /// + /// 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 deploymentName, 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 (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (deploymentName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "deploymentName"); + } + if (deploymentName != null) + { + if (deploymentName.Length > 64) + { + throw new ValidationException(ValidationRules.MaxLength, "deploymentName", 64); + } + if (deploymentName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "deploymentName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(deploymentName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "deploymentName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("deploymentName", deploymentName); + 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.Resources/deployments/{deploymentName}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{deploymentName}", System.Uri.EscapeDataString(deploymentName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + 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 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; + } + + /// + /// Deploys resources to a resource group. + /// + /// + /// You can provide the template and parameters directly in the request or link + /// to JSON files. + /// + /// + /// The name of the resource group to deploy the resources to. The name is case + /// insensitive. The resource group must already exist. + /// + /// + /// The name of the deployment. + /// + /// + /// Additional parameters supplied to the 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> BeginCreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string deploymentName, Deployment 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 (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (deploymentName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "deploymentName"); + } + if (deploymentName != null) + { + if (deploymentName.Length > 64) + { + throw new ValidationException(ValidationRules.MaxLength, "deploymentName", 64); + } + if (deploymentName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "deploymentName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(deploymentName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "deploymentName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (parameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); + } + if (parameters != null) + { + parameters.Validate(); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("deploymentName", deploymentName); + 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.Resources/deployments/{deploymentName}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{deploymentName}", System.Uri.EscapeDataString(deploymentName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + 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 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; + } + + /// + /// Validates whether the specified template is syntactically correct and will + /// be accepted by Azure Resource Manager.. + /// + /// + /// The name of the resource group the template will be deployed to. The name + /// is case insensitive. + /// + /// + /// The name of the deployment. + /// + /// + /// Parameters to validate. + /// + /// + /// 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> BeginValidateWithHttpMessagesAsync(string resourceGroupName, string deploymentName, Deployment 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 (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (deploymentName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "deploymentName"); + } + if (deploymentName != null) + { + if (deploymentName.Length > 64) + { + throw new ValidationException(ValidationRules.MaxLength, "deploymentName", 64); + } + if (deploymentName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "deploymentName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(deploymentName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "deploymentName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (parameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); + } + if (parameters != null) + { + parameters.Validate(); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("deploymentName", deploymentName); + tracingParameters.Add("parameters", parameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginValidate", 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.Resources/deployments/{deploymentName}/validate").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{deploymentName}", System.Uri.EscapeDataString(deploymentName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + 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(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 && (int)_statusCode != 400) + { + 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 == 400) + { + _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; + } + + /// + /// Returns changes that will be made by the deployment if executed at the + /// scope of the resource group. + /// + /// + /// The name of the resource group the template will be deployed to. The name + /// is case insensitive. + /// + /// + /// The name of the deployment. + /// + /// + /// Parameters to validate. + /// + /// + /// 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> BeginWhatIfWithHttpMessagesAsync(string resourceGroupName, string deploymentName, DeploymentWhatIf 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 (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (deploymentName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "deploymentName"); + } + if (deploymentName != null) + { + if (deploymentName.Length > 64) + { + throw new ValidationException(ValidationRules.MaxLength, "deploymentName", 64); + } + if (deploymentName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "deploymentName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(deploymentName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "deploymentName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (parameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); + } + if (parameters != null) + { + parameters.Validate(); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("deploymentName", deploymentName); + tracingParameters.Add("parameters", parameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginWhatIf", 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.Resources/deployments/{deploymentName}/whatIf").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{deploymentName}", System.Uri.EscapeDataString(deploymentName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + 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(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); + } + } + 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; + } + + /// + /// Get all the deployments at the given scope. + /// + /// + /// 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>> ListAtScopeNextWithHttpMessagesAsync(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, "ListAtScopeNext", 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; + } + + /// + /// Get all the deployments at the tenant scope. + /// + /// + /// 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>> ListAtTenantScopeNextWithHttpMessagesAsync(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, "ListAtTenantScopeNext", 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; + } + + /// + /// Get all the deployments for a management 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>> ListAtManagementGroupScopeNextWithHttpMessagesAsync(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, "ListAtManagementGroupScopeNext", 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; + } + + /// + /// Get all the deployments for 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>> ListAtSubscriptionScopeNextWithHttpMessagesAsync(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, "ListAtSubscriptionScopeNext", 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; + } + + /// + /// Get all the deployments for 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 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/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/DeploymentsOperationsExtensions.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/DeploymentsOperationsExtensions.cs new file mode 100644 index 0000000000000..20b3ac7e74688 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/DeploymentsOperationsExtensions.cs @@ -0,0 +1,3137 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Microsoft.Rest.Azure.OData; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for DeploymentsOperations. + /// + public static partial class DeploymentsOperationsExtensions + { + /// + /// Deletes a deployment from the deployment history. + /// + /// + /// A template deployment that is currently running cannot be deleted. Deleting + /// a template deployment removes the associated deployment operations. This is + /// an asynchronous operation that returns a status of 202 until the template + /// deployment is successfully deleted. The Location response header contains + /// the URI that is used to obtain the status of the process. While the process + /// is running, a call to the URI in the Location header returns a status of + /// 202. When the process finishes, the URI in the Location header returns a + /// status of 204 on success. If the asynchronous request failed, the URI in + /// the Location header returns an error-level status code. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The resource scope. + /// + /// + /// The name of the deployment. + /// + public static void DeleteAtScope(this IDeploymentsOperations operations, string scope, string deploymentName) + { + operations.DeleteAtScopeAsync(scope, deploymentName).GetAwaiter().GetResult(); + } + + /// + /// Deletes a deployment from the deployment history. + /// + /// + /// A template deployment that is currently running cannot be deleted. Deleting + /// a template deployment removes the associated deployment operations. This is + /// an asynchronous operation that returns a status of 202 until the template + /// deployment is successfully deleted. The Location response header contains + /// the URI that is used to obtain the status of the process. While the process + /// is running, a call to the URI in the Location header returns a status of + /// 202. When the process finishes, the URI in the Location header returns a + /// status of 204 on success. If the asynchronous request failed, the URI in + /// the Location header returns an error-level status code. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The resource scope. + /// + /// + /// The name of the deployment. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAtScopeAsync(this IDeploymentsOperations operations, string scope, string deploymentName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteAtScopeWithHttpMessagesAsync(scope, deploymentName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Checks whether the deployment exists. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The resource scope. + /// + /// + /// The name of the deployment. + /// + public static bool CheckExistenceAtScope(this IDeploymentsOperations operations, string scope, string deploymentName) + { + return operations.CheckExistenceAtScopeAsync(scope, deploymentName).GetAwaiter().GetResult(); + } + + /// + /// Checks whether the deployment exists. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The resource scope. + /// + /// + /// The name of the deployment. + /// + /// + /// The cancellation token. + /// + public static async Task CheckExistenceAtScopeAsync(this IDeploymentsOperations operations, string scope, string deploymentName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CheckExistenceAtScopeWithHttpMessagesAsync(scope, deploymentName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deploys resources at a given scope. + /// + /// + /// You can provide the template and parameters directly in the request or link + /// to JSON files. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The resource scope. + /// + /// + /// The name of the deployment. + /// + /// + /// Additional parameters supplied to the operation. + /// + public static DeploymentExtended CreateOrUpdateAtScope(this IDeploymentsOperations operations, string scope, string deploymentName, Deployment parameters) + { + return operations.CreateOrUpdateAtScopeAsync(scope, deploymentName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Deploys resources at a given scope. + /// + /// + /// You can provide the template and parameters directly in the request or link + /// to JSON files. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The resource scope. + /// + /// + /// The name of the deployment. + /// + /// + /// Additional parameters supplied to the operation. + /// + /// + /// The cancellation token. + /// + public static async Task CreateOrUpdateAtScopeAsync(this IDeploymentsOperations operations, string scope, string deploymentName, Deployment parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateAtScopeWithHttpMessagesAsync(scope, deploymentName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets a deployment. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The resource scope. + /// + /// + /// The name of the deployment. + /// + public static DeploymentExtended GetAtScope(this IDeploymentsOperations operations, string scope, string deploymentName) + { + return operations.GetAtScopeAsync(scope, deploymentName).GetAwaiter().GetResult(); + } + + /// + /// Gets a deployment. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The resource scope. + /// + /// + /// The name of the deployment. + /// + /// + /// The cancellation token. + /// + public static async Task GetAtScopeAsync(this IDeploymentsOperations operations, string scope, string deploymentName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetAtScopeWithHttpMessagesAsync(scope, deploymentName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Cancels a currently running template deployment. + /// + /// + /// You can cancel a deployment only if the provisioningState is Accepted or + /// Running. After the deployment is canceled, the provisioningState is set to + /// Canceled. Canceling a template deployment stops the currently running + /// template deployment and leaves the resources partially deployed. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The resource scope. + /// + /// + /// The name of the deployment. + /// + public static void CancelAtScope(this IDeploymentsOperations operations, string scope, string deploymentName) + { + operations.CancelAtScopeAsync(scope, deploymentName).GetAwaiter().GetResult(); + } + + /// + /// Cancels a currently running template deployment. + /// + /// + /// You can cancel a deployment only if the provisioningState is Accepted or + /// Running. After the deployment is canceled, the provisioningState is set to + /// Canceled. Canceling a template deployment stops the currently running + /// template deployment and leaves the resources partially deployed. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The resource scope. + /// + /// + /// The name of the deployment. + /// + /// + /// The cancellation token. + /// + public static async Task CancelAtScopeAsync(this IDeploymentsOperations operations, string scope, string deploymentName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.CancelAtScopeWithHttpMessagesAsync(scope, deploymentName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Validates whether the specified template is syntactically correct and will + /// be accepted by Azure Resource Manager.. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The resource scope. + /// + /// + /// The name of the deployment. + /// + /// + /// Parameters to validate. + /// + public static DeploymentValidateResult ValidateAtScope(this IDeploymentsOperations operations, string scope, string deploymentName, Deployment parameters) + { + return operations.ValidateAtScopeAsync(scope, deploymentName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Validates whether the specified template is syntactically correct and will + /// be accepted by Azure Resource Manager.. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The resource scope. + /// + /// + /// The name of the deployment. + /// + /// + /// Parameters to validate. + /// + /// + /// The cancellation token. + /// + public static async Task ValidateAtScopeAsync(this IDeploymentsOperations operations, string scope, string deploymentName, Deployment parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ValidateAtScopeWithHttpMessagesAsync(scope, deploymentName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Exports the template used for specified deployment. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The resource scope. + /// + /// + /// The name of the deployment. + /// + public static DeploymentExportResult ExportTemplateAtScope(this IDeploymentsOperations operations, string scope, string deploymentName) + { + return operations.ExportTemplateAtScopeAsync(scope, deploymentName).GetAwaiter().GetResult(); + } + + /// + /// Exports the template used for specified deployment. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The resource scope. + /// + /// + /// The name of the deployment. + /// + /// + /// The cancellation token. + /// + public static async Task ExportTemplateAtScopeAsync(this IDeploymentsOperations operations, string scope, string deploymentName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ExportTemplateAtScopeWithHttpMessagesAsync(scope, deploymentName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get all the deployments at the given scope. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The resource scope. + /// + /// + /// OData parameters to apply to the operation. + /// + public static IPage ListAtScope(this IDeploymentsOperations operations, string scope, ODataQuery odataQuery = default(ODataQuery)) + { + return operations.ListAtScopeAsync(scope, odataQuery).GetAwaiter().GetResult(); + } + + /// + /// Get all the deployments at the given scope. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The resource scope. + /// + /// + /// OData parameters to apply to the operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAtScopeAsync(this IDeploymentsOperations operations, string scope, ODataQuery odataQuery = default(ODataQuery), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListAtScopeWithHttpMessagesAsync(scope, odataQuery, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes a deployment from the deployment history. + /// + /// + /// A template deployment that is currently running cannot be deleted. Deleting + /// a template deployment removes the associated deployment operations. This is + /// an asynchronous operation that returns a status of 202 until the template + /// deployment is successfully deleted. The Location response header contains + /// the URI that is used to obtain the status of the process. While the process + /// is running, a call to the URI in the Location header returns a status of + /// 202. When the process finishes, the URI in the Location header returns a + /// status of 204 on success. If the asynchronous request failed, the URI in + /// the Location header returns an error-level status code. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the deployment. + /// + public static void DeleteAtTenantScope(this IDeploymentsOperations operations, string deploymentName) + { + operations.DeleteAtTenantScopeAsync(deploymentName).GetAwaiter().GetResult(); + } + + /// + /// Deletes a deployment from the deployment history. + /// + /// + /// A template deployment that is currently running cannot be deleted. Deleting + /// a template deployment removes the associated deployment operations. This is + /// an asynchronous operation that returns a status of 202 until the template + /// deployment is successfully deleted. The Location response header contains + /// the URI that is used to obtain the status of the process. While the process + /// is running, a call to the URI in the Location header returns a status of + /// 202. When the process finishes, the URI in the Location header returns a + /// status of 204 on success. If the asynchronous request failed, the URI in + /// the Location header returns an error-level status code. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the deployment. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAtTenantScopeAsync(this IDeploymentsOperations operations, string deploymentName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteAtTenantScopeWithHttpMessagesAsync(deploymentName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Checks whether the deployment exists. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the deployment. + /// + public static bool CheckExistenceAtTenantScope(this IDeploymentsOperations operations, string deploymentName) + { + return operations.CheckExistenceAtTenantScopeAsync(deploymentName).GetAwaiter().GetResult(); + } + + /// + /// Checks whether the deployment exists. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the deployment. + /// + /// + /// The cancellation token. + /// + public static async Task CheckExistenceAtTenantScopeAsync(this IDeploymentsOperations operations, string deploymentName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CheckExistenceAtTenantScopeWithHttpMessagesAsync(deploymentName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deploys resources at tenant scope. + /// + /// + /// You can provide the template and parameters directly in the request or link + /// to JSON files. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the deployment. + /// + /// + /// Additional parameters supplied to the operation. + /// + public static DeploymentExtended CreateOrUpdateAtTenantScope(this IDeploymentsOperations operations, string deploymentName, ScopedDeployment parameters) + { + return operations.CreateOrUpdateAtTenantScopeAsync(deploymentName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Deploys resources at tenant scope. + /// + /// + /// You can provide the template and parameters directly in the request or link + /// to JSON files. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the deployment. + /// + /// + /// Additional parameters supplied to the operation. + /// + /// + /// The cancellation token. + /// + public static async Task CreateOrUpdateAtTenantScopeAsync(this IDeploymentsOperations operations, string deploymentName, ScopedDeployment parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateAtTenantScopeWithHttpMessagesAsync(deploymentName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets a deployment. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the deployment. + /// + public static DeploymentExtended GetAtTenantScope(this IDeploymentsOperations operations, string deploymentName) + { + return operations.GetAtTenantScopeAsync(deploymentName).GetAwaiter().GetResult(); + } + + /// + /// Gets a deployment. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the deployment. + /// + /// + /// The cancellation token. + /// + public static async Task GetAtTenantScopeAsync(this IDeploymentsOperations operations, string deploymentName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetAtTenantScopeWithHttpMessagesAsync(deploymentName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Cancels a currently running template deployment. + /// + /// + /// You can cancel a deployment only if the provisioningState is Accepted or + /// Running. After the deployment is canceled, the provisioningState is set to + /// Canceled. Canceling a template deployment stops the currently running + /// template deployment and leaves the resources partially deployed. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the deployment. + /// + public static void CancelAtTenantScope(this IDeploymentsOperations operations, string deploymentName) + { + operations.CancelAtTenantScopeAsync(deploymentName).GetAwaiter().GetResult(); + } + + /// + /// Cancels a currently running template deployment. + /// + /// + /// You can cancel a deployment only if the provisioningState is Accepted or + /// Running. After the deployment is canceled, the provisioningState is set to + /// Canceled. Canceling a template deployment stops the currently running + /// template deployment and leaves the resources partially deployed. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the deployment. + /// + /// + /// The cancellation token. + /// + public static async Task CancelAtTenantScopeAsync(this IDeploymentsOperations operations, string deploymentName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.CancelAtTenantScopeWithHttpMessagesAsync(deploymentName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Validates whether the specified template is syntactically correct and will + /// be accepted by Azure Resource Manager.. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the deployment. + /// + /// + /// Parameters to validate. + /// + public static DeploymentValidateResult ValidateAtTenantScope(this IDeploymentsOperations operations, string deploymentName, ScopedDeployment parameters) + { + return operations.ValidateAtTenantScopeAsync(deploymentName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Validates whether the specified template is syntactically correct and will + /// be accepted by Azure Resource Manager.. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the deployment. + /// + /// + /// Parameters to validate. + /// + /// + /// The cancellation token. + /// + public static async Task ValidateAtTenantScopeAsync(this IDeploymentsOperations operations, string deploymentName, ScopedDeployment parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ValidateAtTenantScopeWithHttpMessagesAsync(deploymentName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Returns changes that will be made by the deployment if executed at the + /// scope of the tenant group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the deployment. + /// + /// + /// Parameters to validate. + /// + public static WhatIfOperationResult WhatIfAtTenantScope(this IDeploymentsOperations operations, string deploymentName, ScopedDeploymentWhatIf parameters) + { + return operations.WhatIfAtTenantScopeAsync(deploymentName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Returns changes that will be made by the deployment if executed at the + /// scope of the tenant group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the deployment. + /// + /// + /// Parameters to validate. + /// + /// + /// The cancellation token. + /// + public static async Task WhatIfAtTenantScopeAsync(this IDeploymentsOperations operations, string deploymentName, ScopedDeploymentWhatIf parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.WhatIfAtTenantScopeWithHttpMessagesAsync(deploymentName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Exports the template used for specified deployment. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the deployment. + /// + public static DeploymentExportResult ExportTemplateAtTenantScope(this IDeploymentsOperations operations, string deploymentName) + { + return operations.ExportTemplateAtTenantScopeAsync(deploymentName).GetAwaiter().GetResult(); + } + + /// + /// Exports the template used for specified deployment. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the deployment. + /// + /// + /// The cancellation token. + /// + public static async Task ExportTemplateAtTenantScopeAsync(this IDeploymentsOperations operations, string deploymentName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ExportTemplateAtTenantScopeWithHttpMessagesAsync(deploymentName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get all the deployments at the tenant scope. + /// + /// + /// The operations group for this extension method. + /// + /// + /// OData parameters to apply to the operation. + /// + public static IPage ListAtTenantScope(this IDeploymentsOperations operations, ODataQuery odataQuery = default(ODataQuery)) + { + return operations.ListAtTenantScopeAsync(odataQuery).GetAwaiter().GetResult(); + } + + /// + /// Get all the deployments at the tenant scope. + /// + /// + /// The operations group for this extension method. + /// + /// + /// OData parameters to apply to the operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAtTenantScopeAsync(this IDeploymentsOperations operations, ODataQuery odataQuery = default(ODataQuery), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListAtTenantScopeWithHttpMessagesAsync(odataQuery, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes a deployment from the deployment history. + /// + /// + /// A template deployment that is currently running cannot be deleted. Deleting + /// a template deployment removes the associated deployment operations. This is + /// an asynchronous operation that returns a status of 202 until the template + /// deployment is successfully deleted. The Location response header contains + /// the URI that is used to obtain the status of the process. While the process + /// is running, a call to the URI in the Location header returns a status of + /// 202. When the process finishes, the URI in the Location header returns a + /// status of 204 on success. If the asynchronous request failed, the URI in + /// the Location header returns an error-level status code. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The management group ID. + /// + /// + /// The name of the deployment. + /// + public static void DeleteAtManagementGroupScope(this IDeploymentsOperations operations, string groupId, string deploymentName) + { + operations.DeleteAtManagementGroupScopeAsync(groupId, deploymentName).GetAwaiter().GetResult(); + } + + /// + /// Deletes a deployment from the deployment history. + /// + /// + /// A template deployment that is currently running cannot be deleted. Deleting + /// a template deployment removes the associated deployment operations. This is + /// an asynchronous operation that returns a status of 202 until the template + /// deployment is successfully deleted. The Location response header contains + /// the URI that is used to obtain the status of the process. While the process + /// is running, a call to the URI in the Location header returns a status of + /// 202. When the process finishes, the URI in the Location header returns a + /// status of 204 on success. If the asynchronous request failed, the URI in + /// the Location header returns an error-level status code. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The management group ID. + /// + /// + /// The name of the deployment. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAtManagementGroupScopeAsync(this IDeploymentsOperations operations, string groupId, string deploymentName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteAtManagementGroupScopeWithHttpMessagesAsync(groupId, deploymentName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Checks whether the deployment exists. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The management group ID. + /// + /// + /// The name of the deployment. + /// + public static bool CheckExistenceAtManagementGroupScope(this IDeploymentsOperations operations, string groupId, string deploymentName) + { + return operations.CheckExistenceAtManagementGroupScopeAsync(groupId, deploymentName).GetAwaiter().GetResult(); + } + + /// + /// Checks whether the deployment exists. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The management group ID. + /// + /// + /// The name of the deployment. + /// + /// + /// The cancellation token. + /// + public static async Task CheckExistenceAtManagementGroupScopeAsync(this IDeploymentsOperations operations, string groupId, string deploymentName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CheckExistenceAtManagementGroupScopeWithHttpMessagesAsync(groupId, deploymentName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deploys resources at management group scope. + /// + /// + /// You can provide the template and parameters directly in the request or link + /// to JSON files. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The management group ID. + /// + /// + /// The name of the deployment. + /// + /// + /// Additional parameters supplied to the operation. + /// + public static DeploymentExtended CreateOrUpdateAtManagementGroupScope(this IDeploymentsOperations operations, string groupId, string deploymentName, ScopedDeployment parameters) + { + return operations.CreateOrUpdateAtManagementGroupScopeAsync(groupId, deploymentName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Deploys resources at management group scope. + /// + /// + /// You can provide the template and parameters directly in the request or link + /// to JSON files. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The management group ID. + /// + /// + /// The name of the deployment. + /// + /// + /// Additional parameters supplied to the operation. + /// + /// + /// The cancellation token. + /// + public static async Task CreateOrUpdateAtManagementGroupScopeAsync(this IDeploymentsOperations operations, string groupId, string deploymentName, ScopedDeployment parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateAtManagementGroupScopeWithHttpMessagesAsync(groupId, deploymentName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets a deployment. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The management group ID. + /// + /// + /// The name of the deployment. + /// + public static DeploymentExtended GetAtManagementGroupScope(this IDeploymentsOperations operations, string groupId, string deploymentName) + { + return operations.GetAtManagementGroupScopeAsync(groupId, deploymentName).GetAwaiter().GetResult(); + } + + /// + /// Gets a deployment. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The management group ID. + /// + /// + /// The name of the deployment. + /// + /// + /// The cancellation token. + /// + public static async Task GetAtManagementGroupScopeAsync(this IDeploymentsOperations operations, string groupId, string deploymentName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetAtManagementGroupScopeWithHttpMessagesAsync(groupId, deploymentName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Cancels a currently running template deployment. + /// + /// + /// You can cancel a deployment only if the provisioningState is Accepted or + /// Running. After the deployment is canceled, the provisioningState is set to + /// Canceled. Canceling a template deployment stops the currently running + /// template deployment and leaves the resources partially deployed. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The management group ID. + /// + /// + /// The name of the deployment. + /// + public static void CancelAtManagementGroupScope(this IDeploymentsOperations operations, string groupId, string deploymentName) + { + operations.CancelAtManagementGroupScopeAsync(groupId, deploymentName).GetAwaiter().GetResult(); + } + + /// + /// Cancels a currently running template deployment. + /// + /// + /// You can cancel a deployment only if the provisioningState is Accepted or + /// Running. After the deployment is canceled, the provisioningState is set to + /// Canceled. Canceling a template deployment stops the currently running + /// template deployment and leaves the resources partially deployed. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The management group ID. + /// + /// + /// The name of the deployment. + /// + /// + /// The cancellation token. + /// + public static async Task CancelAtManagementGroupScopeAsync(this IDeploymentsOperations operations, string groupId, string deploymentName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.CancelAtManagementGroupScopeWithHttpMessagesAsync(groupId, deploymentName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Validates whether the specified template is syntactically correct and will + /// be accepted by Azure Resource Manager.. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The management group ID. + /// + /// + /// The name of the deployment. + /// + /// + /// Parameters to validate. + /// + public static DeploymentValidateResult ValidateAtManagementGroupScope(this IDeploymentsOperations operations, string groupId, string deploymentName, ScopedDeployment parameters) + { + return operations.ValidateAtManagementGroupScopeAsync(groupId, deploymentName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Validates whether the specified template is syntactically correct and will + /// be accepted by Azure Resource Manager.. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The management group ID. + /// + /// + /// The name of the deployment. + /// + /// + /// Parameters to validate. + /// + /// + /// The cancellation token. + /// + public static async Task ValidateAtManagementGroupScopeAsync(this IDeploymentsOperations operations, string groupId, string deploymentName, ScopedDeployment parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ValidateAtManagementGroupScopeWithHttpMessagesAsync(groupId, deploymentName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Returns changes that will be made by the deployment if executed at the + /// scope of the management group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The management group ID. + /// + /// + /// The name of the deployment. + /// + /// + /// Parameters to validate. + /// + public static WhatIfOperationResult WhatIfAtManagementGroupScope(this IDeploymentsOperations operations, string groupId, string deploymentName, ScopedDeploymentWhatIf parameters) + { + return operations.WhatIfAtManagementGroupScopeAsync(groupId, deploymentName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Returns changes that will be made by the deployment if executed at the + /// scope of the management group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The management group ID. + /// + /// + /// The name of the deployment. + /// + /// + /// Parameters to validate. + /// + /// + /// The cancellation token. + /// + public static async Task WhatIfAtManagementGroupScopeAsync(this IDeploymentsOperations operations, string groupId, string deploymentName, ScopedDeploymentWhatIf parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.WhatIfAtManagementGroupScopeWithHttpMessagesAsync(groupId, deploymentName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Exports the template used for specified deployment. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The management group ID. + /// + /// + /// The name of the deployment. + /// + public static DeploymentExportResult ExportTemplateAtManagementGroupScope(this IDeploymentsOperations operations, string groupId, string deploymentName) + { + return operations.ExportTemplateAtManagementGroupScopeAsync(groupId, deploymentName).GetAwaiter().GetResult(); + } + + /// + /// Exports the template used for specified deployment. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The management group ID. + /// + /// + /// The name of the deployment. + /// + /// + /// The cancellation token. + /// + public static async Task ExportTemplateAtManagementGroupScopeAsync(this IDeploymentsOperations operations, string groupId, string deploymentName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ExportTemplateAtManagementGroupScopeWithHttpMessagesAsync(groupId, deploymentName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get all the deployments for a management group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The management group ID. + /// + /// + /// OData parameters to apply to the operation. + /// + public static IPage ListAtManagementGroupScope(this IDeploymentsOperations operations, string groupId, ODataQuery odataQuery = default(ODataQuery)) + { + return operations.ListAtManagementGroupScopeAsync(groupId, odataQuery).GetAwaiter().GetResult(); + } + + /// + /// Get all the deployments for a management group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The management group ID. + /// + /// + /// OData parameters to apply to the operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAtManagementGroupScopeAsync(this IDeploymentsOperations operations, string groupId, ODataQuery odataQuery = default(ODataQuery), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListAtManagementGroupScopeWithHttpMessagesAsync(groupId, odataQuery, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes a deployment from the deployment history. + /// + /// + /// A template deployment that is currently running cannot be deleted. Deleting + /// a template deployment removes the associated deployment operations. This is + /// an asynchronous operation that returns a status of 202 until the template + /// deployment is successfully deleted. The Location response header contains + /// the URI that is used to obtain the status of the process. While the process + /// is running, a call to the URI in the Location header returns a status of + /// 202. When the process finishes, the URI in the Location header returns a + /// status of 204 on success. If the asynchronous request failed, the URI in + /// the Location header returns an error-level status code. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the deployment. + /// + public static void DeleteAtSubscriptionScope(this IDeploymentsOperations operations, string deploymentName) + { + operations.DeleteAtSubscriptionScopeAsync(deploymentName).GetAwaiter().GetResult(); + } + + /// + /// Deletes a deployment from the deployment history. + /// + /// + /// A template deployment that is currently running cannot be deleted. Deleting + /// a template deployment removes the associated deployment operations. This is + /// an asynchronous operation that returns a status of 202 until the template + /// deployment is successfully deleted. The Location response header contains + /// the URI that is used to obtain the status of the process. While the process + /// is running, a call to the URI in the Location header returns a status of + /// 202. When the process finishes, the URI in the Location header returns a + /// status of 204 on success. If the asynchronous request failed, the URI in + /// the Location header returns an error-level status code. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the deployment. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAtSubscriptionScopeAsync(this IDeploymentsOperations operations, string deploymentName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteAtSubscriptionScopeWithHttpMessagesAsync(deploymentName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Checks whether the deployment exists. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the deployment. + /// + public static bool CheckExistenceAtSubscriptionScope(this IDeploymentsOperations operations, string deploymentName) + { + return operations.CheckExistenceAtSubscriptionScopeAsync(deploymentName).GetAwaiter().GetResult(); + } + + /// + /// Checks whether the deployment exists. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the deployment. + /// + /// + /// The cancellation token. + /// + public static async Task CheckExistenceAtSubscriptionScopeAsync(this IDeploymentsOperations operations, string deploymentName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CheckExistenceAtSubscriptionScopeWithHttpMessagesAsync(deploymentName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deploys resources at subscription scope. + /// + /// + /// You can provide the template and parameters directly in the request or link + /// to JSON files. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the deployment. + /// + /// + /// Additional parameters supplied to the operation. + /// + public static DeploymentExtended CreateOrUpdateAtSubscriptionScope(this IDeploymentsOperations operations, string deploymentName, Deployment parameters) + { + return operations.CreateOrUpdateAtSubscriptionScopeAsync(deploymentName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Deploys resources at subscription scope. + /// + /// + /// You can provide the template and parameters directly in the request or link + /// to JSON files. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the deployment. + /// + /// + /// Additional parameters supplied to the operation. + /// + /// + /// The cancellation token. + /// + public static async Task CreateOrUpdateAtSubscriptionScopeAsync(this IDeploymentsOperations operations, string deploymentName, Deployment parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateAtSubscriptionScopeWithHttpMessagesAsync(deploymentName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets a deployment. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the deployment. + /// + public static DeploymentExtended GetAtSubscriptionScope(this IDeploymentsOperations operations, string deploymentName) + { + return operations.GetAtSubscriptionScopeAsync(deploymentName).GetAwaiter().GetResult(); + } + + /// + /// Gets a deployment. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the deployment. + /// + /// + /// The cancellation token. + /// + public static async Task GetAtSubscriptionScopeAsync(this IDeploymentsOperations operations, string deploymentName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetAtSubscriptionScopeWithHttpMessagesAsync(deploymentName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Cancels a currently running template deployment. + /// + /// + /// You can cancel a deployment only if the provisioningState is Accepted or + /// Running. After the deployment is canceled, the provisioningState is set to + /// Canceled. Canceling a template deployment stops the currently running + /// template deployment and leaves the resources partially deployed. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the deployment. + /// + public static void CancelAtSubscriptionScope(this IDeploymentsOperations operations, string deploymentName) + { + operations.CancelAtSubscriptionScopeAsync(deploymentName).GetAwaiter().GetResult(); + } + + /// + /// Cancels a currently running template deployment. + /// + /// + /// You can cancel a deployment only if the provisioningState is Accepted or + /// Running. After the deployment is canceled, the provisioningState is set to + /// Canceled. Canceling a template deployment stops the currently running + /// template deployment and leaves the resources partially deployed. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the deployment. + /// + /// + /// The cancellation token. + /// + public static async Task CancelAtSubscriptionScopeAsync(this IDeploymentsOperations operations, string deploymentName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.CancelAtSubscriptionScopeWithHttpMessagesAsync(deploymentName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Validates whether the specified template is syntactically correct and will + /// be accepted by Azure Resource Manager.. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the deployment. + /// + /// + /// Parameters to validate. + /// + public static DeploymentValidateResult ValidateAtSubscriptionScope(this IDeploymentsOperations operations, string deploymentName, Deployment parameters) + { + return operations.ValidateAtSubscriptionScopeAsync(deploymentName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Validates whether the specified template is syntactically correct and will + /// be accepted by Azure Resource Manager.. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the deployment. + /// + /// + /// Parameters to validate. + /// + /// + /// The cancellation token. + /// + public static async Task ValidateAtSubscriptionScopeAsync(this IDeploymentsOperations operations, string deploymentName, Deployment parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ValidateAtSubscriptionScopeWithHttpMessagesAsync(deploymentName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Returns changes that will be made by the deployment if executed at the + /// scope of the subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the deployment. + /// + /// + /// Parameters to What If. + /// + public static WhatIfOperationResult WhatIfAtSubscriptionScope(this IDeploymentsOperations operations, string deploymentName, DeploymentWhatIf parameters) + { + return operations.WhatIfAtSubscriptionScopeAsync(deploymentName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Returns changes that will be made by the deployment if executed at the + /// scope of the subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the deployment. + /// + /// + /// Parameters to What If. + /// + /// + /// The cancellation token. + /// + public static async Task WhatIfAtSubscriptionScopeAsync(this IDeploymentsOperations operations, string deploymentName, DeploymentWhatIf parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.WhatIfAtSubscriptionScopeWithHttpMessagesAsync(deploymentName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Exports the template used for specified deployment. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the deployment. + /// + public static DeploymentExportResult ExportTemplateAtSubscriptionScope(this IDeploymentsOperations operations, string deploymentName) + { + return operations.ExportTemplateAtSubscriptionScopeAsync(deploymentName).GetAwaiter().GetResult(); + } + + /// + /// Exports the template used for specified deployment. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the deployment. + /// + /// + /// The cancellation token. + /// + public static async Task ExportTemplateAtSubscriptionScopeAsync(this IDeploymentsOperations operations, string deploymentName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ExportTemplateAtSubscriptionScopeWithHttpMessagesAsync(deploymentName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get all the deployments for a subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// OData parameters to apply to the operation. + /// + public static IPage ListAtSubscriptionScope(this IDeploymentsOperations operations, ODataQuery odataQuery = default(ODataQuery)) + { + return operations.ListAtSubscriptionScopeAsync(odataQuery).GetAwaiter().GetResult(); + } + + /// + /// Get all the deployments for a subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// OData parameters to apply to the operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAtSubscriptionScopeAsync(this IDeploymentsOperations operations, ODataQuery odataQuery = default(ODataQuery), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListAtSubscriptionScopeWithHttpMessagesAsync(odataQuery, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes a deployment from the deployment history. + /// + /// + /// A template deployment that is currently running cannot be deleted. Deleting + /// a template deployment removes the associated deployment operations. + /// Deleting a template deployment does not affect the state of the resource + /// group. This is an asynchronous operation that returns a status of 202 until + /// the template deployment is successfully deleted. The Location response + /// header contains the URI that is used to obtain the status of the process. + /// While the process is running, a call to the URI in the Location header + /// returns a status of 202. When the process finishes, the URI in the Location + /// header returns a status of 204 on success. If the asynchronous request + /// failed, the URI in the Location header returns an error-level status code. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group with the deployment to delete. The name is + /// case insensitive. + /// + /// + /// The name of the deployment. + /// + public static void Delete(this IDeploymentsOperations operations, string resourceGroupName, string deploymentName) + { + operations.DeleteAsync(resourceGroupName, deploymentName).GetAwaiter().GetResult(); + } + + /// + /// Deletes a deployment from the deployment history. + /// + /// + /// A template deployment that is currently running cannot be deleted. Deleting + /// a template deployment removes the associated deployment operations. + /// Deleting a template deployment does not affect the state of the resource + /// group. This is an asynchronous operation that returns a status of 202 until + /// the template deployment is successfully deleted. The Location response + /// header contains the URI that is used to obtain the status of the process. + /// While the process is running, a call to the URI in the Location header + /// returns a status of 202. When the process finishes, the URI in the Location + /// header returns a status of 204 on success. If the asynchronous request + /// failed, the URI in the Location header returns an error-level status code. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group with the deployment to delete. The name is + /// case insensitive. + /// + /// + /// The name of the deployment. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this IDeploymentsOperations operations, string resourceGroupName, string deploymentName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, deploymentName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Checks whether the deployment exists. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group with the deployment to check. The name is + /// case insensitive. + /// + /// + /// The name of the deployment. + /// + public static bool CheckExistence(this IDeploymentsOperations operations, string resourceGroupName, string deploymentName) + { + return operations.CheckExistenceAsync(resourceGroupName, deploymentName).GetAwaiter().GetResult(); + } + + /// + /// Checks whether the deployment exists. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group with the deployment to check. The name is + /// case insensitive. + /// + /// + /// The name of the deployment. + /// + /// + /// The cancellation token. + /// + public static async Task CheckExistenceAsync(this IDeploymentsOperations operations, string resourceGroupName, string deploymentName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CheckExistenceWithHttpMessagesAsync(resourceGroupName, deploymentName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deploys resources to a resource group. + /// + /// + /// You can provide the template and parameters directly in the request or link + /// to JSON files. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to deploy the resources to. The name is case + /// insensitive. The resource group must already exist. + /// + /// + /// The name of the deployment. + /// + /// + /// Additional parameters supplied to the operation. + /// + public static DeploymentExtended CreateOrUpdate(this IDeploymentsOperations operations, string resourceGroupName, string deploymentName, Deployment parameters) + { + return operations.CreateOrUpdateAsync(resourceGroupName, deploymentName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Deploys resources to a resource group. + /// + /// + /// You can provide the template and parameters directly in the request or link + /// to JSON files. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to deploy the resources to. The name is case + /// insensitive. The resource group must already exist. + /// + /// + /// The name of the deployment. + /// + /// + /// Additional parameters supplied to the operation. + /// + /// + /// The cancellation token. + /// + public static async Task CreateOrUpdateAsync(this IDeploymentsOperations operations, string resourceGroupName, string deploymentName, Deployment parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, deploymentName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets a deployment. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the deployment. + /// + public static DeploymentExtended Get(this IDeploymentsOperations operations, string resourceGroupName, string deploymentName) + { + return operations.GetAsync(resourceGroupName, deploymentName).GetAwaiter().GetResult(); + } + + /// + /// Gets a deployment. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the deployment. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IDeploymentsOperations operations, string resourceGroupName, string deploymentName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, deploymentName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Cancels a currently running template deployment. + /// + /// + /// You can cancel a deployment only if the provisioningState is Accepted or + /// Running. After the deployment is canceled, the provisioningState is set to + /// Canceled. Canceling a template deployment stops the currently running + /// template deployment and leaves the resource group partially deployed. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the deployment. + /// + public static void Cancel(this IDeploymentsOperations operations, string resourceGroupName, string deploymentName) + { + operations.CancelAsync(resourceGroupName, deploymentName).GetAwaiter().GetResult(); + } + + /// + /// Cancels a currently running template deployment. + /// + /// + /// You can cancel a deployment only if the provisioningState is Accepted or + /// Running. After the deployment is canceled, the provisioningState is set to + /// Canceled. Canceling a template deployment stops the currently running + /// template deployment and leaves the resource group partially deployed. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the deployment. + /// + /// + /// The cancellation token. + /// + public static async Task CancelAsync(this IDeploymentsOperations operations, string resourceGroupName, string deploymentName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.CancelWithHttpMessagesAsync(resourceGroupName, deploymentName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Validates whether the specified template is syntactically correct and will + /// be accepted by Azure Resource Manager.. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group the template will be deployed to. The name + /// is case insensitive. + /// + /// + /// The name of the deployment. + /// + /// + /// Parameters to validate. + /// + public static DeploymentValidateResult Validate(this IDeploymentsOperations operations, string resourceGroupName, string deploymentName, Deployment parameters) + { + return operations.ValidateAsync(resourceGroupName, deploymentName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Validates whether the specified template is syntactically correct and will + /// be accepted by Azure Resource Manager.. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group the template will be deployed to. The name + /// is case insensitive. + /// + /// + /// The name of the deployment. + /// + /// + /// Parameters to validate. + /// + /// + /// The cancellation token. + /// + public static async Task ValidateAsync(this IDeploymentsOperations operations, string resourceGroupName, string deploymentName, Deployment parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ValidateWithHttpMessagesAsync(resourceGroupName, deploymentName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Returns changes that will be made by the deployment if executed at the + /// scope of the resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group the template will be deployed to. The name + /// is case insensitive. + /// + /// + /// The name of the deployment. + /// + /// + /// Parameters to validate. + /// + public static WhatIfOperationResult WhatIf(this IDeploymentsOperations operations, string resourceGroupName, string deploymentName, DeploymentWhatIf parameters) + { + return operations.WhatIfAsync(resourceGroupName, deploymentName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Returns changes that will be made by the deployment if executed at the + /// scope of the resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group the template will be deployed to. The name + /// is case insensitive. + /// + /// + /// The name of the deployment. + /// + /// + /// Parameters to validate. + /// + /// + /// The cancellation token. + /// + public static async Task WhatIfAsync(this IDeploymentsOperations operations, string resourceGroupName, string deploymentName, DeploymentWhatIf parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.WhatIfWithHttpMessagesAsync(resourceGroupName, deploymentName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Exports the template used for specified deployment. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the deployment. + /// + public static DeploymentExportResult ExportTemplate(this IDeploymentsOperations operations, string resourceGroupName, string deploymentName) + { + return operations.ExportTemplateAsync(resourceGroupName, deploymentName).GetAwaiter().GetResult(); + } + + /// + /// Exports the template used for specified deployment. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the deployment. + /// + /// + /// The cancellation token. + /// + public static async Task ExportTemplateAsync(this IDeploymentsOperations operations, string resourceGroupName, string deploymentName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ExportTemplateWithHttpMessagesAsync(resourceGroupName, deploymentName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get all the deployments for a resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group with the deployments to get. The name is + /// case insensitive. + /// + /// + /// OData parameters to apply to the operation. + /// + public static IPage ListByResourceGroup(this IDeploymentsOperations operations, string resourceGroupName, ODataQuery odataQuery = default(ODataQuery)) + { + return operations.ListByResourceGroupAsync(resourceGroupName, odataQuery).GetAwaiter().GetResult(); + } + + /// + /// Get all the deployments for a resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group with the deployments to get. The name is + /// case insensitive. + /// + /// + /// OData parameters to apply to the operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByResourceGroupAsync(this IDeploymentsOperations operations, string resourceGroupName, ODataQuery odataQuery = default(ODataQuery), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByResourceGroupWithHttpMessagesAsync(resourceGroupName, odataQuery, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Calculate the hash of the given template. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The template provided to calculate hash. + /// + public static TemplateHashResult CalculateTemplateHash(this IDeploymentsOperations operations, object template) + { + return operations.CalculateTemplateHashAsync(template).GetAwaiter().GetResult(); + } + + /// + /// Calculate the hash of the given template. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The template provided to calculate hash. + /// + /// + /// The cancellation token. + /// + public static async Task CalculateTemplateHashAsync(this IDeploymentsOperations operations, object template, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CalculateTemplateHashWithHttpMessagesAsync(template, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes a deployment from the deployment history. + /// + /// + /// A template deployment that is currently running cannot be deleted. Deleting + /// a template deployment removes the associated deployment operations. This is + /// an asynchronous operation that returns a status of 202 until the template + /// deployment is successfully deleted. The Location response header contains + /// the URI that is used to obtain the status of the process. While the process + /// is running, a call to the URI in the Location header returns a status of + /// 202. When the process finishes, the URI in the Location header returns a + /// status of 204 on success. If the asynchronous request failed, the URI in + /// the Location header returns an error-level status code. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The resource scope. + /// + /// + /// The name of the deployment. + /// + public static void BeginDeleteAtScope(this IDeploymentsOperations operations, string scope, string deploymentName) + { + operations.BeginDeleteAtScopeAsync(scope, deploymentName).GetAwaiter().GetResult(); + } + + /// + /// Deletes a deployment from the deployment history. + /// + /// + /// A template deployment that is currently running cannot be deleted. Deleting + /// a template deployment removes the associated deployment operations. This is + /// an asynchronous operation that returns a status of 202 until the template + /// deployment is successfully deleted. The Location response header contains + /// the URI that is used to obtain the status of the process. While the process + /// is running, a call to the URI in the Location header returns a status of + /// 202. When the process finishes, the URI in the Location header returns a + /// status of 204 on success. If the asynchronous request failed, the URI in + /// the Location header returns an error-level status code. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The resource scope. + /// + /// + /// The name of the deployment. + /// + /// + /// The cancellation token. + /// + public static async Task BeginDeleteAtScopeAsync(this IDeploymentsOperations operations, string scope, string deploymentName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.BeginDeleteAtScopeWithHttpMessagesAsync(scope, deploymentName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Deploys resources at a given scope. + /// + /// + /// You can provide the template and parameters directly in the request or link + /// to JSON files. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The resource scope. + /// + /// + /// The name of the deployment. + /// + /// + /// Additional parameters supplied to the operation. + /// + public static DeploymentExtended BeginCreateOrUpdateAtScope(this IDeploymentsOperations operations, string scope, string deploymentName, Deployment parameters) + { + return operations.BeginCreateOrUpdateAtScopeAsync(scope, deploymentName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Deploys resources at a given scope. + /// + /// + /// You can provide the template and parameters directly in the request or link + /// to JSON files. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The resource scope. + /// + /// + /// The name of the deployment. + /// + /// + /// Additional parameters supplied to the operation. + /// + /// + /// The cancellation token. + /// + public static async Task BeginCreateOrUpdateAtScopeAsync(this IDeploymentsOperations operations, string scope, string deploymentName, Deployment parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginCreateOrUpdateAtScopeWithHttpMessagesAsync(scope, deploymentName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Validates whether the specified template is syntactically correct and will + /// be accepted by Azure Resource Manager.. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The resource scope. + /// + /// + /// The name of the deployment. + /// + /// + /// Parameters to validate. + /// + public static DeploymentValidateResult BeginValidateAtScope(this IDeploymentsOperations operations, string scope, string deploymentName, Deployment parameters) + { + return operations.BeginValidateAtScopeAsync(scope, deploymentName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Validates whether the specified template is syntactically correct and will + /// be accepted by Azure Resource Manager.. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The resource scope. + /// + /// + /// The name of the deployment. + /// + /// + /// Parameters to validate. + /// + /// + /// The cancellation token. + /// + public static async Task BeginValidateAtScopeAsync(this IDeploymentsOperations operations, string scope, string deploymentName, Deployment parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginValidateAtScopeWithHttpMessagesAsync(scope, deploymentName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes a deployment from the deployment history. + /// + /// + /// A template deployment that is currently running cannot be deleted. Deleting + /// a template deployment removes the associated deployment operations. This is + /// an asynchronous operation that returns a status of 202 until the template + /// deployment is successfully deleted. The Location response header contains + /// the URI that is used to obtain the status of the process. While the process + /// is running, a call to the URI in the Location header returns a status of + /// 202. When the process finishes, the URI in the Location header returns a + /// status of 204 on success. If the asynchronous request failed, the URI in + /// the Location header returns an error-level status code. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the deployment. + /// + public static void BeginDeleteAtTenantScope(this IDeploymentsOperations operations, string deploymentName) + { + operations.BeginDeleteAtTenantScopeAsync(deploymentName).GetAwaiter().GetResult(); + } + + /// + /// Deletes a deployment from the deployment history. + /// + /// + /// A template deployment that is currently running cannot be deleted. Deleting + /// a template deployment removes the associated deployment operations. This is + /// an asynchronous operation that returns a status of 202 until the template + /// deployment is successfully deleted. The Location response header contains + /// the URI that is used to obtain the status of the process. While the process + /// is running, a call to the URI in the Location header returns a status of + /// 202. When the process finishes, the URI in the Location header returns a + /// status of 204 on success. If the asynchronous request failed, the URI in + /// the Location header returns an error-level status code. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the deployment. + /// + /// + /// The cancellation token. + /// + public static async Task BeginDeleteAtTenantScopeAsync(this IDeploymentsOperations operations, string deploymentName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.BeginDeleteAtTenantScopeWithHttpMessagesAsync(deploymentName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Deploys resources at tenant scope. + /// + /// + /// You can provide the template and parameters directly in the request or link + /// to JSON files. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the deployment. + /// + /// + /// Additional parameters supplied to the operation. + /// + public static DeploymentExtended BeginCreateOrUpdateAtTenantScope(this IDeploymentsOperations operations, string deploymentName, ScopedDeployment parameters) + { + return operations.BeginCreateOrUpdateAtTenantScopeAsync(deploymentName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Deploys resources at tenant scope. + /// + /// + /// You can provide the template and parameters directly in the request or link + /// to JSON files. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the deployment. + /// + /// + /// Additional parameters supplied to the operation. + /// + /// + /// The cancellation token. + /// + public static async Task BeginCreateOrUpdateAtTenantScopeAsync(this IDeploymentsOperations operations, string deploymentName, ScopedDeployment parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginCreateOrUpdateAtTenantScopeWithHttpMessagesAsync(deploymentName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Validates whether the specified template is syntactically correct and will + /// be accepted by Azure Resource Manager.. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the deployment. + /// + /// + /// Parameters to validate. + /// + public static DeploymentValidateResult BeginValidateAtTenantScope(this IDeploymentsOperations operations, string deploymentName, ScopedDeployment parameters) + { + return operations.BeginValidateAtTenantScopeAsync(deploymentName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Validates whether the specified template is syntactically correct and will + /// be accepted by Azure Resource Manager.. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the deployment. + /// + /// + /// Parameters to validate. + /// + /// + /// The cancellation token. + /// + public static async Task BeginValidateAtTenantScopeAsync(this IDeploymentsOperations operations, string deploymentName, ScopedDeployment parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginValidateAtTenantScopeWithHttpMessagesAsync(deploymentName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Returns changes that will be made by the deployment if executed at the + /// scope of the tenant group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the deployment. + /// + /// + /// Parameters to validate. + /// + public static WhatIfOperationResult BeginWhatIfAtTenantScope(this IDeploymentsOperations operations, string deploymentName, ScopedDeploymentWhatIf parameters) + { + return operations.BeginWhatIfAtTenantScopeAsync(deploymentName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Returns changes that will be made by the deployment if executed at the + /// scope of the tenant group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the deployment. + /// + /// + /// Parameters to validate. + /// + /// + /// The cancellation token. + /// + public static async Task BeginWhatIfAtTenantScopeAsync(this IDeploymentsOperations operations, string deploymentName, ScopedDeploymentWhatIf parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginWhatIfAtTenantScopeWithHttpMessagesAsync(deploymentName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes a deployment from the deployment history. + /// + /// + /// A template deployment that is currently running cannot be deleted. Deleting + /// a template deployment removes the associated deployment operations. This is + /// an asynchronous operation that returns a status of 202 until the template + /// deployment is successfully deleted. The Location response header contains + /// the URI that is used to obtain the status of the process. While the process + /// is running, a call to the URI in the Location header returns a status of + /// 202. When the process finishes, the URI in the Location header returns a + /// status of 204 on success. If the asynchronous request failed, the URI in + /// the Location header returns an error-level status code. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The management group ID. + /// + /// + /// The name of the deployment. + /// + public static void BeginDeleteAtManagementGroupScope(this IDeploymentsOperations operations, string groupId, string deploymentName) + { + operations.BeginDeleteAtManagementGroupScopeAsync(groupId, deploymentName).GetAwaiter().GetResult(); + } + + /// + /// Deletes a deployment from the deployment history. + /// + /// + /// A template deployment that is currently running cannot be deleted. Deleting + /// a template deployment removes the associated deployment operations. This is + /// an asynchronous operation that returns a status of 202 until the template + /// deployment is successfully deleted. The Location response header contains + /// the URI that is used to obtain the status of the process. While the process + /// is running, a call to the URI in the Location header returns a status of + /// 202. When the process finishes, the URI in the Location header returns a + /// status of 204 on success. If the asynchronous request failed, the URI in + /// the Location header returns an error-level status code. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The management group ID. + /// + /// + /// The name of the deployment. + /// + /// + /// The cancellation token. + /// + public static async Task BeginDeleteAtManagementGroupScopeAsync(this IDeploymentsOperations operations, string groupId, string deploymentName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.BeginDeleteAtManagementGroupScopeWithHttpMessagesAsync(groupId, deploymentName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Deploys resources at management group scope. + /// + /// + /// You can provide the template and parameters directly in the request or link + /// to JSON files. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The management group ID. + /// + /// + /// The name of the deployment. + /// + /// + /// Additional parameters supplied to the operation. + /// + public static DeploymentExtended BeginCreateOrUpdateAtManagementGroupScope(this IDeploymentsOperations operations, string groupId, string deploymentName, ScopedDeployment parameters) + { + return operations.BeginCreateOrUpdateAtManagementGroupScopeAsync(groupId, deploymentName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Deploys resources at management group scope. + /// + /// + /// You can provide the template and parameters directly in the request or link + /// to JSON files. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The management group ID. + /// + /// + /// The name of the deployment. + /// + /// + /// Additional parameters supplied to the operation. + /// + /// + /// The cancellation token. + /// + public static async Task BeginCreateOrUpdateAtManagementGroupScopeAsync(this IDeploymentsOperations operations, string groupId, string deploymentName, ScopedDeployment parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginCreateOrUpdateAtManagementGroupScopeWithHttpMessagesAsync(groupId, deploymentName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Validates whether the specified template is syntactically correct and will + /// be accepted by Azure Resource Manager.. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The management group ID. + /// + /// + /// The name of the deployment. + /// + /// + /// Parameters to validate. + /// + public static DeploymentValidateResult BeginValidateAtManagementGroupScope(this IDeploymentsOperations operations, string groupId, string deploymentName, ScopedDeployment parameters) + { + return operations.BeginValidateAtManagementGroupScopeAsync(groupId, deploymentName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Validates whether the specified template is syntactically correct and will + /// be accepted by Azure Resource Manager.. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The management group ID. + /// + /// + /// The name of the deployment. + /// + /// + /// Parameters to validate. + /// + /// + /// The cancellation token. + /// + public static async Task BeginValidateAtManagementGroupScopeAsync(this IDeploymentsOperations operations, string groupId, string deploymentName, ScopedDeployment parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginValidateAtManagementGroupScopeWithHttpMessagesAsync(groupId, deploymentName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Returns changes that will be made by the deployment if executed at the + /// scope of the management group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The management group ID. + /// + /// + /// The name of the deployment. + /// + /// + /// Parameters to validate. + /// + public static WhatIfOperationResult BeginWhatIfAtManagementGroupScope(this IDeploymentsOperations operations, string groupId, string deploymentName, ScopedDeploymentWhatIf parameters) + { + return operations.BeginWhatIfAtManagementGroupScopeAsync(groupId, deploymentName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Returns changes that will be made by the deployment if executed at the + /// scope of the management group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The management group ID. + /// + /// + /// The name of the deployment. + /// + /// + /// Parameters to validate. + /// + /// + /// The cancellation token. + /// + public static async Task BeginWhatIfAtManagementGroupScopeAsync(this IDeploymentsOperations operations, string groupId, string deploymentName, ScopedDeploymentWhatIf parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginWhatIfAtManagementGroupScopeWithHttpMessagesAsync(groupId, deploymentName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes a deployment from the deployment history. + /// + /// + /// A template deployment that is currently running cannot be deleted. Deleting + /// a template deployment removes the associated deployment operations. This is + /// an asynchronous operation that returns a status of 202 until the template + /// deployment is successfully deleted. The Location response header contains + /// the URI that is used to obtain the status of the process. While the process + /// is running, a call to the URI in the Location header returns a status of + /// 202. When the process finishes, the URI in the Location header returns a + /// status of 204 on success. If the asynchronous request failed, the URI in + /// the Location header returns an error-level status code. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the deployment. + /// + public static void BeginDeleteAtSubscriptionScope(this IDeploymentsOperations operations, string deploymentName) + { + operations.BeginDeleteAtSubscriptionScopeAsync(deploymentName).GetAwaiter().GetResult(); + } + + /// + /// Deletes a deployment from the deployment history. + /// + /// + /// A template deployment that is currently running cannot be deleted. Deleting + /// a template deployment removes the associated deployment operations. This is + /// an asynchronous operation that returns a status of 202 until the template + /// deployment is successfully deleted. The Location response header contains + /// the URI that is used to obtain the status of the process. While the process + /// is running, a call to the URI in the Location header returns a status of + /// 202. When the process finishes, the URI in the Location header returns a + /// status of 204 on success. If the asynchronous request failed, the URI in + /// the Location header returns an error-level status code. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the deployment. + /// + /// + /// The cancellation token. + /// + public static async Task BeginDeleteAtSubscriptionScopeAsync(this IDeploymentsOperations operations, string deploymentName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.BeginDeleteAtSubscriptionScopeWithHttpMessagesAsync(deploymentName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Deploys resources at subscription scope. + /// + /// + /// You can provide the template and parameters directly in the request or link + /// to JSON files. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the deployment. + /// + /// + /// Additional parameters supplied to the operation. + /// + public static DeploymentExtended BeginCreateOrUpdateAtSubscriptionScope(this IDeploymentsOperations operations, string deploymentName, Deployment parameters) + { + return operations.BeginCreateOrUpdateAtSubscriptionScopeAsync(deploymentName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Deploys resources at subscription scope. + /// + /// + /// You can provide the template and parameters directly in the request or link + /// to JSON files. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the deployment. + /// + /// + /// Additional parameters supplied to the operation. + /// + /// + /// The cancellation token. + /// + public static async Task BeginCreateOrUpdateAtSubscriptionScopeAsync(this IDeploymentsOperations operations, string deploymentName, Deployment parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginCreateOrUpdateAtSubscriptionScopeWithHttpMessagesAsync(deploymentName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Validates whether the specified template is syntactically correct and will + /// be accepted by Azure Resource Manager.. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the deployment. + /// + /// + /// Parameters to validate. + /// + public static DeploymentValidateResult BeginValidateAtSubscriptionScope(this IDeploymentsOperations operations, string deploymentName, Deployment parameters) + { + return operations.BeginValidateAtSubscriptionScopeAsync(deploymentName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Validates whether the specified template is syntactically correct and will + /// be accepted by Azure Resource Manager.. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the deployment. + /// + /// + /// Parameters to validate. + /// + /// + /// The cancellation token. + /// + public static async Task BeginValidateAtSubscriptionScopeAsync(this IDeploymentsOperations operations, string deploymentName, Deployment parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginValidateAtSubscriptionScopeWithHttpMessagesAsync(deploymentName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Returns changes that will be made by the deployment if executed at the + /// scope of the subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the deployment. + /// + /// + /// Parameters to What If. + /// + public static WhatIfOperationResult BeginWhatIfAtSubscriptionScope(this IDeploymentsOperations operations, string deploymentName, DeploymentWhatIf parameters) + { + return operations.BeginWhatIfAtSubscriptionScopeAsync(deploymentName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Returns changes that will be made by the deployment if executed at the + /// scope of the subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the deployment. + /// + /// + /// Parameters to What If. + /// + /// + /// The cancellation token. + /// + public static async Task BeginWhatIfAtSubscriptionScopeAsync(this IDeploymentsOperations operations, string deploymentName, DeploymentWhatIf parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginWhatIfAtSubscriptionScopeWithHttpMessagesAsync(deploymentName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes a deployment from the deployment history. + /// + /// + /// A template deployment that is currently running cannot be deleted. Deleting + /// a template deployment removes the associated deployment operations. + /// Deleting a template deployment does not affect the state of the resource + /// group. This is an asynchronous operation that returns a status of 202 until + /// the template deployment is successfully deleted. The Location response + /// header contains the URI that is used to obtain the status of the process. + /// While the process is running, a call to the URI in the Location header + /// returns a status of 202. When the process finishes, the URI in the Location + /// header returns a status of 204 on success. If the asynchronous request + /// failed, the URI in the Location header returns an error-level status code. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group with the deployment to delete. The name is + /// case insensitive. + /// + /// + /// The name of the deployment. + /// + public static void BeginDelete(this IDeploymentsOperations operations, string resourceGroupName, string deploymentName) + { + operations.BeginDeleteAsync(resourceGroupName, deploymentName).GetAwaiter().GetResult(); + } + + /// + /// Deletes a deployment from the deployment history. + /// + /// + /// A template deployment that is currently running cannot be deleted. Deleting + /// a template deployment removes the associated deployment operations. + /// Deleting a template deployment does not affect the state of the resource + /// group. This is an asynchronous operation that returns a status of 202 until + /// the template deployment is successfully deleted. The Location response + /// header contains the URI that is used to obtain the status of the process. + /// While the process is running, a call to the URI in the Location header + /// returns a status of 202. When the process finishes, the URI in the Location + /// header returns a status of 204 on success. If the asynchronous request + /// failed, the URI in the Location header returns an error-level status code. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group with the deployment to delete. The name is + /// case insensitive. + /// + /// + /// The name of the deployment. + /// + /// + /// The cancellation token. + /// + public static async Task BeginDeleteAsync(this IDeploymentsOperations operations, string resourceGroupName, string deploymentName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.BeginDeleteWithHttpMessagesAsync(resourceGroupName, deploymentName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Deploys resources to a resource group. + /// + /// + /// You can provide the template and parameters directly in the request or link + /// to JSON files. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to deploy the resources to. The name is case + /// insensitive. The resource group must already exist. + /// + /// + /// The name of the deployment. + /// + /// + /// Additional parameters supplied to the operation. + /// + public static DeploymentExtended BeginCreateOrUpdate(this IDeploymentsOperations operations, string resourceGroupName, string deploymentName, Deployment parameters) + { + return operations.BeginCreateOrUpdateAsync(resourceGroupName, deploymentName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Deploys resources to a resource group. + /// + /// + /// You can provide the template and parameters directly in the request or link + /// to JSON files. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to deploy the resources to. The name is case + /// insensitive. The resource group must already exist. + /// + /// + /// The name of the deployment. + /// + /// + /// Additional parameters supplied to the operation. + /// + /// + /// The cancellation token. + /// + public static async Task BeginCreateOrUpdateAsync(this IDeploymentsOperations operations, string resourceGroupName, string deploymentName, Deployment parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, deploymentName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Validates whether the specified template is syntactically correct and will + /// be accepted by Azure Resource Manager.. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group the template will be deployed to. The name + /// is case insensitive. + /// + /// + /// The name of the deployment. + /// + /// + /// Parameters to validate. + /// + public static DeploymentValidateResult BeginValidate(this IDeploymentsOperations operations, string resourceGroupName, string deploymentName, Deployment parameters) + { + return operations.BeginValidateAsync(resourceGroupName, deploymentName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Validates whether the specified template is syntactically correct and will + /// be accepted by Azure Resource Manager.. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group the template will be deployed to. The name + /// is case insensitive. + /// + /// + /// The name of the deployment. + /// + /// + /// Parameters to validate. + /// + /// + /// The cancellation token. + /// + public static async Task BeginValidateAsync(this IDeploymentsOperations operations, string resourceGroupName, string deploymentName, Deployment parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginValidateWithHttpMessagesAsync(resourceGroupName, deploymentName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Returns changes that will be made by the deployment if executed at the + /// scope of the resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group the template will be deployed to. The name + /// is case insensitive. + /// + /// + /// The name of the deployment. + /// + /// + /// Parameters to validate. + /// + public static WhatIfOperationResult BeginWhatIf(this IDeploymentsOperations operations, string resourceGroupName, string deploymentName, DeploymentWhatIf parameters) + { + return operations.BeginWhatIfAsync(resourceGroupName, deploymentName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Returns changes that will be made by the deployment if executed at the + /// scope of the resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group the template will be deployed to. The name + /// is case insensitive. + /// + /// + /// The name of the deployment. + /// + /// + /// Parameters to validate. + /// + /// + /// The cancellation token. + /// + public static async Task BeginWhatIfAsync(this IDeploymentsOperations operations, string resourceGroupName, string deploymentName, DeploymentWhatIf parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginWhatIfWithHttpMessagesAsync(resourceGroupName, deploymentName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get all the deployments at the given scope. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListAtScopeNext(this IDeploymentsOperations operations, string nextPageLink) + { + return operations.ListAtScopeNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Get all the deployments at the given scope. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAtScopeNextAsync(this IDeploymentsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListAtScopeNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get all the deployments at the tenant scope. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListAtTenantScopeNext(this IDeploymentsOperations operations, string nextPageLink) + { + return operations.ListAtTenantScopeNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Get all the deployments at the tenant scope. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAtTenantScopeNextAsync(this IDeploymentsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListAtTenantScopeNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get all the deployments for a management group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListAtManagementGroupScopeNext(this IDeploymentsOperations operations, string nextPageLink) + { + return operations.ListAtManagementGroupScopeNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Get all the deployments for a management 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> ListAtManagementGroupScopeNextAsync(this IDeploymentsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListAtManagementGroupScopeNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get all the deployments for a subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListAtSubscriptionScopeNext(this IDeploymentsOperations operations, string nextPageLink) + { + return operations.ListAtSubscriptionScopeNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Get all the deployments for 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> ListAtSubscriptionScopeNextAsync(this IDeploymentsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListAtSubscriptionScopeNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get all the deployments for 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 IDeploymentsOperations operations, string nextPageLink) + { + return operations.ListByResourceGroupNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Get all the deployments for 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 IDeploymentsOperations 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/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/FeatureClient.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/FeatureClient.cs new file mode 100644 index 0000000000000..e1a3eeebeca65 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/FeatureClient.cs @@ -0,0 +1,699 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager +{ + 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; + + public partial class FeatureClient : ServiceClient, IFeatureClient, 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 Azure subscription ID. + /// + public string 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 IFeaturesOperations. + /// + public virtual IFeaturesOperations Features { get; private set; } + + /// + /// Gets the ISubscriptionFeatureRegistrationsOperations. + /// + public virtual ISubscriptionFeatureRegistrationsOperations SubscriptionFeatureRegistrations { get; private set; } + + /// + /// Initializes a new instance of the FeatureClient class. + /// + /// + /// HttpClient to be used + /// + /// + /// True: will dispose the provided httpClient on calling FeatureClient.Dispose(). False: will not dispose provided httpClient + protected FeatureClient(HttpClient httpClient, bool disposeHttpClient) : base(httpClient, disposeHttpClient) + { + Initialize(); + } + + /// + /// Initializes a new instance of the FeatureClient class. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + protected FeatureClient(params DelegatingHandler[] handlers) : base(handlers) + { + Initialize(); + } + + /// + /// Initializes a new instance of the FeatureClient class. + /// + /// + /// Optional. The http client handler used to handle http transport. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + protected FeatureClient(HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : base(rootHandler, handlers) + { + Initialize(); + } + + /// + /// Initializes a new instance of the FeatureClient 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 FeatureClient(System.Uri baseUri, params DelegatingHandler[] handlers) : this(handlers) + { + if (baseUri == null) + { + throw new System.ArgumentNullException("baseUri"); + } + BaseUri = baseUri; + } + + /// + /// Initializes a new instance of the FeatureClient 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 FeatureClient(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 FeatureClient 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 FeatureClient(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 FeatureClient class. + /// + /// + /// Required. Credentials needed for the client to connect to Azure. + /// + /// + /// HttpClient to be used + /// + /// + /// True: will dispose the provided httpClient on calling FeatureClient.Dispose(). False: will not dispose provided httpClient + /// + /// Thrown when a required parameter is null + /// + public FeatureClient(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 FeatureClient 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 FeatureClient(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 FeatureClient 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 FeatureClient(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 FeatureClient 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 FeatureClient(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() + { + Features = new FeaturesOperations(this); + SubscriptionFeatureRegistrations = new SubscriptionFeatureRegistrationsOperations(this); + BaseUri = new System.Uri("https://management.azure.com"); + ApiVersion = "2021-07-01"; + 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() + } + }; + 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 CloudErrorJsonConverter()); + } + /// + /// Lists all of the available Microsoft.Features 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>> ListOperationsWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.ApiVersion"); + } + // 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, "ListOperations", tracingParameters); + } + // Construct URL + var _baseUrl = BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Features/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 (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 ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = SafeJsonConvert.DeserializeObject(_responseContent, 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 = 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; + } + + /// + /// Lists all of the available Microsoft.Features REST API operations. + /// + /// + /// 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>> ListOperationsNextWithHttpMessagesAsync(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, "ListOperationsNext", 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 (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 ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = SafeJsonConvert.DeserializeObject(_responseContent, 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 = 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; + } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/FeatureClientExtensions.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/FeatureClientExtensions.cs new file mode 100644 index 0000000000000..cea750a313a80 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/FeatureClientExtensions.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.ResourceManager +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for FeatureClient. + /// + public static partial class FeatureClientExtensions + { + /// + /// Lists all of the available Microsoft.Features REST API operations. + /// + /// + /// The operations group for this extension method. + /// + public static IPage ListOperations(this IFeatureClient operations) + { + return operations.ListOperationsAsync().GetAwaiter().GetResult(); + } + + /// + /// Lists all of the available Microsoft.Features REST API operations. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The cancellation token. + /// + public static async Task> ListOperationsAsync(this IFeatureClient operations, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListOperationsWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Lists all of the available Microsoft.Features REST API operations. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListOperationsNext(this IFeatureClient operations, string nextPageLink) + { + return operations.ListOperationsNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Lists all of the available Microsoft.Features REST API operations. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListOperationsNextAsync(this IFeatureClient operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListOperationsNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/FeaturesOperations.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/FeaturesOperations.cs new file mode 100644 index 0000000000000..c17b9351b70ed --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/FeaturesOperations.cs @@ -0,0 +1,1322 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager +{ + 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; + + /// + /// FeaturesOperations operations. + /// + internal partial class FeaturesOperations : IServiceOperations, IFeaturesOperations + { + /// + /// Initializes a new instance of the FeaturesOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal FeaturesOperations(FeatureClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the FeatureClient + /// + public FeatureClient Client { get; private set; } + + /// + /// Gets all the preview features that are available through AFEC for the + /// 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>> ListAllWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + // 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, "ListAll", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Features/features").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + 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 all the preview features in a provider namespace that are available + /// through AFEC for the subscription. + /// + /// + /// The namespace of the resource provider for getting features. + /// + /// + /// 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 resourceProviderNamespace, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceProviderNamespace == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceProviderNamespace"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceProviderNamespace", resourceProviderNamespace); + 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.Features/providers/{resourceProviderNamespace}/features").ToString(); + _url = _url.Replace("{resourceProviderNamespace}", System.Uri.EscapeDataString(resourceProviderNamespace)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + 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 the preview feature with the specified name. + /// + /// + /// The resource provider namespace for the feature. + /// + /// + /// The name of the feature to get. + /// + /// + /// 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 resourceProviderNamespace, string featureName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceProviderNamespace == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceProviderNamespace"); + } + if (featureName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "featureName"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceProviderNamespace", resourceProviderNamespace); + tracingParameters.Add("featureName", featureName); + 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.Features/providers/{resourceProviderNamespace}/features/{featureName}").ToString(); + _url = _url.Replace("{resourceProviderNamespace}", System.Uri.EscapeDataString(resourceProviderNamespace)); + _url = _url.Replace("{featureName}", System.Uri.EscapeDataString(featureName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + 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; + } + + /// + /// Registers the preview feature for the subscription. + /// + /// + /// The namespace of the resource provider. + /// + /// + /// The name of the feature to register. + /// + /// + /// 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> RegisterWithHttpMessagesAsync(string resourceProviderNamespace, string featureName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceProviderNamespace == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceProviderNamespace"); + } + if (featureName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "featureName"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceProviderNamespace", resourceProviderNamespace); + tracingParameters.Add("featureName", featureName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Register", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Features/providers/{resourceProviderNamespace}/features/{featureName}/register").ToString(); + _url = _url.Replace("{resourceProviderNamespace}", System.Uri.EscapeDataString(resourceProviderNamespace)); + _url = _url.Replace("{featureName}", System.Uri.EscapeDataString(featureName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + 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) + { + 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; + } + + /// + /// Unregisters the preview feature for the subscription. + /// + /// + /// The namespace of the resource provider. + /// + /// + /// The name of the feature to unregister. + /// + /// + /// 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> UnregisterWithHttpMessagesAsync(string resourceProviderNamespace, string featureName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceProviderNamespace == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceProviderNamespace"); + } + if (featureName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "featureName"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceProviderNamespace", resourceProviderNamespace); + tracingParameters.Add("featureName", featureName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Unregister", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Features/providers/{resourceProviderNamespace}/features/{featureName}/unregister").ToString(); + _url = _url.Replace("{resourceProviderNamespace}", System.Uri.EscapeDataString(resourceProviderNamespace)); + _url = _url.Replace("{featureName}", System.Uri.EscapeDataString(featureName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + 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) + { + 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 all the preview features that are available through AFEC for the + /// 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>> ListAllNextWithHttpMessagesAsync(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, "ListAllNext", 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; + } + + /// + /// Gets all the preview features in a provider namespace that are available + /// through AFEC for the 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; + } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/FeaturesOperationsExtensions.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/FeaturesOperationsExtensions.cs new file mode 100644 index 0000000000000..ab76dd04c65c2 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/FeaturesOperationsExtensions.cs @@ -0,0 +1,283 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for FeaturesOperations. + /// + public static partial class FeaturesOperationsExtensions + { + /// + /// Gets all the preview features that are available through AFEC for the + /// subscription. + /// + /// + /// The operations group for this extension method. + /// + public static IPage ListAll(this IFeaturesOperations operations) + { + return operations.ListAllAsync().GetAwaiter().GetResult(); + } + + /// + /// Gets all the preview features that are available through AFEC for the + /// subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAllAsync(this IFeaturesOperations operations, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListAllWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets all the preview features in a provider namespace that are available + /// through AFEC for the subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The namespace of the resource provider for getting features. + /// + public static IPage List(this IFeaturesOperations operations, string resourceProviderNamespace) + { + return operations.ListAsync(resourceProviderNamespace).GetAwaiter().GetResult(); + } + + /// + /// Gets all the preview features in a provider namespace that are available + /// through AFEC for the subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The namespace of the resource provider for getting features. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAsync(this IFeaturesOperations operations, string resourceProviderNamespace, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(resourceProviderNamespace, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets the preview feature with the specified name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The resource provider namespace for the feature. + /// + /// + /// The name of the feature to get. + /// + public static FeatureResult Get(this IFeaturesOperations operations, string resourceProviderNamespace, string featureName) + { + return operations.GetAsync(resourceProviderNamespace, featureName).GetAwaiter().GetResult(); + } + + /// + /// Gets the preview feature with the specified name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The resource provider namespace for the feature. + /// + /// + /// The name of the feature to get. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IFeaturesOperations operations, string resourceProviderNamespace, string featureName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceProviderNamespace, featureName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Registers the preview feature for the subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The namespace of the resource provider. + /// + /// + /// The name of the feature to register. + /// + public static FeatureResult Register(this IFeaturesOperations operations, string resourceProviderNamespace, string featureName) + { + return operations.RegisterAsync(resourceProviderNamespace, featureName).GetAwaiter().GetResult(); + } + + /// + /// Registers the preview feature for the subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The namespace of the resource provider. + /// + /// + /// The name of the feature to register. + /// + /// + /// The cancellation token. + /// + public static async Task RegisterAsync(this IFeaturesOperations operations, string resourceProviderNamespace, string featureName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.RegisterWithHttpMessagesAsync(resourceProviderNamespace, featureName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Unregisters the preview feature for the subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The namespace of the resource provider. + /// + /// + /// The name of the feature to unregister. + /// + public static FeatureResult Unregister(this IFeaturesOperations operations, string resourceProviderNamespace, string featureName) + { + return operations.UnregisterAsync(resourceProviderNamespace, featureName).GetAwaiter().GetResult(); + } + + /// + /// Unregisters the preview feature for the subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The namespace of the resource provider. + /// + /// + /// The name of the feature to unregister. + /// + /// + /// The cancellation token. + /// + public static async Task UnregisterAsync(this IFeaturesOperations operations, string resourceProviderNamespace, string featureName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.UnregisterWithHttpMessagesAsync(resourceProviderNamespace, featureName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets all the preview features that are available through AFEC for the + /// subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListAllNext(this IFeaturesOperations operations, string nextPageLink) + { + return operations.ListAllNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Gets all the preview features that are available through AFEC for the + /// 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> ListAllNextAsync(this IFeaturesOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListAllNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets all the preview features in a provider namespace that are available + /// through AFEC for the subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListNext(this IFeaturesOperations operations, string nextPageLink) + { + return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Gets all the preview features in a provider namespace that are available + /// through AFEC for the 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 IFeaturesOperations 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/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/IAuthorizationOperations.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/IAuthorizationOperations.cs new file mode 100644 index 0000000000000..89228ed2ecb05 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/IAuthorizationOperations.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.ResourceManager +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// AuthorizationOperations operations. + /// + public partial interface IAuthorizationOperations + { + /// + /// Lists all of the available Microsoft.Authorization 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)); + /// + /// Lists all of the available Microsoft.Authorization REST API + /// operations. + /// + /// + /// 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/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/IDataPolicyManifestsOperations.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/IDataPolicyManifestsOperations.cs new file mode 100644 index 0000000000000..17656ba8a87c4 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/IDataPolicyManifestsOperations.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.ResourceManager +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// DataPolicyManifestsOperations operations. + /// + public partial interface IDataPolicyManifestsOperations + { + /// + /// Retrieves a data policy manifest. + /// + /// + /// This operation retrieves the data policy manifest with the given + /// policy mode. + /// + /// + /// The policy mode of the data policy manifest to get. + /// + /// + /// 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> GetByPolicyModeWithHttpMessagesAsync(string policyMode, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Retrieves data policy manifests + /// + /// + /// This operation retrieves a list of all the data policy manifests + /// that match the optional given $filter. Valid values for $filter + /// are: "$filter=namespace eq '{0}'". If $filter is not provided, the + /// unfiltered list includes all data policy manifests for data + /// resource types. If $filter=namespace is provided, the returned list + /// only includes all data policy manifests that have a namespace + /// matching the provided value. + /// + /// + /// The filter to apply on the operation. Valid values for $filter are: + /// "namespace eq '{value}'". If $filter is not provided, no filtering + /// is performed. If $filter=namespace eq '{value}' is provided, the + /// returned list only includes all data policy manifests that have a + /// namespace matching the provided value. + /// + /// + /// 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 filter = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Retrieves data policy manifests + /// + /// + /// This operation retrieves a list of all the data policy manifests + /// that match the optional given $filter. Valid values for $filter + /// are: "$filter=namespace eq '{0}'". If $filter is not provided, the + /// unfiltered list includes all data policy manifests for data + /// resource types. If $filter=namespace is provided, the returned list + /// only includes all data policy manifests that have a namespace + /// matching the provided value. + /// + /// + /// 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/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/IDeploymentOperations.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/IDeploymentOperations.cs new file mode 100644 index 0000000000000..d490a1ba53a72 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/IDeploymentOperations.cs @@ -0,0 +1,405 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// DeploymentOperations operations. + /// + public partial interface IDeploymentOperations + { + /// + /// Gets a deployments operation. + /// + /// + /// The resource scope. + /// + /// + /// The name of the deployment. + /// + /// + /// The ID of the operation to get. + /// + /// + /// 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> GetAtScopeWithHttpMessagesAsync(string scope, string deploymentName, string operationId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets all deployments operations for a deployment. + /// + /// + /// The resource scope. + /// + /// + /// The name of the deployment. + /// + /// + /// The number of results to return. + /// + /// + /// 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>> ListAtScopeWithHttpMessagesAsync(string scope, string deploymentName, int? top = default(int?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets a deployments operation. + /// + /// + /// The name of the deployment. + /// + /// + /// The ID of the operation to get. + /// + /// + /// 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> GetAtTenantScopeWithHttpMessagesAsync(string deploymentName, string operationId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets all deployments operations for a deployment. + /// + /// + /// The name of the deployment. + /// + /// + /// The number of results to return. + /// + /// + /// 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>> ListAtTenantScopeWithHttpMessagesAsync(string deploymentName, int? top = default(int?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets a deployments operation. + /// + /// + /// The management group ID. + /// + /// + /// The name of the deployment. + /// + /// + /// The ID of the operation to get. + /// + /// + /// 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> GetAtManagementGroupScopeWithHttpMessagesAsync(string groupId, string deploymentName, string operationId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets all deployments operations for a deployment. + /// + /// + /// The management group ID. + /// + /// + /// The name of the deployment. + /// + /// + /// The number of results to return. + /// + /// + /// 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>> ListAtManagementGroupScopeWithHttpMessagesAsync(string groupId, string deploymentName, int? top = default(int?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets a deployments operation. + /// + /// + /// The name of the deployment. + /// + /// + /// The ID of the operation to get. + /// + /// + /// 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> GetAtSubscriptionScopeWithHttpMessagesAsync(string deploymentName, string operationId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets all deployments operations for a deployment. + /// + /// + /// The name of the deployment. + /// + /// + /// The number of results to return. + /// + /// + /// 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>> ListAtSubscriptionScopeWithHttpMessagesAsync(string deploymentName, int? top = default(int?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets a deployments operation. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the deployment. + /// + /// + /// The ID of the operation to get. + /// + /// + /// 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 deploymentName, string operationId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets all deployments operations for a deployment. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the deployment. + /// + /// + /// The number of results to return. + /// + /// + /// 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 deploymentName, int? top = default(int?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets all deployments operations for a deployment. + /// + /// + /// 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>> ListAtScopeNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets all deployments operations for a deployment. + /// + /// + /// 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>> ListAtTenantScopeNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets all deployments operations for a deployment. + /// + /// + /// 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>> ListAtManagementGroupScopeNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets all deployments operations for a deployment. + /// + /// + /// 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>> ListAtSubscriptionScopeNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets all deployments operations for a deployment. + /// + /// + /// 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/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/IDeploymentScriptsClient.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/IDeploymentScriptsClient.cs new file mode 100644 index 0000000000000..1da53b5a95fc7 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/IDeploymentScriptsClient.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.ResourceManager +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + + /// + /// The APIs listed in this specification can be used to manage Deployment + /// Scripts resource through the Azure Resource Manager. + /// + public partial interface IDeploymentScriptsClient : 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; } + + /// + /// Subscription Id which forms part of the URI for every service call. + /// + string SubscriptionId { get; set; } + + /// + /// Client Api version. + /// + 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 IDeploymentScriptsOperations. + /// + IDeploymentScriptsOperations DeploymentScripts { get; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/IDeploymentScriptsOperations.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/IDeploymentScriptsOperations.cs new file mode 100644 index 0000000000000..9a3385fa2e190 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/IDeploymentScriptsOperations.cs @@ -0,0 +1,300 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// DeploymentScriptsOperations operations. + /// + public partial interface IDeploymentScriptsOperations + { + /// + /// Creates a deployment script. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Name of the deployment script. + /// + /// + /// Deployment script supplied to the 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> CreateWithHttpMessagesAsync(string resourceGroupName, string scriptName, DeploymentScript deploymentScript, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Updates deployment script tags with specified values. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Name of the deployment script. + /// + /// + /// Deployment script resource with the tags to be updated. + /// + /// + /// 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 scriptName, DeploymentScriptUpdateParameter deploymentScript = default(DeploymentScriptUpdateParameter), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets a deployment script with a given name. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Name of the deployment script. + /// + /// + /// 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 scriptName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes a deployment script. When operation completes, status code + /// 200 returned without content. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Name of the deployment script. + /// + /// + /// 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 scriptName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Lists all deployment scripts for 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>> ListBySubscriptionWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets deployment script logs for a given deployment script name. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Name of the deployment script. + /// + /// + /// 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> GetLogsWithHttpMessagesAsync(string resourceGroupName, string scriptName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets deployment script logs for a given deployment script name. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Name of the deployment script. + /// + /// + /// The number of lines to show from the tail of the deployment script + /// log. Valid value is a positive number up to 1000. If 'tail' is not + /// provided, all available logs are shown up to container instance log + /// capacity of 4mb. + /// + /// + /// 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> GetLogsDefaultWithHttpMessagesAsync(string resourceGroupName, string scriptName, int? tail = default(int?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Lists deployments scripts. + /// + /// + /// 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 deployment script. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Name of the deployment script. + /// + /// + /// Deployment script supplied to the 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> BeginCreateWithHttpMessagesAsync(string resourceGroupName, string scriptName, DeploymentScript deploymentScript, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Lists all deployment scripts for a given 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>> ListBySubscriptionNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Lists deployments scripts. + /// + /// + /// 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/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/IDeploymentsOperations.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/IDeploymentsOperations.cs new file mode 100644 index 0000000000000..15767ed9c350c --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/IDeploymentsOperations.cs @@ -0,0 +1,1908 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Microsoft.Rest.Azure.OData; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// DeploymentsOperations operations. + /// + public partial interface IDeploymentsOperations + { + /// + /// Deletes a deployment from the deployment history. + /// + /// + /// A template deployment that is currently running cannot be deleted. + /// Deleting a template deployment removes the associated deployment + /// operations. This is an asynchronous operation that returns a status + /// of 202 until the template deployment is successfully deleted. The + /// Location response header contains the URI that is used to obtain + /// the status of the process. While the process is running, a call to + /// the URI in the Location header returns a status of 202. When the + /// process finishes, the URI in the Location header returns a status + /// of 204 on success. If the asynchronous request failed, the URI in + /// the Location header returns an error-level status code. + /// + /// + /// The resource scope. + /// + /// + /// The name of the deployment. + /// + /// + /// 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 DeleteAtScopeWithHttpMessagesAsync(string scope, string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Checks whether the deployment exists. + /// + /// + /// The resource scope. + /// + /// + /// The name of the deployment. + /// + /// + /// 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> CheckExistenceAtScopeWithHttpMessagesAsync(string scope, string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deploys resources at a given scope. + /// + /// + /// You can provide the template and parameters directly in the request + /// or link to JSON files. + /// + /// + /// The resource scope. + /// + /// + /// The name of the deployment. + /// + /// + /// Additional parameters supplied to the 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> CreateOrUpdateAtScopeWithHttpMessagesAsync(string scope, string deploymentName, Deployment parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets a deployment. + /// + /// + /// The resource scope. + /// + /// + /// The name of the deployment. + /// + /// + /// 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> GetAtScopeWithHttpMessagesAsync(string scope, string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Cancels a currently running template deployment. + /// + /// + /// You can cancel a deployment only if the provisioningState is + /// Accepted or Running. After the deployment is canceled, the + /// provisioningState is set to Canceled. Canceling a template + /// deployment stops the currently running template deployment and + /// leaves the resources partially deployed. + /// + /// + /// The resource scope. + /// + /// + /// The name of the deployment. + /// + /// + /// 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 CancelAtScopeWithHttpMessagesAsync(string scope, string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Validates whether the specified template is syntactically correct + /// and will be accepted by Azure Resource Manager.. + /// + /// + /// The resource scope. + /// + /// + /// The name of the deployment. + /// + /// + /// Parameters to validate. + /// + /// + /// 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> ValidateAtScopeWithHttpMessagesAsync(string scope, string deploymentName, Deployment parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Exports the template used for specified deployment. + /// + /// + /// The resource scope. + /// + /// + /// The name of the deployment. + /// + /// + /// 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> ExportTemplateAtScopeWithHttpMessagesAsync(string scope, string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get all the deployments at the given scope. + /// + /// + /// The resource scope. + /// + /// + /// OData parameters to apply to the 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>> ListAtScopeWithHttpMessagesAsync(string scope, ODataQuery odataQuery = default(ODataQuery), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes a deployment from the deployment history. + /// + /// + /// A template deployment that is currently running cannot be deleted. + /// Deleting a template deployment removes the associated deployment + /// operations. This is an asynchronous operation that returns a status + /// of 202 until the template deployment is successfully deleted. The + /// Location response header contains the URI that is used to obtain + /// the status of the process. While the process is running, a call to + /// the URI in the Location header returns a status of 202. When the + /// process finishes, the URI in the Location header returns a status + /// of 204 on success. If the asynchronous request failed, the URI in + /// the Location header returns an error-level status code. + /// + /// + /// The name of the deployment. + /// + /// + /// 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 DeleteAtTenantScopeWithHttpMessagesAsync(string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Checks whether the deployment exists. + /// + /// + /// The name of the deployment. + /// + /// + /// 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> CheckExistenceAtTenantScopeWithHttpMessagesAsync(string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deploys resources at tenant scope. + /// + /// + /// You can provide the template and parameters directly in the request + /// or link to JSON files. + /// + /// + /// The name of the deployment. + /// + /// + /// Additional parameters supplied to the 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> CreateOrUpdateAtTenantScopeWithHttpMessagesAsync(string deploymentName, ScopedDeployment parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets a deployment. + /// + /// + /// The name of the deployment. + /// + /// + /// 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> GetAtTenantScopeWithHttpMessagesAsync(string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Cancels a currently running template deployment. + /// + /// + /// You can cancel a deployment only if the provisioningState is + /// Accepted or Running. After the deployment is canceled, the + /// provisioningState is set to Canceled. Canceling a template + /// deployment stops the currently running template deployment and + /// leaves the resources partially deployed. + /// + /// + /// The name of the deployment. + /// + /// + /// 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 CancelAtTenantScopeWithHttpMessagesAsync(string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Validates whether the specified template is syntactically correct + /// and will be accepted by Azure Resource Manager.. + /// + /// + /// The name of the deployment. + /// + /// + /// Parameters to validate. + /// + /// + /// 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> ValidateAtTenantScopeWithHttpMessagesAsync(string deploymentName, ScopedDeployment parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Returns changes that will be made by the deployment if executed at + /// the scope of the tenant group. + /// + /// + /// The name of the deployment. + /// + /// + /// Parameters to validate. + /// + /// + /// 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> WhatIfAtTenantScopeWithHttpMessagesAsync(string deploymentName, ScopedDeploymentWhatIf parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Exports the template used for specified deployment. + /// + /// + /// The name of the deployment. + /// + /// + /// 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> ExportTemplateAtTenantScopeWithHttpMessagesAsync(string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get all the deployments at the tenant scope. + /// + /// + /// OData parameters to apply to the 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>> ListAtTenantScopeWithHttpMessagesAsync(ODataQuery odataQuery = default(ODataQuery), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes a deployment from the deployment history. + /// + /// + /// A template deployment that is currently running cannot be deleted. + /// Deleting a template deployment removes the associated deployment + /// operations. This is an asynchronous operation that returns a status + /// of 202 until the template deployment is successfully deleted. The + /// Location response header contains the URI that is used to obtain + /// the status of the process. While the process is running, a call to + /// the URI in the Location header returns a status of 202. When the + /// process finishes, the URI in the Location header returns a status + /// of 204 on success. If the asynchronous request failed, the URI in + /// the Location header returns an error-level status code. + /// + /// + /// The management group ID. + /// + /// + /// The name of the deployment. + /// + /// + /// 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 DeleteAtManagementGroupScopeWithHttpMessagesAsync(string groupId, string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Checks whether the deployment exists. + /// + /// + /// The management group ID. + /// + /// + /// The name of the deployment. + /// + /// + /// 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> CheckExistenceAtManagementGroupScopeWithHttpMessagesAsync(string groupId, string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deploys resources at management group scope. + /// + /// + /// You can provide the template and parameters directly in the request + /// or link to JSON files. + /// + /// + /// The management group ID. + /// + /// + /// The name of the deployment. + /// + /// + /// Additional parameters supplied to the 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> CreateOrUpdateAtManagementGroupScopeWithHttpMessagesAsync(string groupId, string deploymentName, ScopedDeployment parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets a deployment. + /// + /// + /// The management group ID. + /// + /// + /// The name of the deployment. + /// + /// + /// 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> GetAtManagementGroupScopeWithHttpMessagesAsync(string groupId, string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Cancels a currently running template deployment. + /// + /// + /// You can cancel a deployment only if the provisioningState is + /// Accepted or Running. After the deployment is canceled, the + /// provisioningState is set to Canceled. Canceling a template + /// deployment stops the currently running template deployment and + /// leaves the resources partially deployed. + /// + /// + /// The management group ID. + /// + /// + /// The name of the deployment. + /// + /// + /// 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 CancelAtManagementGroupScopeWithHttpMessagesAsync(string groupId, string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Validates whether the specified template is syntactically correct + /// and will be accepted by Azure Resource Manager.. + /// + /// + /// The management group ID. + /// + /// + /// The name of the deployment. + /// + /// + /// Parameters to validate. + /// + /// + /// 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> ValidateAtManagementGroupScopeWithHttpMessagesAsync(string groupId, string deploymentName, ScopedDeployment parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Returns changes that will be made by the deployment if executed at + /// the scope of the management group. + /// + /// + /// The management group ID. + /// + /// + /// The name of the deployment. + /// + /// + /// Parameters to validate. + /// + /// + /// 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> WhatIfAtManagementGroupScopeWithHttpMessagesAsync(string groupId, string deploymentName, ScopedDeploymentWhatIf parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Exports the template used for specified deployment. + /// + /// + /// The management group ID. + /// + /// + /// The name of the deployment. + /// + /// + /// 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> ExportTemplateAtManagementGroupScopeWithHttpMessagesAsync(string groupId, string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get all the deployments for a management group. + /// + /// + /// The management group ID. + /// + /// + /// OData parameters to apply to the 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>> ListAtManagementGroupScopeWithHttpMessagesAsync(string groupId, ODataQuery odataQuery = default(ODataQuery), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes a deployment from the deployment history. + /// + /// + /// A template deployment that is currently running cannot be deleted. + /// Deleting a template deployment removes the associated deployment + /// operations. This is an asynchronous operation that returns a status + /// of 202 until the template deployment is successfully deleted. The + /// Location response header contains the URI that is used to obtain + /// the status of the process. While the process is running, a call to + /// the URI in the Location header returns a status of 202. When the + /// process finishes, the URI in the Location header returns a status + /// of 204 on success. If the asynchronous request failed, the URI in + /// the Location header returns an error-level status code. + /// + /// + /// The name of the deployment. + /// + /// + /// 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 DeleteAtSubscriptionScopeWithHttpMessagesAsync(string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Checks whether the deployment exists. + /// + /// + /// The name of the deployment. + /// + /// + /// 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> CheckExistenceAtSubscriptionScopeWithHttpMessagesAsync(string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deploys resources at subscription scope. + /// + /// + /// You can provide the template and parameters directly in the request + /// or link to JSON files. + /// + /// + /// The name of the deployment. + /// + /// + /// Additional parameters supplied to the 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> CreateOrUpdateAtSubscriptionScopeWithHttpMessagesAsync(string deploymentName, Deployment parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets a deployment. + /// + /// + /// The name of the deployment. + /// + /// + /// 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> GetAtSubscriptionScopeWithHttpMessagesAsync(string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Cancels a currently running template deployment. + /// + /// + /// You can cancel a deployment only if the provisioningState is + /// Accepted or Running. After the deployment is canceled, the + /// provisioningState is set to Canceled. Canceling a template + /// deployment stops the currently running template deployment and + /// leaves the resources partially deployed. + /// + /// + /// The name of the deployment. + /// + /// + /// 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 CancelAtSubscriptionScopeWithHttpMessagesAsync(string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Validates whether the specified template is syntactically correct + /// and will be accepted by Azure Resource Manager.. + /// + /// + /// The name of the deployment. + /// + /// + /// Parameters to validate. + /// + /// + /// 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> ValidateAtSubscriptionScopeWithHttpMessagesAsync(string deploymentName, Deployment parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Returns changes that will be made by the deployment if executed at + /// the scope of the subscription. + /// + /// + /// The name of the deployment. + /// + /// + /// Parameters to What If. + /// + /// + /// 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> WhatIfAtSubscriptionScopeWithHttpMessagesAsync(string deploymentName, DeploymentWhatIf parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Exports the template used for specified deployment. + /// + /// + /// The name of the deployment. + /// + /// + /// 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> ExportTemplateAtSubscriptionScopeWithHttpMessagesAsync(string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get all the deployments for a subscription. + /// + /// + /// OData parameters to apply to the 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>> ListAtSubscriptionScopeWithHttpMessagesAsync(ODataQuery odataQuery = default(ODataQuery), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes a deployment from the deployment history. + /// + /// + /// A template deployment that is currently running cannot be deleted. + /// Deleting a template deployment removes the associated deployment + /// operations. Deleting a template deployment does not affect the + /// state of the resource group. This is an asynchronous operation that + /// returns a status of 202 until the template deployment is + /// successfully deleted. The Location response header contains the URI + /// that is used to obtain the status of the process. While the process + /// is running, a call to the URI in the Location header returns a + /// status of 202. When the process finishes, the URI in the Location + /// header returns a status of 204 on success. If the asynchronous + /// request failed, the URI in the Location header returns an + /// error-level status code. + /// + /// + /// The name of the resource group with the deployment to delete. The + /// name is case insensitive. + /// + /// + /// The name of the deployment. + /// + /// + /// 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 deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Checks whether the deployment exists. + /// + /// + /// The name of the resource group with the deployment to check. The + /// name is case insensitive. + /// + /// + /// The name of the deployment. + /// + /// + /// 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> CheckExistenceWithHttpMessagesAsync(string resourceGroupName, string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deploys resources to a resource group. + /// + /// + /// You can provide the template and parameters directly in the request + /// or link to JSON files. + /// + /// + /// The name of the resource group to deploy the resources to. The name + /// is case insensitive. The resource group must already exist. + /// + /// + /// The name of the deployment. + /// + /// + /// Additional parameters supplied to the 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> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string deploymentName, Deployment parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets a deployment. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the deployment. + /// + /// + /// 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 deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Cancels a currently running template deployment. + /// + /// + /// You can cancel a deployment only if the provisioningState is + /// Accepted or Running. After the deployment is canceled, the + /// provisioningState is set to Canceled. Canceling a template + /// deployment stops the currently running template deployment and + /// leaves the resource group partially deployed. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the deployment. + /// + /// + /// 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 CancelWithHttpMessagesAsync(string resourceGroupName, string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Validates whether the specified template is syntactically correct + /// and will be accepted by Azure Resource Manager.. + /// + /// + /// The name of the resource group the template will be deployed to. + /// The name is case insensitive. + /// + /// + /// The name of the deployment. + /// + /// + /// Parameters to validate. + /// + /// + /// 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> ValidateWithHttpMessagesAsync(string resourceGroupName, string deploymentName, Deployment parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Returns changes that will be made by the deployment if executed at + /// the scope of the resource group. + /// + /// + /// The name of the resource group the template will be deployed to. + /// The name is case insensitive. + /// + /// + /// The name of the deployment. + /// + /// + /// Parameters to validate. + /// + /// + /// 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> WhatIfWithHttpMessagesAsync(string resourceGroupName, string deploymentName, DeploymentWhatIf parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Exports the template used for specified deployment. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the deployment. + /// + /// + /// 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> ExportTemplateWithHttpMessagesAsync(string resourceGroupName, string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get all the deployments for a resource group. + /// + /// + /// The name of the resource group with the deployments to get. The + /// name is case insensitive. + /// + /// + /// OData parameters to apply to the 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>> ListByResourceGroupWithHttpMessagesAsync(string resourceGroupName, ODataQuery odataQuery = default(ODataQuery), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Calculate the hash of the given template. + /// + /// + /// The template provided to calculate hash. + /// + /// + /// 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> CalculateTemplateHashWithHttpMessagesAsync(object template, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes a deployment from the deployment history. + /// + /// + /// A template deployment that is currently running cannot be deleted. + /// Deleting a template deployment removes the associated deployment + /// operations. This is an asynchronous operation that returns a status + /// of 202 until the template deployment is successfully deleted. The + /// Location response header contains the URI that is used to obtain + /// the status of the process. While the process is running, a call to + /// the URI in the Location header returns a status of 202. When the + /// process finishes, the URI in the Location header returns a status + /// of 204 on success. If the asynchronous request failed, the URI in + /// the Location header returns an error-level status code. + /// + /// + /// The resource scope. + /// + /// + /// The name of the deployment. + /// + /// + /// 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 BeginDeleteAtScopeWithHttpMessagesAsync(string scope, string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deploys resources at a given scope. + /// + /// + /// You can provide the template and parameters directly in the request + /// or link to JSON files. + /// + /// + /// The resource scope. + /// + /// + /// The name of the deployment. + /// + /// + /// Additional parameters supplied to the 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> BeginCreateOrUpdateAtScopeWithHttpMessagesAsync(string scope, string deploymentName, Deployment parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Validates whether the specified template is syntactically correct + /// and will be accepted by Azure Resource Manager.. + /// + /// + /// The resource scope. + /// + /// + /// The name of the deployment. + /// + /// + /// Parameters to validate. + /// + /// + /// 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> BeginValidateAtScopeWithHttpMessagesAsync(string scope, string deploymentName, Deployment parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes a deployment from the deployment history. + /// + /// + /// A template deployment that is currently running cannot be deleted. + /// Deleting a template deployment removes the associated deployment + /// operations. This is an asynchronous operation that returns a status + /// of 202 until the template deployment is successfully deleted. The + /// Location response header contains the URI that is used to obtain + /// the status of the process. While the process is running, a call to + /// the URI in the Location header returns a status of 202. When the + /// process finishes, the URI in the Location header returns a status + /// of 204 on success. If the asynchronous request failed, the URI in + /// the Location header returns an error-level status code. + /// + /// + /// The name of the deployment. + /// + /// + /// 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 BeginDeleteAtTenantScopeWithHttpMessagesAsync(string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deploys resources at tenant scope. + /// + /// + /// You can provide the template and parameters directly in the request + /// or link to JSON files. + /// + /// + /// The name of the deployment. + /// + /// + /// Additional parameters supplied to the 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> BeginCreateOrUpdateAtTenantScopeWithHttpMessagesAsync(string deploymentName, ScopedDeployment parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Validates whether the specified template is syntactically correct + /// and will be accepted by Azure Resource Manager.. + /// + /// + /// The name of the deployment. + /// + /// + /// Parameters to validate. + /// + /// + /// 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> BeginValidateAtTenantScopeWithHttpMessagesAsync(string deploymentName, ScopedDeployment parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Returns changes that will be made by the deployment if executed at + /// the scope of the tenant group. + /// + /// + /// The name of the deployment. + /// + /// + /// Parameters to validate. + /// + /// + /// 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> BeginWhatIfAtTenantScopeWithHttpMessagesAsync(string deploymentName, ScopedDeploymentWhatIf parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes a deployment from the deployment history. + /// + /// + /// A template deployment that is currently running cannot be deleted. + /// Deleting a template deployment removes the associated deployment + /// operations. This is an asynchronous operation that returns a status + /// of 202 until the template deployment is successfully deleted. The + /// Location response header contains the URI that is used to obtain + /// the status of the process. While the process is running, a call to + /// the URI in the Location header returns a status of 202. When the + /// process finishes, the URI in the Location header returns a status + /// of 204 on success. If the asynchronous request failed, the URI in + /// the Location header returns an error-level status code. + /// + /// + /// The management group ID. + /// + /// + /// The name of the deployment. + /// + /// + /// 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 BeginDeleteAtManagementGroupScopeWithHttpMessagesAsync(string groupId, string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deploys resources at management group scope. + /// + /// + /// You can provide the template and parameters directly in the request + /// or link to JSON files. + /// + /// + /// The management group ID. + /// + /// + /// The name of the deployment. + /// + /// + /// Additional parameters supplied to the 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> BeginCreateOrUpdateAtManagementGroupScopeWithHttpMessagesAsync(string groupId, string deploymentName, ScopedDeployment parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Validates whether the specified template is syntactically correct + /// and will be accepted by Azure Resource Manager.. + /// + /// + /// The management group ID. + /// + /// + /// The name of the deployment. + /// + /// + /// Parameters to validate. + /// + /// + /// 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> BeginValidateAtManagementGroupScopeWithHttpMessagesAsync(string groupId, string deploymentName, ScopedDeployment parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Returns changes that will be made by the deployment if executed at + /// the scope of the management group. + /// + /// + /// The management group ID. + /// + /// + /// The name of the deployment. + /// + /// + /// Parameters to validate. + /// + /// + /// 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> BeginWhatIfAtManagementGroupScopeWithHttpMessagesAsync(string groupId, string deploymentName, ScopedDeploymentWhatIf parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes a deployment from the deployment history. + /// + /// + /// A template deployment that is currently running cannot be deleted. + /// Deleting a template deployment removes the associated deployment + /// operations. This is an asynchronous operation that returns a status + /// of 202 until the template deployment is successfully deleted. The + /// Location response header contains the URI that is used to obtain + /// the status of the process. While the process is running, a call to + /// the URI in the Location header returns a status of 202. When the + /// process finishes, the URI in the Location header returns a status + /// of 204 on success. If the asynchronous request failed, the URI in + /// the Location header returns an error-level status code. + /// + /// + /// The name of the deployment. + /// + /// + /// 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 BeginDeleteAtSubscriptionScopeWithHttpMessagesAsync(string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deploys resources at subscription scope. + /// + /// + /// You can provide the template and parameters directly in the request + /// or link to JSON files. + /// + /// + /// The name of the deployment. + /// + /// + /// Additional parameters supplied to the 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> BeginCreateOrUpdateAtSubscriptionScopeWithHttpMessagesAsync(string deploymentName, Deployment parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Validates whether the specified template is syntactically correct + /// and will be accepted by Azure Resource Manager.. + /// + /// + /// The name of the deployment. + /// + /// + /// Parameters to validate. + /// + /// + /// 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> BeginValidateAtSubscriptionScopeWithHttpMessagesAsync(string deploymentName, Deployment parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Returns changes that will be made by the deployment if executed at + /// the scope of the subscription. + /// + /// + /// The name of the deployment. + /// + /// + /// Parameters to What If. + /// + /// + /// 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> BeginWhatIfAtSubscriptionScopeWithHttpMessagesAsync(string deploymentName, DeploymentWhatIf parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes a deployment from the deployment history. + /// + /// + /// A template deployment that is currently running cannot be deleted. + /// Deleting a template deployment removes the associated deployment + /// operations. Deleting a template deployment does not affect the + /// state of the resource group. This is an asynchronous operation that + /// returns a status of 202 until the template deployment is + /// successfully deleted. The Location response header contains the URI + /// that is used to obtain the status of the process. While the process + /// is running, a call to the URI in the Location header returns a + /// status of 202. When the process finishes, the URI in the Location + /// header returns a status of 204 on success. If the asynchronous + /// request failed, the URI in the Location header returns an + /// error-level status code. + /// + /// + /// The name of the resource group with the deployment to delete. The + /// name is case insensitive. + /// + /// + /// The name of the deployment. + /// + /// + /// 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 deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deploys resources to a resource group. + /// + /// + /// You can provide the template and parameters directly in the request + /// or link to JSON files. + /// + /// + /// The name of the resource group to deploy the resources to. The name + /// is case insensitive. The resource group must already exist. + /// + /// + /// The name of the deployment. + /// + /// + /// Additional parameters supplied to the 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> BeginCreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string deploymentName, Deployment parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Validates whether the specified template is syntactically correct + /// and will be accepted by Azure Resource Manager.. + /// + /// + /// The name of the resource group the template will be deployed to. + /// The name is case insensitive. + /// + /// + /// The name of the deployment. + /// + /// + /// Parameters to validate. + /// + /// + /// 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> BeginValidateWithHttpMessagesAsync(string resourceGroupName, string deploymentName, Deployment parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Returns changes that will be made by the deployment if executed at + /// the scope of the resource group. + /// + /// + /// The name of the resource group the template will be deployed to. + /// The name is case insensitive. + /// + /// + /// The name of the deployment. + /// + /// + /// Parameters to validate. + /// + /// + /// 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> BeginWhatIfWithHttpMessagesAsync(string resourceGroupName, string deploymentName, DeploymentWhatIf parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get all the deployments at the given scope. + /// + /// + /// 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>> ListAtScopeNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get all the deployments at the tenant scope. + /// + /// + /// 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>> ListAtTenantScopeNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get all the deployments for a management 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>> ListAtManagementGroupScopeNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get all the deployments for 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>> ListAtSubscriptionScopeNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get all the deployments for 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/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/IFeatureClient.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/IFeatureClient.cs new file mode 100644 index 0000000000000..7ae21a2724d96 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/IFeatureClient.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.ResourceManager +{ + 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; + + /// + /// + public partial interface IFeatureClient : 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 Azure subscription ID. + /// + string 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 IFeaturesOperations. + /// + IFeaturesOperations Features { get; } + + /// + /// Gets the ISubscriptionFeatureRegistrationsOperations. + /// + ISubscriptionFeatureRegistrationsOperations SubscriptionFeatureRegistrations { get; } + + /// + /// Lists all of the available Microsoft.Features REST API operations. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + Task>> ListOperationsWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + + /// + /// Lists all of the available Microsoft.Features REST API operations. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + Task>> ListOperationsNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/IFeaturesOperations.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/IFeaturesOperations.cs new file mode 100644 index 0000000000000..88a8eb8213e0e --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/IFeaturesOperations.cs @@ -0,0 +1,191 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// FeaturesOperations operations. + /// + public partial interface IFeaturesOperations + { + /// + /// Gets all the preview features that are available through AFEC for + /// the 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>> ListAllWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets all the preview features in a provider namespace that are + /// available through AFEC for the subscription. + /// + /// + /// The namespace of the resource provider for getting features. + /// + /// + /// 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 resourceProviderNamespace, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets the preview feature with the specified name. + /// + /// + /// The resource provider namespace for the feature. + /// + /// + /// The name of the feature to get. + /// + /// + /// 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 resourceProviderNamespace, string featureName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Registers the preview feature for the subscription. + /// + /// + /// The namespace of the resource provider. + /// + /// + /// The name of the feature to register. + /// + /// + /// 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> RegisterWithHttpMessagesAsync(string resourceProviderNamespace, string featureName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Unregisters the preview feature for the subscription. + /// + /// + /// The namespace of the resource provider. + /// + /// + /// The name of the feature to unregister. + /// + /// + /// 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> UnregisterWithHttpMessagesAsync(string resourceProviderNamespace, string featureName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets all the preview features that are available through AFEC for + /// the 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>> ListAllNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets all the preview features in a provider namespace that are + /// available through AFEC for the 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)); + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/IManagementLinkClient.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/IManagementLinkClient.cs new file mode 100644 index 0000000000000..c842679731d64 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/IManagementLinkClient.cs @@ -0,0 +1,88 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + + /// + /// Azure resources can be linked together to form logical relationships. + /// You can establish links between resources belonging to different + /// resource groups. However, all the linked resources must belong to the + /// same subscription. Each resource can be linked to 50 other resources. + /// If any of the linked resources are deleted or moved, the link owner + /// must clean up the remaining link. + /// + public partial interface IManagementLinkClient : 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 API version to use for the 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 IOperations. + /// + IOperations Operations { get; } + + /// + /// Gets the IResourceLinksOperations. + /// + IResourceLinksOperations ResourceLinks { get; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/IManagementLockClient.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/IManagementLockClient.cs new file mode 100644 index 0000000000000..fe4d5ca32802e --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/IManagementLockClient.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.ResourceManager +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + + /// + /// Azure resources can be locked to prevent other users in your + /// organization from deleting or modifying resources. + /// + public partial interface IManagementLockClient : 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 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 IAuthorizationOperations. + /// + IAuthorizationOperations AuthorizationOperations { get; } + + /// + /// Gets the IManagementLocksOperations. + /// + IManagementLocksOperations ManagementLocks { get; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/IManagementLocksOperations.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/IManagementLocksOperations.cs new file mode 100644 index 0000000000000..6b34ffe8a16a7 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/IManagementLocksOperations.cs @@ -0,0 +1,615 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Microsoft.Rest.Azure.OData; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// ManagementLocksOperations operations. + /// + public partial interface IManagementLocksOperations + { + /// + /// Creates or updates a management lock at the resource group level. + /// + /// + /// When you apply a lock at a parent scope, all child resources + /// inherit the same lock. To create management locks, you must have + /// access to Microsoft.Authorization/* or + /// Microsoft.Authorization/locks/* actions. Of the built-in roles, + /// only Owner and User Access Administrator are granted those actions. + /// + /// + /// The name of the resource group to lock. + /// + /// + /// The lock name. The lock name can be a maximum of 260 characters. It + /// cannot contain <, > %, &, :, \, ?, /, or any control + /// characters. + /// + /// + /// The management lock parameters. + /// + /// + /// 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> CreateOrUpdateAtResourceGroupLevelWithHttpMessagesAsync(string resourceGroupName, string lockName, ManagementLockObject parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes a management lock at the resource group level. + /// + /// + /// To delete management locks, you must have access to + /// Microsoft.Authorization/* or Microsoft.Authorization/locks/* + /// actions. Of the built-in roles, only Owner and User Access + /// Administrator are granted those actions. + /// + /// + /// The name of the resource group containing the lock. + /// + /// + /// The name of lock to delete. + /// + /// + /// 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 DeleteAtResourceGroupLevelWithHttpMessagesAsync(string resourceGroupName, string lockName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets a management lock at the resource group level. + /// + /// + /// The name of the locked resource group. + /// + /// + /// The name of the lock to get. + /// + /// + /// 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> GetAtResourceGroupLevelWithHttpMessagesAsync(string resourceGroupName, string lockName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Create or update a management lock by scope. + /// + /// + /// The scope for the lock. When providing a scope for the assignment, + /// use '/subscriptions/{subscriptionId}' for subscriptions, + /// '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}' + /// for resource groups, and + /// '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePathIfPresent}/{resourceType}/{resourceName}' + /// for resources. + /// + /// + /// The name of lock. + /// + /// + /// Create or update management lock parameters. + /// + /// + /// 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> CreateOrUpdateByScopeWithHttpMessagesAsync(string scope, string lockName, ManagementLockObject parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Delete a management lock by scope. + /// + /// + /// The scope for the lock. + /// + /// + /// The name of lock. + /// + /// + /// 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 DeleteByScopeWithHttpMessagesAsync(string scope, string lockName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get a management lock by scope. + /// + /// + /// The scope for the lock. + /// + /// + /// The name of lock. + /// + /// + /// 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> GetByScopeWithHttpMessagesAsync(string scope, string lockName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Creates or updates a management lock at the resource level or any + /// level below the resource. + /// + /// + /// When you apply a lock at a parent scope, all child resources + /// inherit the same lock. To create management locks, you must have + /// access to Microsoft.Authorization/* or + /// Microsoft.Authorization/locks/* actions. Of the built-in roles, + /// only Owner and User Access Administrator are granted those actions. + /// + /// + /// The name of the resource group containing the resource to lock. + /// + /// + /// The resource provider namespace of the resource to lock. + /// + /// + /// The parent resource identity. + /// + /// + /// The resource type of the resource to lock. + /// + /// + /// The name of the resource to lock. + /// + /// + /// The name of lock. The lock name can be a maximum of 260 characters. + /// It cannot contain <, > %, &, :, \, ?, /, or any control + /// characters. + /// + /// + /// Parameters for creating or updating a management lock. + /// + /// + /// 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> CreateOrUpdateAtResourceLevelWithHttpMessagesAsync(string resourceGroupName, string resourceProviderNamespace, string parentResourcePath, string resourceType, string resourceName, string lockName, ManagementLockObject parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes the management lock of a resource or any level below the + /// resource. + /// + /// + /// To delete management locks, you must have access to + /// Microsoft.Authorization/* or Microsoft.Authorization/locks/* + /// actions. Of the built-in roles, only Owner and User Access + /// Administrator are granted those actions. + /// + /// + /// The name of the resource group containing the resource with the + /// lock to delete. + /// + /// + /// The resource provider namespace of the resource with the lock to + /// delete. + /// + /// + /// The parent resource identity. + /// + /// + /// The resource type of the resource with the lock to delete. + /// + /// + /// The name of the resource with the lock to delete. + /// + /// + /// The name of the lock to delete. + /// + /// + /// 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 DeleteAtResourceLevelWithHttpMessagesAsync(string resourceGroupName, string resourceProviderNamespace, string parentResourcePath, string resourceType, string resourceName, string lockName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get the management lock of a resource or any level below resource. + /// + /// + /// The name of the resource group. + /// + /// + /// The namespace of the resource provider. + /// + /// + /// An extra path parameter needed in some services, like SQL + /// Databases. + /// + /// + /// The type of the resource. + /// + /// + /// The name of the resource. + /// + /// + /// The name of lock. + /// + /// + /// 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> GetAtResourceLevelWithHttpMessagesAsync(string resourceGroupName, string resourceProviderNamespace, string parentResourcePath, string resourceType, string resourceName, string lockName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Creates or updates a management lock at the subscription level. + /// + /// + /// When you apply a lock at a parent scope, all child resources + /// inherit the same lock. To create management locks, you must have + /// access to Microsoft.Authorization/* or + /// Microsoft.Authorization/locks/* actions. Of the built-in roles, + /// only Owner and User Access Administrator are granted those actions. + /// + /// + /// The name of lock. The lock name can be a maximum of 260 characters. + /// It cannot contain <, > %, &, :, \, ?, /, or any control + /// characters. + /// + /// + /// The management lock parameters. + /// + /// + /// 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> CreateOrUpdateAtSubscriptionLevelWithHttpMessagesAsync(string lockName, ManagementLockObject parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes the management lock at the subscription level. + /// + /// + /// To delete management locks, you must have access to + /// Microsoft.Authorization/* or Microsoft.Authorization/locks/* + /// actions. Of the built-in roles, only Owner and User Access + /// Administrator are granted those actions. + /// + /// + /// The name of lock to delete. + /// + /// + /// 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 DeleteAtSubscriptionLevelWithHttpMessagesAsync(string lockName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets a management lock at the subscription level. + /// + /// + /// The name of the lock to get. + /// + /// + /// 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> GetAtSubscriptionLevelWithHttpMessagesAsync(string lockName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets all the management locks for a resource group. + /// + /// + /// The name of the resource group containing the locks to get. + /// + /// + /// OData parameters to apply to the 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>> ListAtResourceGroupLevelWithHttpMessagesAsync(string resourceGroupName, ODataQuery odataQuery = default(ODataQuery), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets all the management locks for a resource or any level below + /// resource. + /// + /// + /// The name of the resource group containing the locked resource. The + /// name is case insensitive. + /// + /// + /// The namespace of the resource provider. + /// + /// + /// The parent resource identity. + /// + /// + /// The resource type of the locked resource. + /// + /// + /// The name of the locked resource. + /// + /// + /// OData parameters to apply to the 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>> ListAtResourceLevelWithHttpMessagesAsync(string resourceGroupName, string resourceProviderNamespace, string parentResourcePath, string resourceType, string resourceName, ODataQuery odataQuery = default(ODataQuery), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets all the management locks for a subscription. + /// + /// + /// OData parameters to apply to the 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>> ListAtSubscriptionLevelWithHttpMessagesAsync(ODataQuery odataQuery = default(ODataQuery), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets all the management locks for a scope. + /// + /// + /// The scope for the lock. When providing a scope for the assignment, + /// use '/subscriptions/{subscriptionId}' for subscriptions, + /// '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}' + /// for resource groups, and + /// '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePathIfPresent}/{resourceType}/{resourceName}' + /// for resources. + /// + /// + /// OData parameters to apply to the 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>> ListByScopeWithHttpMessagesAsync(string scope, ODataQuery odataQuery = default(ODataQuery), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets all the management locks for 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>> ListAtResourceGroupLevelNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets all the management locks for a resource or any level below + /// resource. + /// + /// + /// 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>> ListAtResourceLevelNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets all the management locks for 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>> ListAtSubscriptionLevelNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets all the management locks for a scope. + /// + /// + /// 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>> ListByScopeNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/IOperations.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/IOperations.cs new file mode 100644 index 0000000000000..47e539f2fbfdc --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/IOperations.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.ResourceManager +{ + 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 Microsoft.Resources 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)); + /// + /// Lists all of the available Microsoft.Resources REST API operations. + /// + /// + /// 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/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/IPolicyAssignmentsOperations.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/IPolicyAssignmentsOperations.cs new file mode 100644 index 0000000000000..388885526e11d --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/IPolicyAssignmentsOperations.cs @@ -0,0 +1,738 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Microsoft.Rest.Azure.OData; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// PolicyAssignmentsOperations operations. + /// + public partial interface IPolicyAssignmentsOperations + { + /// + /// Deletes a policy assignment. + /// + /// + /// This operation deletes a policy assignment, given its name and the + /// scope it was created in. The scope of a policy assignment is the + /// part of its ID preceding + /// '/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + /// + /// + /// The scope of the policy assignment. Valid scopes are: management + /// group (format: + /// '/providers/Microsoft.Management/managementGroups/{managementGroup}'), + /// subscription (format: '/subscriptions/{subscriptionId}'), resource + /// group (format: + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', + /// or resource (format: + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' + /// + /// + /// The name of the policy assignment to delete. + /// + /// + /// 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> DeleteWithHttpMessagesAsync(string scope, string policyAssignmentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Creates or updates a policy assignment. + /// + /// + /// This operation creates or updates a policy assignment with the + /// given scope and name. Policy assignments apply to all resources + /// contained within their scope. For example, when you assign a policy + /// at resource group scope, that policy applies to all resources in + /// the group. + /// + /// + /// The scope of the policy assignment. Valid scopes are: management + /// group (format: + /// '/providers/Microsoft.Management/managementGroups/{managementGroup}'), + /// subscription (format: '/subscriptions/{subscriptionId}'), resource + /// group (format: + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', + /// or resource (format: + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' + /// + /// + /// The name of the policy assignment. + /// + /// + /// Parameters for the policy assignment. + /// + /// + /// 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 scope, string policyAssignmentName, PolicyAssignment parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Retrieves a policy assignment. + /// + /// + /// This operation retrieves a single policy assignment, given its name + /// and the scope it was created at. + /// + /// + /// The scope of the policy assignment. Valid scopes are: management + /// group (format: + /// '/providers/Microsoft.Management/managementGroups/{managementGroup}'), + /// subscription (format: '/subscriptions/{subscriptionId}'), resource + /// group (format: + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', + /// or resource (format: + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' + /// + /// + /// The name of the policy assignment to get. + /// + /// + /// 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 scope, string policyAssignmentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Updates a policy assignment. + /// + /// + /// This operation updates a policy assignment with the given scope and + /// name. Policy assignments apply to all resources contained within + /// their scope. For example, when you assign a policy at resource + /// group scope, that policy applies to all resources in the group. + /// + /// + /// The scope of the policy assignment. Valid scopes are: management + /// group (format: + /// '/providers/Microsoft.Management/managementGroups/{managementGroup}'), + /// subscription (format: '/subscriptions/{subscriptionId}'), resource + /// group (format: + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', + /// or resource (format: + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' + /// + /// + /// The name of the policy assignment. + /// + /// + /// Parameters for policy assignment patch request. + /// + /// + /// 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 scope, string policyAssignmentName, PolicyAssignmentUpdate parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Retrieves all policy assignments that apply to a resource group. + /// + /// + /// This operation retrieves the list of all policy assignments + /// associated with the given resource group in the given subscription + /// that match the optional given $filter. Valid values for $filter + /// are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq + /// '{value}''. If $filter is not provided, the unfiltered list + /// includes all policy assignments associated with the resource group, + /// including those that apply directly or apply from containing + /// scopes, as well as any applied to resources contained within the + /// resource group. If $filter=atScope() is provided, the returned list + /// includes all policy assignments that apply to the resource group, + /// which is everything in the unfiltered list except those applied to + /// resources contained within the resource group. If + /// $filter=atExactScope() is provided, the returned list only includes + /// all policy assignments that at the resource group. If + /// $filter=policyDefinitionId eq '{value}' is provided, the returned + /// list includes all policy assignments of the policy definition whose + /// id is {value} that apply to the resource group. + /// + /// + /// The name of the resource group that contains policy assignments. + /// + /// + /// The filter to apply on the operation. Valid values for $filter are: + /// 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. + /// If $filter is not provided, no filtering is performed. If + /// $filter=atScope() is provided, the returned list only includes all + /// policy assignments that apply to the scope, which is everything in + /// the unfiltered list except those applied to sub scopes contained + /// within the given scope. If $filter=atExactScope() is provided, the + /// returned list only includes all policy assignments that at the + /// given scope. If $filter=policyDefinitionId eq '{value}' is + /// provided, the returned list includes all policy assignments of the + /// policy definition whose id is {value}. + /// + /// + /// Maximum number of records to return. When the $top filter is not + /// provided, it will return 500 records. + /// + /// + /// 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>> ListForResourceGroupWithHttpMessagesAsync(string resourceGroupName, string filter = default(string), int? top = default(int?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Retrieves all policy assignments that apply to a resource. + /// + /// + /// This operation retrieves the list of all policy assignments + /// associated with the specified resource in the given resource group + /// and subscription that match the optional given $filter. Valid + /// values for $filter are: 'atScope()', 'atExactScope()' or + /// 'policyDefinitionId eq '{value}''. If $filter is not provided, the + /// unfiltered list includes all policy assignments associated with the + /// resource, including those that apply directly or from all + /// containing scopes, as well as any applied to resources contained + /// within the resource. If $filter=atScope() is provided, the returned + /// list includes all policy assignments that apply to the resource, + /// which is everything in the unfiltered list except those applied to + /// resources contained within the resource. If $filter=atExactScope() + /// is provided, the returned list only includes all policy assignments + /// that at the resource level. If $filter=policyDefinitionId eq + /// '{value}' is provided, the returned list includes all policy + /// assignments of the policy definition whose id is {value} that apply + /// to the resource. Three parameters plus the resource name are used + /// to identify a specific resource. If the resource is not part of a + /// parent resource (the more common case), the parent resource path + /// should not be provided (or provided as ''). For example a web app + /// could be specified as ({resourceProviderNamespace} == + /// 'Microsoft.Web', {parentResourcePath} == '', {resourceType} == + /// 'sites', {resourceName} == 'MyWebApp'). If the resource is part of + /// a parent resource, then all parameters should be provided. For + /// example a virtual machine DNS name could be specified as + /// ({resourceProviderNamespace} == 'Microsoft.Compute', + /// {parentResourcePath} == 'virtualMachines/MyVirtualMachine', + /// {resourceType} == 'domainNames', {resourceName} == + /// 'MyComputerName'). A convenient alternative to providing the + /// namespace and type name separately is to provide both in the + /// {resourceType} parameter, format: ({resourceProviderNamespace} == + /// '', {parentResourcePath} == '', {resourceType} == + /// 'Microsoft.Web/sites', {resourceName} == 'MyWebApp'). + /// + /// + /// The name of the resource group containing the resource. + /// + /// + /// The namespace of the resource provider. For example, the namespace + /// of a virtual machine is Microsoft.Compute (from + /// Microsoft.Compute/virtualMachines) + /// + /// + /// The parent resource path. Use empty string if there is none. + /// + /// + /// The resource type name. For example the type name of a web app is + /// 'sites' (from Microsoft.Web/sites). + /// + /// + /// The name of the resource. + /// + /// + /// OData parameters to apply to the 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>> ListForResourceWithHttpMessagesAsync(string resourceGroupName, string resourceProviderNamespace, string parentResourcePath, string resourceType, string resourceName, ODataQuery odataQuery = default(ODataQuery), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Retrieves all policy assignments that apply to a management group. + /// + /// + /// This operation retrieves the list of all policy assignments + /// applicable to the management group that match the given $filter. + /// Valid values for $filter are: 'atScope()', 'atExactScope()' or + /// 'policyDefinitionId eq '{value}''. If $filter=atScope() is + /// provided, the returned list includes all policy assignments that + /// are assigned to the management group or the management group's + /// ancestors. If $filter=atExactScope() is provided, the returned list + /// only includes all policy assignments that at the management group. + /// If $filter=policyDefinitionId eq '{value}' is provided, the + /// returned list includes all policy assignments of the policy + /// definition whose id is {value} that apply to the management group. + /// + /// + /// The ID of the management group. + /// + /// + /// The filter to apply on the operation. Valid values for $filter are: + /// 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. + /// If $filter is not provided, no filtering is performed. If + /// $filter=atScope() is provided, the returned list only includes all + /// policy assignments that apply to the scope, which is everything in + /// the unfiltered list except those applied to sub scopes contained + /// within the given scope. If $filter=atExactScope() is provided, the + /// returned list only includes all policy assignments that at the + /// given scope. If $filter=policyDefinitionId eq '{value}' is + /// provided, the returned list includes all policy assignments of the + /// policy definition whose id is {value}. + /// + /// + /// Maximum number of records to return. When the $top filter is not + /// provided, it will return 500 records. + /// + /// + /// 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>> ListForManagementGroupWithHttpMessagesAsync(string managementGroupId, string filter = default(string), int? top = default(int?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Retrieves all policy assignments that apply to a subscription. + /// + /// + /// This operation retrieves the list of all policy assignments + /// associated with the given subscription that match the optional + /// given $filter. Valid values for $filter are: 'atScope()', + /// 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter + /// is not provided, the unfiltered list includes all policy + /// assignments associated with the subscription, including those that + /// apply directly or from management groups that contain the given + /// subscription, as well as any applied to objects contained within + /// the subscription. If $filter=atScope() is provided, the returned + /// list includes all policy assignments that apply to the + /// subscription, which is everything in the unfiltered list except + /// those applied to objects contained within the subscription. If + /// $filter=atExactScope() is provided, the returned list only includes + /// all policy assignments that at the subscription. If + /// $filter=policyDefinitionId eq '{value}' is provided, the returned + /// list includes all policy assignments of the policy definition whose + /// id is {value}. + /// + /// + /// OData parameters to apply to the 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>> ListWithHttpMessagesAsync(ODataQuery odataQuery = default(ODataQuery), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes a policy assignment. + /// + /// + /// This operation deletes the policy with the given ID. Policy + /// assignment IDs have this format: + /// '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + /// Valid formats for {scope} are: + /// '/providers/Microsoft.Management/managementGroups/{managementGroup}' + /// (management group), '/subscriptions/{subscriptionId}' + /// (subscription), + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' + /// (resource group), or + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' + /// (resource). + /// + /// + /// The ID of the policy assignment to delete. Use the format + /// '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + /// + /// + /// 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> DeleteByIdWithHttpMessagesAsync(string policyAssignmentId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Creates or updates a policy assignment. + /// + /// + /// This operation creates or updates the policy assignment with the + /// given ID. Policy assignments made on a scope apply to all resources + /// contained in that scope. For example, when you assign a policy to a + /// resource group that policy applies to all resources in the group. + /// Policy assignment IDs have this format: + /// '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + /// Valid scopes are: management group (format: + /// '/providers/Microsoft.Management/managementGroups/{managementGroup}'), + /// subscription (format: '/subscriptions/{subscriptionId}'), resource + /// group (format: + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', + /// or resource (format: + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + /// + /// + /// The ID of the policy assignment to create. Use the format + /// '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + /// + /// + /// Parameters for policy assignment. + /// + /// + /// 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> CreateByIdWithHttpMessagesAsync(string policyAssignmentId, PolicyAssignment parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Retrieves the policy assignment with the given ID. + /// + /// + /// The operation retrieves the policy assignment with the given ID. + /// Policy assignment IDs have this format: + /// '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + /// Valid scopes are: management group (format: + /// '/providers/Microsoft.Management/managementGroups/{managementGroup}'), + /// subscription (format: '/subscriptions/{subscriptionId}'), resource + /// group (format: + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', + /// or resource (format: + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + /// + /// + /// The ID of the policy assignment to get. Use the format + /// '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + /// + /// + /// 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> GetByIdWithHttpMessagesAsync(string policyAssignmentId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Updates a policy assignment. + /// + /// + /// This operation updates the policy assignment with the given ID. + /// Policy assignments made on a scope apply to all resources contained + /// in that scope. For example, when you assign a policy to a resource + /// group that policy applies to all resources in the group. Policy + /// assignment IDs have this format: + /// '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + /// Valid scopes are: management group (format: + /// '/providers/Microsoft.Management/managementGroups/{managementGroup}'), + /// subscription (format: '/subscriptions/{subscriptionId}'), resource + /// group (format: + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', + /// or resource (format: + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + /// + /// + /// The ID of the policy assignment to update. Use the format + /// '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + /// + /// + /// Parameters for policy assignment patch request. + /// + /// + /// 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> UpdateByIdWithHttpMessagesAsync(string policyAssignmentId, PolicyAssignmentUpdate parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Retrieves all policy assignments that apply to a resource group. + /// + /// + /// This operation retrieves the list of all policy assignments + /// associated with the given resource group in the given subscription + /// that match the optional given $filter. Valid values for $filter + /// are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq + /// '{value}''. If $filter is not provided, the unfiltered list + /// includes all policy assignments associated with the resource group, + /// including those that apply directly or apply from containing + /// scopes, as well as any applied to resources contained within the + /// resource group. If $filter=atScope() is provided, the returned list + /// includes all policy assignments that apply to the resource group, + /// which is everything in the unfiltered list except those applied to + /// resources contained within the resource group. If + /// $filter=atExactScope() is provided, the returned list only includes + /// all policy assignments that at the resource group. If + /// $filter=policyDefinitionId eq '{value}' is provided, the returned + /// list includes all policy assignments of the policy definition whose + /// id is {value} that apply to the 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>> ListForResourceGroupNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Retrieves all policy assignments that apply to a resource. + /// + /// + /// This operation retrieves the list of all policy assignments + /// associated with the specified resource in the given resource group + /// and subscription that match the optional given $filter. Valid + /// values for $filter are: 'atScope()', 'atExactScope()' or + /// 'policyDefinitionId eq '{value}''. If $filter is not provided, the + /// unfiltered list includes all policy assignments associated with the + /// resource, including those that apply directly or from all + /// containing scopes, as well as any applied to resources contained + /// within the resource. If $filter=atScope() is provided, the returned + /// list includes all policy assignments that apply to the resource, + /// which is everything in the unfiltered list except those applied to + /// resources contained within the resource. If $filter=atExactScope() + /// is provided, the returned list only includes all policy assignments + /// that at the resource level. If $filter=policyDefinitionId eq + /// '{value}' is provided, the returned list includes all policy + /// assignments of the policy definition whose id is {value} that apply + /// to the resource. Three parameters plus the resource name are used + /// to identify a specific resource. If the resource is not part of a + /// parent resource (the more common case), the parent resource path + /// should not be provided (or provided as ''). For example a web app + /// could be specified as ({resourceProviderNamespace} == + /// 'Microsoft.Web', {parentResourcePath} == '', {resourceType} == + /// 'sites', {resourceName} == 'MyWebApp'). If the resource is part of + /// a parent resource, then all parameters should be provided. For + /// example a virtual machine DNS name could be specified as + /// ({resourceProviderNamespace} == 'Microsoft.Compute', + /// {parentResourcePath} == 'virtualMachines/MyVirtualMachine', + /// {resourceType} == 'domainNames', {resourceName} == + /// 'MyComputerName'). A convenient alternative to providing the + /// namespace and type name separately is to provide both in the + /// {resourceType} parameter, format: ({resourceProviderNamespace} == + /// '', {parentResourcePath} == '', {resourceType} == + /// 'Microsoft.Web/sites', {resourceName} == 'MyWebApp'). + /// + /// + /// 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>> ListForResourceNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Retrieves all policy assignments that apply to a management group. + /// + /// + /// This operation retrieves the list of all policy assignments + /// applicable to the management group that match the given $filter. + /// Valid values for $filter are: 'atScope()', 'atExactScope()' or + /// 'policyDefinitionId eq '{value}''. If $filter=atScope() is + /// provided, the returned list includes all policy assignments that + /// are assigned to the management group or the management group's + /// ancestors. If $filter=atExactScope() is provided, the returned list + /// only includes all policy assignments that at the management group. + /// If $filter=policyDefinitionId eq '{value}' is provided, the + /// returned list includes all policy assignments of the policy + /// definition whose id is {value} that apply to the management 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>> ListForManagementGroupNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Retrieves all policy assignments that apply to a subscription. + /// + /// + /// This operation retrieves the list of all policy assignments + /// associated with the given subscription that match the optional + /// given $filter. Valid values for $filter are: 'atScope()', + /// 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter + /// is not provided, the unfiltered list includes all policy + /// assignments associated with the subscription, including those that + /// apply directly or from management groups that contain the given + /// subscription, as well as any applied to objects contained within + /// the subscription. If $filter=atScope() is provided, the returned + /// list includes all policy assignments that apply to the + /// subscription, which is everything in the unfiltered list except + /// those applied to objects contained within the subscription. If + /// $filter=atExactScope() is provided, the returned list only includes + /// all policy assignments that at the subscription. If + /// $filter=policyDefinitionId eq '{value}' is provided, the returned + /// list includes all policy assignments of the policy definition whose + /// id is {value}. + /// + /// + /// 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/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/IPolicyClient.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/IPolicyClient.cs new file mode 100644 index 0000000000000..32307497cef6a --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/IPolicyClient.cs @@ -0,0 +1,92 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + + /// + /// + public partial interface IPolicyClient : 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 IDataPolicyManifestsOperations. + /// + IDataPolicyManifestsOperations DataPolicyManifests { get; } + + /// + /// Gets the IPolicyAssignmentsOperations. + /// + IPolicyAssignmentsOperations PolicyAssignments { get; } + + /// + /// Gets the IPolicyDefinitionsOperations. + /// + IPolicyDefinitionsOperations PolicyDefinitions { get; } + + /// + /// Gets the IPolicySetDefinitionsOperations. + /// + IPolicySetDefinitionsOperations PolicySetDefinitions { get; } + + /// + /// Gets the IPolicyExemptionsOperations. + /// + IPolicyExemptionsOperations PolicyExemptions { get; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/IPolicyDefinitionsOperations.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/IPolicyDefinitionsOperations.cs new file mode 100644 index 0000000000000..6f1b1d5dbbc5f --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/IPolicyDefinitionsOperations.cs @@ -0,0 +1,483 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// PolicyDefinitionsOperations operations. + /// + public partial interface IPolicyDefinitionsOperations + { + /// + /// Creates or updates a policy definition in a subscription. + /// + /// + /// This operation creates or updates a policy definition in the given + /// subscription with the given name. + /// + /// + /// The name of the policy definition to create. + /// + /// + /// The policy definition properties. + /// + /// + /// 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 policyDefinitionName, PolicyDefinition parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes a policy definition in a subscription. + /// + /// + /// This operation deletes the policy definition in the given + /// subscription with the given name. + /// + /// + /// The name of the policy definition to delete. + /// + /// + /// 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 policyDefinitionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Retrieves a policy definition in a subscription. + /// + /// + /// This operation retrieves the policy definition in the given + /// subscription with the given name. + /// + /// + /// The name of the policy definition to get. + /// + /// + /// 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 policyDefinitionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Retrieves a built-in policy definition. + /// + /// + /// This operation retrieves the built-in policy definition with the + /// given name. + /// + /// + /// The name of the built-in policy definition to get. + /// + /// + /// 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> GetBuiltInWithHttpMessagesAsync(string policyDefinitionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Creates or updates a policy definition in a management group. + /// + /// + /// This operation creates or updates a policy definition in the given + /// management group with the given name. + /// + /// + /// The name of the policy definition to create. + /// + /// + /// The policy definition properties. + /// + /// + /// The ID of the management group. + /// + /// + /// 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> CreateOrUpdateAtManagementGroupWithHttpMessagesAsync(string policyDefinitionName, PolicyDefinition parameters, string managementGroupId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes a policy definition in a management group. + /// + /// + /// This operation deletes the policy definition in the given + /// management group with the given name. + /// + /// + /// The name of the policy definition to delete. + /// + /// + /// The ID of the management group. + /// + /// + /// 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 DeleteAtManagementGroupWithHttpMessagesAsync(string policyDefinitionName, string managementGroupId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Retrieve a policy definition in a management group. + /// + /// + /// This operation retrieves the policy definition in the given + /// management group with the given name. + /// + /// + /// The name of the policy definition to get. + /// + /// + /// The ID of the management group. + /// + /// + /// 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> GetAtManagementGroupWithHttpMessagesAsync(string policyDefinitionName, string managementGroupId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Retrieves policy definitions in a subscription + /// + /// + /// This operation retrieves a list of all the policy definitions in a + /// given subscription that match the optional given $filter. Valid + /// values for $filter are: 'atExactScope()', 'policyType -eq {value}' + /// or 'category eq '{value}''. If $filter is not provided, the + /// unfiltered list includes all policy definitions associated with the + /// subscription, including those that apply directly or from + /// management groups that contain the given subscription. If + /// $filter=atExactScope() is provided, the returned list only includes + /// all policy definitions that at the given subscription. If + /// $filter='policyType -eq {value}' is provided, the returned list + /// only includes all policy definitions whose type match the {value}. + /// Possible policyType values are NotSpecified, BuiltIn, Custom, and + /// Static. If $filter='category -eq {value}' is provided, the returned + /// list only includes all policy definitions whose category match the + /// {value}. + /// + /// + /// The filter to apply on the operation. Valid values for $filter are: + /// 'atExactScope()', 'policyType -eq {value}' or 'category eq + /// '{value}''. If $filter is not provided, no filtering is performed. + /// If $filter=atExactScope() is provided, the returned list only + /// includes all policy definitions that at the given scope. If + /// $filter='policyType -eq {value}' is provided, the returned list + /// only includes all policy definitions whose type match the {value}. + /// Possible policyType values are NotSpecified, BuiltIn, Custom, and + /// Static. If $filter='category -eq {value}' is provided, the returned + /// list only includes all policy definitions whose category match the + /// {value}. + /// + /// + /// Maximum number of records to return. When the $top filter is not + /// provided, it will return 500 records. + /// + /// + /// 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 filter = default(string), int? top = default(int?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Retrieve built-in policy definitions + /// + /// + /// This operation retrieves a list of all the built-in policy + /// definitions that match the optional given $filter. If + /// $filter='policyType -eq {value}' is provided, the returned list + /// only includes all built-in policy definitions whose type match the + /// {value}. Possible policyType values are NotSpecified, BuiltIn, + /// Custom, and Static. If $filter='category -eq {value}' is provided, + /// the returned list only includes all built-in policy definitions + /// whose category match the {value}. + /// + /// + /// The filter to apply on the operation. Valid values for $filter are: + /// 'atExactScope()', 'policyType -eq {value}' or 'category eq + /// '{value}''. If $filter is not provided, no filtering is performed. + /// If $filter=atExactScope() is provided, the returned list only + /// includes all policy definitions that at the given scope. If + /// $filter='policyType -eq {value}' is provided, the returned list + /// only includes all policy definitions whose type match the {value}. + /// Possible policyType values are NotSpecified, BuiltIn, Custom, and + /// Static. If $filter='category -eq {value}' is provided, the returned + /// list only includes all policy definitions whose category match the + /// {value}. + /// + /// + /// Maximum number of records to return. When the $top filter is not + /// provided, it will return 500 records. + /// + /// + /// 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>> ListBuiltInWithHttpMessagesAsync(string filter = default(string), int? top = default(int?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Retrieve policy definitions in a management group + /// + /// + /// This operation retrieves a list of all the policy definitions in a + /// given management group that match the optional given $filter. Valid + /// values for $filter are: 'atExactScope()', 'policyType -eq {value}' + /// or 'category eq '{value}''. If $filter is not provided, the + /// unfiltered list includes all policy definitions associated with the + /// management group, including those that apply directly or from + /// management groups that contain the given management group. If + /// $filter=atExactScope() is provided, the returned list only includes + /// all policy definitions that at the given management group. If + /// $filter='policyType -eq {value}' is provided, the returned list + /// only includes all policy definitions whose type match the {value}. + /// Possible policyType values are NotSpecified, BuiltIn, Custom, and + /// Static. If $filter='category -eq {value}' is provided, the returned + /// list only includes all policy definitions whose category match the + /// {value}. + /// + /// + /// The ID of the management group. + /// + /// + /// The filter to apply on the operation. Valid values for $filter are: + /// 'atExactScope()', 'policyType -eq {value}' or 'category eq + /// '{value}''. If $filter is not provided, no filtering is performed. + /// If $filter=atExactScope() is provided, the returned list only + /// includes all policy definitions that at the given scope. If + /// $filter='policyType -eq {value}' is provided, the returned list + /// only includes all policy definitions whose type match the {value}. + /// Possible policyType values are NotSpecified, BuiltIn, Custom, and + /// Static. If $filter='category -eq {value}' is provided, the returned + /// list only includes all policy definitions whose category match the + /// {value}. + /// + /// + /// Maximum number of records to return. When the $top filter is not + /// provided, it will return 500 records. + /// + /// + /// 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>> ListByManagementGroupWithHttpMessagesAsync(string managementGroupId, string filter = default(string), int? top = default(int?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Retrieves policy definitions in a subscription + /// + /// + /// This operation retrieves a list of all the policy definitions in a + /// given subscription that match the optional given $filter. Valid + /// values for $filter are: 'atExactScope()', 'policyType -eq {value}' + /// or 'category eq '{value}''. If $filter is not provided, the + /// unfiltered list includes all policy definitions associated with the + /// subscription, including those that apply directly or from + /// management groups that contain the given subscription. If + /// $filter=atExactScope() is provided, the returned list only includes + /// all policy definitions that at the given subscription. If + /// $filter='policyType -eq {value}' is provided, the returned list + /// only includes all policy definitions whose type match the {value}. + /// Possible policyType values are NotSpecified, BuiltIn, Custom, and + /// Static. If $filter='category -eq {value}' is provided, the returned + /// list only includes all policy definitions whose category match the + /// {value}. + /// + /// + /// 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)); + /// + /// Retrieve built-in policy definitions + /// + /// + /// This operation retrieves a list of all the built-in policy + /// definitions that match the optional given $filter. If + /// $filter='policyType -eq {value}' is provided, the returned list + /// only includes all built-in policy definitions whose type match the + /// {value}. Possible policyType values are NotSpecified, BuiltIn, + /// Custom, and Static. If $filter='category -eq {value}' is provided, + /// the returned list only includes all built-in policy definitions + /// whose category match the {value}. + /// + /// + /// 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>> ListBuiltInNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Retrieve policy definitions in a management group + /// + /// + /// This operation retrieves a list of all the policy definitions in a + /// given management group that match the optional given $filter. Valid + /// values for $filter are: 'atExactScope()', 'policyType -eq {value}' + /// or 'category eq '{value}''. If $filter is not provided, the + /// unfiltered list includes all policy definitions associated with the + /// management group, including those that apply directly or from + /// management groups that contain the given management group. If + /// $filter=atExactScope() is provided, the returned list only includes + /// all policy definitions that at the given management group. If + /// $filter='policyType -eq {value}' is provided, the returned list + /// only includes all policy definitions whose type match the {value}. + /// Possible policyType values are NotSpecified, BuiltIn, Custom, and + /// Static. If $filter='category -eq {value}' is provided, the returned + /// list only includes all policy definitions whose category match the + /// {value}. + /// + /// + /// 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>> ListByManagementGroupNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/IPolicyExemptionsOperations.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/IPolicyExemptionsOperations.cs new file mode 100644 index 0000000000000..60e1fbf115760 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/IPolicyExemptionsOperations.cs @@ -0,0 +1,523 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// PolicyExemptionsOperations operations. + /// + public partial interface IPolicyExemptionsOperations + { + /// + /// Deletes a policy exemption. + /// + /// + /// This operation deletes a policy exemption, given its name and the + /// scope it was created in. The scope of a policy exemption is the + /// part of its ID preceding + /// '/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}'. + /// + /// + /// The scope of the policy exemption. Valid scopes are: management + /// group (format: + /// '/providers/Microsoft.Management/managementGroups/{managementGroup}'), + /// subscription (format: '/subscriptions/{subscriptionId}'), resource + /// group (format: + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', + /// or resource (format: + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' + /// + /// + /// The name of the policy exemption to delete. + /// + /// + /// 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 scope, string policyExemptionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Creates or updates a policy exemption. + /// + /// + /// This operation creates or updates a policy exemption with the given + /// scope and name. Policy exemptions apply to all resources contained + /// within their scope. For example, when you create a policy exemption + /// at resource group scope for a policy assignment at the same or + /// above level, the exemption exempts to all applicable resources in + /// the resource group. + /// + /// + /// The scope of the policy exemption. Valid scopes are: management + /// group (format: + /// '/providers/Microsoft.Management/managementGroups/{managementGroup}'), + /// subscription (format: '/subscriptions/{subscriptionId}'), resource + /// group (format: + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', + /// or resource (format: + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' + /// + /// + /// The name of the policy exemption to delete. + /// + /// + /// Parameters for the policy exemption. + /// + /// + /// 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 scope, string policyExemptionName, PolicyExemption parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Retrieves a policy exemption. + /// + /// + /// This operation retrieves a single policy exemption, given its name + /// and the scope it was created at. + /// + /// + /// The scope of the policy exemption. Valid scopes are: management + /// group (format: + /// '/providers/Microsoft.Management/managementGroups/{managementGroup}'), + /// subscription (format: '/subscriptions/{subscriptionId}'), resource + /// group (format: + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', + /// or resource (format: + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' + /// + /// + /// The name of the policy exemption to delete. + /// + /// + /// 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 scope, string policyExemptionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Retrieves all policy exemptions that apply to a subscription. + /// + /// + /// This operation retrieves the list of all policy exemptions + /// associated with the given subscription that match the optional + /// given $filter. Valid values for $filter are: 'atScope()', + /// 'atExactScope()', 'excludeExpired()' or 'policyAssignmentId eq + /// '{value}''. If $filter is not provided, the unfiltered list + /// includes all policy exemptions associated with the subscription, + /// including those that apply directly or from management groups that + /// contain the given subscription, as well as any applied to objects + /// contained within the subscription. + /// + /// + /// The filter to apply on the operation. Valid values for $filter are: + /// 'atScope()', 'atExactScope()', 'excludeExpired()' or + /// 'policyAssignmentId eq '{value}''. If $filter is not provided, no + /// filtering is performed. If $filter is not provided, the unfiltered + /// list includes all policy exemptions associated with the scope, + /// including those that apply directly or apply from containing + /// scopes. If $filter=atScope() is provided, the returned list only + /// includes all policy exemptions that apply to the scope, which is + /// everything in the unfiltered list except those applied to sub + /// scopes contained within the given scope. If $filter=atExactScope() + /// is provided, the returned list only includes all policy exemptions + /// that at the given scope. If $filter=excludeExpired() is provided, + /// the returned list only includes all policy exemptions that either + /// haven't expired or didn't set expiration date. If + /// $filter=policyAssignmentId eq '{value}' is provided. the returned + /// list only includes all policy exemptions that are associated with + /// the give policyAssignmentId. + /// + /// + /// 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 filter = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Retrieves all policy exemptions that apply to a resource group. + /// + /// + /// This operation retrieves the list of all policy exemptions + /// associated with the given resource group in the given subscription + /// that match the optional given $filter. Valid values for $filter + /// are: 'atScope()', 'atExactScope()', 'excludeExpired()' or + /// 'policyAssignmentId eq '{value}''. If $filter is not provided, the + /// unfiltered list includes all policy exemptions associated with the + /// resource group, including those that apply directly or apply from + /// containing scopes, as well as any applied to resources contained + /// within the resource group. + /// + /// + /// The name of the resource group containing the resource. + /// + /// + /// The filter to apply on the operation. Valid values for $filter are: + /// 'atScope()', 'atExactScope()', 'excludeExpired()' or + /// 'policyAssignmentId eq '{value}''. If $filter is not provided, no + /// filtering is performed. If $filter is not provided, the unfiltered + /// list includes all policy exemptions associated with the scope, + /// including those that apply directly or apply from containing + /// scopes. If $filter=atScope() is provided, the returned list only + /// includes all policy exemptions that apply to the scope, which is + /// everything in the unfiltered list except those applied to sub + /// scopes contained within the given scope. If $filter=atExactScope() + /// is provided, the returned list only includes all policy exemptions + /// that at the given scope. If $filter=excludeExpired() is provided, + /// the returned list only includes all policy exemptions that either + /// haven't expired or didn't set expiration date. If + /// $filter=policyAssignmentId eq '{value}' is provided. the returned + /// list only includes all policy exemptions that are associated with + /// the give policyAssignmentId. + /// + /// + /// 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>> ListForResourceGroupWithHttpMessagesAsync(string resourceGroupName, string filter = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Retrieves all policy exemptions that apply to a resource. + /// + /// + /// This operation retrieves the list of all policy exemptions + /// associated with the specified resource in the given resource group + /// and subscription that match the optional given $filter. Valid + /// values for $filter are: 'atScope()', 'atExactScope()', + /// 'excludeExpired()' or 'policyAssignmentId eq '{value}''. If $filter + /// is not provided, the unfiltered list includes all policy exemptions + /// associated with the resource, including those that apply directly + /// or from all containing scopes, as well as any applied to resources + /// contained within the resource. Three parameters plus the resource + /// name are used to identify a specific resource. If the resource is + /// not part of a parent resource (the more common case), the parent + /// resource path should not be provided (or provided as ''). For + /// example a web app could be specified as + /// ({resourceProviderNamespace} == 'Microsoft.Web', + /// {parentResourcePath} == '', {resourceType} == 'sites', + /// {resourceName} == 'MyWebApp'). If the resource is part of a parent + /// resource, then all parameters should be provided. For example a + /// virtual machine DNS name could be specified as + /// ({resourceProviderNamespace} == 'Microsoft.Compute', + /// {parentResourcePath} == 'virtualMachines/MyVirtualMachine', + /// {resourceType} == 'domainNames', {resourceName} == + /// 'MyComputerName'). A convenient alternative to providing the + /// namespace and type name separately is to provide both in the + /// {resourceType} parameter, format: ({resourceProviderNamespace} == + /// '', {parentResourcePath} == '', {resourceType} == + /// 'Microsoft.Web/sites', {resourceName} == 'MyWebApp'). + /// + /// + /// The name of the resource group containing the resource. + /// + /// + /// The namespace of the resource provider. For example, the namespace + /// of a virtual machine is Microsoft.Compute (from + /// Microsoft.Compute/virtualMachines) + /// + /// + /// The parent resource path. Use empty string if there is none. + /// + /// + /// The resource type name. For example the type name of a web app is + /// 'sites' (from Microsoft.Web/sites). + /// + /// + /// The name of the resource. + /// + /// + /// The filter to apply on the operation. Valid values for $filter are: + /// 'atScope()', 'atExactScope()', 'excludeExpired()' or + /// 'policyAssignmentId eq '{value}''. If $filter is not provided, no + /// filtering is performed. If $filter is not provided, the unfiltered + /// list includes all policy exemptions associated with the scope, + /// including those that apply directly or apply from containing + /// scopes. If $filter=atScope() is provided, the returned list only + /// includes all policy exemptions that apply to the scope, which is + /// everything in the unfiltered list except those applied to sub + /// scopes contained within the given scope. If $filter=atExactScope() + /// is provided, the returned list only includes all policy exemptions + /// that at the given scope. If $filter=excludeExpired() is provided, + /// the returned list only includes all policy exemptions that either + /// haven't expired or didn't set expiration date. If + /// $filter=policyAssignmentId eq '{value}' is provided. the returned + /// list only includes all policy exemptions that are associated with + /// the give policyAssignmentId. + /// + /// + /// 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>> ListForResourceWithHttpMessagesAsync(string resourceGroupName, string resourceProviderNamespace, string parentResourcePath, string resourceType, string resourceName, string filter = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Retrieves all policy exemptions that apply to a management group. + /// + /// + /// This operation retrieves the list of all policy exemptions + /// applicable to the management group that match the given $filter. + /// Valid values for $filter are: 'atScope()', 'atExactScope()', + /// 'excludeExpired()' or 'policyAssignmentId eq '{value}''. If + /// $filter=atScope() is provided, the returned list includes all + /// policy exemptions that are assigned to the management group or the + /// management group's ancestors. + /// + /// + /// The ID of the management group. + /// + /// + /// The filter to apply on the operation. Valid values for $filter are: + /// 'atScope()', 'atExactScope()', 'excludeExpired()' or + /// 'policyAssignmentId eq '{value}''. If $filter is not provided, no + /// filtering is performed. If $filter is not provided, the unfiltered + /// list includes all policy exemptions associated with the scope, + /// including those that apply directly or apply from containing + /// scopes. If $filter=atScope() is provided, the returned list only + /// includes all policy exemptions that apply to the scope, which is + /// everything in the unfiltered list except those applied to sub + /// scopes contained within the given scope. If $filter=atExactScope() + /// is provided, the returned list only includes all policy exemptions + /// that at the given scope. If $filter=excludeExpired() is provided, + /// the returned list only includes all policy exemptions that either + /// haven't expired or didn't set expiration date. If + /// $filter=policyAssignmentId eq '{value}' is provided. the returned + /// list only includes all policy exemptions that are associated with + /// the give policyAssignmentId. + /// + /// + /// 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>> ListForManagementGroupWithHttpMessagesAsync(string managementGroupId, string filter = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Retrieves all policy exemptions that apply to a subscription. + /// + /// + /// This operation retrieves the list of all policy exemptions + /// associated with the given subscription that match the optional + /// given $filter. Valid values for $filter are: 'atScope()', + /// 'atExactScope()', 'excludeExpired()' or 'policyAssignmentId eq + /// '{value}''. If $filter is not provided, the unfiltered list + /// includes all policy exemptions associated with the subscription, + /// including those that apply directly or from management groups that + /// contain the given subscription, as well as any applied to objects + /// contained within the 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)); + /// + /// Retrieves all policy exemptions that apply to a resource group. + /// + /// + /// This operation retrieves the list of all policy exemptions + /// associated with the given resource group in the given subscription + /// that match the optional given $filter. Valid values for $filter + /// are: 'atScope()', 'atExactScope()', 'excludeExpired()' or + /// 'policyAssignmentId eq '{value}''. If $filter is not provided, the + /// unfiltered list includes all policy exemptions associated with the + /// resource group, including those that apply directly or apply from + /// containing scopes, as well as any applied to resources contained + /// within the 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>> ListForResourceGroupNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Retrieves all policy exemptions that apply to a resource. + /// + /// + /// This operation retrieves the list of all policy exemptions + /// associated with the specified resource in the given resource group + /// and subscription that match the optional given $filter. Valid + /// values for $filter are: 'atScope()', 'atExactScope()', + /// 'excludeExpired()' or 'policyAssignmentId eq '{value}''. If $filter + /// is not provided, the unfiltered list includes all policy exemptions + /// associated with the resource, including those that apply directly + /// or from all containing scopes, as well as any applied to resources + /// contained within the resource. Three parameters plus the resource + /// name are used to identify a specific resource. If the resource is + /// not part of a parent resource (the more common case), the parent + /// resource path should not be provided (or provided as ''). For + /// example a web app could be specified as + /// ({resourceProviderNamespace} == 'Microsoft.Web', + /// {parentResourcePath} == '', {resourceType} == 'sites', + /// {resourceName} == 'MyWebApp'). If the resource is part of a parent + /// resource, then all parameters should be provided. For example a + /// virtual machine DNS name could be specified as + /// ({resourceProviderNamespace} == 'Microsoft.Compute', + /// {parentResourcePath} == 'virtualMachines/MyVirtualMachine', + /// {resourceType} == 'domainNames', {resourceName} == + /// 'MyComputerName'). A convenient alternative to providing the + /// namespace and type name separately is to provide both in the + /// {resourceType} parameter, format: ({resourceProviderNamespace} == + /// '', {parentResourcePath} == '', {resourceType} == + /// 'Microsoft.Web/sites', {resourceName} == 'MyWebApp'). + /// + /// + /// 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>> ListForResourceNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Retrieves all policy exemptions that apply to a management group. + /// + /// + /// This operation retrieves the list of all policy exemptions + /// applicable to the management group that match the given $filter. + /// Valid values for $filter are: 'atScope()', 'atExactScope()', + /// 'excludeExpired()' or 'policyAssignmentId eq '{value}''. If + /// $filter=atScope() is provided, the returned list includes all + /// policy exemptions that are assigned to the management group or the + /// management group's ancestors. + /// + /// + /// 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>> ListForManagementGroupNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/IPolicySetDefinitionsOperations.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/IPolicySetDefinitionsOperations.cs new file mode 100644 index 0000000000000..23854dfadcc61 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/IPolicySetDefinitionsOperations.cs @@ -0,0 +1,477 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// PolicySetDefinitionsOperations operations. + /// + public partial interface IPolicySetDefinitionsOperations + { + /// + /// Creates or updates a policy set definition. + /// + /// + /// This operation creates or updates a policy set definition in the + /// given subscription with the given name. + /// + /// + /// The name of the policy set definition to create. + /// + /// + /// The policy set definition properties. + /// + /// + /// 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 policySetDefinitionName, PolicySetDefinition parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes a policy set definition. + /// + /// + /// This operation deletes the policy set definition in the given + /// subscription with the given name. + /// + /// + /// The name of the policy set definition to delete. + /// + /// + /// 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 policySetDefinitionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Retrieves a policy set definition. + /// + /// + /// This operation retrieves the policy set definition in the given + /// subscription with the given name. + /// + /// + /// The name of the policy set definition to get. + /// + /// + /// 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 policySetDefinitionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Retrieves a built in policy set definition. + /// + /// + /// This operation retrieves the built-in policy set definition with + /// the given name. + /// + /// + /// The name of the policy set definition to get. + /// + /// + /// 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> GetBuiltInWithHttpMessagesAsync(string policySetDefinitionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Retrieves the policy set definitions for a subscription. + /// + /// + /// This operation retrieves a list of all the policy set definitions + /// in a given subscription that match the optional given $filter. + /// Valid values for $filter are: 'atExactScope()', 'policyType -eq + /// {value}' or 'category eq '{value}''. If $filter is not provided, + /// the unfiltered list includes all policy set definitions associated + /// with the subscription, including those that apply directly or from + /// management groups that contain the given subscription. If + /// $filter=atExactScope() is provided, the returned list only includes + /// all policy set definitions that at the given subscription. If + /// $filter='policyType -eq {value}' is provided, the returned list + /// only includes all policy set definitions whose type match the + /// {value}. Possible policyType values are NotSpecified, BuiltIn and + /// Custom. If $filter='category -eq {value}' is provided, the returned + /// list only includes all policy set definitions whose category match + /// the {value}. + /// + /// + /// The filter to apply on the operation. Valid values for $filter are: + /// 'atExactScope()', 'policyType -eq {value}' or 'category eq + /// '{value}''. If $filter is not provided, no filtering is performed. + /// If $filter=atExactScope() is provided, the returned list only + /// includes all policy set definitions that at the given scope. If + /// $filter='policyType -eq {value}' is provided, the returned list + /// only includes all policy set definitions whose type match the + /// {value}. Possible policyType values are NotSpecified, BuiltIn, + /// Custom, and Static. If $filter='category -eq {value}' is provided, + /// the returned list only includes all policy set definitions whose + /// category match the {value}. + /// + /// + /// Maximum number of records to return. When the $top filter is not + /// provided, it will return 500 records. + /// + /// + /// 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 filter = default(string), int? top = default(int?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Retrieves built-in policy set definitions. + /// + /// + /// This operation retrieves a list of all the built-in policy set + /// definitions that match the optional given $filter. If + /// $filter='category -eq {value}' is provided, the returned list only + /// includes all built-in policy set definitions whose category match + /// the {value}. + /// + /// + /// The filter to apply on the operation. Valid values for $filter are: + /// 'atExactScope()', 'policyType -eq {value}' or 'category eq + /// '{value}''. If $filter is not provided, no filtering is performed. + /// If $filter=atExactScope() is provided, the returned list only + /// includes all policy set definitions that at the given scope. If + /// $filter='policyType -eq {value}' is provided, the returned list + /// only includes all policy set definitions whose type match the + /// {value}. Possible policyType values are NotSpecified, BuiltIn, + /// Custom, and Static. If $filter='category -eq {value}' is provided, + /// the returned list only includes all policy set definitions whose + /// category match the {value}. + /// + /// + /// Maximum number of records to return. When the $top filter is not + /// provided, it will return 500 records. + /// + /// + /// 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>> ListBuiltInWithHttpMessagesAsync(string filter = default(string), int? top = default(int?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Creates or updates a policy set definition. + /// + /// + /// This operation creates or updates a policy set definition in the + /// given management group with the given name. + /// + /// + /// The name of the policy set definition to create. + /// + /// + /// The policy set definition properties. + /// + /// + /// The ID of the management group. + /// + /// + /// 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> CreateOrUpdateAtManagementGroupWithHttpMessagesAsync(string policySetDefinitionName, PolicySetDefinition parameters, string managementGroupId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes a policy set definition. + /// + /// + /// This operation deletes the policy set definition in the given + /// management group with the given name. + /// + /// + /// The name of the policy set definition to delete. + /// + /// + /// The ID of the management group. + /// + /// + /// 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 DeleteAtManagementGroupWithHttpMessagesAsync(string policySetDefinitionName, string managementGroupId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Retrieves a policy set definition. + /// + /// + /// This operation retrieves the policy set definition in the given + /// management group with the given name. + /// + /// + /// The name of the policy set definition to get. + /// + /// + /// The ID of the management group. + /// + /// + /// 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> GetAtManagementGroupWithHttpMessagesAsync(string policySetDefinitionName, string managementGroupId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Retrieves all policy set definitions in management group. + /// + /// + /// This operation retrieves a list of all the policy set definitions + /// in a given management group that match the optional given $filter. + /// Valid values for $filter are: 'atExactScope()', 'policyType -eq + /// {value}' or 'category eq '{value}''. If $filter is not provided, + /// the unfiltered list includes all policy set definitions associated + /// with the management group, including those that apply directly or + /// from management groups that contain the given management group. If + /// $filter=atExactScope() is provided, the returned list only includes + /// all policy set definitions that at the given management group. If + /// $filter='policyType -eq {value}' is provided, the returned list + /// only includes all policy set definitions whose type match the + /// {value}. Possible policyType values are NotSpecified, BuiltIn and + /// Custom. If $filter='category -eq {value}' is provided, the returned + /// list only includes all policy set definitions whose category match + /// the {value}. + /// + /// + /// The ID of the management group. + /// + /// + /// The filter to apply on the operation. Valid values for $filter are: + /// 'atExactScope()', 'policyType -eq {value}' or 'category eq + /// '{value}''. If $filter is not provided, no filtering is performed. + /// If $filter=atExactScope() is provided, the returned list only + /// includes all policy set definitions that at the given scope. If + /// $filter='policyType -eq {value}' is provided, the returned list + /// only includes all policy set definitions whose type match the + /// {value}. Possible policyType values are NotSpecified, BuiltIn, + /// Custom, and Static. If $filter='category -eq {value}' is provided, + /// the returned list only includes all policy set definitions whose + /// category match the {value}. + /// + /// + /// Maximum number of records to return. When the $top filter is not + /// provided, it will return 500 records. + /// + /// + /// 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>> ListByManagementGroupWithHttpMessagesAsync(string managementGroupId, string filter = default(string), int? top = default(int?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Retrieves the policy set definitions for a subscription. + /// + /// + /// This operation retrieves a list of all the policy set definitions + /// in a given subscription that match the optional given $filter. + /// Valid values for $filter are: 'atExactScope()', 'policyType -eq + /// {value}' or 'category eq '{value}''. If $filter is not provided, + /// the unfiltered list includes all policy set definitions associated + /// with the subscription, including those that apply directly or from + /// management groups that contain the given subscription. If + /// $filter=atExactScope() is provided, the returned list only includes + /// all policy set definitions that at the given subscription. If + /// $filter='policyType -eq {value}' is provided, the returned list + /// only includes all policy set definitions whose type match the + /// {value}. Possible policyType values are NotSpecified, BuiltIn and + /// Custom. If $filter='category -eq {value}' is provided, the returned + /// list only includes all policy set definitions whose category match + /// the {value}. + /// + /// + /// 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)); + /// + /// Retrieves built-in policy set definitions. + /// + /// + /// This operation retrieves a list of all the built-in policy set + /// definitions that match the optional given $filter. If + /// $filter='category -eq {value}' is provided, the returned list only + /// includes all built-in policy set definitions whose category match + /// the {value}. + /// + /// + /// 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>> ListBuiltInNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Retrieves all policy set definitions in management group. + /// + /// + /// This operation retrieves a list of all the policy set definitions + /// in a given management group that match the optional given $filter. + /// Valid values for $filter are: 'atExactScope()', 'policyType -eq + /// {value}' or 'category eq '{value}''. If $filter is not provided, + /// the unfiltered list includes all policy set definitions associated + /// with the management group, including those that apply directly or + /// from management groups that contain the given management group. If + /// $filter=atExactScope() is provided, the returned list only includes + /// all policy set definitions that at the given management group. If + /// $filter='policyType -eq {value}' is provided, the returned list + /// only includes all policy set definitions whose type match the + /// {value}. Possible policyType values are NotSpecified, BuiltIn and + /// Custom. If $filter='category -eq {value}' is provided, the returned + /// list only includes all policy set definitions whose category match + /// the {value}. + /// + /// + /// 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>> ListByManagementGroupNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/IProviderResourceTypesOperations.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/IProviderResourceTypesOperations.cs new file mode 100644 index 0000000000000..dc9596a63a4b0 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/IProviderResourceTypesOperations.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.ResourceManager +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// ProviderResourceTypesOperations operations. + /// + public partial interface IProviderResourceTypesOperations + { + /// + /// List the resource types for a specified resource provider. + /// + /// + /// The namespace of the resource provider. + /// + /// + /// The $expand query parameter. For example, to include property + /// aliases in response, use $expand=resourceTypes/aliases. + /// + /// + /// 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 resourceProviderNamespace, string expand = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/IProvidersOperations.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/IProvidersOperations.cs new file mode 100644 index 0000000000000..aba0f9df18e52 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/IProvidersOperations.cs @@ -0,0 +1,264 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// ProvidersOperations operations. + /// + public partial interface IProvidersOperations + { + /// + /// Unregisters a subscription from a resource provider. + /// + /// + /// The namespace of the resource provider to unregister. + /// + /// + /// 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> UnregisterWithHttpMessagesAsync(string resourceProviderNamespace, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Registers a management group with a resource provider. + /// + /// + /// The namespace of the resource provider to register. + /// + /// + /// The management group ID. + /// + /// + /// 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 RegisterAtManagementGroupScopeWithHttpMessagesAsync(string resourceProviderNamespace, string groupId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get the provider permissions. + /// + /// + /// The namespace of the resource provider. + /// + /// + /// 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> ProviderPermissionsWithHttpMessagesAsync(string resourceProviderNamespace, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Registers a subscription with a resource provider. + /// + /// + /// The namespace of the resource provider to register. + /// + /// + /// The third party consent for S2S. + /// + /// + /// 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> RegisterWithHttpMessagesAsync(string resourceProviderNamespace, ProviderRegistrationRequest properties = default(ProviderRegistrationRequest), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets all resource providers for a subscription. + /// + /// + /// The properties to include in the results. For example, use + /// &$expand=metadata in the query string to retrieve resource + /// provider metadata. To include property aliases in response, use + /// $expand=resourceTypes/aliases. + /// + /// + /// 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 expand = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets all resource providers for the tenant. + /// + /// + /// The properties to include in the results. For example, use + /// &$expand=metadata in the query string to retrieve resource + /// provider metadata. To include property aliases in response, use + /// $expand=resourceTypes/aliases. + /// + /// + /// 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>> ListAtTenantScopeWithHttpMessagesAsync(string expand = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets the specified resource provider. + /// + /// + /// The namespace of the resource provider. + /// + /// + /// The $expand query parameter. For example, to include property + /// aliases in response, use $expand=resourceTypes/aliases. + /// + /// + /// 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 resourceProviderNamespace, string expand = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets the specified resource provider at the tenant level. + /// + /// + /// The namespace of the resource provider. + /// + /// + /// The $expand query parameter. For example, to include property + /// aliases in response, use $expand=resourceTypes/aliases. + /// + /// + /// 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> GetAtTenantScopeWithHttpMessagesAsync(string resourceProviderNamespace, string expand = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets all resource providers for 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)); + /// + /// Gets all resource providers for the tenant. + /// + /// + /// 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>> ListAtTenantScopeNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/IResourceGroupsOperations.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/IResourceGroupsOperations.cs new file mode 100644 index 0000000000000..079b910cfc0da --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/IResourceGroupsOperations.cs @@ -0,0 +1,284 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Microsoft.Rest.Azure.OData; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// ResourceGroupsOperations operations. + /// + public partial interface IResourceGroupsOperations + { + /// + /// Checks whether a resource group exists. + /// + /// + /// The name of the resource group to check. 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 a required parameter is null + /// + Task> CheckExistenceWithHttpMessagesAsync(string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Creates or updates a resource group. + /// + /// + /// The name of the resource group to create or update. Can include + /// alphanumeric, underscore, parentheses, hyphen, period (except at + /// end), and Unicode characters that match the allowed characters. + /// + /// + /// Parameters supplied to the create or update a resource group. + /// + /// + /// 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, ResourceGroup parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes a resource group. + /// + /// + /// When you delete a resource group, all of its resources are also + /// deleted. Deleting a resource group deletes all of its template + /// deployments and currently stored operations. + /// + /// + /// The name of the resource group to delete. The name is case + /// insensitive. + /// + /// + /// The resource types you want to force delete. Currently, only the + /// following is supported: + /// forceDeletionTypes=Microsoft.Compute/virtualMachines,Microsoft.Compute/virtualMachineScaleSets + /// + /// + /// 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 forceDeletionTypes = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets a resource group. + /// + /// + /// The name of the resource group to get. 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> GetWithHttpMessagesAsync(string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Updates a resource group. + /// + /// + /// Resource groups can be updated through a simple PATCH operation to + /// a group address. The format of the request is the same as that for + /// creating a resource group. If a field is unspecified, the current + /// value is retained. + /// + /// + /// The name of the resource group to update. The name is case + /// insensitive. + /// + /// + /// Parameters supplied to update a resource group. + /// + /// + /// 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, ResourceGroupPatchable parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Captures the specified resource group as a template. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Parameters for exporting the template. + /// + /// + /// 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> ExportTemplateWithHttpMessagesAsync(string resourceGroupName, ExportTemplateRequest parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets all the resource groups for a subscription. + /// + /// + /// OData parameters to apply to the 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>> ListWithHttpMessagesAsync(ODataQuery odataQuery = default(ODataQuery), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes a resource group. + /// + /// + /// When you delete a resource group, all of its resources are also + /// deleted. Deleting a resource group deletes all of its template + /// deployments and currently stored operations. + /// + /// + /// The name of the resource group to delete. The name is case + /// insensitive. + /// + /// + /// The resource types you want to force delete. Currently, only the + /// following is supported: + /// forceDeletionTypes=Microsoft.Compute/virtualMachines,Microsoft.Compute/virtualMachineScaleSets + /// + /// + /// 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 forceDeletionTypes = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Captures the specified resource group as a template. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Parameters for exporting the template. + /// + /// + /// 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> BeginExportTemplateWithHttpMessagesAsync(string resourceGroupName, ExportTemplateRequest parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets all the resource groups for 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)); + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/IResourceLinksOperations.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/IResourceLinksOperations.cs new file mode 100644 index 0000000000000..17f290230a3ea --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/IResourceLinksOperations.cs @@ -0,0 +1,197 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Microsoft.Rest.Azure.OData; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// ResourceLinksOperations operations. + /// + public partial interface IResourceLinksOperations + { + /// + /// Deletes a resource link with the specified ID. + /// + /// + /// The fully qualified ID of the resource link. Use the format, + /// /subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/{provider-namespace}/{resource-type}/{resource-name}/Microsoft.Resources/links/{link-name}. + /// For example, + /// /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup/Microsoft.Web/sites/mySite/Microsoft.Resources/links/myLink + /// + /// + /// 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 linkId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Creates or updates a resource link between the specified resources. + /// + /// + /// The fully qualified ID of the resource link. Use the format, + /// /subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/{provider-namespace}/{resource-type}/{resource-name}/Microsoft.Resources/links/{link-name}. + /// For example, + /// /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup/Microsoft.Web/sites/mySite/Microsoft.Resources/links/myLink + /// + /// + /// Parameters for creating or updating a resource link. + /// + /// + /// 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 linkId, ResourceLink parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets a resource link with the specified ID. + /// + /// + /// The fully qualified Id of the resource link. For example, + /// /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup/Microsoft.Web/sites/mySite/Microsoft.Resources/links/myLink + /// + /// + /// 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 linkId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets all the linked resources for the subscription. + /// + /// + /// OData parameters to apply to the 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>> ListAtSubscriptionWithHttpMessagesAsync(ODataQuery odataQuery = default(ODataQuery), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets a list of resource links at and below the specified source + /// scope. + /// + /// + /// The fully qualified ID of the scope for getting the resource links. + /// For example, to list resource links at and under a resource group, + /// set the scope to + /// /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup. + /// + /// + /// OData parameters to apply to the 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>> ListAtSourceScopeWithHttpMessagesAsync(string scope, ODataQuery odataQuery = default(ODataQuery), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets all the linked resources for the 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>> ListAtSubscriptionNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets a list of resource links at and below the specified source + /// scope. + /// + /// + /// 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>> ListAtSourceScopeNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/IResourceManagementClient.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/IResourceManagementClient.cs new file mode 100644 index 0000000000000..43f5a54c009f6 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/IResourceManagementClient.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.ResourceManager +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + + /// + /// Provides operations for working with resources and resource groups. + /// + public partial interface IResourceManagementClient : 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 Microsoft Azure subscription ID. + /// + string 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 IOperations. + /// + IOperations Operations { get; } + + /// + /// Gets the IDeploymentsOperations. + /// + IDeploymentsOperations Deployments { get; } + + /// + /// Gets the IProvidersOperations. + /// + IProvidersOperations Providers { get; } + + /// + /// Gets the IProviderResourceTypesOperations. + /// + IProviderResourceTypesOperations ProviderResourceTypes { get; } + + /// + /// Gets the IResourcesOperations. + /// + IResourcesOperations Resources { get; } + + /// + /// Gets the IResourceGroupsOperations. + /// + IResourceGroupsOperations ResourceGroups { get; } + + /// + /// Gets the ITagsOperations. + /// + ITagsOperations Tags { get; } + + /// + /// Gets the IDeploymentOperations. + /// + IDeploymentOperations DeploymentOperations { get; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/IResourcesOperations.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/IResourcesOperations.cs new file mode 100644 index 0000000000000..e15905153906c --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/IResourcesOperations.cs @@ -0,0 +1,775 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Microsoft.Rest.Azure.OData; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// ResourcesOperations operations. + /// + public partial interface IResourcesOperations + { + /// + /// Get all the resources for a resource group. + /// + /// + /// The resource group with the resources to get. + /// + /// + /// OData parameters to apply to the 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>> ListByResourceGroupWithHttpMessagesAsync(string resourceGroupName, ODataQuery odataQuery = default(ODataQuery), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Moves resources from one resource group to another resource group. + /// + /// + /// The resources to be moved must be in the same source resource group + /// in the source subscription being used. The target resource group + /// may be in a different subscription. When moving resources, both the + /// source group and the target group are locked for the duration of + /// the operation. Write and delete operations are blocked on the + /// groups until the move completes. + /// + /// + /// The name of the resource group from the source subscription + /// containing the resources to be moved. + /// + /// + /// Parameters for moving resources. + /// + /// + /// 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 MoveResourcesWithHttpMessagesAsync(string sourceResourceGroupName, ResourcesMoveInfo parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Validates whether resources can be moved from one resource group to + /// another resource group. + /// + /// + /// This operation checks whether the specified resources can be moved + /// to the target. The resources to be moved must be in the same source + /// resource group in the source subscription being used. The target + /// resource group may be in a different subscription. If validation + /// succeeds, it returns HTTP response code 204 (no content). If + /// validation fails, it returns HTTP response code 409 (Conflict) with + /// an error message. Retrieve the URL in the Location header value to + /// check the result of the long-running operation. + /// + /// + /// The name of the resource group from the source subscription + /// containing the resources to be validated for move. + /// + /// + /// Parameters for moving resources. + /// + /// + /// 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 ValidateMoveResourcesWithHttpMessagesAsync(string sourceResourceGroupName, ResourcesMoveInfo parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get all the resources in a subscription. + /// + /// + /// OData parameters to apply to the 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>> ListWithHttpMessagesAsync(ODataQuery odataQuery = default(ODataQuery), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Checks whether a resource exists. + /// + /// + /// The name of the resource group containing the resource to check. + /// The name is case insensitive. + /// + /// + /// The resource provider of the resource to check. + /// + /// + /// The parent resource identity. + /// + /// + /// The resource type. + /// + /// + /// The name of the resource to check whether it exists. + /// + /// + /// The API version to use for the operation. + /// + /// + /// 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> CheckExistenceWithHttpMessagesAsync(string resourceGroupName, string resourceProviderNamespace, string parentResourcePath, string resourceType, string resourceName, string apiVersion, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes a resource. + /// + /// + /// The name of the resource group that contains the resource to + /// delete. The name is case insensitive. + /// + /// + /// The namespace of the resource provider. + /// + /// + /// The parent resource identity. + /// + /// + /// The resource type. + /// + /// + /// The name of the resource to delete. + /// + /// + /// The API version to use for the operation. + /// + /// + /// 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 resourceProviderNamespace, string parentResourcePath, string resourceType, string resourceName, string apiVersion, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Creates a resource. + /// + /// + /// The name of the resource group for the resource. The name is case + /// insensitive. + /// + /// + /// The namespace of the resource provider. + /// + /// + /// The parent resource identity. + /// + /// + /// The resource type of the resource to create. + /// + /// + /// The name of the resource to create. + /// + /// + /// The API version to use for the operation. + /// + /// + /// Parameters for creating or updating the 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> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string resourceProviderNamespace, string parentResourcePath, string resourceType, string resourceName, string apiVersion, GenericResource parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Updates a resource. + /// + /// + /// The name of the resource group for the resource. The name is case + /// insensitive. + /// + /// + /// The namespace of the resource provider. + /// + /// + /// The parent resource identity. + /// + /// + /// The resource type of the resource to update. + /// + /// + /// The name of the resource to update. + /// + /// + /// The API version to use for the operation. + /// + /// + /// Parameters for updating the 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> UpdateWithHttpMessagesAsync(string resourceGroupName, string resourceProviderNamespace, string parentResourcePath, string resourceType, string resourceName, string apiVersion, GenericResource parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets a resource. + /// + /// + /// The name of the resource group containing the resource to get. The + /// name is case insensitive. + /// + /// + /// The namespace of the resource provider. + /// + /// + /// The parent resource identity. + /// + /// + /// The resource type of the resource. + /// + /// + /// The name of the resource to get. + /// + /// + /// The API version to use for the 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> GetWithHttpMessagesAsync(string resourceGroupName, string resourceProviderNamespace, string parentResourcePath, string resourceType, string resourceName, string apiVersion, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Checks by ID whether a resource exists. + /// + /// + /// The fully qualified ID of the resource, including the resource name + /// and resource type. Use the format, + /// /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name} + /// + /// + /// The API version to use for the operation. + /// + /// + /// 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> CheckExistenceByIdWithHttpMessagesAsync(string resourceId, string apiVersion, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes a resource by ID. + /// + /// + /// The fully qualified ID of the resource, including the resource name + /// and resource type. Use the format, + /// /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name} + /// + /// + /// The API version to use for the operation. + /// + /// + /// 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 DeleteByIdWithHttpMessagesAsync(string resourceId, string apiVersion, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Create a resource by ID. + /// + /// + /// The fully qualified ID of the resource, including the resource name + /// and resource type. Use the format, + /// /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name} + /// + /// + /// The API version to use for the operation. + /// + /// + /// Create or update resource parameters. + /// + /// + /// 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> CreateOrUpdateByIdWithHttpMessagesAsync(string resourceId, string apiVersion, GenericResource parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Updates a resource by ID. + /// + /// + /// The fully qualified ID of the resource, including the resource name + /// and resource type. Use the format, + /// /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name} + /// + /// + /// The API version to use for the operation. + /// + /// + /// Update resource parameters. + /// + /// + /// 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> UpdateByIdWithHttpMessagesAsync(string resourceId, string apiVersion, GenericResource parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets a resource by ID. + /// + /// + /// The fully qualified ID of the resource, including the resource name + /// and resource type. Use the format, + /// /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name} + /// + /// + /// The API version to use for the 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> GetByIdWithHttpMessagesAsync(string resourceId, string apiVersion, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Moves resources from one resource group to another resource group. + /// + /// + /// The resources to be moved must be in the same source resource group + /// in the source subscription being used. The target resource group + /// may be in a different subscription. When moving resources, both the + /// source group and the target group are locked for the duration of + /// the operation. Write and delete operations are blocked on the + /// groups until the move completes. + /// + /// + /// The name of the resource group from the source subscription + /// containing the resources to be moved. + /// + /// + /// Parameters for moving resources. + /// + /// + /// 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 BeginMoveResourcesWithHttpMessagesAsync(string sourceResourceGroupName, ResourcesMoveInfo parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Validates whether resources can be moved from one resource group to + /// another resource group. + /// + /// + /// This operation checks whether the specified resources can be moved + /// to the target. The resources to be moved must be in the same source + /// resource group in the source subscription being used. The target + /// resource group may be in a different subscription. If validation + /// succeeds, it returns HTTP response code 204 (no content). If + /// validation fails, it returns HTTP response code 409 (Conflict) with + /// an error message. Retrieve the URL in the Location header value to + /// check the result of the long-running operation. + /// + /// + /// The name of the resource group from the source subscription + /// containing the resources to be validated for move. + /// + /// + /// Parameters for moving resources. + /// + /// + /// 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 BeginValidateMoveResourcesWithHttpMessagesAsync(string sourceResourceGroupName, ResourcesMoveInfo parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes a resource. + /// + /// + /// The name of the resource group that contains the resource to + /// delete. The name is case insensitive. + /// + /// + /// The namespace of the resource provider. + /// + /// + /// The parent resource identity. + /// + /// + /// The resource type. + /// + /// + /// The name of the resource to delete. + /// + /// + /// The API version to use for the operation. + /// + /// + /// 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 resourceProviderNamespace, string parentResourcePath, string resourceType, string resourceName, string apiVersion, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Creates a resource. + /// + /// + /// The name of the resource group for the resource. The name is case + /// insensitive. + /// + /// + /// The namespace of the resource provider. + /// + /// + /// The parent resource identity. + /// + /// + /// The resource type of the resource to create. + /// + /// + /// The name of the resource to create. + /// + /// + /// The API version to use for the operation. + /// + /// + /// Parameters for creating or updating the 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> BeginCreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string resourceProviderNamespace, string parentResourcePath, string resourceType, string resourceName, string apiVersion, GenericResource parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Updates a resource. + /// + /// + /// The name of the resource group for the resource. The name is case + /// insensitive. + /// + /// + /// The namespace of the resource provider. + /// + /// + /// The parent resource identity. + /// + /// + /// The resource type of the resource to update. + /// + /// + /// The name of the resource to update. + /// + /// + /// The API version to use for the operation. + /// + /// + /// Parameters for updating the 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> BeginUpdateWithHttpMessagesAsync(string resourceGroupName, string resourceProviderNamespace, string parentResourcePath, string resourceType, string resourceName, string apiVersion, GenericResource parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes a resource by ID. + /// + /// + /// The fully qualified ID of the resource, including the resource name + /// and resource type. Use the format, + /// /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name} + /// + /// + /// The API version to use for the operation. + /// + /// + /// 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 BeginDeleteByIdWithHttpMessagesAsync(string resourceId, string apiVersion, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Create a resource by ID. + /// + /// + /// The fully qualified ID of the resource, including the resource name + /// and resource type. Use the format, + /// /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name} + /// + /// + /// The API version to use for the operation. + /// + /// + /// Create or update resource parameters. + /// + /// + /// 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> BeginCreateOrUpdateByIdWithHttpMessagesAsync(string resourceId, string apiVersion, GenericResource parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Updates a resource by ID. + /// + /// + /// The fully qualified ID of the resource, including the resource name + /// and resource type. Use the format, + /// /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name} + /// + /// + /// The API version to use for the operation. + /// + /// + /// Update resource parameters. + /// + /// + /// 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> BeginUpdateByIdWithHttpMessagesAsync(string resourceId, string apiVersion, GenericResource parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get all the resources for 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)); + /// + /// Get all the resources 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)); + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/ISubscriptionClient.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/ISubscriptionClient.cs new file mode 100644 index 0000000000000..f44cf5bfaa5f3 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/ISubscriptionClient.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.ResourceManager +{ + 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; + + /// + /// All resource groups and resources exist within subscriptions. These + /// operation enable you get information about your subscriptions and + /// tenants. A tenant is a dedicated instance of Azure Active Directory + /// (Azure AD) for your organization. + /// + public partial interface ISubscriptionClient : 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 API version to use for the 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 ISubscriptionsOperations. + /// + ISubscriptionsOperations Subscriptions { get; } + + /// + /// Gets the ITenantsOperations. + /// + ITenantsOperations Tenants { get; } + + /// + /// Checks resource name validity + /// + /// + /// A resource name is valid if it is not a reserved word, does not + /// contains a reserved word and does not start with a reserved word + /// + /// + /// Resource object with values for resource name and resource type + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + Task> CheckResourceNameWithHttpMessagesAsync(ResourceName resourceNameDefinition = default(ResourceName), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/ISubscriptionFeatureRegistrationsOperations.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/ISubscriptionFeatureRegistrationsOperations.cs new file mode 100644 index 0000000000000..31742017d9c6a --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/ISubscriptionFeatureRegistrationsOperations.cs @@ -0,0 +1,189 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// SubscriptionFeatureRegistrationsOperations operations. + /// + public partial interface ISubscriptionFeatureRegistrationsOperations + { + /// + /// Returns a feature registration + /// + /// + /// The provider namespace. + /// + /// + /// The feature 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 providerNamespace, string featureName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Create or update a feature registration. + /// + /// + /// The provider namespace. + /// + /// + /// The feature name. + /// + /// + /// Subscription Feature Registration Type details. + /// + /// + /// 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 providerNamespace, string featureName, SubscriptionFeatureRegistration subscriptionFeatureRegistrationType = default(SubscriptionFeatureRegistration), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes a feature registration + /// + /// + /// The provider namespace. + /// + /// + /// The feature name. + /// + /// + /// 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 providerNamespace, string featureName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Returns subscription feature registrations for given subscription + /// and provider namespace. + /// + /// + /// The provider namespace. + /// + /// + /// 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>> ListBySubscriptionWithHttpMessagesAsync(string providerNamespace, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Returns subscription feature registrations for 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>> ListAllBySubscriptionWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Returns subscription feature registrations for given subscription + /// and provider namespace. + /// + /// + /// 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>> ListBySubscriptionNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Returns subscription feature registrations for given 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>> ListAllBySubscriptionNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/ISubscriptionsOperations.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/ISubscriptionsOperations.cs new file mode 100644 index 0000000000000..dee3820826689 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/ISubscriptionsOperations.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.ResourceManager +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// SubscriptionsOperations operations. + /// + public partial interface ISubscriptionsOperations + { + /// + /// Gets all available geo-locations. + /// + /// + /// This operation provides all the locations that are available for + /// resource providers; however, each resource provider may support a + /// subset of this list. + /// + /// + /// The ID of the target subscription. + /// + /// + /// Whether to include extended locations. + /// + /// + /// 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>> ListLocationsWithHttpMessagesAsync(string subscriptionId, bool? includeExtendedLocations = default(bool?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets details about a specified subscription. + /// + /// + /// The ID of the target 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> GetWithHttpMessagesAsync(string subscriptionId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets all subscriptions for a tenant. + /// + /// + /// 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)); + /// + /// Compares a subscriptions logical zone mapping + /// + /// + /// The ID of the target subscription. + /// + /// + /// Parameters for checking zone peers. + /// + /// + /// 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> CheckZonePeersWithHttpMessagesAsync(string subscriptionId, CheckZonePeersRequest parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets all subscriptions for a tenant. + /// + /// + /// 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/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/ITagsOperations.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/ITagsOperations.cs new file mode 100644 index 0000000000000..6feb9c72b1f9c --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/ITagsOperations.cs @@ -0,0 +1,299 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// TagsOperations operations. + /// + public partial interface ITagsOperations + { + /// + /// Deletes a predefined tag value for a predefined tag name. + /// + /// + /// This operation allows deleting a value from the list of predefined + /// values for an existing predefined tag name. The value being deleted + /// must not be in use as a tag value for the given tag name for any + /// resource. + /// + /// + /// The name of the tag. + /// + /// + /// The value of the tag to delete. + /// + /// + /// 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 DeleteValueWithHttpMessagesAsync(string tagName, string tagValue, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Creates a predefined value for a predefined tag name. + /// + /// + /// This operation allows adding a value to the list of predefined + /// values for an existing predefined tag name. A tag value can have a + /// maximum of 256 characters. + /// + /// + /// The name of the tag. + /// + /// + /// The value of the tag to create. + /// + /// + /// 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> CreateOrUpdateValueWithHttpMessagesAsync(string tagName, string tagValue, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Creates a predefined tag name. + /// + /// + /// This operation allows adding a name to the list of predefined tag + /// names for the given subscription. A tag name can have a maximum of + /// 512 characters and is case-insensitive. Tag names cannot have the + /// following prefixes which are reserved for Azure use: 'microsoft', + /// 'azure', 'windows'. + /// + /// + /// The name of the tag to create. + /// + /// + /// 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 tagName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes a predefined tag name. + /// + /// + /// This operation allows deleting a name from the list of predefined + /// tag names for the given subscription. The name being deleted must + /// not be in use as a tag name for any resource. All predefined values + /// for the given name must have already been deleted. + /// + /// + /// The name of the tag. + /// + /// + /// 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 tagName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets a summary of tag usage under the subscription. + /// + /// + /// This operation performs a union of predefined tags, resource tags, + /// resource group tags and subscription tags, and returns a summary of + /// usage for each tag name and value under the given subscription. In + /// case of a large number of tags, this operation may return a + /// previously cached result. + /// + /// + /// 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)); + /// + /// Creates or updates the entire set of tags on a resource or + /// subscription. + /// + /// + /// This operation allows adding or replacing the entire set of tags on + /// the specified resource or subscription. The specified entity can + /// have a maximum of 50 tags. + /// + /// + /// The resource scope. + /// + /// + /// + /// + /// 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> CreateOrUpdateAtScopeWithHttpMessagesAsync(string scope, TagsResource parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Selectively updates the set of tags on a resource or subscription. + /// + /// + /// This operation allows replacing, merging or selectively deleting + /// tags on the specified resource or subscription. The specified + /// entity can have a maximum of 50 tags at the end of the operation. + /// The 'replace' option replaces the entire set of existing tags with + /// a new set. The 'merge' option allows adding tags with new names and + /// updating the values of tags with existing names. The 'delete' + /// option allows selectively deleting tags based on given names or + /// name/value pairs. + /// + /// + /// The resource scope. + /// + /// + /// + /// + /// 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> UpdateAtScopeWithHttpMessagesAsync(string scope, TagsPatchResource parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets the entire set of tags on a resource or subscription. + /// + /// + /// The resource scope. + /// + /// + /// 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> GetAtScopeWithHttpMessagesAsync(string scope, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes the entire set of tags on a resource or subscription. + /// + /// + /// The resource scope. + /// + /// + /// 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 DeleteAtScopeWithHttpMessagesAsync(string scope, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets a summary of tag usage under the subscription. + /// + /// + /// This operation performs a union of predefined tags, resource tags, + /// resource group tags and subscription tags, and returns a summary of + /// usage for each tag name and value under the given subscription. In + /// case of a large number of tags, this operation may return a + /// previously cached 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/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/ITemplateSpecVersionsOperations.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/ITemplateSpecVersionsOperations.cs new file mode 100644 index 0000000000000..63b3688082fcd --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/ITemplateSpecVersionsOperations.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.ResourceManager +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// TemplateSpecVersionsOperations operations. + /// + public partial interface ITemplateSpecVersionsOperations + { + /// + /// Creates or updates a Template Spec version. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Name of the Template Spec. + /// + /// + /// The version of the Template Spec. + /// + /// + /// Template Spec Version supplied to the 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> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string templateSpecName, string templateSpecVersion, TemplateSpecVersion templateSpecVersionModel, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Updates Template Spec Version tags with specified values. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Name of the Template Spec. + /// + /// + /// The version of the Template Spec. + /// + /// + /// Template Spec Version resource with the tags to be updated. + /// + /// + /// 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 templateSpecName, string templateSpecVersion, TemplateSpecVersionUpdateModel templateSpecVersionUpdateModel = default(TemplateSpecVersionUpdateModel), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets a Template Spec version from a specific Template Spec. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Name of the Template Spec. + /// + /// + /// The version of the Template Spec. + /// + /// + /// 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 templateSpecName, string templateSpecVersion, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes a specific version from a Template Spec. When operation + /// completes, status code 200 returned without content. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Name of the Template Spec. + /// + /// + /// The version of the Template Spec. + /// + /// + /// 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 templateSpecName, string templateSpecVersion, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Lists all the Template Spec versions in the specified Template + /// Spec. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Name of the Template Spec. + /// + /// + /// 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 templateSpecName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Lists all the Template Spec versions in the specified Template + /// Spec. + /// + /// + /// 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/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/ITemplateSpecsClient.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/ITemplateSpecsClient.cs new file mode 100644 index 0000000000000..00e83e8042a9f --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/ITemplateSpecsClient.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.ResourceManager +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + + /// + /// The APIs listed in this specification can be used to manage Template + /// Spec resources through the Azure Resource Manager. + /// + public partial interface ITemplateSpecsClient : 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; } + + /// + /// Subscription Id which forms part of the URI for every service call. + /// + string SubscriptionId { get; set; } + + /// + /// Client Api version. + /// + 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 ITemplateSpecsOperations. + /// + ITemplateSpecsOperations TemplateSpecs { get; } + + /// + /// Gets the ITemplateSpecVersionsOperations. + /// + ITemplateSpecVersionsOperations TemplateSpecVersions { get; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/ITemplateSpecsOperations.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/ITemplateSpecsOperations.cs new file mode 100644 index 0000000000000..876a485861829 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/ITemplateSpecsOperations.cs @@ -0,0 +1,228 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// TemplateSpecsOperations operations. + /// + public partial interface ITemplateSpecsOperations + { + /// + /// Creates or updates a Template Spec. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Name of the Template Spec. + /// + /// + /// Template Spec supplied to the 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> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string templateSpecName, TemplateSpec templateSpec, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Updates Template Spec tags with specified values. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Name of the Template Spec. + /// + /// + /// Template Spec resource with the tags to be updated. + /// + /// + /// 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 templateSpecName, TemplateSpecUpdateModel templateSpec = default(TemplateSpecUpdateModel), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets a Template Spec with a given name. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Name of the Template Spec. + /// + /// + /// Allows for expansion of additional Template Spec details in the + /// response. Optional. Possible values include: 'versions' + /// + /// + /// 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 templateSpecName, string expand = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes a Template Spec by name. When operation completes, status + /// code 200 returned without content. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Name of the Template Spec. + /// + /// + /// 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 templateSpecName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Lists all the Template Specs within the specified subscriptions. + /// + /// + /// Allows for expansion of additional Template Spec details in the + /// response. Optional. Possible values include: 'versions' + /// + /// + /// 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>> ListBySubscriptionWithHttpMessagesAsync(string expand = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Lists all the Template Specs within the specified resource group. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Allows for expansion of additional Template Spec details in the + /// response. Optional. Possible values include: 'versions' + /// + /// + /// 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, string expand = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Lists all the Template Specs within the specified subscriptions. + /// + /// + /// 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>> ListBySubscriptionNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Lists all the Template Specs within the specified 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/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/ITenantsOperations.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/ITenantsOperations.cs new file mode 100644 index 0000000000000..dd947f7281f78 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/ITenantsOperations.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.ResourceManager +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// TenantsOperations operations. + /// + public partial interface ITenantsOperations + { + /// + /// Gets the tenants for your account. + /// + /// + /// 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)); + /// + /// Gets the tenants for your account. + /// + /// + /// 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/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/ManagementLinkClient.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/ManagementLinkClient.cs new file mode 100644 index 0000000000000..82892ad753d47 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/ManagementLinkClient.cs @@ -0,0 +1,369 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager +{ + 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 resources can be linked together to form logical relationships. + /// You can establish links between resources belonging to different + /// resource groups. However, all the linked resources must belong to the + /// same subscription. Each resource can be linked to 50 other resources. + /// If any of the linked resources are deleted or moved, the link owner + /// must clean up the remaining link. + /// + public partial class ManagementLinkClient : ServiceClient, IManagementLinkClient, 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 API version to use for the 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 IOperations. + /// + public virtual IOperations Operations { get; private set; } + + /// + /// Gets the IResourceLinksOperations. + /// + public virtual IResourceLinksOperations ResourceLinks { get; private set; } + + /// + /// Initializes a new instance of the ManagementLinkClient class. + /// + /// + /// HttpClient to be used + /// + /// + /// True: will dispose the provided httpClient on calling ManagementLinkClient.Dispose(). False: will not dispose provided httpClient + protected ManagementLinkClient(HttpClient httpClient, bool disposeHttpClient) : base(httpClient, disposeHttpClient) + { + Initialize(); + } + + /// + /// Initializes a new instance of the ManagementLinkClient class. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + protected ManagementLinkClient(params DelegatingHandler[] handlers) : base(handlers) + { + Initialize(); + } + + /// + /// Initializes a new instance of the ManagementLinkClient class. + /// + /// + /// Optional. The http client handler used to handle http transport. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + protected ManagementLinkClient(HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : base(rootHandler, handlers) + { + Initialize(); + } + + /// + /// Initializes a new instance of the ManagementLinkClient 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 ManagementLinkClient(System.Uri baseUri, params DelegatingHandler[] handlers) : this(handlers) + { + if (baseUri == null) + { + throw new System.ArgumentNullException("baseUri"); + } + BaseUri = baseUri; + } + + /// + /// Initializes a new instance of the ManagementLinkClient 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 ManagementLinkClient(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 ManagementLinkClient 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 ManagementLinkClient(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 ManagementLinkClient class. + /// + /// + /// Required. Credentials needed for the client to connect to Azure. + /// + /// + /// HttpClient to be used + /// + /// + /// True: will dispose the provided httpClient on calling ManagementLinkClient.Dispose(). False: will not dispose provided httpClient + /// + /// Thrown when a required parameter is null + /// + public ManagementLinkClient(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 ManagementLinkClient 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 ManagementLinkClient(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 ManagementLinkClient 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 ManagementLinkClient(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 ManagementLinkClient 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 ManagementLinkClient(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() + { + Operations = new Operations(this); + ResourceLinks = new ResourceLinksOperations(this); + BaseUri = new System.Uri("https://management.azure.com"); + ApiVersion = "2016-09-01"; + 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() + } + }; + 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 CloudErrorJsonConverter()); + } + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/ManagementLockClient.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/ManagementLockClient.cs new file mode 100644 index 0000000000000..56084b16280eb --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/ManagementLockClient.cs @@ -0,0 +1,367 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager +{ + 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 resources can be locked to prevent other users in your + /// organization from deleting or modifying resources. + /// + public partial class ManagementLockClient : ServiceClient, IManagementLockClient, 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 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 IAuthorizationOperations. + /// + public virtual IAuthorizationOperations AuthorizationOperations { get; private set; } + + /// + /// Gets the IManagementLocksOperations. + /// + public virtual IManagementLocksOperations ManagementLocks { get; private set; } + + /// + /// Initializes a new instance of the ManagementLockClient class. + /// + /// + /// HttpClient to be used + /// + /// + /// True: will dispose the provided httpClient on calling ManagementLockClient.Dispose(). False: will not dispose provided httpClient + protected ManagementLockClient(HttpClient httpClient, bool disposeHttpClient) : base(httpClient, disposeHttpClient) + { + Initialize(); + } + + /// + /// Initializes a new instance of the ManagementLockClient class. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + protected ManagementLockClient(params DelegatingHandler[] handlers) : base(handlers) + { + Initialize(); + } + + /// + /// Initializes a new instance of the ManagementLockClient class. + /// + /// + /// Optional. The http client handler used to handle http transport. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + protected ManagementLockClient(HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : base(rootHandler, handlers) + { + Initialize(); + } + + /// + /// Initializes a new instance of the ManagementLockClient 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 ManagementLockClient(System.Uri baseUri, params DelegatingHandler[] handlers) : this(handlers) + { + if (baseUri == null) + { + throw new System.ArgumentNullException("baseUri"); + } + BaseUri = baseUri; + } + + /// + /// Initializes a new instance of the ManagementLockClient 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 ManagementLockClient(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 ManagementLockClient 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 ManagementLockClient(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 ManagementLockClient class. + /// + /// + /// Required. Credentials needed for the client to connect to Azure. + /// + /// + /// HttpClient to be used + /// + /// + /// True: will dispose the provided httpClient on calling ManagementLockClient.Dispose(). False: will not dispose provided httpClient + /// + /// Thrown when a required parameter is null + /// + public ManagementLockClient(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 ManagementLockClient 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 ManagementLockClient(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 ManagementLockClient 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 ManagementLockClient(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 ManagementLockClient 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 ManagementLockClient(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() + { + AuthorizationOperations = new AuthorizationOperations(this); + ManagementLocks = new ManagementLocksOperations(this); + BaseUri = new System.Uri("https://management.azure.com"); + ApiVersion = "2020-05-01"; + 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/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/ManagementLocksOperations.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/ManagementLocksOperations.cs new file mode 100644 index 0000000000000..8f37ffbb311c8 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/ManagementLocksOperations.cs @@ -0,0 +1,4230 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Microsoft.Rest.Azure.OData; + 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; + + /// + /// ManagementLocksOperations operations. + /// + internal partial class ManagementLocksOperations : IServiceOperations, IManagementLocksOperations + { + /// + /// Initializes a new instance of the ManagementLocksOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal ManagementLocksOperations(ManagementLockClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the ManagementLockClient + /// + public ManagementLockClient Client { get; private set; } + + /// + /// Creates or updates a management lock at the resource group level. + /// + /// + /// When you apply a lock at a parent scope, all child resources inherit the + /// same lock. To create management locks, you must have access to + /// Microsoft.Authorization/* or Microsoft.Authorization/locks/* actions. Of + /// the built-in roles, only Owner and User Access Administrator are granted + /// those actions. + /// + /// + /// The name of the resource group to lock. + /// + /// + /// The lock name. The lock name can be a maximum of 260 characters. It cannot + /// contain <, > %, &, :, \, ?, /, or any control characters. + /// + /// + /// The management lock parameters. + /// + /// + /// 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> CreateOrUpdateAtResourceGroupLevelWithHttpMessagesAsync(string resourceGroupName, string lockName, ManagementLockObject 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 (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (lockName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "lockName"); + } + if (parameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); + } + if (parameters != null) + { + parameters.Validate(); + } + 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 (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("lockName", lockName); + tracingParameters.Add("parameters", parameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "CreateOrUpdateAtResourceGroupLevel", 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.Authorization/locks/{lockName}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{lockName}", System.Uri.EscapeDataString(lockName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + 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); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Deletes a management lock at the resource group level. + /// + /// + /// To delete management locks, you must have access to + /// Microsoft.Authorization/* or Microsoft.Authorization/locks/* actions. Of + /// the built-in roles, only Owner and User Access Administrator are granted + /// those actions. + /// + /// + /// The name of the resource group containing the lock. + /// + /// + /// The name of lock to delete. + /// + /// + /// 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 DeleteAtResourceGroupLevelWithHttpMessagesAsync(string resourceGroupName, string lockName, 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 (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (lockName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "lockName"); + } + 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 (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("lockName", lockName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "DeleteAtResourceGroupLevel", 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.Authorization/locks/{lockName}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{lockName}", System.Uri.EscapeDataString(lockName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + 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 != 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 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 management lock at the resource group level. + /// + /// + /// The name of the locked resource group. + /// + /// + /// The name of the lock to get. + /// + /// + /// 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> GetAtResourceGroupLevelWithHttpMessagesAsync(string resourceGroupName, string lockName, 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 (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (lockName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "lockName"); + } + 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 (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("lockName", lockName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetAtResourceGroupLevel", 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.Authorization/locks/{lockName}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{lockName}", System.Uri.EscapeDataString(lockName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + 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; + } + + /// + /// Create or update a management lock by scope. + /// + /// + /// The scope for the lock. When providing a scope for the assignment, use + /// '/subscriptions/{subscriptionId}' for subscriptions, + /// '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}' for + /// resource groups, and + /// '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePathIfPresent}/{resourceType}/{resourceName}' + /// for resources. + /// + /// + /// The name of lock. + /// + /// + /// Create or update management lock parameters. + /// + /// + /// 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> CreateOrUpdateByScopeWithHttpMessagesAsync(string scope, string lockName, ManagementLockObject parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (scope == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "scope"); + } + if (lockName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "lockName"); + } + if (parameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); + } + if (parameters != null) + { + parameters.Validate(); + } + 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("scope", scope); + tracingParameters.Add("lockName", lockName); + tracingParameters.Add("parameters", parameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "CreateOrUpdateByScope", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{scope}/providers/Microsoft.Authorization/locks/{lockName}").ToString(); + _url = _url.Replace("{scope}", System.Uri.EscapeDataString(scope)); + _url = _url.Replace("{lockName}", System.Uri.EscapeDataString(lockName)); + 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); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Delete a management lock by scope. + /// + /// + /// The scope for the lock. + /// + /// + /// The name of lock. + /// + /// + /// 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 DeleteByScopeWithHttpMessagesAsync(string scope, string lockName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (scope == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "scope"); + } + if (lockName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "lockName"); + } + 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("scope", scope); + tracingParameters.Add("lockName", lockName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "DeleteByScope", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{scope}/providers/Microsoft.Authorization/locks/{lockName}").ToString(); + _url = _url.Replace("{scope}", System.Uri.EscapeDataString(scope)); + _url = _url.Replace("{lockName}", System.Uri.EscapeDataString(lockName)); + 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 != 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 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; + } + + /// + /// Get a management lock by scope. + /// + /// + /// The scope for the lock. + /// + /// + /// The name of lock. + /// + /// + /// 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> GetByScopeWithHttpMessagesAsync(string scope, string lockName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (scope == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "scope"); + } + if (lockName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "lockName"); + } + 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("scope", scope); + tracingParameters.Add("lockName", lockName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetByScope", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{scope}/providers/Microsoft.Authorization/locks/{lockName}").ToString(); + _url = _url.Replace("{scope}", System.Uri.EscapeDataString(scope)); + _url = _url.Replace("{lockName}", System.Uri.EscapeDataString(lockName)); + 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 or updates a management lock at the resource level or any level + /// below the resource. + /// + /// + /// When you apply a lock at a parent scope, all child resources inherit the + /// same lock. To create management locks, you must have access to + /// Microsoft.Authorization/* or Microsoft.Authorization/locks/* actions. Of + /// the built-in roles, only Owner and User Access Administrator are granted + /// those actions. + /// + /// + /// The name of the resource group containing the resource to lock. + /// + /// + /// The resource provider namespace of the resource to lock. + /// + /// + /// The parent resource identity. + /// + /// + /// The resource type of the resource to lock. + /// + /// + /// The name of the resource to lock. + /// + /// + /// The name of lock. The lock name can be a maximum of 260 characters. It + /// cannot contain <, > %, &, :, \, ?, /, or any control characters. + /// + /// + /// Parameters for creating or updating a management lock. + /// + /// + /// 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> CreateOrUpdateAtResourceLevelWithHttpMessagesAsync(string resourceGroupName, string resourceProviderNamespace, string parentResourcePath, string resourceType, string resourceName, string lockName, ManagementLockObject 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 (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (resourceProviderNamespace == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceProviderNamespace"); + } + if (parentResourcePath == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "parentResourcePath"); + } + if (resourceType == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceType"); + } + if (resourceName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceName"); + } + if (lockName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "lockName"); + } + if (parameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); + } + if (parameters != null) + { + parameters.Validate(); + } + 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 (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("resourceProviderNamespace", resourceProviderNamespace); + tracingParameters.Add("parentResourcePath", parentResourcePath); + tracingParameters.Add("resourceType", resourceType); + tracingParameters.Add("resourceName", resourceName); + tracingParameters.Add("lockName", lockName); + tracingParameters.Add("parameters", parameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "CreateOrUpdateAtResourceLevel", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/locks/{lockName}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{resourceProviderNamespace}", System.Uri.EscapeDataString(resourceProviderNamespace)); + _url = _url.Replace("{parentResourcePath}", parentResourcePath); + _url = _url.Replace("{resourceType}", resourceType); + _url = _url.Replace("{resourceName}", System.Uri.EscapeDataString(resourceName)); + _url = _url.Replace("{lockName}", System.Uri.EscapeDataString(lockName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + 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); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Deletes the management lock of a resource or any level below the resource. + /// + /// + /// To delete management locks, you must have access to + /// Microsoft.Authorization/* or Microsoft.Authorization/locks/* actions. Of + /// the built-in roles, only Owner and User Access Administrator are granted + /// those actions. + /// + /// + /// The name of the resource group containing the resource with the lock to + /// delete. + /// + /// + /// The resource provider namespace of the resource with the lock to delete. + /// + /// + /// The parent resource identity. + /// + /// + /// The resource type of the resource with the lock to delete. + /// + /// + /// The name of the resource with the lock to delete. + /// + /// + /// The name of the lock to delete. + /// + /// + /// 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 DeleteAtResourceLevelWithHttpMessagesAsync(string resourceGroupName, string resourceProviderNamespace, string parentResourcePath, string resourceType, string resourceName, string lockName, 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 (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (resourceProviderNamespace == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceProviderNamespace"); + } + if (parentResourcePath == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "parentResourcePath"); + } + if (resourceType == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceType"); + } + if (resourceName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceName"); + } + if (lockName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "lockName"); + } + 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 (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("resourceProviderNamespace", resourceProviderNamespace); + tracingParameters.Add("parentResourcePath", parentResourcePath); + tracingParameters.Add("resourceType", resourceType); + tracingParameters.Add("resourceName", resourceName); + tracingParameters.Add("lockName", lockName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "DeleteAtResourceLevel", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/locks/{lockName}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{resourceProviderNamespace}", System.Uri.EscapeDataString(resourceProviderNamespace)); + _url = _url.Replace("{parentResourcePath}", parentResourcePath); + _url = _url.Replace("{resourceType}", resourceType); + _url = _url.Replace("{resourceName}", System.Uri.EscapeDataString(resourceName)); + _url = _url.Replace("{lockName}", System.Uri.EscapeDataString(lockName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + 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 != 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 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; + } + + /// + /// Get the management lock of a resource or any level below resource. + /// + /// + /// The name of the resource group. + /// + /// + /// The namespace of the resource provider. + /// + /// + /// An extra path parameter needed in some services, like SQL Databases. + /// + /// + /// The type of the resource. + /// + /// + /// The name of the resource. + /// + /// + /// The name of lock. + /// + /// + /// 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> GetAtResourceLevelWithHttpMessagesAsync(string resourceGroupName, string resourceProviderNamespace, string parentResourcePath, string resourceType, string resourceName, string lockName, 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 (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (resourceProviderNamespace == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceProviderNamespace"); + } + if (parentResourcePath == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "parentResourcePath"); + } + if (resourceType == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceType"); + } + if (resourceName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceName"); + } + if (lockName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "lockName"); + } + 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 (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("resourceProviderNamespace", resourceProviderNamespace); + tracingParameters.Add("parentResourcePath", parentResourcePath); + tracingParameters.Add("resourceType", resourceType); + tracingParameters.Add("resourceName", resourceName); + tracingParameters.Add("lockName", lockName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetAtResourceLevel", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/locks/{lockName}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{resourceProviderNamespace}", System.Uri.EscapeDataString(resourceProviderNamespace)); + _url = _url.Replace("{parentResourcePath}", parentResourcePath); + _url = _url.Replace("{resourceType}", resourceType); + _url = _url.Replace("{resourceName}", System.Uri.EscapeDataString(resourceName)); + _url = _url.Replace("{lockName}", System.Uri.EscapeDataString(lockName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + 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 or updates a management lock at the subscription level. + /// + /// + /// When you apply a lock at a parent scope, all child resources inherit the + /// same lock. To create management locks, you must have access to + /// Microsoft.Authorization/* or Microsoft.Authorization/locks/* actions. Of + /// the built-in roles, only Owner and User Access Administrator are granted + /// those actions. + /// + /// + /// The name of lock. The lock name can be a maximum of 260 characters. It + /// cannot contain <, > %, &, :, \, ?, /, or any control characters. + /// + /// + /// The management lock parameters. + /// + /// + /// 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> CreateOrUpdateAtSubscriptionLevelWithHttpMessagesAsync(string lockName, ManagementLockObject parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (lockName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "lockName"); + } + if (parameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); + } + if (parameters != null) + { + parameters.Validate(); + } + 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 (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("lockName", lockName); + tracingParameters.Add("parameters", parameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "CreateOrUpdateAtSubscriptionLevel", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks/{lockName}").ToString(); + _url = _url.Replace("{lockName}", System.Uri.EscapeDataString(lockName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + 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); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Deletes the management lock at the subscription level. + /// + /// + /// To delete management locks, you must have access to + /// Microsoft.Authorization/* or Microsoft.Authorization/locks/* actions. Of + /// the built-in roles, only Owner and User Access Administrator are granted + /// those actions. + /// + /// + /// The name of lock to delete. + /// + /// + /// 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 DeleteAtSubscriptionLevelWithHttpMessagesAsync(string lockName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (lockName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "lockName"); + } + 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 (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("lockName", lockName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "DeleteAtSubscriptionLevel", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks/{lockName}").ToString(); + _url = _url.Replace("{lockName}", System.Uri.EscapeDataString(lockName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + 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 != 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 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 management lock at the subscription level. + /// + /// + /// The name of the lock to get. + /// + /// + /// 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> GetAtSubscriptionLevelWithHttpMessagesAsync(string lockName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (lockName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "lockName"); + } + 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 (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("lockName", lockName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetAtSubscriptionLevel", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks/{lockName}").ToString(); + _url = _url.Replace("{lockName}", System.Uri.EscapeDataString(lockName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + 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 all the management locks for a resource group. + /// + /// + /// The name of the resource group containing the locks to get. + /// + /// + /// OData parameters to apply to the 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>> ListAtResourceGroupLevelWithHttpMessagesAsync(string resourceGroupName, ODataQuery odataQuery = default(ODataQuery), 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 (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + 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 (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("odataQuery", odataQuery); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListAtResourceGroupLevel", 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.Authorization/locks").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (odataQuery != null) + { + var _odataFilter = odataQuery.ToString(); + if (!string.IsNullOrEmpty(_odataFilter)) + { + _queryParameters.Add(_odataFilter); + } + } + 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 all the management locks for a resource or any level below resource. + /// + /// + /// The name of the resource group containing the locked resource. The name is + /// case insensitive. + /// + /// + /// The namespace of the resource provider. + /// + /// + /// The parent resource identity. + /// + /// + /// The resource type of the locked resource. + /// + /// + /// The name of the locked resource. + /// + /// + /// OData parameters to apply to the 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>> ListAtResourceLevelWithHttpMessagesAsync(string resourceGroupName, string resourceProviderNamespace, string parentResourcePath, string resourceType, string resourceName, ODataQuery odataQuery = default(ODataQuery), 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 (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (resourceProviderNamespace == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceProviderNamespace"); + } + if (parentResourcePath == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "parentResourcePath"); + } + if (resourceType == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceType"); + } + if (resourceName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceName"); + } + 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 (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("odataQuery", odataQuery); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("resourceProviderNamespace", resourceProviderNamespace); + tracingParameters.Add("parentResourcePath", parentResourcePath); + tracingParameters.Add("resourceType", resourceType); + tracingParameters.Add("resourceName", resourceName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListAtResourceLevel", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/locks").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{resourceProviderNamespace}", System.Uri.EscapeDataString(resourceProviderNamespace)); + _url = _url.Replace("{parentResourcePath}", parentResourcePath); + _url = _url.Replace("{resourceType}", resourceType); + _url = _url.Replace("{resourceName}", System.Uri.EscapeDataString(resourceName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (odataQuery != null) + { + var _odataFilter = odataQuery.ToString(); + if (!string.IsNullOrEmpty(_odataFilter)) + { + _queryParameters.Add(_odataFilter); + } + } + 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 all the management locks for a subscription. + /// + /// + /// OData parameters to apply to the 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>> ListAtSubscriptionLevelWithHttpMessagesAsync(ODataQuery odataQuery = default(ODataQuery), 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 (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("odataQuery", odataQuery); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListAtSubscriptionLevel", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (odataQuery != null) + { + var _odataFilter = odataQuery.ToString(); + if (!string.IsNullOrEmpty(_odataFilter)) + { + _queryParameters.Add(_odataFilter); + } + } + 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 all the management locks for a scope. + /// + /// + /// The scope for the lock. When providing a scope for the assignment, use + /// '/subscriptions/{subscriptionId}' for subscriptions, + /// '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}' for + /// resource groups, and + /// '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePathIfPresent}/{resourceType}/{resourceName}' + /// for resources. + /// + /// + /// OData parameters to apply to the 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>> ListByScopeWithHttpMessagesAsync(string scope, ODataQuery odataQuery = default(ODataQuery), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (scope == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "scope"); + } + 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("odataQuery", odataQuery); + tracingParameters.Add("scope", scope); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByScope", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{scope}/providers/Microsoft.Authorization/locks").ToString(); + _url = _url.Replace("{scope}", System.Uri.EscapeDataString(scope)); + List _queryParameters = new List(); + if (odataQuery != null) + { + var _odataFilter = odataQuery.ToString(); + if (!string.IsNullOrEmpty(_odataFilter)) + { + _queryParameters.Add(_odataFilter); + } + } + 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 all the management locks for 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>> ListAtResourceGroupLevelNextWithHttpMessagesAsync(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, "ListAtResourceGroupLevelNext", 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; + } + + /// + /// Gets all the management locks for a resource or any level below resource. + /// + /// + /// 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>> ListAtResourceLevelNextWithHttpMessagesAsync(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, "ListAtResourceLevelNext", 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; + } + + /// + /// Gets all the management locks for 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>> ListAtSubscriptionLevelNextWithHttpMessagesAsync(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, "ListAtSubscriptionLevelNext", 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; + } + + /// + /// Gets all the management locks for a scope. + /// + /// + /// 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>> ListByScopeNextWithHttpMessagesAsync(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, "ListByScopeNext", 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/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/ManagementLocksOperationsExtensions.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/ManagementLocksOperationsExtensions.cs new file mode 100644 index 0000000000000..5efb409dc0aa4 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/ManagementLocksOperationsExtensions.cs @@ -0,0 +1,996 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Microsoft.Rest.Azure.OData; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for ManagementLocksOperations. + /// + public static partial class ManagementLocksOperationsExtensions + { + /// + /// Creates or updates a management lock at the resource group level. + /// + /// + /// When you apply a lock at a parent scope, all child resources inherit the + /// same lock. To create management locks, you must have access to + /// Microsoft.Authorization/* or Microsoft.Authorization/locks/* actions. Of + /// the built-in roles, only Owner and User Access Administrator are granted + /// those actions. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to lock. + /// + /// + /// The lock name. The lock name can be a maximum of 260 characters. It cannot + /// contain <, > %, &, :, \, ?, /, or any control characters. + /// + /// + /// The management lock parameters. + /// + public static ManagementLockObject CreateOrUpdateAtResourceGroupLevel(this IManagementLocksOperations operations, string resourceGroupName, string lockName, ManagementLockObject parameters) + { + return operations.CreateOrUpdateAtResourceGroupLevelAsync(resourceGroupName, lockName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Creates or updates a management lock at the resource group level. + /// + /// + /// When you apply a lock at a parent scope, all child resources inherit the + /// same lock. To create management locks, you must have access to + /// Microsoft.Authorization/* or Microsoft.Authorization/locks/* actions. Of + /// the built-in roles, only Owner and User Access Administrator are granted + /// those actions. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to lock. + /// + /// + /// The lock name. The lock name can be a maximum of 260 characters. It cannot + /// contain <, > %, &, :, \, ?, /, or any control characters. + /// + /// + /// The management lock parameters. + /// + /// + /// The cancellation token. + /// + public static async Task CreateOrUpdateAtResourceGroupLevelAsync(this IManagementLocksOperations operations, string resourceGroupName, string lockName, ManagementLockObject parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateAtResourceGroupLevelWithHttpMessagesAsync(resourceGroupName, lockName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes a management lock at the resource group level. + /// + /// + /// To delete management locks, you must have access to + /// Microsoft.Authorization/* or Microsoft.Authorization/locks/* actions. Of + /// the built-in roles, only Owner and User Access Administrator are granted + /// those actions. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group containing the lock. + /// + /// + /// The name of lock to delete. + /// + public static void DeleteAtResourceGroupLevel(this IManagementLocksOperations operations, string resourceGroupName, string lockName) + { + operations.DeleteAtResourceGroupLevelAsync(resourceGroupName, lockName).GetAwaiter().GetResult(); + } + + /// + /// Deletes a management lock at the resource group level. + /// + /// + /// To delete management locks, you must have access to + /// Microsoft.Authorization/* or Microsoft.Authorization/locks/* actions. Of + /// the built-in roles, only Owner and User Access Administrator are granted + /// those actions. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group containing the lock. + /// + /// + /// The name of lock to delete. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAtResourceGroupLevelAsync(this IManagementLocksOperations operations, string resourceGroupName, string lockName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteAtResourceGroupLevelWithHttpMessagesAsync(resourceGroupName, lockName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Gets a management lock at the resource group level. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the locked resource group. + /// + /// + /// The name of the lock to get. + /// + public static ManagementLockObject GetAtResourceGroupLevel(this IManagementLocksOperations operations, string resourceGroupName, string lockName) + { + return operations.GetAtResourceGroupLevelAsync(resourceGroupName, lockName).GetAwaiter().GetResult(); + } + + /// + /// Gets a management lock at the resource group level. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the locked resource group. + /// + /// + /// The name of the lock to get. + /// + /// + /// The cancellation token. + /// + public static async Task GetAtResourceGroupLevelAsync(this IManagementLocksOperations operations, string resourceGroupName, string lockName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetAtResourceGroupLevelWithHttpMessagesAsync(resourceGroupName, lockName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Create or update a management lock by scope. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope for the lock. When providing a scope for the assignment, use + /// '/subscriptions/{subscriptionId}' for subscriptions, + /// '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}' for + /// resource groups, and + /// '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePathIfPresent}/{resourceType}/{resourceName}' + /// for resources. + /// + /// + /// The name of lock. + /// + /// + /// Create or update management lock parameters. + /// + public static ManagementLockObject CreateOrUpdateByScope(this IManagementLocksOperations operations, string scope, string lockName, ManagementLockObject parameters) + { + return operations.CreateOrUpdateByScopeAsync(scope, lockName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Create or update a management lock by scope. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope for the lock. When providing a scope for the assignment, use + /// '/subscriptions/{subscriptionId}' for subscriptions, + /// '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}' for + /// resource groups, and + /// '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePathIfPresent}/{resourceType}/{resourceName}' + /// for resources. + /// + /// + /// The name of lock. + /// + /// + /// Create or update management lock parameters. + /// + /// + /// The cancellation token. + /// + public static async Task CreateOrUpdateByScopeAsync(this IManagementLocksOperations operations, string scope, string lockName, ManagementLockObject parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateByScopeWithHttpMessagesAsync(scope, lockName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Delete a management lock by scope. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope for the lock. + /// + /// + /// The name of lock. + /// + public static void DeleteByScope(this IManagementLocksOperations operations, string scope, string lockName) + { + operations.DeleteByScopeAsync(scope, lockName).GetAwaiter().GetResult(); + } + + /// + /// Delete a management lock by scope. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope for the lock. + /// + /// + /// The name of lock. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteByScopeAsync(this IManagementLocksOperations operations, string scope, string lockName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteByScopeWithHttpMessagesAsync(scope, lockName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Get a management lock by scope. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope for the lock. + /// + /// + /// The name of lock. + /// + public static ManagementLockObject GetByScope(this IManagementLocksOperations operations, string scope, string lockName) + { + return operations.GetByScopeAsync(scope, lockName).GetAwaiter().GetResult(); + } + + /// + /// Get a management lock by scope. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope for the lock. + /// + /// + /// The name of lock. + /// + /// + /// The cancellation token. + /// + public static async Task GetByScopeAsync(this IManagementLocksOperations operations, string scope, string lockName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetByScopeWithHttpMessagesAsync(scope, lockName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Creates or updates a management lock at the resource level or any level + /// below the resource. + /// + /// + /// When you apply a lock at a parent scope, all child resources inherit the + /// same lock. To create management locks, you must have access to + /// Microsoft.Authorization/* or Microsoft.Authorization/locks/* actions. Of + /// the built-in roles, only Owner and User Access Administrator are granted + /// those actions. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group containing the resource to lock. + /// + /// + /// The resource provider namespace of the resource to lock. + /// + /// + /// The parent resource identity. + /// + /// + /// The resource type of the resource to lock. + /// + /// + /// The name of the resource to lock. + /// + /// + /// The name of lock. The lock name can be a maximum of 260 characters. It + /// cannot contain <, > %, &, :, \, ?, /, or any control characters. + /// + /// + /// Parameters for creating or updating a management lock. + /// + public static ManagementLockObject CreateOrUpdateAtResourceLevel(this IManagementLocksOperations operations, string resourceGroupName, string resourceProviderNamespace, string parentResourcePath, string resourceType, string resourceName, string lockName, ManagementLockObject parameters) + { + return operations.CreateOrUpdateAtResourceLevelAsync(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, lockName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Creates or updates a management lock at the resource level or any level + /// below the resource. + /// + /// + /// When you apply a lock at a parent scope, all child resources inherit the + /// same lock. To create management locks, you must have access to + /// Microsoft.Authorization/* or Microsoft.Authorization/locks/* actions. Of + /// the built-in roles, only Owner and User Access Administrator are granted + /// those actions. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group containing the resource to lock. + /// + /// + /// The resource provider namespace of the resource to lock. + /// + /// + /// The parent resource identity. + /// + /// + /// The resource type of the resource to lock. + /// + /// + /// The name of the resource to lock. + /// + /// + /// The name of lock. The lock name can be a maximum of 260 characters. It + /// cannot contain <, > %, &, :, \, ?, /, or any control characters. + /// + /// + /// Parameters for creating or updating a management lock. + /// + /// + /// The cancellation token. + /// + public static async Task CreateOrUpdateAtResourceLevelAsync(this IManagementLocksOperations operations, string resourceGroupName, string resourceProviderNamespace, string parentResourcePath, string resourceType, string resourceName, string lockName, ManagementLockObject parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateAtResourceLevelWithHttpMessagesAsync(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, lockName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes the management lock of a resource or any level below the resource. + /// + /// + /// To delete management locks, you must have access to + /// Microsoft.Authorization/* or Microsoft.Authorization/locks/* actions. Of + /// the built-in roles, only Owner and User Access Administrator are granted + /// those actions. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group containing the resource with the lock to + /// delete. + /// + /// + /// The resource provider namespace of the resource with the lock to delete. + /// + /// + /// The parent resource identity. + /// + /// + /// The resource type of the resource with the lock to delete. + /// + /// + /// The name of the resource with the lock to delete. + /// + /// + /// The name of the lock to delete. + /// + public static void DeleteAtResourceLevel(this IManagementLocksOperations operations, string resourceGroupName, string resourceProviderNamespace, string parentResourcePath, string resourceType, string resourceName, string lockName) + { + operations.DeleteAtResourceLevelAsync(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, lockName).GetAwaiter().GetResult(); + } + + /// + /// Deletes the management lock of a resource or any level below the resource. + /// + /// + /// To delete management locks, you must have access to + /// Microsoft.Authorization/* or Microsoft.Authorization/locks/* actions. Of + /// the built-in roles, only Owner and User Access Administrator are granted + /// those actions. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group containing the resource with the lock to + /// delete. + /// + /// + /// The resource provider namespace of the resource with the lock to delete. + /// + /// + /// The parent resource identity. + /// + /// + /// The resource type of the resource with the lock to delete. + /// + /// + /// The name of the resource with the lock to delete. + /// + /// + /// The name of the lock to delete. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAtResourceLevelAsync(this IManagementLocksOperations operations, string resourceGroupName, string resourceProviderNamespace, string parentResourcePath, string resourceType, string resourceName, string lockName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteAtResourceLevelWithHttpMessagesAsync(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, lockName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Get the management lock of a resource or any level below resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The namespace of the resource provider. + /// + /// + /// An extra path parameter needed in some services, like SQL Databases. + /// + /// + /// The type of the resource. + /// + /// + /// The name of the resource. + /// + /// + /// The name of lock. + /// + public static ManagementLockObject GetAtResourceLevel(this IManagementLocksOperations operations, string resourceGroupName, string resourceProviderNamespace, string parentResourcePath, string resourceType, string resourceName, string lockName) + { + return operations.GetAtResourceLevelAsync(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, lockName).GetAwaiter().GetResult(); + } + + /// + /// Get the management lock of a resource or any level below resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The namespace of the resource provider. + /// + /// + /// An extra path parameter needed in some services, like SQL Databases. + /// + /// + /// The type of the resource. + /// + /// + /// The name of the resource. + /// + /// + /// The name of lock. + /// + /// + /// The cancellation token. + /// + public static async Task GetAtResourceLevelAsync(this IManagementLocksOperations operations, string resourceGroupName, string resourceProviderNamespace, string parentResourcePath, string resourceType, string resourceName, string lockName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetAtResourceLevelWithHttpMessagesAsync(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, lockName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Creates or updates a management lock at the subscription level. + /// + /// + /// When you apply a lock at a parent scope, all child resources inherit the + /// same lock. To create management locks, you must have access to + /// Microsoft.Authorization/* or Microsoft.Authorization/locks/* actions. Of + /// the built-in roles, only Owner and User Access Administrator are granted + /// those actions. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of lock. The lock name can be a maximum of 260 characters. It + /// cannot contain <, > %, &, :, \, ?, /, or any control characters. + /// + /// + /// The management lock parameters. + /// + public static ManagementLockObject CreateOrUpdateAtSubscriptionLevel(this IManagementLocksOperations operations, string lockName, ManagementLockObject parameters) + { + return operations.CreateOrUpdateAtSubscriptionLevelAsync(lockName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Creates or updates a management lock at the subscription level. + /// + /// + /// When you apply a lock at a parent scope, all child resources inherit the + /// same lock. To create management locks, you must have access to + /// Microsoft.Authorization/* or Microsoft.Authorization/locks/* actions. Of + /// the built-in roles, only Owner and User Access Administrator are granted + /// those actions. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of lock. The lock name can be a maximum of 260 characters. It + /// cannot contain <, > %, &, :, \, ?, /, or any control characters. + /// + /// + /// The management lock parameters. + /// + /// + /// The cancellation token. + /// + public static async Task CreateOrUpdateAtSubscriptionLevelAsync(this IManagementLocksOperations operations, string lockName, ManagementLockObject parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateAtSubscriptionLevelWithHttpMessagesAsync(lockName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes the management lock at the subscription level. + /// + /// + /// To delete management locks, you must have access to + /// Microsoft.Authorization/* or Microsoft.Authorization/locks/* actions. Of + /// the built-in roles, only Owner and User Access Administrator are granted + /// those actions. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of lock to delete. + /// + public static void DeleteAtSubscriptionLevel(this IManagementLocksOperations operations, string lockName) + { + operations.DeleteAtSubscriptionLevelAsync(lockName).GetAwaiter().GetResult(); + } + + /// + /// Deletes the management lock at the subscription level. + /// + /// + /// To delete management locks, you must have access to + /// Microsoft.Authorization/* or Microsoft.Authorization/locks/* actions. Of + /// the built-in roles, only Owner and User Access Administrator are granted + /// those actions. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of lock to delete. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAtSubscriptionLevelAsync(this IManagementLocksOperations operations, string lockName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteAtSubscriptionLevelWithHttpMessagesAsync(lockName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Gets a management lock at the subscription level. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the lock to get. + /// + public static ManagementLockObject GetAtSubscriptionLevel(this IManagementLocksOperations operations, string lockName) + { + return operations.GetAtSubscriptionLevelAsync(lockName).GetAwaiter().GetResult(); + } + + /// + /// Gets a management lock at the subscription level. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the lock to get. + /// + /// + /// The cancellation token. + /// + public static async Task GetAtSubscriptionLevelAsync(this IManagementLocksOperations operations, string lockName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetAtSubscriptionLevelWithHttpMessagesAsync(lockName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets all the management locks for a resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group containing the locks to get. + /// + /// + /// OData parameters to apply to the operation. + /// + public static IPage ListAtResourceGroupLevel(this IManagementLocksOperations operations, string resourceGroupName, ODataQuery odataQuery = default(ODataQuery)) + { + return operations.ListAtResourceGroupLevelAsync(resourceGroupName, odataQuery).GetAwaiter().GetResult(); + } + + /// + /// Gets all the management locks for a resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group containing the locks to get. + /// + /// + /// OData parameters to apply to the operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAtResourceGroupLevelAsync(this IManagementLocksOperations operations, string resourceGroupName, ODataQuery odataQuery = default(ODataQuery), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListAtResourceGroupLevelWithHttpMessagesAsync(resourceGroupName, odataQuery, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets all the management locks for a resource or any level below resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group containing the locked resource. The name is + /// case insensitive. + /// + /// + /// The namespace of the resource provider. + /// + /// + /// The parent resource identity. + /// + /// + /// The resource type of the locked resource. + /// + /// + /// The name of the locked resource. + /// + /// + /// OData parameters to apply to the operation. + /// + public static IPage ListAtResourceLevel(this IManagementLocksOperations operations, string resourceGroupName, string resourceProviderNamespace, string parentResourcePath, string resourceType, string resourceName, ODataQuery odataQuery = default(ODataQuery)) + { + return operations.ListAtResourceLevelAsync(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, odataQuery).GetAwaiter().GetResult(); + } + + /// + /// Gets all the management locks for a resource or any level below resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group containing the locked resource. The name is + /// case insensitive. + /// + /// + /// The namespace of the resource provider. + /// + /// + /// The parent resource identity. + /// + /// + /// The resource type of the locked resource. + /// + /// + /// The name of the locked resource. + /// + /// + /// OData parameters to apply to the operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAtResourceLevelAsync(this IManagementLocksOperations operations, string resourceGroupName, string resourceProviderNamespace, string parentResourcePath, string resourceType, string resourceName, ODataQuery odataQuery = default(ODataQuery), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListAtResourceLevelWithHttpMessagesAsync(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, odataQuery, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets all the management locks for a subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// OData parameters to apply to the operation. + /// + public static IPage ListAtSubscriptionLevel(this IManagementLocksOperations operations, ODataQuery odataQuery = default(ODataQuery)) + { + return operations.ListAtSubscriptionLevelAsync(odataQuery).GetAwaiter().GetResult(); + } + + /// + /// Gets all the management locks for a subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// OData parameters to apply to the operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAtSubscriptionLevelAsync(this IManagementLocksOperations operations, ODataQuery odataQuery = default(ODataQuery), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListAtSubscriptionLevelWithHttpMessagesAsync(odataQuery, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets all the management locks for a scope. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope for the lock. When providing a scope for the assignment, use + /// '/subscriptions/{subscriptionId}' for subscriptions, + /// '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}' for + /// resource groups, and + /// '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePathIfPresent}/{resourceType}/{resourceName}' + /// for resources. + /// + /// + /// OData parameters to apply to the operation. + /// + public static IPage ListByScope(this IManagementLocksOperations operations, string scope, ODataQuery odataQuery = default(ODataQuery)) + { + return operations.ListByScopeAsync(scope, odataQuery).GetAwaiter().GetResult(); + } + + /// + /// Gets all the management locks for a scope. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope for the lock. When providing a scope for the assignment, use + /// '/subscriptions/{subscriptionId}' for subscriptions, + /// '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}' for + /// resource groups, and + /// '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePathIfPresent}/{resourceType}/{resourceName}' + /// for resources. + /// + /// + /// OData parameters to apply to the operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByScopeAsync(this IManagementLocksOperations operations, string scope, ODataQuery odataQuery = default(ODataQuery), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByScopeWithHttpMessagesAsync(scope, odataQuery, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets all the management locks for a resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListAtResourceGroupLevelNext(this IManagementLocksOperations operations, string nextPageLink) + { + return operations.ListAtResourceGroupLevelNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Gets all the management locks for 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> ListAtResourceGroupLevelNextAsync(this IManagementLocksOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListAtResourceGroupLevelNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets all the management locks for a resource or any level below resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListAtResourceLevelNext(this IManagementLocksOperations operations, string nextPageLink) + { + return operations.ListAtResourceLevelNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Gets all the management locks for a resource or any level below resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAtResourceLevelNextAsync(this IManagementLocksOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListAtResourceLevelNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets all the management locks for a subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListAtSubscriptionLevelNext(this IManagementLocksOperations operations, string nextPageLink) + { + return operations.ListAtSubscriptionLevelNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Gets all the management locks for 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> ListAtSubscriptionLevelNextAsync(this IManagementLocksOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListAtSubscriptionLevelNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets all the management locks for a scope. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListByScopeNext(this IManagementLocksOperations operations, string nextPageLink) + { + return operations.ListByScopeNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Gets all the management locks for a scope. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByScopeNextAsync(this IManagementLocksOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByScopeNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/Alias.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/Alias.cs new file mode 100644 index 0000000000000..586f96ec93902 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/Alias.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.ResourceManager.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The alias type. + /// + public partial class Alias + { + /// + /// Initializes a new instance of the Alias class. + /// + public Alias() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Alias class. + /// + /// The alias name. + /// The paths for an alias. + /// The type of the alias. Possible values include: + /// 'NotSpecified', 'PlainText', 'Mask' + /// The default path for an alias. + /// The default pattern for an + /// alias. + /// The default alias path metadata. + /// Applies to the default path and to any alias path that doesn't have + /// metadata + public Alias(string name = default(string), IList paths = default(IList), AliasType? type = default(AliasType?), string defaultPath = default(string), AliasPattern defaultPattern = default(AliasPattern), AliasPathMetadata defaultMetadata = default(AliasPathMetadata)) + { + Name = name; + Paths = paths; + Type = type; + DefaultPath = defaultPath; + DefaultPattern = defaultPattern; + DefaultMetadata = defaultMetadata; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the alias name. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Gets or sets the paths for an alias. + /// + [JsonProperty(PropertyName = "paths")] + public IList Paths { get; set; } + + /// + /// Gets or sets the type of the alias. Possible values include: + /// 'NotSpecified', 'PlainText', 'Mask' + /// + [JsonProperty(PropertyName = "type")] + public AliasType? Type { get; set; } + + /// + /// Gets or sets the default path for an alias. + /// + [JsonProperty(PropertyName = "defaultPath")] + public string DefaultPath { get; set; } + + /// + /// Gets or sets the default pattern for an alias. + /// + [JsonProperty(PropertyName = "defaultPattern")] + public AliasPattern DefaultPattern { get; set; } + + /// + /// Gets the default alias path metadata. Applies to the default path + /// and to any alias path that doesn't have metadata + /// + [JsonProperty(PropertyName = "defaultMetadata")] + public AliasPathMetadata DefaultMetadata { get; private set; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/AliasPath.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/AliasPath.cs new file mode 100644 index 0000000000000..e77e23be94d23 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/AliasPath.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.ResourceManager.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The type of the paths for alias. + /// + public partial class AliasPath + { + /// + /// Initializes a new instance of the AliasPath class. + /// + public AliasPath() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the AliasPath class. + /// + /// The path of an alias. + /// The API versions. + /// The pattern for an alias path. + /// The metadata of the alias path. If missing, + /// fall back to the default metadata of the alias. + public AliasPath(string path = default(string), IList apiVersions = default(IList), AliasPattern pattern = default(AliasPattern), AliasPathMetadata metadata = default(AliasPathMetadata)) + { + Path = path; + ApiVersions = apiVersions; + Pattern = pattern; + Metadata = metadata; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the path of an alias. + /// + [JsonProperty(PropertyName = "path")] + public string Path { get; set; } + + /// + /// Gets or sets the API versions. + /// + [JsonProperty(PropertyName = "apiVersions")] + public IList ApiVersions { get; set; } + + /// + /// Gets or sets the pattern for an alias path. + /// + [JsonProperty(PropertyName = "pattern")] + public AliasPattern Pattern { get; set; } + + /// + /// Gets the metadata of the alias path. If missing, fall back to the + /// default metadata of the alias. + /// + [JsonProperty(PropertyName = "metadata")] + public AliasPathMetadata Metadata { get; private set; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/AliasPathAttributes.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/AliasPathAttributes.cs new file mode 100644 index 0000000000000..95f7f1812b76e --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/AliasPathAttributes.cs @@ -0,0 +1,29 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager.Models +{ + + /// + /// Defines values for AliasPathAttributes. + /// + public static class AliasPathAttributes + { + /// + /// The token that the alias path is referring to has no attributes. + /// + public const string None = "None"; + /// + /// The token that the alias path is referring to is modifiable by + /// policies with 'modify' effect. + /// + public const string Modifiable = "Modifiable"; + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/AliasPathMetadata.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/AliasPathMetadata.cs new file mode 100644 index 0000000000000..1825f6e635cf0 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/AliasPathMetadata.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.ResourceManager.Models +{ + using Newtonsoft.Json; + using System.Linq; + + public partial class AliasPathMetadata + { + /// + /// Initializes a new instance of the AliasPathMetadata class. + /// + public AliasPathMetadata() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the AliasPathMetadata class. + /// + /// The type of the token that the alias path is + /// referring to. Possible values include: 'NotSpecified', 'Any', + /// 'String', 'Object', 'Array', 'Integer', 'Number', 'Boolean' + /// The attributes of the token that the alias + /// path is referring to. Possible values include: 'None', + /// 'Modifiable' + public AliasPathMetadata(string type = default(string), string attributes = default(string)) + { + Type = type; + Attributes = attributes; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the type of the token that the alias path is referring to. + /// Possible values include: 'NotSpecified', 'Any', 'String', 'Object', + /// 'Array', 'Integer', 'Number', 'Boolean' + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; private set; } + + /// + /// Gets the attributes of the token that the alias path is referring + /// to. Possible values include: 'None', 'Modifiable' + /// + [JsonProperty(PropertyName = "attributes")] + public string Attributes { get; private set; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/AliasPathTokenType.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/AliasPathTokenType.cs new file mode 100644 index 0000000000000..d6872ec13c300 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/AliasPathTokenType.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.ResourceManager.Models +{ + + /// + /// Defines values for AliasPathTokenType. + /// + public static class AliasPathTokenType + { + /// + /// The token type is not specified. + /// + public const string NotSpecified = "NotSpecified"; + /// + /// The token type can be anything. + /// + public const string Any = "Any"; + /// + /// The token type is string. + /// + public const string String = "String"; + /// + /// The token type is object. + /// + public const string Object = "Object"; + /// + /// The token type is array. + /// + public const string Array = "Array"; + /// + /// The token type is integer. + /// + public const string Integer = "Integer"; + /// + /// The token type is number. + /// + public const string Number = "Number"; + /// + /// The token type is boolean. + /// + public const string Boolean = "Boolean"; + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/AliasPattern.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/AliasPattern.cs new file mode 100644 index 0000000000000..224944423d3bb --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/AliasPattern.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.ResourceManager.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The type of the pattern for an alias path. + /// + public partial class AliasPattern + { + /// + /// Initializes a new instance of the AliasPattern class. + /// + public AliasPattern() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the AliasPattern class. + /// + /// The alias pattern phrase. + /// The alias pattern variable. + /// The type of alias pattern. Possible values + /// include: 'NotSpecified', 'Extract' + public AliasPattern(string phrase = default(string), string variable = default(string), AliasPatternType? type = default(AliasPatternType?)) + { + Phrase = phrase; + Variable = variable; + Type = type; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the alias pattern phrase. + /// + [JsonProperty(PropertyName = "phrase")] + public string Phrase { get; set; } + + /// + /// Gets or sets the alias pattern variable. + /// + [JsonProperty(PropertyName = "variable")] + public string Variable { get; set; } + + /// + /// Gets or sets the type of alias pattern. Possible values include: + /// 'NotSpecified', 'Extract' + /// + [JsonProperty(PropertyName = "type")] + public AliasPatternType? Type { get; set; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/AliasPatternType.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/AliasPatternType.cs new file mode 100644 index 0000000000000..dc764ea101764 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/AliasPatternType.cs @@ -0,0 +1,66 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager.Models +{ + using Newtonsoft.Json; + using Newtonsoft.Json.Converters; + using System.Runtime; + using System.Runtime.Serialization; + + /// + /// Defines values for AliasPatternType. + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum AliasPatternType + { + /// + /// NotSpecified is not allowed. + /// + [EnumMember(Value = "NotSpecified")] + NotSpecified, + /// + /// Extract is the only allowed value. + /// + [EnumMember(Value = "Extract")] + Extract + } + internal static class AliasPatternTypeEnumExtension + { + internal static string ToSerializedValue(this AliasPatternType? value) + { + return value == null ? null : ((AliasPatternType)value).ToSerializedValue(); + } + + internal static string ToSerializedValue(this AliasPatternType value) + { + switch( value ) + { + case AliasPatternType.NotSpecified: + return "NotSpecified"; + case AliasPatternType.Extract: + return "Extract"; + } + return null; + } + + internal static AliasPatternType? ParseAliasPatternType(this string value) + { + switch( value ) + { + case "NotSpecified": + return AliasPatternType.NotSpecified; + case "Extract": + return AliasPatternType.Extract; + } + return null; + } + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/AliasType.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/AliasType.cs new file mode 100644 index 0000000000000..482cd058fb910 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/AliasType.cs @@ -0,0 +1,75 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager.Models +{ + using Newtonsoft.Json; + using Newtonsoft.Json.Converters; + using System.Runtime; + using System.Runtime.Serialization; + + /// + /// Defines values for AliasType. + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum AliasType + { + /// + /// Alias type is unknown (same as not providing alias type). + /// + [EnumMember(Value = "NotSpecified")] + NotSpecified, + /// + /// Alias value is not secret. + /// + [EnumMember(Value = "PlainText")] + PlainText, + /// + /// Alias value is secret. + /// + [EnumMember(Value = "Mask")] + Mask + } + internal static class AliasTypeEnumExtension + { + internal static string ToSerializedValue(this AliasType? value) + { + return value == null ? null : ((AliasType)value).ToSerializedValue(); + } + + internal static string ToSerializedValue(this AliasType value) + { + switch( value ) + { + case AliasType.NotSpecified: + return "NotSpecified"; + case AliasType.PlainText: + return "PlainText"; + case AliasType.Mask: + return "Mask"; + } + return null; + } + + internal static AliasType? ParseAliasType(this string value) + { + switch( value ) + { + case "NotSpecified": + return AliasType.NotSpecified; + case "PlainText": + return AliasType.PlainText; + case "Mask": + return AliasType.Mask; + } + return null; + } + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ApiProfile.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ApiProfile.cs new file mode 100644 index 0000000000000..2ff4ca3275714 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ApiProfile.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.ResourceManager.Models +{ + using Newtonsoft.Json; + using System.Linq; + + public partial class ApiProfile + { + /// + /// Initializes a new instance of the ApiProfile class. + /// + public ApiProfile() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ApiProfile class. + /// + /// The profile version. + /// The API version. + public ApiProfile(string profileVersion = default(string), string apiVersion = default(string)) + { + ProfileVersion = profileVersion; + ApiVersion = apiVersion; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the profile version. + /// + [JsonProperty(PropertyName = "profileVersion")] + public string ProfileVersion { get; private set; } + + /// + /// Gets the API version. + /// + [JsonProperty(PropertyName = "apiVersion")] + public string ApiVersion { get; private set; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/AuthorizationProfile.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/AuthorizationProfile.cs new file mode 100644 index 0000000000000..7840550d6a730 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/AuthorizationProfile.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.ResourceManager.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Authorization Profile + /// + public partial class AuthorizationProfile + { + /// + /// Initializes a new instance of the AuthorizationProfile class. + /// + public AuthorizationProfile() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the AuthorizationProfile class. + /// + /// The requested time + /// The requester + /// The requester object id + /// The approved time + /// The approver + public AuthorizationProfile(System.DateTime? requestedTime = default(System.DateTime?), string requester = default(string), string requesterObjectId = default(string), System.DateTime? approvedTime = default(System.DateTime?), string approver = default(string)) + { + RequestedTime = requestedTime; + Requester = requester; + RequesterObjectId = requesterObjectId; + ApprovedTime = approvedTime; + Approver = approver; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the requested time + /// + [JsonProperty(PropertyName = "requestedTime")] + public System.DateTime? RequestedTime { get; private set; } + + /// + /// Gets the requester + /// + [JsonProperty(PropertyName = "requester")] + public string Requester { get; private set; } + + /// + /// Gets the requester object id + /// + [JsonProperty(PropertyName = "requesterObjectId")] + public string RequesterObjectId { get; private set; } + + /// + /// Gets the approved time + /// + [JsonProperty(PropertyName = "approvedTime")] + public System.DateTime? ApprovedTime { get; private set; } + + /// + /// Gets the approver + /// + [JsonProperty(PropertyName = "approver")] + public string Approver { get; private set; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/AvailabilityZonePeers.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/AvailabilityZonePeers.cs new file mode 100644 index 0000000000000..2920b2a731c00 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/AvailabilityZonePeers.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.ResourceManager.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// List of availability zones shared by the subscriptions. + /// + public partial class AvailabilityZonePeers + { + /// + /// Initializes a new instance of the AvailabilityZonePeers class. + /// + public AvailabilityZonePeers() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the AvailabilityZonePeers class. + /// + /// The availabilityZone. + /// Details of shared availability zone. + public AvailabilityZonePeers(string availabilityZone = default(string), IList peers = default(IList)) + { + AvailabilityZone = availabilityZone; + Peers = peers; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the availabilityZone. + /// + [JsonProperty(PropertyName = "availabilityZone")] + public string AvailabilityZone { get; private set; } + + /// + /// Gets or sets details of shared availability zone. + /// + [JsonProperty(PropertyName = "peers")] + public IList Peers { get; set; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/AzureCliScript.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/AzureCliScript.cs new file mode 100644 index 0000000000000..a1fb85ae59e2c --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/AzureCliScript.cs @@ -0,0 +1,244 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Object model for the Azure CLI script. + /// + [Newtonsoft.Json.JsonObject("AzureCLI")] + [Rest.Serialization.JsonTransformation] + public partial class AzureCliScript : DeploymentScript + { + /// + /// Initializes a new instance of the AzureCliScript class. + /// + public AzureCliScript() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the AzureCliScript class. + /// + /// The location of the ACI and the storage + /// account for the deployment script. + /// Interval for which the service + /// retains the script resource after it reaches a terminal state. + /// Resource will be deleted when this duration expires. Duration is + /// based on ISO 8601 pattern (for example P1D means one day). + /// Azure CLI module version to be + /// used. + /// String Id used to locate any resource on + /// Azure. + /// Name of this resource. + /// Type of this resource. + /// Optional property. Managed identity to be + /// used for this deployment script. Currently, only user-assigned MSI + /// is supported. + /// Resource tags. + /// The system metadata related to this + /// resource. + /// Container settings. + /// Storage Account + /// settings. + /// The clean up preference when the + /// script execution gets in a terminal state. Default setting is + /// 'Always'. Possible values include: 'Always', 'OnSuccess', + /// 'OnExpiration' + /// State of the script execution. This + /// only appears in the response. Possible values include: 'Creating', + /// 'ProvisioningResources', 'Running', 'Succeeded', 'Failed', + /// 'Canceled' + /// Contains the results of script + /// execution. + /// List of script outputs. + /// Uri for the script. This is the + /// entry point for the external script. + /// Supporting files for the + /// external script. + /// Script body. + /// Command line arguments to pass to the + /// script. Arguments are separated by spaces. ex: -Name blue* + /// -Location 'West US 2' + /// The environment variables to + /// pass over to the script. + /// Gets or sets how the deployment script + /// should be forced to execute even if the script resource has not + /// changed. Can be current time stamp or a GUID. + /// Maximum allowed script execution time + /// specified in ISO 8601 format. Default value is P1D + public AzureCliScript(string location, System.TimeSpan retentionInterval, string azCliVersion, string id = default(string), string name = default(string), string type = default(string), ManagedServiceIdentity identity = default(ManagedServiceIdentity), IDictionary tags = default(IDictionary), SystemData systemData = default(SystemData), ContainerConfiguration containerSettings = default(ContainerConfiguration), StorageAccountConfiguration storageAccountSettings = default(StorageAccountConfiguration), string cleanupPreference = default(string), string provisioningState = default(string), ScriptStatus status = default(ScriptStatus), IDictionary outputs = default(IDictionary), string primaryScriptUri = default(string), IList supportingScriptUris = default(IList), string scriptContent = default(string), string arguments = default(string), IList environmentVariables = default(IList), string forceUpdateTag = default(string), System.TimeSpan? timeout = default(System.TimeSpan?)) + : base(location, id, name, type, identity, tags, systemData) + { + ContainerSettings = containerSettings; + StorageAccountSettings = storageAccountSettings; + CleanupPreference = cleanupPreference; + ProvisioningState = provisioningState; + Status = status; + Outputs = outputs; + PrimaryScriptUri = primaryScriptUri; + SupportingScriptUris = supportingScriptUris; + ScriptContent = scriptContent; + Arguments = arguments; + EnvironmentVariables = environmentVariables; + ForceUpdateTag = forceUpdateTag; + RetentionInterval = retentionInterval; + Timeout = timeout; + AzCliVersion = azCliVersion; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets container settings. + /// + [JsonProperty(PropertyName = "properties.containerSettings")] + public ContainerConfiguration ContainerSettings { get; set; } + + /// + /// Gets or sets storage Account settings. + /// + [JsonProperty(PropertyName = "properties.storageAccountSettings")] + public StorageAccountConfiguration StorageAccountSettings { get; set; } + + /// + /// Gets or sets the clean up preference when the script execution gets + /// in a terminal state. Default setting is 'Always'. Possible values + /// include: 'Always', 'OnSuccess', 'OnExpiration' + /// + [JsonProperty(PropertyName = "properties.cleanupPreference")] + public string CleanupPreference { get; set; } + + /// + /// Gets state of the script execution. This only appears in the + /// response. Possible values include: 'Creating', + /// 'ProvisioningResources', 'Running', 'Succeeded', 'Failed', + /// 'Canceled' + /// + [JsonProperty(PropertyName = "properties.provisioningState")] + public string ProvisioningState { get; private set; } + + /// + /// Gets contains the results of script execution. + /// + [JsonProperty(PropertyName = "properties.status")] + public ScriptStatus Status { get; private set; } + + /// + /// Gets list of script outputs. + /// + [JsonProperty(PropertyName = "properties.outputs")] + public IDictionary Outputs { get; private set; } + + /// + /// Gets or sets uri for the script. This is the entry point for the + /// external script. + /// + [JsonProperty(PropertyName = "properties.primaryScriptUri")] + public string PrimaryScriptUri { get; set; } + + /// + /// Gets or sets supporting files for the external script. + /// + [JsonProperty(PropertyName = "properties.supportingScriptUris")] + public IList SupportingScriptUris { get; set; } + + /// + /// Gets or sets script body. + /// + [JsonProperty(PropertyName = "properties.scriptContent")] + public string ScriptContent { get; set; } + + /// + /// Gets or sets command line arguments to pass to the script. + /// Arguments are separated by spaces. ex: -Name blue* -Location 'West + /// US 2' + /// + [JsonProperty(PropertyName = "properties.arguments")] + public string Arguments { get; set; } + + /// + /// Gets or sets the environment variables to pass over to the script. + /// + [JsonProperty(PropertyName = "properties.environmentVariables")] + public IList EnvironmentVariables { get; set; } + + /// + /// Gets or sets how the deployment script should be forced to execute + /// even if the script resource has not changed. Can be current time + /// stamp or a GUID. + /// + [JsonProperty(PropertyName = "properties.forceUpdateTag")] + public string ForceUpdateTag { get; set; } + + /// + /// Gets or sets interval for which the service retains the script + /// resource after it reaches a terminal state. Resource will be + /// deleted when this duration expires. Duration is based on ISO 8601 + /// pattern (for example P1D means one day). + /// + [JsonProperty(PropertyName = "properties.retentionInterval")] + public System.TimeSpan RetentionInterval { get; set; } + + /// + /// Gets or sets maximum allowed script execution time specified in ISO + /// 8601 format. Default value is P1D + /// + [JsonProperty(PropertyName = "properties.timeout")] + public System.TimeSpan? Timeout { get; set; } + + /// + /// Gets or sets azure CLI module version to be used. + /// + [JsonProperty(PropertyName = "properties.azCliVersion")] + public string AzCliVersion { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public override void Validate() + { + base.Validate(); + if (AzCliVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "AzCliVersion"); + } + if (ContainerSettings != null) + { + ContainerSettings.Validate(); + } + if (EnvironmentVariables != null) + { + foreach (var element in EnvironmentVariables) + { + if (element != null) + { + element.Validate(); + } + } + } + } + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/AzurePowerShellScript.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/AzurePowerShellScript.cs new file mode 100644 index 0000000000000..8c3f8e6dad0d8 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/AzurePowerShellScript.cs @@ -0,0 +1,244 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Object model for the Azure PowerShell script. + /// + [Newtonsoft.Json.JsonObject("AzurePowerShell")] + [Rest.Serialization.JsonTransformation] + public partial class AzurePowerShellScript : DeploymentScript + { + /// + /// Initializes a new instance of the AzurePowerShellScript class. + /// + public AzurePowerShellScript() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the AzurePowerShellScript class. + /// + /// The location of the ACI and the storage + /// account for the deployment script. + /// Interval for which the service + /// retains the script resource after it reaches a terminal state. + /// Resource will be deleted when this duration expires. Duration is + /// based on ISO 8601 pattern (for example P1D means one day). + /// Azure PowerShell module version + /// to be used. + /// String Id used to locate any resource on + /// Azure. + /// Name of this resource. + /// Type of this resource. + /// Optional property. Managed identity to be + /// used for this deployment script. Currently, only user-assigned MSI + /// is supported. + /// Resource tags. + /// The system metadata related to this + /// resource. + /// Container settings. + /// Storage Account + /// settings. + /// The clean up preference when the + /// script execution gets in a terminal state. Default setting is + /// 'Always'. Possible values include: 'Always', 'OnSuccess', + /// 'OnExpiration' + /// State of the script execution. This + /// only appears in the response. Possible values include: 'Creating', + /// 'ProvisioningResources', 'Running', 'Succeeded', 'Failed', + /// 'Canceled' + /// Contains the results of script + /// execution. + /// List of script outputs. + /// Uri for the script. This is the + /// entry point for the external script. + /// Supporting files for the + /// external script. + /// Script body. + /// Command line arguments to pass to the + /// script. Arguments are separated by spaces. ex: -Name blue* + /// -Location 'West US 2' + /// The environment variables to + /// pass over to the script. + /// Gets or sets how the deployment script + /// should be forced to execute even if the script resource has not + /// changed. Can be current time stamp or a GUID. + /// Maximum allowed script execution time + /// specified in ISO 8601 format. Default value is P1D + public AzurePowerShellScript(string location, System.TimeSpan retentionInterval, string azPowerShellVersion, string id = default(string), string name = default(string), string type = default(string), ManagedServiceIdentity identity = default(ManagedServiceIdentity), IDictionary tags = default(IDictionary), SystemData systemData = default(SystemData), ContainerConfiguration containerSettings = default(ContainerConfiguration), StorageAccountConfiguration storageAccountSettings = default(StorageAccountConfiguration), string cleanupPreference = default(string), string provisioningState = default(string), ScriptStatus status = default(ScriptStatus), IDictionary outputs = default(IDictionary), string primaryScriptUri = default(string), IList supportingScriptUris = default(IList), string scriptContent = default(string), string arguments = default(string), IList environmentVariables = default(IList), string forceUpdateTag = default(string), System.TimeSpan? timeout = default(System.TimeSpan?)) + : base(location, id, name, type, identity, tags, systemData) + { + ContainerSettings = containerSettings; + StorageAccountSettings = storageAccountSettings; + CleanupPreference = cleanupPreference; + ProvisioningState = provisioningState; + Status = status; + Outputs = outputs; + PrimaryScriptUri = primaryScriptUri; + SupportingScriptUris = supportingScriptUris; + ScriptContent = scriptContent; + Arguments = arguments; + EnvironmentVariables = environmentVariables; + ForceUpdateTag = forceUpdateTag; + RetentionInterval = retentionInterval; + Timeout = timeout; + AzPowerShellVersion = azPowerShellVersion; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets container settings. + /// + [JsonProperty(PropertyName = "properties.containerSettings")] + public ContainerConfiguration ContainerSettings { get; set; } + + /// + /// Gets or sets storage Account settings. + /// + [JsonProperty(PropertyName = "properties.storageAccountSettings")] + public StorageAccountConfiguration StorageAccountSettings { get; set; } + + /// + /// Gets or sets the clean up preference when the script execution gets + /// in a terminal state. Default setting is 'Always'. Possible values + /// include: 'Always', 'OnSuccess', 'OnExpiration' + /// + [JsonProperty(PropertyName = "properties.cleanupPreference")] + public string CleanupPreference { get; set; } + + /// + /// Gets state of the script execution. This only appears in the + /// response. Possible values include: 'Creating', + /// 'ProvisioningResources', 'Running', 'Succeeded', 'Failed', + /// 'Canceled' + /// + [JsonProperty(PropertyName = "properties.provisioningState")] + public string ProvisioningState { get; private set; } + + /// + /// Gets contains the results of script execution. + /// + [JsonProperty(PropertyName = "properties.status")] + public ScriptStatus Status { get; private set; } + + /// + /// Gets list of script outputs. + /// + [JsonProperty(PropertyName = "properties.outputs")] + public IDictionary Outputs { get; private set; } + + /// + /// Gets or sets uri for the script. This is the entry point for the + /// external script. + /// + [JsonProperty(PropertyName = "properties.primaryScriptUri")] + public string PrimaryScriptUri { get; set; } + + /// + /// Gets or sets supporting files for the external script. + /// + [JsonProperty(PropertyName = "properties.supportingScriptUris")] + public IList SupportingScriptUris { get; set; } + + /// + /// Gets or sets script body. + /// + [JsonProperty(PropertyName = "properties.scriptContent")] + public string ScriptContent { get; set; } + + /// + /// Gets or sets command line arguments to pass to the script. + /// Arguments are separated by spaces. ex: -Name blue* -Location 'West + /// US 2' + /// + [JsonProperty(PropertyName = "properties.arguments")] + public string Arguments { get; set; } + + /// + /// Gets or sets the environment variables to pass over to the script. + /// + [JsonProperty(PropertyName = "properties.environmentVariables")] + public IList EnvironmentVariables { get; set; } + + /// + /// Gets or sets how the deployment script should be forced to execute + /// even if the script resource has not changed. Can be current time + /// stamp or a GUID. + /// + [JsonProperty(PropertyName = "properties.forceUpdateTag")] + public string ForceUpdateTag { get; set; } + + /// + /// Gets or sets interval for which the service retains the script + /// resource after it reaches a terminal state. Resource will be + /// deleted when this duration expires. Duration is based on ISO 8601 + /// pattern (for example P1D means one day). + /// + [JsonProperty(PropertyName = "properties.retentionInterval")] + public System.TimeSpan RetentionInterval { get; set; } + + /// + /// Gets or sets maximum allowed script execution time specified in ISO + /// 8601 format. Default value is P1D + /// + [JsonProperty(PropertyName = "properties.timeout")] + public System.TimeSpan? Timeout { get; set; } + + /// + /// Gets or sets azure PowerShell module version to be used. + /// + [JsonProperty(PropertyName = "properties.azPowerShellVersion")] + public string AzPowerShellVersion { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public override void Validate() + { + base.Validate(); + if (AzPowerShellVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "AzPowerShellVersion"); + } + if (ContainerSettings != null) + { + ContainerSettings.Validate(); + } + if (EnvironmentVariables != null) + { + foreach (var element in EnvironmentVariables) + { + if (element != null) + { + element.Validate(); + } + } + } + } + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/AzureResourceBase.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/AzureResourceBase.cs new file mode 100644 index 0000000000000..cc88e8879a789 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/AzureResourceBase.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.ResourceManager.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Common properties for all Azure resources. + /// + public partial class AzureResourceBase : IResource + { + /// + /// Initializes a new instance of the AzureResourceBase class. + /// + public AzureResourceBase() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the AzureResourceBase class. + /// + /// String Id used to locate any resource on + /// Azure. + /// Name of this resource. + /// Type of this resource. + /// Azure Resource Manager metadata containing + /// createdBy and modifiedBy information. + public AzureResourceBase(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 string Id used to locate any resource on Azure. + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; private set; } + + /// + /// Gets name of this resource. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; private set; } + + /// + /// Gets type of this resource. + /// + [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/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/BasicDependency.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/BasicDependency.cs new file mode 100644 index 0000000000000..86d63ecd13672 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/BasicDependency.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.ResourceManager.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Deployment dependency information. + /// + public partial class BasicDependency + { + /// + /// Initializes a new instance of the BasicDependency class. + /// + public BasicDependency() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the BasicDependency class. + /// + /// The ID of the dependency. + /// The dependency resource type. + /// The dependency resource name. + public BasicDependency(string id = default(string), string resourceType = default(string), string resourceName = default(string)) + { + Id = id; + ResourceType = resourceType; + ResourceName = resourceName; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the ID of the dependency. + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; set; } + + /// + /// Gets or sets the dependency resource type. + /// + [JsonProperty(PropertyName = "resourceType")] + public string ResourceType { get; set; } + + /// + /// Gets or sets the dependency resource name. + /// + [JsonProperty(PropertyName = "resourceName")] + public string ResourceName { get; set; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ChangeType.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ChangeType.cs new file mode 100644 index 0000000000000..c1477220758bd --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ChangeType.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.ResourceManager.Models +{ + using Newtonsoft.Json; + using Newtonsoft.Json.Converters; + using System.Runtime; + using System.Runtime.Serialization; + + /// + /// Defines values for ChangeType. + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum ChangeType + { + /// + /// The resource does not exist in the current state but is present in + /// the desired state. The resource will be created when the deployment + /// is executed. + /// + [EnumMember(Value = "Create")] + Create, + /// + /// The resource exists in the current state and is missing from the + /// desired state. The resource will be deleted when the deployment is + /// executed. + /// + [EnumMember(Value = "Delete")] + Delete, + /// + /// The resource exists in the current state and is missing from the + /// desired state. The resource will not be deployed or modified when + /// the deployment is executed. + /// + [EnumMember(Value = "Ignore")] + Ignore, + /// + /// The resource exists in the current state and the desired state and + /// will be redeployed when the deployment is executed. The properties + /// of the resource may or may not change. + /// + [EnumMember(Value = "Deploy")] + Deploy, + /// + /// The resource exists in the current state and the desired state and + /// will be redeployed when the deployment is executed. The properties + /// of the resource will not change. + /// + [EnumMember(Value = "NoChange")] + NoChange, + /// + /// The resource exists in the current state and the desired state and + /// will be redeployed when the deployment is executed. The properties + /// of the resource will change. + /// + [EnumMember(Value = "Modify")] + Modify, + /// + /// The resource is not supported by What-If. + /// + [EnumMember(Value = "Unsupported")] + Unsupported + } + internal static class ChangeTypeEnumExtension + { + internal static string ToSerializedValue(this ChangeType? value) + { + return value == null ? null : ((ChangeType)value).ToSerializedValue(); + } + + internal static string ToSerializedValue(this ChangeType value) + { + switch( value ) + { + case ChangeType.Create: + return "Create"; + case ChangeType.Delete: + return "Delete"; + case ChangeType.Ignore: + return "Ignore"; + case ChangeType.Deploy: + return "Deploy"; + case ChangeType.NoChange: + return "NoChange"; + case ChangeType.Modify: + return "Modify"; + case ChangeType.Unsupported: + return "Unsupported"; + } + return null; + } + + internal static ChangeType? ParseChangeType(this string value) + { + switch( value ) + { + case "Create": + return ChangeType.Create; + case "Delete": + return ChangeType.Delete; + case "Ignore": + return ChangeType.Ignore; + case "Deploy": + return ChangeType.Deploy; + case "NoChange": + return ChangeType.NoChange; + case "Modify": + return ChangeType.Modify; + case "Unsupported": + return ChangeType.Unsupported; + } + return null; + } + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/CheckResourceNameResult.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/CheckResourceNameResult.cs new file mode 100644 index 0000000000000..d34372d05eed2 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/CheckResourceNameResult.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.ResourceManager.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Resource Name valid if not a reserved word, does not contain a reserved + /// word and does not start with a reserved word + /// + public partial class CheckResourceNameResult + { + /// + /// Initializes a new instance of the CheckResourceNameResult class. + /// + public CheckResourceNameResult() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the CheckResourceNameResult class. + /// + /// Name of Resource + /// Type of Resource + /// Is the resource name Allowed or Reserved. + /// Possible values include: 'Allowed', 'Reserved' + public CheckResourceNameResult(string name = default(string), string type = default(string), string status = default(string)) + { + Name = name; + Type = type; + Status = status; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets name of Resource + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Gets or sets type of Resource + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; set; } + + /// + /// Gets or sets is the resource name Allowed or Reserved. Possible + /// values include: 'Allowed', 'Reserved' + /// + [JsonProperty(PropertyName = "status")] + public string Status { get; set; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/CheckZonePeersRequest.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/CheckZonePeersRequest.cs new file mode 100644 index 0000000000000..34ec7f5b94083 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/CheckZonePeersRequest.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.ResourceManager.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Check zone peers request parameters. + /// + public partial class CheckZonePeersRequest + { + /// + /// Initializes a new instance of the CheckZonePeersRequest class. + /// + public CheckZonePeersRequest() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the CheckZonePeersRequest class. + /// + /// The Microsoft location. + /// The peer Microsoft Azure subscription + /// ID. + public CheckZonePeersRequest(string location = default(string), IList subscriptionIds = default(IList)) + { + Location = location; + SubscriptionIds = subscriptionIds; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the Microsoft location. + /// + [JsonProperty(PropertyName = "location")] + public string Location { get; set; } + + /// + /// Gets or sets the peer Microsoft Azure subscription ID. + /// + [JsonProperty(PropertyName = "subscriptionIds")] + public IList SubscriptionIds { get; set; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/CheckZonePeersResult.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/CheckZonePeersResult.cs new file mode 100644 index 0000000000000..543b8b258bd22 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/CheckZonePeersResult.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.ResourceManager.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Result of the Check zone peers operation. + /// + public partial class CheckZonePeersResult + { + /// + /// Initializes a new instance of the CheckZonePeersResult class. + /// + public CheckZonePeersResult() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the CheckZonePeersResult class. + /// + /// The subscription ID. + /// the location of the subscription. + /// The Availability Zones shared + /// by the subscriptions. + public CheckZonePeersResult(string subscriptionId = default(string), string location = default(string), IList availabilityZonePeers = default(IList)) + { + SubscriptionId = subscriptionId; + Location = location; + AvailabilityZonePeers = availabilityZonePeers; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the subscription ID. + /// + [JsonProperty(PropertyName = "subscriptionId")] + public string SubscriptionId { get; private set; } + + /// + /// Gets or sets the location of the subscription. + /// + [JsonProperty(PropertyName = "location")] + public string Location { get; set; } + + /// + /// Gets or sets the Availability Zones shared by the subscriptions. + /// + [JsonProperty(PropertyName = "availabilityZonePeers")] + public IList AvailabilityZonePeers { get; set; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/CleanupOptions.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/CleanupOptions.cs new file mode 100644 index 0000000000000..77c061d76a39c --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/CleanupOptions.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.ResourceManager.Models +{ + + /// + /// Defines values for CleanupOptions. + /// + public static class CleanupOptions + { + public const string Always = "Always"; + public const string OnSuccess = "OnSuccess"; + public const string OnExpiration = "OnExpiration"; + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ContainerConfiguration.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ContainerConfiguration.cs new file mode 100644 index 0000000000000..5237d57be407e --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ContainerConfiguration.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.ResourceManager.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Settings to customize ACI container instance. + /// + public partial class ContainerConfiguration + { + /// + /// Initializes a new instance of the ContainerConfiguration class. + /// + public ContainerConfiguration() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ContainerConfiguration class. + /// + /// Container group name, if not + /// specified then the name will get auto-generated. Not specifying a + /// 'containerGroupName' indicates the system to generate a unique name + /// which might end up flagging an Azure Policy as non-compliant. Use + /// 'containerGroupName' when you have an Azure Policy that expects a + /// specific naming convention or when you want to fully control the + /// name. 'containerGroupName' property must be between 1 and 63 + /// characters long, must contain only lowercase letters, numbers, and + /// dashes and it cannot start or end with a dash and consecutive + /// dashes are not allowed. To specify a 'containerGroupName', add the + /// following object to properties: { "containerSettings": { + /// "containerGroupName": "contoso-container" } }. If you do not want + /// to specify a 'containerGroupName' then do not add + /// 'containerSettings' property. + public ContainerConfiguration(string containerGroupName = default(string)) + { + ContainerGroupName = containerGroupName; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets container group name, if not specified then the name + /// will get auto-generated. Not specifying a 'containerGroupName' + /// indicates the system to generate a unique name which might end up + /// flagging an Azure Policy as non-compliant. Use 'containerGroupName' + /// when you have an Azure Policy that expects a specific naming + /// convention or when you want to fully control the name. + /// 'containerGroupName' property must be between 1 and 63 characters + /// long, must contain only lowercase letters, numbers, and dashes and + /// it cannot start or end with a dash and consecutive dashes are not + /// allowed. To specify a 'containerGroupName', add the following + /// object to properties: { "containerSettings": { + /// "containerGroupName": "contoso-container" } }. If you do not want + /// to specify a 'containerGroupName' then do not add + /// 'containerSettings' property. + /// + [JsonProperty(PropertyName = "containerGroupName")] + public string ContainerGroupName { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (ContainerGroupName != null) + { + if (ContainerGroupName.Length > 63) + { + throw new ValidationException(ValidationRules.MaxLength, "ContainerGroupName", 63); + } + if (ContainerGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "ContainerGroupName", 1); + } + } + } + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/CreatedByType.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/CreatedByType.cs new file mode 100644 index 0000000000000..e6bc620661a86 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/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.ResourceManager.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/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/DataEffect.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/DataEffect.cs new file mode 100644 index 0000000000000..a26e1a4abde56 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/DataEffect.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.ResourceManager.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The data effect definition. + /// + public partial class DataEffect + { + /// + /// Initializes a new instance of the DataEffect class. + /// + public DataEffect() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the DataEffect class. + /// + /// The data effect name. + /// The data effect details schema. + public DataEffect(string name = default(string), object detailsSchema = default(object)) + { + Name = name; + DetailsSchema = detailsSchema; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the data effect name. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Gets or sets the data effect details schema. + /// + [JsonProperty(PropertyName = "detailsSchema")] + public object DetailsSchema { get; set; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/DataManifestCustomResourceFunctionDefinition.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/DataManifestCustomResourceFunctionDefinition.cs new file mode 100644 index 0000000000000..b4248ecf787ad --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/DataManifestCustomResourceFunctionDefinition.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.ResourceManager.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The custom resource function definition. + /// + public partial class DataManifestCustomResourceFunctionDefinition + { + /// + /// Initializes a new instance of the + /// DataManifestCustomResourceFunctionDefinition class. + /// + public DataManifestCustomResourceFunctionDefinition() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// DataManifestCustomResourceFunctionDefinition class. + /// + /// The function name as it will appear in the + /// policy rule. eg - 'vault'. + /// The fully qualified + /// control plane resource type that this function represents. eg - + /// 'Microsoft.KeyVault/vaults'. + /// The top-level properties that can + /// be selected on the function's output. eg - [ "name", "location" ] + /// if vault().name and vault().location are supported + /// A value indicating whether the + /// custom properties within the property bag are allowed. Needs + /// api-version to be specified in the policy rule eg - + /// vault('2019-06-01'). + public DataManifestCustomResourceFunctionDefinition(string name = default(string), string fullyQualifiedResourceType = default(string), IList defaultProperties = default(IList), bool? allowCustomProperties = default(bool?)) + { + Name = name; + FullyQualifiedResourceType = fullyQualifiedResourceType; + DefaultProperties = defaultProperties; + AllowCustomProperties = allowCustomProperties; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the function name as it will appear in the policy + /// rule. eg - 'vault'. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Gets or sets the fully qualified control plane resource type that + /// this function represents. eg - 'Microsoft.KeyVault/vaults'. + /// + [JsonProperty(PropertyName = "fullyQualifiedResourceType")] + public string FullyQualifiedResourceType { get; set; } + + /// + /// Gets or sets the top-level properties that can be selected on the + /// function's output. eg - [ "name", "location" ] if vault().name and + /// vault().location are supported + /// + [JsonProperty(PropertyName = "defaultProperties")] + public IList DefaultProperties { get; set; } + + /// + /// Gets or sets a value indicating whether the custom properties + /// within the property bag are allowed. Needs api-version to be + /// specified in the policy rule eg - vault('2019-06-01'). + /// + [JsonProperty(PropertyName = "allowCustomProperties")] + public bool? AllowCustomProperties { get; set; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/DataPolicyManifest.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/DataPolicyManifest.cs new file mode 100644 index 0000000000000..46946a624682f --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/DataPolicyManifest.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.ResourceManager.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The data policy manifest. + /// + [Rest.Serialization.JsonTransformation] + public partial class DataPolicyManifest : IResource + { + /// + /// Initializes a new instance of the DataPolicyManifest class. + /// + public DataPolicyManifest() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the DataPolicyManifest class. + /// + /// The list of namespaces for the data policy + /// manifest. + /// The policy mode of the data policy + /// manifest. + /// A value indicating whether policy mode + /// is allowed only in built-in definitions. + /// An array of resource type + /// aliases. + /// The effect definition. + /// The non-alias field accessor values that + /// can be used in the policy rule. + /// The standard resource functions + /// (subscription and/or resourceGroup). + /// An array of data manifest custom resource + /// definition. + /// The ID of the data policy manifest. + /// The name of the data policy manifest (it's the + /// same as the Policy Mode). + /// The type of the resource + /// (Microsoft.Authorization/dataPolicyManifests). + public DataPolicyManifest(IList namespaces = default(IList), string policyMode = default(string), bool? isBuiltInOnly = default(bool?), IList resourceTypeAliases = default(IList), IList effects = default(IList), IList fieldValues = default(IList), IList standard = default(IList), IList custom = default(IList), string id = default(string), string name = default(string), string type = default(string)) + { + Namespaces = namespaces; + PolicyMode = policyMode; + IsBuiltInOnly = isBuiltInOnly; + ResourceTypeAliases = resourceTypeAliases; + Effects = effects; + FieldValues = fieldValues; + Standard = standard; + Custom = custom; + Id = id; + Name = name; + Type = type; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the list of namespaces for the data policy manifest. + /// + [JsonProperty(PropertyName = "properties.namespaces")] + public IList Namespaces { get; set; } + + /// + /// Gets or sets the policy mode of the data policy manifest. + /// + [JsonProperty(PropertyName = "properties.policyMode")] + public string PolicyMode { get; set; } + + /// + /// Gets or sets a value indicating whether policy mode is allowed only + /// in built-in definitions. + /// + [JsonProperty(PropertyName = "properties.isBuiltInOnly")] + public bool? IsBuiltInOnly { get; set; } + + /// + /// Gets or sets an array of resource type aliases. + /// + [JsonProperty(PropertyName = "properties.resourceTypeAliases")] + public IList ResourceTypeAliases { get; set; } + + /// + /// Gets or sets the effect definition. + /// + [JsonProperty(PropertyName = "properties.effects")] + public IList Effects { get; set; } + + /// + /// Gets or sets the non-alias field accessor values that can be used + /// in the policy rule. + /// + [JsonProperty(PropertyName = "properties.fieldValues")] + public IList FieldValues { get; set; } + + /// + /// Gets or sets the standard resource functions (subscription and/or + /// resourceGroup). + /// + [JsonProperty(PropertyName = "properties.resourceFunctions.standard")] + public IList Standard { get; set; } + + /// + /// Gets or sets an array of data manifest custom resource definition. + /// + [JsonProperty(PropertyName = "properties.resourceFunctions.custom")] + public IList Custom { get; set; } + + /// + /// Gets the ID of the data policy manifest. + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; private set; } + + /// + /// Gets the name of the data policy manifest (it's the same as the + /// Policy Mode). + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; private set; } + + /// + /// Gets the type of the resource + /// (Microsoft.Authorization/dataPolicyManifests). + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; private set; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/DebugSetting.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/DebugSetting.cs new file mode 100644 index 0000000000000..4050c505d2194 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/DebugSetting.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.ResourceManager.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The debug setting. + /// + public partial class DebugSetting + { + /// + /// Initializes a new instance of the DebugSetting class. + /// + public DebugSetting() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the DebugSetting class. + /// + /// Specifies the type of information to log + /// for debugging. The permitted values are none, requestContent, + /// responseContent, or both requestContent and responseContent + /// separated by a comma. The default is none. When setting this value, + /// carefully consider the type of information you are passing in + /// during deployment. By logging information about the request or + /// response, you could potentially expose sensitive data that is + /// retrieved through the deployment operations. + public DebugSetting(string detailLevel = default(string)) + { + DetailLevel = detailLevel; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets specifies the type of information to log for + /// debugging. The permitted values are none, requestContent, + /// responseContent, or both requestContent and responseContent + /// separated by a comma. The default is none. When setting this value, + /// carefully consider the type of information you are passing in + /// during deployment. By logging information about the request or + /// response, you could potentially expose sensitive data that is + /// retrieved through the deployment operations. + /// + [JsonProperty(PropertyName = "detailLevel")] + public string DetailLevel { get; set; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/Dependency.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/Dependency.cs new file mode 100644 index 0000000000000..dfbbe31aa24a6 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/Dependency.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.ResourceManager.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Deployment dependency information. + /// + public partial class Dependency + { + /// + /// Initializes a new instance of the Dependency class. + /// + public Dependency() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Dependency class. + /// + /// The list of dependencies. + /// The ID of the dependency. + /// The dependency resource type. + /// The dependency resource name. + public Dependency(IList dependsOn = default(IList), string id = default(string), string resourceType = default(string), string resourceName = default(string)) + { + DependsOn = dependsOn; + Id = id; + ResourceType = resourceType; + ResourceName = resourceName; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the list of dependencies. + /// + [JsonProperty(PropertyName = "dependsOn")] + public IList DependsOn { get; set; } + + /// + /// Gets or sets the ID of the dependency. + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; set; } + + /// + /// Gets or sets the dependency resource type. + /// + [JsonProperty(PropertyName = "resourceType")] + public string ResourceType { get; set; } + + /// + /// Gets or sets the dependency resource name. + /// + [JsonProperty(PropertyName = "resourceName")] + public string ResourceName { get; set; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/Deployment.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/Deployment.cs new file mode 100644 index 0000000000000..db880f6df32d6 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/Deployment.cs @@ -0,0 +1,88 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Deployment operation parameters. + /// + public partial class Deployment + { + /// + /// Initializes a new instance of the Deployment class. + /// + public Deployment() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Deployment class. + /// + /// The deployment properties. + /// The location to store the deployment + /// data. + /// Deployment tags + public Deployment(DeploymentProperties properties, string location = default(string), IDictionary tags = default(IDictionary)) + { + Location = location; + Properties = properties; + Tags = tags; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the location to store the deployment data. + /// + [JsonProperty(PropertyName = "location")] + public string Location { get; set; } + + /// + /// Gets or sets the deployment properties. + /// + [JsonProperty(PropertyName = "properties")] + public DeploymentProperties Properties { get; set; } + + /// + /// Gets or sets deployment tags + /// + [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 (Properties != null) + { + Properties.Validate(); + } + } + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/DeploymentExportResult.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/DeploymentExportResult.cs new file mode 100644 index 0000000000000..7a6d04bcefdf6 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/DeploymentExportResult.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.ResourceManager.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The deployment export result. + /// + public partial class DeploymentExportResult + { + /// + /// Initializes a new instance of the DeploymentExportResult class. + /// + public DeploymentExportResult() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the DeploymentExportResult class. + /// + /// The template content. + public DeploymentExportResult(object template = default(object)) + { + Template = template; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the template content. + /// + [JsonProperty(PropertyName = "template")] + public object Template { get; set; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/DeploymentExtended.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/DeploymentExtended.cs new file mode 100644 index 0000000000000..52b5881d604f3 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/DeploymentExtended.cs @@ -0,0 +1,108 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Deployment information. + /// + public partial class DeploymentExtended : IResource + { + /// + /// Initializes a new instance of the DeploymentExtended class. + /// + public DeploymentExtended() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the DeploymentExtended class. + /// + /// The ID of the deployment. + /// The name of the deployment. + /// The type of the deployment. + /// the location of the deployment. + /// Deployment properties. + /// Deployment tags + public DeploymentExtended(string id = default(string), string name = default(string), string type = default(string), string location = default(string), DeploymentPropertiesExtended properties = default(DeploymentPropertiesExtended), IDictionary tags = default(IDictionary)) + { + Id = id; + Name = name; + Type = type; + Location = location; + Properties = properties; + Tags = tags; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the ID of the deployment. + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; private set; } + + /// + /// Gets the name of the deployment. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; private set; } + + /// + /// Gets the type of the deployment. + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; private set; } + + /// + /// Gets or sets the location of the deployment. + /// + [JsonProperty(PropertyName = "location")] + public string Location { get; set; } + + /// + /// Gets or sets deployment properties. + /// + [JsonProperty(PropertyName = "properties")] + public DeploymentPropertiesExtended Properties { get; set; } + + /// + /// Gets or sets deployment tags + /// + [JsonProperty(PropertyName = "tags")] + public IDictionary Tags { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Properties != null) + { + Properties.Validate(); + } + } + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/DeploymentExtendedFilter.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/DeploymentExtendedFilter.cs new file mode 100644 index 0000000000000..d718f38e5b663 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/DeploymentExtendedFilter.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.ResourceManager.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Deployment filter. + /// + public partial class DeploymentExtendedFilter + { + /// + /// Initializes a new instance of the DeploymentExtendedFilter class. + /// + public DeploymentExtendedFilter() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the DeploymentExtendedFilter class. + /// + /// The provisioning state. + public DeploymentExtendedFilter(string provisioningState = default(string)) + { + ProvisioningState = provisioningState; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the provisioning state. + /// + [JsonProperty(PropertyName = "provisioningState")] + public string ProvisioningState { get; set; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/DeploymentMode.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/DeploymentMode.cs new file mode 100644 index 0000000000000..75858d645dc5d --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/DeploymentMode.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.ResourceManager.Models +{ + using Newtonsoft.Json; + using Newtonsoft.Json.Converters; + using System.Runtime; + using System.Runtime.Serialization; + + /// + /// Defines values for DeploymentMode. + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum DeploymentMode + { + [EnumMember(Value = "Incremental")] + Incremental, + [EnumMember(Value = "Complete")] + Complete + } + internal static class DeploymentModeEnumExtension + { + internal static string ToSerializedValue(this DeploymentMode? value) + { + return value == null ? null : ((DeploymentMode)value).ToSerializedValue(); + } + + internal static string ToSerializedValue(this DeploymentMode value) + { + switch( value ) + { + case DeploymentMode.Incremental: + return "Incremental"; + case DeploymentMode.Complete: + return "Complete"; + } + return null; + } + + internal static DeploymentMode? ParseDeploymentMode(this string value) + { + switch( value ) + { + case "Incremental": + return DeploymentMode.Incremental; + case "Complete": + return DeploymentMode.Complete; + } + return null; + } + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/DeploymentOperation.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/DeploymentOperation.cs new file mode 100644 index 0000000000000..3448f5876439e --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/DeploymentOperation.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.ResourceManager.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Deployment operation information. + /// + public partial class DeploymentOperation + { + /// + /// Initializes a new instance of the DeploymentOperation class. + /// + public DeploymentOperation() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the DeploymentOperation class. + /// + /// Full deployment operation ID. + /// Deployment operation ID. + /// Deployment properties. + public DeploymentOperation(string id = default(string), string operationId = default(string), DeploymentOperationProperties properties = default(DeploymentOperationProperties)) + { + Id = id; + OperationId = operationId; + Properties = properties; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets full deployment operation ID. + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; private set; } + + /// + /// Gets deployment operation ID. + /// + [JsonProperty(PropertyName = "operationId")] + public string OperationId { get; private set; } + + /// + /// Gets or sets deployment properties. + /// + [JsonProperty(PropertyName = "properties")] + public DeploymentOperationProperties Properties { get; set; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/DeploymentOperationProperties.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/DeploymentOperationProperties.cs new file mode 100644 index 0000000000000..2b6bd75c29861 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/DeploymentOperationProperties.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.ResourceManager.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Deployment operation properties. + /// + public partial class DeploymentOperationProperties + { + /// + /// Initializes a new instance of the DeploymentOperationProperties + /// class. + /// + public DeploymentOperationProperties() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the DeploymentOperationProperties + /// class. + /// + /// The name of the current + /// provisioning operation. Possible values include: 'NotSpecified', + /// 'Create', 'Delete', 'Waiting', 'AzureAsyncOperationWaiting', + /// 'ResourceCacheWaiting', 'Action', 'Read', + /// 'EvaluateDeploymentOutput', 'DeploymentCleanup' + /// The state of the + /// provisioning. + /// The date and time of the operation. + /// The duration of the operation. + /// Deployment operation service request + /// id. + /// Operation status code from the resource + /// provider. This property may not be set if a response has not yet + /// been received. + /// Operation status message from the + /// resource provider. This property is optional. It will only be + /// provided if an error was received from the resource + /// provider. + /// The target resource. + /// The HTTP request message. + /// The HTTP response message. + public DeploymentOperationProperties(ProvisioningOperation? provisioningOperation = default(ProvisioningOperation?), string provisioningState = default(string), System.DateTime? timestamp = default(System.DateTime?), string duration = default(string), string serviceRequestId = default(string), string statusCode = default(string), StatusMessage statusMessage = default(StatusMessage), TargetResource targetResource = default(TargetResource), HttpMessage request = default(HttpMessage), HttpMessage response = default(HttpMessage)) + { + ProvisioningOperation = provisioningOperation; + ProvisioningState = provisioningState; + Timestamp = timestamp; + Duration = duration; + ServiceRequestId = serviceRequestId; + StatusCode = statusCode; + StatusMessage = statusMessage; + TargetResource = targetResource; + Request = request; + Response = response; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the name of the current provisioning operation. Possible + /// values include: 'NotSpecified', 'Create', 'Delete', 'Waiting', + /// 'AzureAsyncOperationWaiting', 'ResourceCacheWaiting', 'Action', + /// 'Read', 'EvaluateDeploymentOutput', 'DeploymentCleanup' + /// + [JsonProperty(PropertyName = "provisioningOperation")] + public ProvisioningOperation? ProvisioningOperation { get; private set; } + + /// + /// Gets the state of the provisioning. + /// + [JsonProperty(PropertyName = "provisioningState")] + public string ProvisioningState { get; private set; } + + /// + /// Gets the date and time of the operation. + /// + [JsonProperty(PropertyName = "timestamp")] + public System.DateTime? Timestamp { get; private set; } + + /// + /// Gets the duration of the operation. + /// + [JsonProperty(PropertyName = "duration")] + public string Duration { get; private set; } + + /// + /// Gets deployment operation service request id. + /// + [JsonProperty(PropertyName = "serviceRequestId")] + public string ServiceRequestId { get; private set; } + + /// + /// Gets operation status code from the resource provider. This + /// property may not be set if a response has not yet been received. + /// + [JsonProperty(PropertyName = "statusCode")] + public string StatusCode { get; private set; } + + /// + /// Gets operation status message from the resource provider. This + /// property is optional. It will only be provided if an error was + /// received from the resource provider. + /// + [JsonProperty(PropertyName = "statusMessage")] + public StatusMessage StatusMessage { get; private set; } + + /// + /// Gets the target resource. + /// + [JsonProperty(PropertyName = "targetResource")] + public TargetResource TargetResource { get; private set; } + + /// + /// Gets the HTTP request message. + /// + [JsonProperty(PropertyName = "request")] + public HttpMessage Request { get; private set; } + + /// + /// Gets the HTTP response message. + /// + [JsonProperty(PropertyName = "response")] + public HttpMessage Response { get; private set; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/DeploymentProperties.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/DeploymentProperties.cs new file mode 100644 index 0000000000000..e35cdd7b5cfcc --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/DeploymentProperties.cs @@ -0,0 +1,168 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Deployment properties. + /// + public partial class DeploymentProperties + { + /// + /// Initializes a new instance of the DeploymentProperties class. + /// + public DeploymentProperties() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the DeploymentProperties class. + /// + /// The mode that is used to deploy resources. This + /// value can be either Incremental or Complete. In Incremental mode, + /// resources are deployed without deleting existing resources that are + /// not included in the template. In Complete mode, resources are + /// deployed and existing resources in the resource group that are not + /// included in the template are deleted. Be careful when using + /// Complete mode as you may unintentionally delete resources. Possible + /// values include: 'Incremental', 'Complete' + /// The template content. You use this element + /// when you want to pass the template syntax directly in the request + /// rather than link to an existing template. It can be a JObject or + /// well-formed JSON string. Use either the templateLink property or + /// the template property, but not both. + /// The URI of the template. Use either the + /// templateLink property or the template property, but not + /// both. + /// Name and value pairs that define the + /// deployment parameters for the template. You use this element when + /// you want to provide the parameter values directly in the request + /// rather than link to an existing parameter file. Use either the + /// parametersLink property or the parameters property, but not both. + /// It can be a JObject or a well formed JSON string. + /// The URI of parameters file. You use + /// this element to link to an existing parameters file. Use either the + /// parametersLink property or the parameters property, but not + /// both. + /// The debug setting of the + /// deployment. + /// The deployment on error + /// behavior. + /// Specifies whether + /// template expressions are evaluated within the scope of the parent + /// template or nested template. Only applicable to nested templates. + /// If not specified, default value is outer. + public DeploymentProperties(DeploymentMode mode, object template = default(object), TemplateLink templateLink = default(TemplateLink), object parameters = default(object), ParametersLink parametersLink = default(ParametersLink), DebugSetting debugSetting = default(DebugSetting), OnErrorDeployment onErrorDeployment = default(OnErrorDeployment), ExpressionEvaluationOptions expressionEvaluationOptions = default(ExpressionEvaluationOptions)) + { + Template = template; + TemplateLink = templateLink; + Parameters = parameters; + ParametersLink = parametersLink; + Mode = mode; + DebugSetting = debugSetting; + OnErrorDeployment = onErrorDeployment; + ExpressionEvaluationOptions = expressionEvaluationOptions; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the template content. You use this element when you + /// want to pass the template syntax directly in the request rather + /// than link to an existing template. It can be a JObject or + /// well-formed JSON string. Use either the templateLink property or + /// the template property, but not both. + /// + [JsonProperty(PropertyName = "template")] + public object Template { get; set; } + + /// + /// Gets or sets the URI of the template. Use either the templateLink + /// property or the template property, but not both. + /// + [JsonProperty(PropertyName = "templateLink")] + public TemplateLink TemplateLink { get; set; } + + /// + /// Gets or sets name and value pairs that define the deployment + /// parameters for the template. You use this element when you want to + /// provide the parameter values directly in the request rather than + /// link to an existing parameter file. Use either the parametersLink + /// property or the parameters property, but not both. It can be a + /// JObject or a well formed JSON string. + /// + [JsonProperty(PropertyName = "parameters")] + public object Parameters { get; set; } + + /// + /// Gets or sets the URI of parameters file. You use this element to + /// link to an existing parameters file. Use either the parametersLink + /// property or the parameters property, but not both. + /// + [JsonProperty(PropertyName = "parametersLink")] + public ParametersLink ParametersLink { get; set; } + + /// + /// Gets or sets the mode that is used to deploy resources. This value + /// can be either Incremental or Complete. In Incremental mode, + /// resources are deployed without deleting existing resources that are + /// not included in the template. In Complete mode, resources are + /// deployed and existing resources in the resource group that are not + /// included in the template are deleted. Be careful when using + /// Complete mode as you may unintentionally delete resources. Possible + /// values include: 'Incremental', 'Complete' + /// + [JsonProperty(PropertyName = "mode")] + public DeploymentMode Mode { get; set; } + + /// + /// Gets or sets the debug setting of the deployment. + /// + [JsonProperty(PropertyName = "debugSetting")] + public DebugSetting DebugSetting { get; set; } + + /// + /// Gets or sets the deployment on error behavior. + /// + [JsonProperty(PropertyName = "onErrorDeployment")] + public OnErrorDeployment OnErrorDeployment { get; set; } + + /// + /// Gets or sets specifies whether template expressions are evaluated + /// within the scope of the parent template or nested template. Only + /// applicable to nested templates. If not specified, default value is + /// outer. + /// + [JsonProperty(PropertyName = "expressionEvaluationOptions")] + public ExpressionEvaluationOptions ExpressionEvaluationOptions { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (ParametersLink != null) + { + ParametersLink.Validate(); + } + } + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/DeploymentPropertiesExtended.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/DeploymentPropertiesExtended.cs new file mode 100644 index 0000000000000..b3b8cf0c31963 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/DeploymentPropertiesExtended.cs @@ -0,0 +1,218 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Deployment properties with additional details. + /// + public partial class DeploymentPropertiesExtended + { + /// + /// Initializes a new instance of the DeploymentPropertiesExtended + /// class. + /// + public DeploymentPropertiesExtended() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the DeploymentPropertiesExtended + /// class. + /// + /// Denotes the state of provisioning. + /// Possible values include: 'NotSpecified', 'Accepted', 'Running', + /// 'Ready', 'Creating', 'Created', 'Deleting', 'Deleted', 'Canceled', + /// 'Failed', 'Succeeded', 'Updating' + /// The correlation ID of the + /// deployment. + /// The timestamp of the template + /// deployment. + /// The duration of the template + /// deployment. + /// Key/value pairs that represent deployment + /// output. + /// The list of resource providers needed for + /// the deployment. + /// The list of deployment + /// dependencies. + /// The URI referencing the + /// template. + /// Deployment parameters. + /// The URI referencing the parameters. + /// + /// The deployment mode. Possible values are + /// Incremental and Complete. Possible values include: 'Incremental', + /// 'Complete' + /// The debug setting of the + /// deployment. + /// The deployment on error + /// behavior. + /// The hash produced for the + /// template. + /// Array of provisioned + /// resources. + /// Array of validated + /// resources. + /// The deployment error. + public DeploymentPropertiesExtended(string provisioningState = default(string), string correlationId = default(string), System.DateTime? timestamp = default(System.DateTime?), string duration = default(string), object outputs = default(object), IList providers = default(IList), IList dependencies = default(IList), TemplateLink templateLink = default(TemplateLink), object parameters = default(object), ParametersLink parametersLink = default(ParametersLink), DeploymentMode? mode = default(DeploymentMode?), DebugSetting debugSetting = default(DebugSetting), OnErrorDeploymentExtended onErrorDeployment = default(OnErrorDeploymentExtended), string templateHash = default(string), IList outputResources = default(IList), IList validatedResources = default(IList), ErrorResponse error = default(ErrorResponse)) + { + ProvisioningState = provisioningState; + CorrelationId = correlationId; + Timestamp = timestamp; + Duration = duration; + Outputs = outputs; + Providers = providers; + Dependencies = dependencies; + TemplateLink = templateLink; + Parameters = parameters; + ParametersLink = parametersLink; + Mode = mode; + DebugSetting = debugSetting; + OnErrorDeployment = onErrorDeployment; + TemplateHash = templateHash; + OutputResources = outputResources; + ValidatedResources = validatedResources; + Error = error; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets denotes the state of provisioning. Possible values include: + /// 'NotSpecified', 'Accepted', 'Running', 'Ready', 'Creating', + /// 'Created', 'Deleting', 'Deleted', 'Canceled', 'Failed', + /// 'Succeeded', 'Updating' + /// + [JsonProperty(PropertyName = "provisioningState")] + public string ProvisioningState { get; private set; } + + /// + /// Gets the correlation ID of the deployment. + /// + [JsonProperty(PropertyName = "correlationId")] + public string CorrelationId { get; private set; } + + /// + /// Gets the timestamp of the template deployment. + /// + [JsonProperty(PropertyName = "timestamp")] + public System.DateTime? Timestamp { get; private set; } + + /// + /// Gets the duration of the template deployment. + /// + [JsonProperty(PropertyName = "duration")] + public string Duration { get; private set; } + + /// + /// Gets key/value pairs that represent deployment output. + /// + [JsonProperty(PropertyName = "outputs")] + public object Outputs { get; private set; } + + /// + /// Gets the list of resource providers needed for the deployment. + /// + [JsonProperty(PropertyName = "providers")] + public IList Providers { get; private set; } + + /// + /// Gets the list of deployment dependencies. + /// + [JsonProperty(PropertyName = "dependencies")] + public IList Dependencies { get; private set; } + + /// + /// Gets the URI referencing the template. + /// + [JsonProperty(PropertyName = "templateLink")] + public TemplateLink TemplateLink { get; private set; } + + /// + /// Gets deployment parameters. + /// + [JsonProperty(PropertyName = "parameters")] + public object Parameters { get; private set; } + + /// + /// Gets the URI referencing the parameters. + /// + [JsonProperty(PropertyName = "parametersLink")] + public ParametersLink ParametersLink { get; private set; } + + /// + /// Gets the deployment mode. Possible values are Incremental and + /// Complete. Possible values include: 'Incremental', 'Complete' + /// + [JsonProperty(PropertyName = "mode")] + public DeploymentMode? Mode { get; private set; } + + /// + /// Gets the debug setting of the deployment. + /// + [JsonProperty(PropertyName = "debugSetting")] + public DebugSetting DebugSetting { get; private set; } + + /// + /// Gets the deployment on error behavior. + /// + [JsonProperty(PropertyName = "onErrorDeployment")] + public OnErrorDeploymentExtended OnErrorDeployment { get; private set; } + + /// + /// Gets the hash produced for the template. + /// + [JsonProperty(PropertyName = "templateHash")] + public string TemplateHash { get; private set; } + + /// + /// Gets array of provisioned resources. + /// + [JsonProperty(PropertyName = "outputResources")] + public IList OutputResources { get; private set; } + + /// + /// Gets array of validated resources. + /// + [JsonProperty(PropertyName = "validatedResources")] + public IList ValidatedResources { get; private set; } + + /// + /// Gets the deployment error. + /// + [JsonProperty(PropertyName = "error")] + public ErrorResponse Error { get; private set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (ParametersLink != null) + { + ParametersLink.Validate(); + } + } + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/DeploymentScript.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/DeploymentScript.cs new file mode 100644 index 0000000000000..43a83c843d969 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/DeploymentScript.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.ResourceManager.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Deployment script object. + /// + public partial class DeploymentScript : AzureResourceBase + { + /// + /// Initializes a new instance of the DeploymentScript class. + /// + public DeploymentScript() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the DeploymentScript class. + /// + /// The location of the ACI and the storage + /// account for the deployment script. + /// String Id used to locate any resource on + /// Azure. + /// Name of this resource. + /// Type of this resource. + /// Optional property. Managed identity to be + /// used for this deployment script. Currently, only user-assigned MSI + /// is supported. + /// Resource tags. + /// The system metadata related to this + /// resource. + public DeploymentScript(string location, string id = default(string), string name = default(string), string type = default(string), ManagedServiceIdentity identity = default(ManagedServiceIdentity), IDictionary tags = default(IDictionary), SystemData systemData = default(SystemData)) + : base(id, name, type) + { + Identity = identity; + Location = location; + Tags = tags; + SystemData = systemData; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets optional property. Managed identity to be used for + /// this deployment script. Currently, only user-assigned MSI is + /// supported. + /// + [JsonProperty(PropertyName = "identity")] + public ManagedServiceIdentity Identity { get; set; } + + /// + /// Gets or sets the location of the ACI and the storage account for + /// the deployment script. + /// + [JsonProperty(PropertyName = "location")] + public string Location { get; set; } + + /// + /// Gets or sets resource tags. + /// + [JsonProperty(PropertyName = "tags")] + public IDictionary Tags { get; set; } + + /// + /// Gets the system metadata related to this resource. + /// + [JsonProperty(PropertyName = "systemData")] + public SystemData SystemData { get; private 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/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/DeploymentScriptUpdateParameter.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/DeploymentScriptUpdateParameter.cs new file mode 100644 index 0000000000000..e6b83cd589622 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/DeploymentScriptUpdateParameter.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.ResourceManager.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Deployment script parameters to be updated. + /// + public partial class DeploymentScriptUpdateParameter : AzureResourceBase + { + /// + /// Initializes a new instance of the DeploymentScriptUpdateParameter + /// class. + /// + public DeploymentScriptUpdateParameter() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the DeploymentScriptUpdateParameter + /// class. + /// + /// String Id used to locate any resource on + /// Azure. + /// Name of this resource. + /// Type of this resource. + /// Resource tags to be updated. + public DeploymentScriptUpdateParameter(string id = default(string), string name = default(string), string type = default(string), IDictionary tags = default(IDictionary)) + : base(id, name, type) + { + Tags = tags; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets resource tags to be updated. + /// + [JsonProperty(PropertyName = "tags")] + public IDictionary Tags { get; set; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/DeploymentScriptsError.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/DeploymentScriptsError.cs new file mode 100644 index 0000000000000..f1c016a6b6674 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/DeploymentScriptsError.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.ResourceManager.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Deployment scripts error response. + /// + public partial class DeploymentScriptsError + { + /// + /// Initializes a new instance of the DeploymentScriptsError class. + /// + public DeploymentScriptsError() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the DeploymentScriptsError class. + /// + public DeploymentScriptsError(ErrorResponse error = default(ErrorResponse)) + { + Error = error; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// + [JsonProperty(PropertyName = "error")] + public ErrorResponse Error { get; set; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/DeploymentScriptsErrorException.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/DeploymentScriptsErrorException.cs new file mode 100644 index 0000000000000..9c543639995bd --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/DeploymentScriptsErrorException.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.ResourceManager.Models +{ + using Microsoft.Rest; + + /// + /// Exception thrown for an invalid response with DeploymentScriptsError + /// information. + /// + public partial class DeploymentScriptsErrorException : 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 DeploymentScriptsError Body { get; set; } + + /// + /// Initializes a new instance of the DeploymentScriptsErrorException class. + /// + public DeploymentScriptsErrorException() + { + } + + /// + /// Initializes a new instance of the DeploymentScriptsErrorException class. + /// + /// The exception message. + public DeploymentScriptsErrorException(string message) + : this(message, null) + { + } + + /// + /// Initializes a new instance of the DeploymentScriptsErrorException class. + /// + /// The exception message. + /// Inner exception. + public DeploymentScriptsErrorException(string message, System.Exception innerException) + : base(message, innerException) + { + } + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/DeploymentValidateResult.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/DeploymentValidateResult.cs new file mode 100644 index 0000000000000..e24a56fc7d7b0 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/DeploymentValidateResult.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.ResourceManager.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Information from validate template deployment response. + /// + public partial class DeploymentValidateResult + { + /// + /// Initializes a new instance of the DeploymentValidateResult class. + /// + public DeploymentValidateResult() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the DeploymentValidateResult class. + /// + /// The deployment validation error. + /// The template deployment + /// properties. + public DeploymentValidateResult(ErrorResponse error = default(ErrorResponse), DeploymentPropertiesExtended properties = default(DeploymentPropertiesExtended)) + { + Error = error; + Properties = properties; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the deployment validation error. + /// + [JsonProperty(PropertyName = "error")] + public ErrorResponse Error { get; private set; } + + /// + /// Gets or sets the template deployment properties. + /// + [JsonProperty(PropertyName = "properties")] + public DeploymentPropertiesExtended Properties { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Properties != null) + { + Properties.Validate(); + } + } + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/DeploymentWhatIf.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/DeploymentWhatIf.cs new file mode 100644 index 0000000000000..7b7006791fda8 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/DeploymentWhatIf.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.ResourceManager.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Deployment What-if operation parameters. + /// + public partial class DeploymentWhatIf + { + /// + /// Initializes a new instance of the DeploymentWhatIf class. + /// + public DeploymentWhatIf() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the DeploymentWhatIf class. + /// + /// The deployment properties. + /// The location to store the deployment + /// data. + public DeploymentWhatIf(DeploymentWhatIfProperties properties, string location = default(string)) + { + Location = location; + Properties = properties; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the location to store the deployment data. + /// + [JsonProperty(PropertyName = "location")] + public string Location { get; set; } + + /// + /// Gets or sets the deployment properties. + /// + [JsonProperty(PropertyName = "properties")] + public DeploymentWhatIfProperties Properties { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Properties == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Properties"); + } + if (Properties != null) + { + Properties.Validate(); + } + } + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/DeploymentWhatIfProperties.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/DeploymentWhatIfProperties.cs new file mode 100644 index 0000000000000..a27c9d82ce914 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/DeploymentWhatIfProperties.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.ResourceManager.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Deployment What-if properties. + /// + public partial class DeploymentWhatIfProperties : DeploymentProperties + { + /// + /// Initializes a new instance of the DeploymentWhatIfProperties class. + /// + public DeploymentWhatIfProperties() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the DeploymentWhatIfProperties class. + /// + /// The mode that is used to deploy resources. This + /// value can be either Incremental or Complete. In Incremental mode, + /// resources are deployed without deleting existing resources that are + /// not included in the template. In Complete mode, resources are + /// deployed and existing resources in the resource group that are not + /// included in the template are deleted. Be careful when using + /// Complete mode as you may unintentionally delete resources. Possible + /// values include: 'Incremental', 'Complete' + /// The template content. You use this element + /// when you want to pass the template syntax directly in the request + /// rather than link to an existing template. It can be a JObject or + /// well-formed JSON string. Use either the templateLink property or + /// the template property, but not both. + /// The URI of the template. Use either the + /// templateLink property or the template property, but not + /// both. + /// Name and value pairs that define the + /// deployment parameters for the template. You use this element when + /// you want to provide the parameter values directly in the request + /// rather than link to an existing parameter file. Use either the + /// parametersLink property or the parameters property, but not both. + /// It can be a JObject or a well formed JSON string. + /// The URI of parameters file. You use + /// this element to link to an existing parameters file. Use either the + /// parametersLink property or the parameters property, but not + /// both. + /// The debug setting of the + /// deployment. + /// The deployment on error + /// behavior. + /// Specifies whether + /// template expressions are evaluated within the scope of the parent + /// template or nested template. Only applicable to nested templates. + /// If not specified, default value is outer. + /// Optional What-If operation + /// settings. + public DeploymentWhatIfProperties(DeploymentMode mode, object template = default(object), TemplateLink templateLink = default(TemplateLink), object parameters = default(object), ParametersLink parametersLink = default(ParametersLink), DebugSetting debugSetting = default(DebugSetting), OnErrorDeployment onErrorDeployment = default(OnErrorDeployment), ExpressionEvaluationOptions expressionEvaluationOptions = default(ExpressionEvaluationOptions), DeploymentWhatIfSettings whatIfSettings = default(DeploymentWhatIfSettings)) + : base(mode, template, templateLink, parameters, parametersLink, debugSetting, onErrorDeployment, expressionEvaluationOptions) + { + WhatIfSettings = whatIfSettings; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets optional What-If operation settings. + /// + [JsonProperty(PropertyName = "whatIfSettings")] + public DeploymentWhatIfSettings WhatIfSettings { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public override void Validate() + { + base.Validate(); + } + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/DeploymentWhatIfSettings.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/DeploymentWhatIfSettings.cs new file mode 100644 index 0000000000000..f075adb81e9dd --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/DeploymentWhatIfSettings.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.ResourceManager.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Deployment What-If operation settings. + /// + public partial class DeploymentWhatIfSettings + { + /// + /// Initializes a new instance of the DeploymentWhatIfSettings class. + /// + public DeploymentWhatIfSettings() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the DeploymentWhatIfSettings class. + /// + /// The format of the What-If results. + /// Possible values include: 'ResourceIdOnly', + /// 'FullResourcePayloads' + public DeploymentWhatIfSettings(WhatIfResultFormat? resultFormat = default(WhatIfResultFormat?)) + { + ResultFormat = resultFormat; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the format of the What-If results. Possible values + /// include: 'ResourceIdOnly', 'FullResourcePayloads' + /// + [JsonProperty(PropertyName = "resultFormat")] + public WhatIfResultFormat? ResultFormat { get; set; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/DeploymentsWhatIfAtManagementGroupScopeHeaders.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/DeploymentsWhatIfAtManagementGroupScopeHeaders.cs new file mode 100644 index 0000000000000..6058c502889ee --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/DeploymentsWhatIfAtManagementGroupScopeHeaders.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.ResourceManager.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Defines headers for WhatIfAtManagementGroupScope operation. + /// + public partial class DeploymentsWhatIfAtManagementGroupScopeHeaders + { + /// + /// Initializes a new instance of the + /// DeploymentsWhatIfAtManagementGroupScopeHeaders class. + /// + public DeploymentsWhatIfAtManagementGroupScopeHeaders() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// DeploymentsWhatIfAtManagementGroupScopeHeaders class. + /// + /// URL to get status of this long-running + /// operation. + /// Number of seconds to wait before polling + /// for status. + public DeploymentsWhatIfAtManagementGroupScopeHeaders(string location = default(string), string retryAfter = default(string)) + { + Location = location; + RetryAfter = retryAfter; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets URL to get status of this long-running operation. + /// + [JsonProperty(PropertyName = "Location")] + public string Location { get; set; } + + /// + /// Gets or sets number of seconds to wait before polling for status. + /// + [JsonProperty(PropertyName = "Retry-After")] + public string RetryAfter { get; set; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/DeploymentsWhatIfAtSubscriptionScopeHeaders.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/DeploymentsWhatIfAtSubscriptionScopeHeaders.cs new file mode 100644 index 0000000000000..39fb9ddba476e --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/DeploymentsWhatIfAtSubscriptionScopeHeaders.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.ResourceManager.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Defines headers for WhatIfAtSubscriptionScope operation. + /// + public partial class DeploymentsWhatIfAtSubscriptionScopeHeaders + { + /// + /// Initializes a new instance of the + /// DeploymentsWhatIfAtSubscriptionScopeHeaders class. + /// + public DeploymentsWhatIfAtSubscriptionScopeHeaders() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// DeploymentsWhatIfAtSubscriptionScopeHeaders class. + /// + /// URL to get status of this long-running + /// operation. + /// Number of seconds to wait before polling + /// for status. + public DeploymentsWhatIfAtSubscriptionScopeHeaders(string location = default(string), string retryAfter = default(string)) + { + Location = location; + RetryAfter = retryAfter; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets URL to get status of this long-running operation. + /// + [JsonProperty(PropertyName = "Location")] + public string Location { get; set; } + + /// + /// Gets or sets number of seconds to wait before polling for status. + /// + [JsonProperty(PropertyName = "Retry-After")] + public string RetryAfter { get; set; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/DeploymentsWhatIfAtTenantScopeHeaders.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/DeploymentsWhatIfAtTenantScopeHeaders.cs new file mode 100644 index 0000000000000..46ee97559368c --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/DeploymentsWhatIfAtTenantScopeHeaders.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.ResourceManager.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Defines headers for WhatIfAtTenantScope operation. + /// + public partial class DeploymentsWhatIfAtTenantScopeHeaders + { + /// + /// Initializes a new instance of the + /// DeploymentsWhatIfAtTenantScopeHeaders class. + /// + public DeploymentsWhatIfAtTenantScopeHeaders() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// DeploymentsWhatIfAtTenantScopeHeaders class. + /// + /// URL to get status of this long-running + /// operation. + /// Number of seconds to wait before polling + /// for status. + public DeploymentsWhatIfAtTenantScopeHeaders(string location = default(string), string retryAfter = default(string)) + { + Location = location; + RetryAfter = retryAfter; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets URL to get status of this long-running operation. + /// + [JsonProperty(PropertyName = "Location")] + public string Location { get; set; } + + /// + /// Gets or sets number of seconds to wait before polling for status. + /// + [JsonProperty(PropertyName = "Retry-After")] + public string RetryAfter { get; set; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/DeploymentsWhatIfHeaders.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/DeploymentsWhatIfHeaders.cs new file mode 100644 index 0000000000000..9c2995a12ccb9 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/DeploymentsWhatIfHeaders.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.ResourceManager.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Defines headers for WhatIf operation. + /// + public partial class DeploymentsWhatIfHeaders + { + /// + /// Initializes a new instance of the DeploymentsWhatIfHeaders class. + /// + public DeploymentsWhatIfHeaders() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the DeploymentsWhatIfHeaders class. + /// + /// URL to get status of this long-running + /// operation. + /// Number of seconds to wait before polling + /// for status. + public DeploymentsWhatIfHeaders(string location = default(string), string retryAfter = default(string)) + { + Location = location; + RetryAfter = retryAfter; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets URL to get status of this long-running operation. + /// + [JsonProperty(PropertyName = "Location")] + public string Location { get; set; } + + /// + /// Gets or sets number of seconds to wait before polling for status. + /// + [JsonProperty(PropertyName = "Retry-After")] + public string RetryAfter { get; set; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/EnforcementMode.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/EnforcementMode.cs new file mode 100644 index 0000000000000..cd875a0c87030 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/EnforcementMode.cs @@ -0,0 +1,29 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager.Models +{ + + /// + /// Defines values for EnforcementMode. + /// + public static class EnforcementMode + { + /// + /// The policy effect is enforced during resource creation or update. + /// + public const string Default = "Default"; + /// + /// The policy effect is not enforced during resource creation or + /// update. + /// + public const string DoNotEnforce = "DoNotEnforce"; + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/EnvironmentVariable.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/EnvironmentVariable.cs new file mode 100644 index 0000000000000..0119e3d4939e6 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/EnvironmentVariable.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.ResourceManager.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// The environment variable to pass to the script in the container + /// instance. + /// + public partial class EnvironmentVariable + { + /// + /// Initializes a new instance of the EnvironmentVariable class. + /// + public EnvironmentVariable() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the EnvironmentVariable class. + /// + /// The name of the environment variable. + /// The value of the environment variable. + /// The value of the secure environment + /// variable. + public EnvironmentVariable(string name, string value = default(string), string secureValue = default(string)) + { + Name = name; + Value = value; + SecureValue = secureValue; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the name of the environment variable. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Gets or sets the value of the environment variable. + /// + [JsonProperty(PropertyName = "value")] + public string Value { get; set; } + + /// + /// Gets or sets the value of the secure environment variable. + /// + [JsonProperty(PropertyName = "secureValue")] + public string SecureValue { 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/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ErrorAdditionalInfo.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ErrorAdditionalInfo.cs new file mode 100644 index 0000000000000..87c3a1a6fd3b3 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/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.ResourceManager.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/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ErrorDefinition.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ErrorDefinition.cs new file mode 100644 index 0000000000000..6e79fbdc028fb --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ErrorDefinition.cs @@ -0,0 +1,71 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Error definition. + /// + public partial class ErrorDefinition + { + /// + /// Initializes a new instance of the ErrorDefinition class. + /// + public ErrorDefinition() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ErrorDefinition class. + /// + /// Service specific error code which serves as the + /// substatus for the HTTP error code. + /// Description of the error. + /// Internal error details. + public ErrorDefinition(string code = default(string), string message = default(string), IList details = default(IList)) + { + Code = code; + Message = message; + Details = details; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets service specific error code which serves as the substatus for + /// the HTTP error code. + /// + [JsonProperty(PropertyName = "code")] + public string Code { get; private set; } + + /// + /// Gets description of the error. + /// + [JsonProperty(PropertyName = "message")] + public string Message { get; private set; } + + /// + /// Gets or sets internal error details. + /// + [JsonProperty(PropertyName = "details")] + public IList Details { get; set; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ErrorDetail.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ErrorDetail.cs new file mode 100644 index 0000000000000..a515312f044f7 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/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.ResourceManager.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/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ErrorResponse.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ErrorResponse.cs new file mode 100644 index 0000000000000..831192154e4e4 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/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.ResourceManager.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/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ErrorResponseException.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ErrorResponseException.cs new file mode 100644 index 0000000000000..a9790c9188e78 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/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.ResourceManager.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/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ExemptionCategory.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ExemptionCategory.cs new file mode 100644 index 0000000000000..dc456ca1e7f4e --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ExemptionCategory.cs @@ -0,0 +1,30 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager.Models +{ + + /// + /// Defines values for ExemptionCategory. + /// + public static class ExemptionCategory + { + /// + /// This category of exemptions usually means the scope is not + /// applicable for the policy. + /// + public const string Waiver = "Waiver"; + /// + /// This category of exemptions usually means the mitigation actions + /// have been applied to the scope. + /// + public const string Mitigated = "Mitigated"; + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ExportTemplateRequest.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ExportTemplateRequest.cs new file mode 100644 index 0000000000000..2ba24000c21d5 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ExportTemplateRequest.cs @@ -0,0 +1,71 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Export resource group template request parameters. + /// + public partial class ExportTemplateRequest + { + /// + /// Initializes a new instance of the ExportTemplateRequest class. + /// + public ExportTemplateRequest() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ExportTemplateRequest class. + /// + /// The IDs of the resources to filter the + /// export by. To export all resources, supply an array with single + /// entry '*'. + /// The export template options. A CSV-formatted + /// list containing zero or more of the following: + /// 'IncludeParameterDefaultValue', 'IncludeComments', + /// 'SkipResourceNameParameterization', + /// 'SkipAllParameterization' + public ExportTemplateRequest(IList resources = default(IList), string options = default(string)) + { + Resources = resources; + Options = options; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the IDs of the resources to filter the export by. To + /// export all resources, supply an array with single entry '*'. + /// + [JsonProperty(PropertyName = "resources")] + public IList Resources { get; set; } + + /// + /// Gets or sets the export template options. A CSV-formatted list + /// containing zero or more of the following: + /// 'IncludeParameterDefaultValue', 'IncludeComments', + /// 'SkipResourceNameParameterization', 'SkipAllParameterization' + /// + [JsonProperty(PropertyName = "options")] + public string Options { get; set; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ExpressionEvaluationOptions.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ExpressionEvaluationOptions.cs new file mode 100644 index 0000000000000..c4abdf4f77588 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ExpressionEvaluationOptions.cs @@ -0,0 +1,58 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Specifies whether template expressions are evaluated within the scope + /// of the parent template or nested template. + /// + public partial class ExpressionEvaluationOptions + { + /// + /// Initializes a new instance of the ExpressionEvaluationOptions + /// class. + /// + public ExpressionEvaluationOptions() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ExpressionEvaluationOptions + /// class. + /// + /// The scope to be used for evaluation of + /// parameters, variables and functions in a nested template. Possible + /// values include: 'NotSpecified', 'Outer', 'Inner' + public ExpressionEvaluationOptions(string scope = default(string)) + { + Scope = scope; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the scope to be used for evaluation of parameters, + /// variables and functions in a nested template. Possible values + /// include: 'NotSpecified', 'Outer', 'Inner' + /// + [JsonProperty(PropertyName = "scope")] + public string Scope { get; set; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ExpressionEvaluationOptionsScopeType.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ExpressionEvaluationOptionsScopeType.cs new file mode 100644 index 0000000000000..b15140dfe03b9 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ExpressionEvaluationOptionsScopeType.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.ResourceManager.Models +{ + + /// + /// Defines values for ExpressionEvaluationOptionsScopeType. + /// + public static class ExpressionEvaluationOptionsScopeType + { + public const string NotSpecified = "NotSpecified"; + public const string Outer = "Outer"; + public const string Inner = "Inner"; + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ExtendedLocation.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ExtendedLocation.cs new file mode 100644 index 0000000000000..db81c48ee2937 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ExtendedLocation.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.ResourceManager.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Resource extended location. + /// + public partial class ExtendedLocation + { + /// + /// Initializes a new instance of the ExtendedLocation class. + /// + public ExtendedLocation() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ExtendedLocation class. + /// + /// The extended location type. Possible values + /// include: 'EdgeZone' + /// The extended location name. + public ExtendedLocation(string type = default(string), string name = default(string)) + { + Type = type; + Name = name; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the extended location type. Possible values include: + /// 'EdgeZone' + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; set; } + + /// + /// Gets or sets the extended location name. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ExtendedLocationType.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ExtendedLocationType.cs new file mode 100644 index 0000000000000..263fe40a3798b --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ExtendedLocationType.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.ResourceManager.Models +{ + + /// + /// Defines values for ExtendedLocationType. + /// + public static class ExtendedLocationType + { + public const string EdgeZone = "EdgeZone"; + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/FeatureProperties.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/FeatureProperties.cs new file mode 100644 index 0000000000000..6e86168579bc9 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/FeatureProperties.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.ResourceManager.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Information about feature. + /// + public partial class FeatureProperties + { + /// + /// Initializes a new instance of the FeatureProperties class. + /// + public FeatureProperties() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the FeatureProperties class. + /// + /// The registration state of the feature for the + /// subscription. + public FeatureProperties(string state = default(string)) + { + State = state; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the registration state of the feature for the + /// subscription. + /// + [JsonProperty(PropertyName = "state")] + public string State { get; set; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/FeatureResult.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/FeatureResult.cs new file mode 100644 index 0000000000000..56b34b0199580 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/FeatureResult.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.ResourceManager.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Previewed feature information. + /// + public partial class FeatureResult + { + /// + /// Initializes a new instance of the FeatureResult class. + /// + public FeatureResult() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the FeatureResult class. + /// + /// The name of the feature. + /// Properties of the previewed + /// feature. + /// The resource ID of the feature. + /// The resource type of the feature. + public FeatureResult(string name = default(string), FeatureProperties properties = default(FeatureProperties), string id = default(string), string type = default(string)) + { + Name = name; + Properties = properties; + Id = id; + Type = type; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the name of the feature. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Gets or sets properties of the previewed feature. + /// + [JsonProperty(PropertyName = "properties")] + public FeatureProperties Properties { get; set; } + + /// + /// Gets or sets the resource ID of the feature. + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; set; } + + /// + /// Gets or sets the resource type of the feature. + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; set; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/Filter.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/Filter.cs new file mode 100644 index 0000000000000..143f1a28943a1 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/Filter.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.ResourceManager.Models +{ + using Newtonsoft.Json; + using Newtonsoft.Json.Converters; + using System.Runtime; + using System.Runtime.Serialization; + + /// + /// Defines values for Filter. + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum Filter + { + [EnumMember(Value = "atScope()")] + AtScope + } + internal static class FilterEnumExtension + { + internal static string ToSerializedValue(this Filter? value) + { + return value == null ? null : ((Filter)value).ToSerializedValue(); + } + + internal static string ToSerializedValue(this Filter value) + { + switch( value ) + { + case Filter.AtScope: + return "atScope()"; + } + return null; + } + + internal static Filter? ParseFilter(this string value) + { + switch( value ) + { + case "atScope()": + return Filter.AtScope; + } + return null; + } + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/GenericResource.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/GenericResource.cs new file mode 100644 index 0000000000000..f2834b15dfdbd --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/GenericResource.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.ResourceManager.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Resource information. + /// + public partial class GenericResource : Resource + { + /// + /// Initializes a new instance of the GenericResource class. + /// + public GenericResource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the GenericResource class. + /// + /// Resource ID + /// Resource name + /// Resource type + /// Resource location + /// Resource extended location. + /// Resource tags + /// The plan of the resource. + /// The resource properties. + /// The kind of the resource. + /// ID of the resource that manages this + /// resource. + /// The SKU of the resource. + /// The identity of the resource. + public GenericResource(string id = default(string), string name = default(string), string type = default(string), string location = default(string), ExtendedLocation extendedLocation = default(ExtendedLocation), IDictionary tags = default(IDictionary), Plan plan = default(Plan), object properties = default(object), string kind = default(string), string managedBy = default(string), Sku sku = default(Sku), Identity identity = default(Identity)) + : base(id, name, type, location, extendedLocation, tags) + { + Plan = plan; + Properties = properties; + Kind = kind; + ManagedBy = managedBy; + Sku = sku; + Identity = identity; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the plan of the resource. + /// + [JsonProperty(PropertyName = "plan")] + public Plan Plan { get; set; } + + /// + /// Gets or sets the resource properties. + /// + [JsonProperty(PropertyName = "properties")] + public object Properties { get; set; } + + /// + /// Gets or sets the kind of the resource. + /// + [JsonProperty(PropertyName = "kind")] + public string Kind { get; set; } + + /// + /// Gets or sets ID of the resource that manages this resource. + /// + [JsonProperty(PropertyName = "managedBy")] + public string ManagedBy { get; set; } + + /// + /// Gets or sets the SKU of the resource. + /// + [JsonProperty(PropertyName = "sku")] + public Sku Sku { get; set; } + + /// + /// Gets or sets the identity of the resource. + /// + [JsonProperty(PropertyName = "identity")] + public Identity Identity { 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\\._,\\(\\)]+$"); + } + } + } + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/GenericResourceExpanded.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/GenericResourceExpanded.cs new file mode 100644 index 0000000000000..3300fecd2edd4 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/GenericResourceExpanded.cs @@ -0,0 +1,100 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Resource information. + /// + public partial class GenericResourceExpanded : GenericResource + { + /// + /// Initializes a new instance of the GenericResourceExpanded class. + /// + public GenericResourceExpanded() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the GenericResourceExpanded class. + /// + /// Resource ID + /// Resource name + /// Resource type + /// Resource location + /// Resource extended location. + /// Resource tags + /// The plan of the resource. + /// The resource properties. + /// The kind of the resource. + /// ID of the resource that manages this + /// resource. + /// The SKU of the resource. + /// The identity of the resource. + /// The created time of the resource. This is + /// only present if requested via the $expand query parameter. + /// The changed time of the resource. This is + /// only present if requested via the $expand query parameter. + /// The provisioning state of the + /// resource. This is only present if requested via the $expand query + /// parameter. + public GenericResourceExpanded(string id = default(string), string name = default(string), string type = default(string), string location = default(string), ExtendedLocation extendedLocation = default(ExtendedLocation), IDictionary tags = default(IDictionary), Plan plan = default(Plan), object properties = default(object), string kind = default(string), string managedBy = default(string), Sku sku = default(Sku), Identity identity = default(Identity), System.DateTime? createdTime = default(System.DateTime?), System.DateTime? changedTime = default(System.DateTime?), string provisioningState = default(string)) + : base(id, name, type, location, extendedLocation, tags, plan, properties, kind, managedBy, sku, identity) + { + CreatedTime = createdTime; + ChangedTime = changedTime; + ProvisioningState = provisioningState; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the created time of the resource. This is only present if + /// requested via the $expand query parameter. + /// + [JsonProperty(PropertyName = "createdTime")] + public System.DateTime? CreatedTime { get; private set; } + + /// + /// Gets the changed time of the resource. This is only present if + /// requested via the $expand query parameter. + /// + [JsonProperty(PropertyName = "changedTime")] + public System.DateTime? ChangedTime { get; private set; } + + /// + /// Gets the provisioning state of the resource. This is only present + /// if requested via the $expand query parameter. + /// + [JsonProperty(PropertyName = "provisioningState")] + public string ProvisioningState { get; private set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public override void Validate() + { + base.Validate(); + } + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/GenericResourceFilter.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/GenericResourceFilter.cs new file mode 100644 index 0000000000000..93dbd2d06e57b --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/GenericResourceFilter.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.ResourceManager.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Resource filter. + /// + public partial class GenericResourceFilter + { + /// + /// Initializes a new instance of the GenericResourceFilter class. + /// + public GenericResourceFilter() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the GenericResourceFilter class. + /// + /// The resource type. + /// The tag name. + /// The tag value. + public GenericResourceFilter(string resourceType = default(string), string tagname = default(string), string tagvalue = default(string)) + { + ResourceType = resourceType; + Tagname = tagname; + Tagvalue = tagvalue; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the resource type. + /// + [JsonProperty(PropertyName = "resourceType")] + public string ResourceType { get; set; } + + /// + /// Gets or sets the tag name. + /// + [JsonProperty(PropertyName = "tagname")] + public string Tagname { get; set; } + + /// + /// Gets or sets the tag value. + /// + [JsonProperty(PropertyName = "tagvalue")] + public string Tagvalue { get; set; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/HttpMessage.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/HttpMessage.cs new file mode 100644 index 0000000000000..c9622e0b67ba5 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/HttpMessage.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.ResourceManager.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// HTTP message. + /// + public partial class HttpMessage + { + /// + /// Initializes a new instance of the HttpMessage class. + /// + public HttpMessage() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the HttpMessage class. + /// + /// HTTP message content. + public HttpMessage(object content = default(object)) + { + Content = content; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets HTTP message content. + /// + [JsonProperty(PropertyName = "content")] + public object Content { get; set; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/Identity.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/Identity.cs new file mode 100644 index 0000000000000..dd150852c121e --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/Identity.cs @@ -0,0 +1,88 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + 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 tenant ID of resource. + /// The identity type. Possible values include: + /// 'SystemAssigned', 'UserAssigned', 'SystemAssigned, UserAssigned', + /// 'None' + /// The list of user identities + /// associated with the resource. The user identity dictionary key + /// references will be ARM resource ids in the form: + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. + public Identity(string principalId = default(string), string tenantId = default(string), ResourceIdentityType? type = default(ResourceIdentityType?), IDictionary userAssignedIdentities = default(IDictionary)) + { + PrincipalId = principalId; + TenantId = tenantId; + Type = type; + UserAssignedIdentities = userAssignedIdentities; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the principal ID of resource identity. + /// + [JsonProperty(PropertyName = "principalId")] + public string PrincipalId { get; private set; } + + /// + /// Gets the tenant ID of resource. + /// + [JsonProperty(PropertyName = "tenantId")] + public string TenantId { get; private set; } + + /// + /// Gets or sets the identity type. Possible values include: + /// 'SystemAssigned', 'UserAssigned', 'SystemAssigned, UserAssigned', + /// 'None' + /// + [JsonProperty(PropertyName = "type")] + public ResourceIdentityType? Type { get; set; } + + /// + /// Gets or sets the list of user identities associated with the + /// resource. The user identity dictionary key references will be ARM + /// resource ids in the form: + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. + /// + [JsonProperty(PropertyName = "userAssignedIdentities")] + public IDictionary UserAssignedIdentities { get; set; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/IdentityUserAssignedIdentitiesValue.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/IdentityUserAssignedIdentitiesValue.cs new file mode 100644 index 0000000000000..94f992f7392bd --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/IdentityUserAssignedIdentitiesValue.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.ResourceManager.Models +{ + using Newtonsoft.Json; + using System.Linq; + + public partial class IdentityUserAssignedIdentitiesValue + { + /// + /// Initializes a new instance of the + /// IdentityUserAssignedIdentitiesValue class. + /// + public IdentityUserAssignedIdentitiesValue() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// IdentityUserAssignedIdentitiesValue class. + /// + /// The principal id of user assigned + /// identity. + /// The client id of user assigned + /// identity. + public IdentityUserAssignedIdentitiesValue(string principalId = default(string), string clientId = default(string)) + { + PrincipalId = principalId; + ClientId = clientId; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the principal id of user assigned identity. + /// + [JsonProperty(PropertyName = "principalId")] + public string PrincipalId { get; private set; } + + /// + /// Gets the client id of user assigned identity. + /// + [JsonProperty(PropertyName = "clientId")] + public string ClientId { get; private set; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/LinkedTemplateArtifact.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/LinkedTemplateArtifact.cs new file mode 100644 index 0000000000000..6ebb80d7812e0 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/LinkedTemplateArtifact.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.ResourceManager.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Represents a Template Spec artifact containing an embedded Azure + /// Resource Manager template for use as a linked template. + /// + public partial class LinkedTemplateArtifact + { + /// + /// Initializes a new instance of the LinkedTemplateArtifact class. + /// + public LinkedTemplateArtifact() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the LinkedTemplateArtifact class. + /// + /// A filesystem safe relative path of the + /// artifact. + /// The Azure Resource Manager template. + public LinkedTemplateArtifact(string path, object template) + { + Path = path; + Template = template; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets a filesystem safe relative path of the artifact. + /// + [JsonProperty(PropertyName = "path")] + public string Path { get; set; } + + /// + /// Gets or sets the Azure Resource Manager template. + /// + [JsonProperty(PropertyName = "template")] + public object Template { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Path == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Path"); + } + if (Template == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Template"); + } + } + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/Location.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/Location.cs new file mode 100644 index 0000000000000..598099f07a501 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/Location.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.ResourceManager.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Location information. + /// + public partial class Location + { + /// + /// Initializes a new instance of the Location class. + /// + public Location() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Location class. + /// + /// The fully qualified ID of the location. For + /// example, + /// /subscriptions/00000000-0000-0000-0000-000000000000/locations/westus. + /// The subscription ID. + /// The location name. + /// The location type. Possible values include: + /// 'Region', 'EdgeZone' + /// The display name of the location. + /// The display name of the location + /// and its region. + /// Metadata of the location, such as lat/long, + /// paired region, and others. + public Location(string id = default(string), string subscriptionId = default(string), string name = default(string), LocationType? type = default(LocationType?), string displayName = default(string), string regionalDisplayName = default(string), LocationMetadata metadata = default(LocationMetadata)) + { + Id = id; + SubscriptionId = subscriptionId; + Name = name; + Type = type; + DisplayName = displayName; + RegionalDisplayName = regionalDisplayName; + Metadata = metadata; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the fully qualified ID of the location. For example, + /// /subscriptions/00000000-0000-0000-0000-000000000000/locations/westus. + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; private set; } + + /// + /// Gets the subscription ID. + /// + [JsonProperty(PropertyName = "subscriptionId")] + public string SubscriptionId { get; private set; } + + /// + /// Gets the location name. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; private set; } + + /// + /// Gets the location type. Possible values include: 'Region', + /// 'EdgeZone' + /// + [JsonProperty(PropertyName = "type")] + public LocationType? Type { get; private set; } + + /// + /// Gets the display name of the location. + /// + [JsonProperty(PropertyName = "displayName")] + public string DisplayName { get; private set; } + + /// + /// Gets the display name of the location and its region. + /// + [JsonProperty(PropertyName = "regionalDisplayName")] + public string RegionalDisplayName { get; private set; } + + /// + /// Gets or sets metadata of the location, such as lat/long, paired + /// region, and others. + /// + [JsonProperty(PropertyName = "metadata")] + public LocationMetadata Metadata { get; set; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/LocationMetadata.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/LocationMetadata.cs new file mode 100644 index 0000000000000..7904ca9a0e3ed --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/LocationMetadata.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.ResourceManager.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Location metadata information + /// + public partial class LocationMetadata + { + /// + /// Initializes a new instance of the LocationMetadata class. + /// + public LocationMetadata() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the LocationMetadata class. + /// + /// The type of the region. Possible values + /// include: 'Physical', 'Logical' + /// The category of the region. Possible + /// values include: 'Recommended', 'Extended', 'Other' + /// The geography group of the + /// location. + /// The longitude of the location. + /// The latitude of the location. + /// The physical location of the Azure + /// location. + /// The regions paired to this + /// region. + /// The home location of an edge + /// zone. + public LocationMetadata(string regionType = default(string), string regionCategory = default(string), string geographyGroup = default(string), string longitude = default(string), string latitude = default(string), string physicalLocation = default(string), IList pairedRegion = default(IList), string homeLocation = default(string)) + { + RegionType = regionType; + RegionCategory = regionCategory; + GeographyGroup = geographyGroup; + Longitude = longitude; + Latitude = latitude; + PhysicalLocation = physicalLocation; + PairedRegion = pairedRegion; + HomeLocation = homeLocation; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the type of the region. Possible values include: 'Physical', + /// 'Logical' + /// + [JsonProperty(PropertyName = "regionType")] + public string RegionType { get; private set; } + + /// + /// Gets the category of the region. Possible values include: + /// 'Recommended', 'Extended', 'Other' + /// + [JsonProperty(PropertyName = "regionCategory")] + public string RegionCategory { get; private set; } + + /// + /// Gets the geography group of the location. + /// + [JsonProperty(PropertyName = "geographyGroup")] + public string GeographyGroup { get; private set; } + + /// + /// Gets the longitude of the location. + /// + [JsonProperty(PropertyName = "longitude")] + public string Longitude { get; private set; } + + /// + /// Gets the latitude of the location. + /// + [JsonProperty(PropertyName = "latitude")] + public string Latitude { get; private set; } + + /// + /// Gets the physical location of the Azure location. + /// + [JsonProperty(PropertyName = "physicalLocation")] + public string PhysicalLocation { get; private set; } + + /// + /// Gets or sets the regions paired to this region. + /// + [JsonProperty(PropertyName = "pairedRegion")] + public IList PairedRegion { get; set; } + + /// + /// Gets the home location of an edge zone. + /// + [JsonProperty(PropertyName = "homeLocation")] + public string HomeLocation { get; private set; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/LocationType.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/LocationType.cs new file mode 100644 index 0000000000000..dc03102a3ca3f --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/LocationType.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.ResourceManager.Models +{ + using Newtonsoft.Json; + using Newtonsoft.Json.Converters; + using System.Runtime; + using System.Runtime.Serialization; + + /// + /// Defines values for LocationType. + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum LocationType + { + [EnumMember(Value = "Region")] + Region, + [EnumMember(Value = "EdgeZone")] + EdgeZone + } + internal static class LocationTypeEnumExtension + { + internal static string ToSerializedValue(this LocationType? value) + { + return value == null ? null : ((LocationType)value).ToSerializedValue(); + } + + internal static string ToSerializedValue(this LocationType value) + { + switch( value ) + { + case LocationType.Region: + return "Region"; + case LocationType.EdgeZone: + return "EdgeZone"; + } + return null; + } + + internal static LocationType? ParseLocationType(this string value) + { + switch( value ) + { + case "Region": + return LocationType.Region; + case "EdgeZone": + return LocationType.EdgeZone; + } + return null; + } + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/LockLevel.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/LockLevel.cs new file mode 100644 index 0000000000000..f57b4854103d5 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/LockLevel.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.ResourceManager.Models +{ + + /// + /// Defines values for LockLevel. + /// + public static class LockLevel + { + public const string NotSpecified = "NotSpecified"; + public const string CanNotDelete = "CanNotDelete"; + public const string ReadOnly = "ReadOnly"; + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ManagedByTenant.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ManagedByTenant.cs new file mode 100644 index 0000000000000..8a1f42a3828f7 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ManagedByTenant.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.ResourceManager.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Information about a tenant managing the subscription. + /// + public partial class ManagedByTenant + { + /// + /// Initializes a new instance of the ManagedByTenant class. + /// + public ManagedByTenant() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ManagedByTenant class. + /// + /// The tenant ID of the managing tenant. This + /// is a GUID. + public ManagedByTenant(string tenantId = default(string)) + { + TenantId = tenantId; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the tenant ID of the managing tenant. This is a GUID. + /// + [JsonProperty(PropertyName = "tenantId")] + public string TenantId { get; private set; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ManagedServiceIdentity.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ManagedServiceIdentity.cs new file mode 100644 index 0000000000000..57cad4ab69910 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ManagedServiceIdentity.cs @@ -0,0 +1,75 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Managed identity generic object. + /// + public partial class ManagedServiceIdentity + { + /// + /// Initializes a new instance of the ManagedServiceIdentity class. + /// + public ManagedServiceIdentity() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ManagedServiceIdentity class. + /// + /// Type of the managed identity. Possible values + /// include: 'UserAssigned' + /// ID of the Azure Active Directory. + /// The list of user-assigned + /// managed identities associated with the resource. Key is the Azure + /// resource Id of the managed identity. + public ManagedServiceIdentity(string type = default(string), string tenantId = default(string), IDictionary userAssignedIdentities = default(IDictionary)) + { + Type = type; + TenantId = tenantId; + UserAssignedIdentities = userAssignedIdentities; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets type of the managed identity. Possible values include: + /// 'UserAssigned' + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; set; } + + /// + /// Gets ID of the Azure Active Directory. + /// + [JsonProperty(PropertyName = "tenantId")] + public string TenantId { get; private set; } + + /// + /// Gets or sets the list of user-assigned managed identities + /// associated with the resource. Key is the Azure resource Id of the + /// managed identity. + /// + [JsonProperty(PropertyName = "userAssignedIdentities")] + public IDictionary UserAssignedIdentities { get; set; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ManagedServiceIdentityType.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ManagedServiceIdentityType.cs new file mode 100644 index 0000000000000..5641636c2ecd9 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ManagedServiceIdentityType.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.ResourceManager.Models +{ + + /// + /// Defines values for ManagedServiceIdentityType. + /// + public static class ManagedServiceIdentityType + { + public const string UserAssigned = "UserAssigned"; + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ManagementLockObject.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ManagementLockObject.cs new file mode 100644 index 0000000000000..061777ce2b5bf --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ManagementLockObject.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.ResourceManager.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The lock information. + /// + [Rest.Serialization.JsonTransformation] + public partial class ManagementLockObject : IResource + { + /// + /// Initializes a new instance of the ManagementLockObject class. + /// + public ManagementLockObject() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ManagementLockObject class. + /// + /// The level of the lock. Possible values are: + /// NotSpecified, CanNotDelete, ReadOnly. CanNotDelete means authorized + /// users are able to read and modify the resources, but not delete. + /// ReadOnly means authorized users can only read from a resource, but + /// they can't modify or delete it. Possible values include: + /// 'NotSpecified', 'CanNotDelete', 'ReadOnly' + /// Notes about the lock. Maximum of 512 + /// characters. + /// The owners of the lock. + /// The resource ID of the lock. + /// The resource type of the lock - + /// Microsoft.Authorization/locks. + /// The name of the lock. + public ManagementLockObject(string level, string notes = default(string), IList owners = default(IList), string id = default(string), string type = default(string), string name = default(string), SystemData systemData = default(SystemData)) + { + Level = level; + Notes = notes; + Owners = owners; + Id = id; + Type = type; + Name = name; + SystemData = systemData; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the level of the lock. Possible values are: + /// NotSpecified, CanNotDelete, ReadOnly. CanNotDelete means authorized + /// users are able to read and modify the resources, but not delete. + /// ReadOnly means authorized users can only read from a resource, but + /// they can't modify or delete it. Possible values include: + /// 'NotSpecified', 'CanNotDelete', 'ReadOnly' + /// + [JsonProperty(PropertyName = "properties.level")] + public string Level { get; set; } + + /// + /// Gets or sets notes about the lock. Maximum of 512 characters. + /// + [JsonProperty(PropertyName = "properties.notes")] + public string Notes { get; set; } + + /// + /// Gets or sets the owners of the lock. + /// + [JsonProperty(PropertyName = "properties.owners")] + public IList Owners { get; set; } + + /// + /// Gets the resource ID of the lock. + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; private set; } + + /// + /// Gets the resource type of the lock - Microsoft.Authorization/locks. + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; private set; } + + /// + /// Gets the name of the lock. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; private set; } + + /// + /// + [JsonProperty(PropertyName = "systemData")] + public SystemData SystemData { get; private set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Level == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Level"); + } + } + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ManagementLockOwner.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ManagementLockOwner.cs new file mode 100644 index 0000000000000..3223e31ecba75 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ManagementLockOwner.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.ResourceManager.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Lock owner properties. + /// + public partial class ManagementLockOwner + { + /// + /// Initializes a new instance of the ManagementLockOwner class. + /// + public ManagementLockOwner() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ManagementLockOwner class. + /// + /// The application ID of the lock + /// owner. + public ManagementLockOwner(string applicationId = default(string)) + { + ApplicationId = applicationId; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the application ID of the lock owner. + /// + [JsonProperty(PropertyName = "applicationId")] + public string ApplicationId { get; set; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/NonComplianceMessage.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/NonComplianceMessage.cs new file mode 100644 index 0000000000000..d7c74d09cff14 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/NonComplianceMessage.cs @@ -0,0 +1,88 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// A message that describes why a resource is non-compliant with the + /// policy. This is shown in 'deny' error messages and on resource's + /// non-compliant compliance results. + /// + public partial class NonComplianceMessage + { + /// + /// Initializes a new instance of the NonComplianceMessage class. + /// + public NonComplianceMessage() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the NonComplianceMessage class. + /// + /// A message that describes why a resource is + /// non-compliant with the policy. This is shown in 'deny' error + /// messages and on resource's non-compliant compliance + /// results. + /// The policy definition + /// reference ID within a policy set definition the message is intended + /// for. This is only applicable if the policy assignment assigns a + /// policy set definition. If this is not provided the message applies + /// to all policies assigned by this policy assignment. + public NonComplianceMessage(string message, string policyDefinitionReferenceId = default(string)) + { + Message = message; + PolicyDefinitionReferenceId = policyDefinitionReferenceId; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets a message that describes why a resource is + /// non-compliant with the policy. This is shown in 'deny' error + /// messages and on resource's non-compliant compliance results. + /// + [JsonProperty(PropertyName = "message")] + public string Message { get; set; } + + /// + /// Gets or sets the policy definition reference ID within a policy set + /// definition the message is intended for. This is only applicable if + /// the policy assignment assigns a policy set definition. If this is + /// not provided the message applies to all policies assigned by this + /// policy assignment. + /// + [JsonProperty(PropertyName = "policyDefinitionReferenceId")] + public string PolicyDefinitionReferenceId { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Message == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Message"); + } + } + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/OnErrorDeployment.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/OnErrorDeployment.cs new file mode 100644 index 0000000000000..bb89dd8e83bc1 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/OnErrorDeployment.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.ResourceManager.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Deployment on error behavior. + /// + public partial class OnErrorDeployment + { + /// + /// Initializes a new instance of the OnErrorDeployment class. + /// + public OnErrorDeployment() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the OnErrorDeployment class. + /// + /// The deployment on error behavior type. Possible + /// values are LastSuccessful and SpecificDeployment. Possible values + /// include: 'LastSuccessful', 'SpecificDeployment' + /// The deployment to be used on error + /// case. + public OnErrorDeployment(OnErrorDeploymentType? type = default(OnErrorDeploymentType?), string deploymentName = default(string)) + { + Type = type; + DeploymentName = deploymentName; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the deployment on error behavior type. Possible values + /// are LastSuccessful and SpecificDeployment. Possible values include: + /// 'LastSuccessful', 'SpecificDeployment' + /// + [JsonProperty(PropertyName = "type")] + public OnErrorDeploymentType? Type { get; set; } + + /// + /// Gets or sets the deployment to be used on error case. + /// + [JsonProperty(PropertyName = "deploymentName")] + public string DeploymentName { get; set; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/OnErrorDeploymentExtended.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/OnErrorDeploymentExtended.cs new file mode 100644 index 0000000000000..74c041f61fb7a --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/OnErrorDeploymentExtended.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.ResourceManager.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Deployment on error behavior with additional details. + /// + public partial class OnErrorDeploymentExtended + { + /// + /// Initializes a new instance of the OnErrorDeploymentExtended class. + /// + public OnErrorDeploymentExtended() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the OnErrorDeploymentExtended class. + /// + /// The state of the provisioning for + /// the on error deployment. + /// The deployment on error behavior type. Possible + /// values are LastSuccessful and SpecificDeployment. Possible values + /// include: 'LastSuccessful', 'SpecificDeployment' + /// The deployment to be used on error + /// case. + public OnErrorDeploymentExtended(string provisioningState = default(string), OnErrorDeploymentType? type = default(OnErrorDeploymentType?), string deploymentName = default(string)) + { + ProvisioningState = provisioningState; + Type = type; + DeploymentName = deploymentName; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the state of the provisioning for the on error deployment. + /// + [JsonProperty(PropertyName = "provisioningState")] + public string ProvisioningState { get; private set; } + + /// + /// Gets or sets the deployment on error behavior type. Possible values + /// are LastSuccessful and SpecificDeployment. Possible values include: + /// 'LastSuccessful', 'SpecificDeployment' + /// + [JsonProperty(PropertyName = "type")] + public OnErrorDeploymentType? Type { get; set; } + + /// + /// Gets or sets the deployment to be used on error case. + /// + [JsonProperty(PropertyName = "deploymentName")] + public string DeploymentName { get; set; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/OnErrorDeploymentType.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/OnErrorDeploymentType.cs new file mode 100644 index 0000000000000..1871c20061c51 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/OnErrorDeploymentType.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.ResourceManager.Models +{ + using Newtonsoft.Json; + using Newtonsoft.Json.Converters; + using System.Runtime; + using System.Runtime.Serialization; + + /// + /// Defines values for OnErrorDeploymentType. + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum OnErrorDeploymentType + { + [EnumMember(Value = "LastSuccessful")] + LastSuccessful, + [EnumMember(Value = "SpecificDeployment")] + SpecificDeployment + } + internal static class OnErrorDeploymentTypeEnumExtension + { + internal static string ToSerializedValue(this OnErrorDeploymentType? value) + { + return value == null ? null : ((OnErrorDeploymentType)value).ToSerializedValue(); + } + + internal static string ToSerializedValue(this OnErrorDeploymentType value) + { + switch( value ) + { + case OnErrorDeploymentType.LastSuccessful: + return "LastSuccessful"; + case OnErrorDeploymentType.SpecificDeployment: + return "SpecificDeployment"; + } + return null; + } + + internal static OnErrorDeploymentType? ParseOnErrorDeploymentType(this string value) + { + switch( value ) + { + case "LastSuccessful": + return OnErrorDeploymentType.LastSuccessful; + case "SpecificDeployment": + return OnErrorDeploymentType.SpecificDeployment; + } + return null; + } + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/Operation.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/Operation.cs new file mode 100644 index 0000000000000..fdac5ca3c8c95 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/Operation.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.ResourceManager.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Microsoft.Resources operation + /// + public partial class Operation + { + /// + /// Initializes a new instance of the Operation class. + /// + public Operation() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Operation class. + /// + /// Operation name: + /// {provider}/{resource}/{operation} + /// The object that represents the + /// operation. + public Operation(string name = default(string), OperationDisplay display = default(OperationDisplay)) + { + Name = name; + Display = display; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets operation name: {provider}/{resource}/{operation} + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Gets or sets the object that represents the operation. + /// + [JsonProperty(PropertyName = "display")] + public OperationDisplay Display { get; set; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/OperationDisplay.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/OperationDisplay.cs new file mode 100644 index 0000000000000..df5d9350a8b2d --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/OperationDisplay.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.ResourceManager.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The object that represents 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. + /// + /// Service provider: + /// Microsoft.Resources + /// Resource on which the operation is + /// performed: Profile, endpoint, etc. + /// Operation type: Read, write, delete, + /// etc. + /// Description of the operation. + 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 or sets service provider: Microsoft.Resources + /// + [JsonProperty(PropertyName = "provider")] + public string Provider { get; set; } + + /// + /// Gets or sets resource on which the operation is performed: Profile, + /// endpoint, etc. + /// + [JsonProperty(PropertyName = "resource")] + public string Resource { get; set; } + + /// + /// Gets or sets operation type: Read, write, delete, etc. + /// + [JsonProperty(PropertyName = "operation")] + public string Operation { get; set; } + + /// + /// Gets or sets description of the operation. + /// + [JsonProperty(PropertyName = "description")] + public string Description { get; set; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/OperationListResult.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/OperationListResult.cs new file mode 100644 index 0000000000000..b75ee39d020d6 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/OperationListResult.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.ResourceManager.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Result of the request to list Microsoft.Resources operations. It + /// contains a list of operations and a URL link to get the next set of + /// results. + /// + public partial class OperationListResult + { + /// + /// Initializes a new instance of the OperationListResult class. + /// + public OperationListResult() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the OperationListResult class. + /// + /// List of Microsoft.Resources operations. + /// URL to get the next set of operation list + /// results if there are any. + public OperationListResult(IList value = default(IList), string nextLink = default(string)) + { + Value = value; + NextLink = nextLink; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets list of Microsoft.Resources operations. + /// + [JsonProperty(PropertyName = "value")] + public IList Value { get; set; } + + /// + /// Gets or sets URL to get the next set of operation list results if + /// there are any. + /// + [JsonProperty(PropertyName = "nextLink")] + public string NextLink { get; set; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/Page.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/Page.cs new file mode 100644 index 0000000000000..c6f2533504c2f --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/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.ResourceManager.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/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/Page1.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/Page1.cs new file mode 100644 index 0000000000000..62aaea7013be7 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/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.ResourceManager.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/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/PairedRegion.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/PairedRegion.cs new file mode 100644 index 0000000000000..b5bf1a91097aa --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/PairedRegion.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.ResourceManager.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Information regarding paired region. + /// + public partial class PairedRegion + { + /// + /// Initializes a new instance of the PairedRegion class. + /// + public PairedRegion() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the PairedRegion class. + /// + /// The name of the paired region. + /// The fully qualified ID of the location. For + /// example, + /// /subscriptions/00000000-0000-0000-0000-000000000000/locations/westus. + /// The subscription ID. + public PairedRegion(string name = default(string), string id = default(string), string subscriptionId = default(string)) + { + Name = name; + Id = id; + SubscriptionId = subscriptionId; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the name of the paired region. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; private set; } + + /// + /// Gets the fully qualified ID of the location. For example, + /// /subscriptions/00000000-0000-0000-0000-000000000000/locations/westus. + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; private set; } + + /// + /// Gets the subscription ID. + /// + [JsonProperty(PropertyName = "subscriptionId")] + public string SubscriptionId { get; private set; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ParameterDefinitionsValue.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ParameterDefinitionsValue.cs new file mode 100644 index 0000000000000..4d27d1cf7d070 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ParameterDefinitionsValue.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.ResourceManager.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The definition of a parameter that can be provided to the policy. + /// + public partial class ParameterDefinitionsValue + { + /// + /// Initializes a new instance of the ParameterDefinitionsValue class. + /// + public ParameterDefinitionsValue() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ParameterDefinitionsValue class. + /// + /// The data type of the parameter. Possible values + /// include: 'String', 'Array', 'Object', 'Boolean', 'Integer', + /// 'Float', 'DateTime' + /// The allowed values for the + /// parameter. + /// The default value for the parameter if + /// no value is provided. + /// General metadata for the parameter. + public ParameterDefinitionsValue(string type = default(string), IList allowedValues = default(IList), object defaultValue = default(object), ParameterDefinitionsValueMetadata metadata = default(ParameterDefinitionsValueMetadata)) + { + Type = type; + AllowedValues = allowedValues; + DefaultValue = defaultValue; + Metadata = metadata; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the data type of the parameter. Possible values + /// include: 'String', 'Array', 'Object', 'Boolean', 'Integer', + /// 'Float', 'DateTime' + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; set; } + + /// + /// Gets or sets the allowed values for the parameter. + /// + [JsonProperty(PropertyName = "allowedValues")] + public IList AllowedValues { get; set; } + + /// + /// Gets or sets the default value for the parameter if no value is + /// provided. + /// + [JsonProperty(PropertyName = "defaultValue")] + public object DefaultValue { get; set; } + + /// + /// Gets or sets general metadata for the parameter. + /// + [JsonProperty(PropertyName = "metadata")] + public ParameterDefinitionsValueMetadata Metadata { get; set; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ParameterDefinitionsValueMetadata.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ParameterDefinitionsValueMetadata.cs new file mode 100644 index 0000000000000..3ae26a4239ec6 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ParameterDefinitionsValueMetadata.cs @@ -0,0 +1,101 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// General metadata for the parameter. + /// + public partial class ParameterDefinitionsValueMetadata + { + /// + /// Initializes a new instance of the ParameterDefinitionsValueMetadata + /// class. + /// + public ParameterDefinitionsValueMetadata() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ParameterDefinitionsValueMetadata + /// class. + /// + /// Unmatched properties from the + /// message are deserialized this collection + /// The display name for the + /// parameter. + /// The description of the parameter. + /// Used when assigning the policy definition + /// through the portal. Provides a context aware list of values for the + /// user to choose from. + /// Set to true to have Azure portal + /// create role assignments on the resource ID or resource scope value + /// of this parameter during policy assignment. This property is useful + /// in case you wish to assign permissions outside the assignment + /// scope. + public ParameterDefinitionsValueMetadata(IDictionary additionalProperties = default(IDictionary), string displayName = default(string), string description = default(string), string strongType = default(string), bool? assignPermissions = default(bool?)) + { + AdditionalProperties = additionalProperties; + DisplayName = displayName; + Description = description; + StrongType = strongType; + AssignPermissions = assignPermissions; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets unmatched properties from the message are deserialized + /// this collection + /// + [JsonExtensionData] + public IDictionary AdditionalProperties { get; set; } + + /// + /// Gets or sets the display name for the parameter. + /// + [JsonProperty(PropertyName = "displayName")] + public string DisplayName { get; set; } + + /// + /// Gets or sets the description of the parameter. + /// + [JsonProperty(PropertyName = "description")] + public string Description { get; set; } + + /// + /// Gets or sets used when assigning the policy definition through the + /// portal. Provides a context aware list of values for the user to + /// choose from. + /// + [JsonProperty(PropertyName = "strongType")] + public string StrongType { get; set; } + + /// + /// Gets or sets set to true to have Azure portal create role + /// assignments on the resource ID or resource scope value of this + /// parameter during policy assignment. This property is useful in case + /// you wish to assign permissions outside the assignment scope. + /// + [JsonProperty(PropertyName = "assignPermissions")] + public bool? AssignPermissions { get; set; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ParameterType.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ParameterType.cs new file mode 100644 index 0000000000000..f0b5f6f8e58ca --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ParameterType.cs @@ -0,0 +1,27 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager.Models +{ + + /// + /// Defines values for ParameterType. + /// + public static class ParameterType + { + public const string String = "String"; + public const string Array = "Array"; + public const string Object = "Object"; + public const string Boolean = "Boolean"; + public const string Integer = "Integer"; + public const string Float = "Float"; + public const string DateTime = "DateTime"; + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ParameterValuesValue.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ParameterValuesValue.cs new file mode 100644 index 0000000000000..7997512fea459 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ParameterValuesValue.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.ResourceManager.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The value of a parameter. + /// + public partial class ParameterValuesValue + { + /// + /// Initializes a new instance of the ParameterValuesValue class. + /// + public ParameterValuesValue() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ParameterValuesValue class. + /// + /// The value of the parameter. + public ParameterValuesValue(object value = default(object)) + { + Value = value; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the value of the parameter. + /// + [JsonProperty(PropertyName = "value")] + public object Value { get; set; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ParametersLink.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ParametersLink.cs new file mode 100644 index 0000000000000..349825db101d0 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ParametersLink.cs @@ -0,0 +1,75 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Entity representing the reference to the deployment parameters. + /// + public partial class ParametersLink + { + /// + /// Initializes a new instance of the ParametersLink class. + /// + public ParametersLink() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ParametersLink class. + /// + /// The URI of the parameters file. + /// If included, must match the + /// ContentVersion in the template. + public ParametersLink(string uri, string contentVersion = default(string)) + { + Uri = uri; + ContentVersion = contentVersion; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the URI of the parameters file. + /// + [JsonProperty(PropertyName = "uri")] + public string Uri { get; set; } + + /// + /// Gets or sets if included, must match the ContentVersion in the + /// template. + /// + [JsonProperty(PropertyName = "contentVersion")] + public string ContentVersion { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Uri == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Uri"); + } + } + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/Peers.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/Peers.cs new file mode 100644 index 0000000000000..a499857290759 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/Peers.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.ResourceManager.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Information about shared availability zone. + /// + public partial class Peers + { + /// + /// Initializes a new instance of the Peers class. + /// + public Peers() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Peers class. + /// + /// The subscription ID. + /// The availabilityZone. + public Peers(string subscriptionId = default(string), string availabilityZone = default(string)) + { + SubscriptionId = subscriptionId; + AvailabilityZone = availabilityZone; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the subscription ID. + /// + [JsonProperty(PropertyName = "subscriptionId")] + public string SubscriptionId { get; private set; } + + /// + /// Gets the availabilityZone. + /// + [JsonProperty(PropertyName = "availabilityZone")] + public string AvailabilityZone { get; private set; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/Permission.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/Permission.cs new file mode 100644 index 0000000000000..0baf8262ec85f --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/Permission.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.ResourceManager.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Role definition permissions. + /// + public partial class Permission + { + /// + /// Initializes a new instance of the Permission class. + /// + public Permission() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Permission class. + /// + /// Allowed actions. + /// Denied actions. + /// Allowed Data actions. + /// Denied Data actions. + public Permission(IList actions = default(IList), IList notActions = default(IList), IList dataActions = default(IList), IList notDataActions = default(IList)) + { + Actions = actions; + NotActions = notActions; + DataActions = dataActions; + NotDataActions = notDataActions; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets allowed actions. + /// + [JsonProperty(PropertyName = "actions")] + public IList Actions { get; set; } + + /// + /// Gets or sets denied actions. + /// + [JsonProperty(PropertyName = "notActions")] + public IList NotActions { get; set; } + + /// + /// Gets or sets allowed Data actions. + /// + [JsonProperty(PropertyName = "dataActions")] + public IList DataActions { get; set; } + + /// + /// Gets or sets denied Data actions. + /// + [JsonProperty(PropertyName = "notDataActions")] + public IList NotDataActions { get; set; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/Plan.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/Plan.cs new file mode 100644 index 0000000000000..af9d7de799be8 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/Plan.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.ResourceManager.Models +{ + 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. + /// + /// The plan ID. + /// The publisher ID. + /// The offer ID. + /// The promotion code. + /// The plan's version. + public Plan(string name = default(string), string publisher = default(string), string product = default(string), 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 the plan ID. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Gets or sets the publisher ID. + /// + [JsonProperty(PropertyName = "publisher")] + public string Publisher { get; set; } + + /// + /// Gets or sets the offer ID. + /// + [JsonProperty(PropertyName = "product")] + public string Product { get; set; } + + /// + /// Gets or sets the promotion code. + /// + [JsonProperty(PropertyName = "promotionCode")] + public string PromotionCode { get; set; } + + /// + /// Gets or sets the plan's version. + /// + [JsonProperty(PropertyName = "version")] + public string Version { get; set; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/PolicyAssignment.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/PolicyAssignment.cs new file mode 100644 index 0000000000000..3a1fdef7db6ea --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/PolicyAssignment.cs @@ -0,0 +1,190 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The policy assignment. + /// + [Rest.Serialization.JsonTransformation] + public partial class PolicyAssignment : IResource + { + /// + /// Initializes a new instance of the PolicyAssignment class. + /// + public PolicyAssignment() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the PolicyAssignment class. + /// + /// The display name of the policy + /// assignment. + /// The ID of the policy definition or + /// policy set definition being assigned. + /// The scope for the policy assignment. + /// The policy's excluded scopes. + /// The parameter values for the assigned + /// policy rule. The keys are the parameter names. + /// This message will be part of response in + /// case of policy violation. + /// The policy assignment metadata. Metadata is + /// an open ended object and is typically a collection of key value + /// pairs. + /// The policy assignment enforcement + /// mode. Possible values are Default and DoNotEnforce. Possible values + /// include: 'Default', 'DoNotEnforce' + /// The messages that describe why + /// a resource is non-compliant with the policy. + /// The ID of the policy assignment. + /// The type of the policy assignment. + /// The name of the policy assignment. + /// The location of the policy assignment. Only + /// required when utilizing managed identity. + /// The managed identity associated with the + /// policy assignment. + /// The system metadata relating to this + /// resource. + public PolicyAssignment(string displayName = default(string), string policyDefinitionId = default(string), string scope = default(string), IList notScopes = default(IList), IDictionary parameters = default(IDictionary), string description = default(string), object metadata = default(object), string enforcementMode = default(string), IList nonComplianceMessages = default(IList), string id = default(string), string type = default(string), string name = default(string), string location = default(string), Identity identity = default(Identity), SystemData systemData = default(SystemData)) + { + DisplayName = displayName; + PolicyDefinitionId = policyDefinitionId; + Scope = scope; + NotScopes = notScopes; + Parameters = parameters; + Description = description; + Metadata = metadata; + EnforcementMode = enforcementMode; + NonComplianceMessages = nonComplianceMessages; + Id = id; + Type = type; + Name = name; + Location = location; + Identity = identity; + SystemData = systemData; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the display name of the policy assignment. + /// + [JsonProperty(PropertyName = "properties.displayName")] + public string DisplayName { get; set; } + + /// + /// Gets or sets the ID of the policy definition or policy set + /// definition being assigned. + /// + [JsonProperty(PropertyName = "properties.policyDefinitionId")] + public string PolicyDefinitionId { get; set; } + + /// + /// Gets the scope for the policy assignment. + /// + [JsonProperty(PropertyName = "properties.scope")] + public string Scope { get; private set; } + + /// + /// Gets or sets the policy's excluded scopes. + /// + [JsonProperty(PropertyName = "properties.notScopes")] + public IList NotScopes { get; set; } + + /// + /// Gets or sets the parameter values for the assigned policy rule. The + /// keys are the parameter names. + /// + [JsonProperty(PropertyName = "properties.parameters")] + public IDictionary Parameters { get; set; } + + /// + /// Gets or sets this message will be part of response in case of + /// policy violation. + /// + [JsonProperty(PropertyName = "properties.description")] + public string Description { get; set; } + + /// + /// Gets or sets the policy assignment metadata. Metadata is an open + /// ended object and is typically a collection of key value pairs. + /// + [JsonProperty(PropertyName = "properties.metadata")] + public object Metadata { get; set; } + + /// + /// Gets or sets the policy assignment enforcement mode. Possible + /// values are Default and DoNotEnforce. Possible values include: + /// 'Default', 'DoNotEnforce' + /// + [JsonProperty(PropertyName = "properties.enforcementMode")] + public string EnforcementMode { get; set; } + + /// + /// Gets or sets the messages that describe why a resource is + /// non-compliant with the policy. + /// + [JsonProperty(PropertyName = "properties.nonComplianceMessages")] + public IList NonComplianceMessages { get; set; } + + /// + /// Gets the ID of the policy assignment. + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; private set; } + + /// + /// Gets the type of the policy assignment. + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; private set; } + + /// + /// Gets the name of the policy assignment. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; private set; } + + /// + /// Gets or sets the location of the policy assignment. Only required + /// when utilizing managed identity. + /// + [JsonProperty(PropertyName = "location")] + public string Location { get; set; } + + /// + /// Gets or sets the managed identity associated with the policy + /// assignment. + /// + [JsonProperty(PropertyName = "identity")] + public Identity Identity { get; set; } + + /// + /// Gets the system metadata relating to this resource. + /// + [JsonProperty(PropertyName = "systemData")] + public SystemData SystemData { get; private set; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/PolicyAssignmentUpdate.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/PolicyAssignmentUpdate.cs new file mode 100644 index 0000000000000..6c109800adc6c --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/PolicyAssignmentUpdate.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.ResourceManager.Models +{ + using Newtonsoft.Json; + using System.Linq; + + public partial class PolicyAssignmentUpdate + { + /// + /// Initializes a new instance of the PolicyAssignmentUpdate class. + /// + public PolicyAssignmentUpdate() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the PolicyAssignmentUpdate class. + /// + /// The location of the policy assignment. Only + /// required when utilizing managed identity. + /// The managed identity associated with the + /// policy assignment. + public PolicyAssignmentUpdate(string location = default(string), Identity identity = default(Identity)) + { + Location = location; + Identity = identity; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the location of the policy assignment. Only required + /// when utilizing managed identity. + /// + [JsonProperty(PropertyName = "location")] + public string Location { get; set; } + + /// + /// Gets or sets the managed identity associated with the policy + /// assignment. + /// + [JsonProperty(PropertyName = "identity")] + public Identity Identity { get; set; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/PolicyDefinition.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/PolicyDefinition.cs new file mode 100644 index 0000000000000..66ea554eacf38 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/PolicyDefinition.cs @@ -0,0 +1,154 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The policy definition. + /// + [Rest.Serialization.JsonTransformation] + public partial class PolicyDefinition : IResource + { + /// + /// Initializes a new instance of the PolicyDefinition class. + /// + public PolicyDefinition() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the PolicyDefinition class. + /// + /// The type of policy definition. Possible + /// values are NotSpecified, BuiltIn, Custom, and Static. Possible + /// values include: 'NotSpecified', 'BuiltIn', 'Custom', + /// 'Static' + /// The policy definition mode. Some examples are + /// All, Indexed, Microsoft.KeyVault.Data. + /// The display name of the policy + /// definition. + /// The policy definition + /// description. + /// The policy rule. + /// The policy definition metadata. Metadata is + /// an open ended object and is typically a collection of key value + /// pairs. + /// The parameter definitions for parameters + /// used in the policy rule. The keys are the parameter names. + /// The ID of the policy definition. + /// The name of the policy definition. + /// The type of the resource + /// (Microsoft.Authorization/policyDefinitions). + /// The system metadata relating to this + /// resource. + public PolicyDefinition(string policyType = default(string), string mode = default(string), string displayName = default(string), string description = default(string), object policyRule = default(object), object metadata = default(object), IDictionary parameters = default(IDictionary), string id = default(string), string name = default(string), string type = default(string), SystemData systemData = default(SystemData)) + { + PolicyType = policyType; + Mode = mode; + DisplayName = displayName; + Description = description; + PolicyRule = policyRule; + Metadata = metadata; + Parameters = parameters; + Id = id; + Name = name; + Type = type; + SystemData = systemData; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the type of policy definition. Possible values are + /// NotSpecified, BuiltIn, Custom, and Static. Possible values include: + /// 'NotSpecified', 'BuiltIn', 'Custom', 'Static' + /// + [JsonProperty(PropertyName = "properties.policyType")] + public string PolicyType { get; set; } + + /// + /// Gets or sets the policy definition mode. Some examples are All, + /// Indexed, Microsoft.KeyVault.Data. + /// + [JsonProperty(PropertyName = "properties.mode")] + public string Mode { get; set; } + + /// + /// Gets or sets the display name of the policy definition. + /// + [JsonProperty(PropertyName = "properties.displayName")] + public string DisplayName { get; set; } + + /// + /// Gets or sets the policy definition description. + /// + [JsonProperty(PropertyName = "properties.description")] + public string Description { get; set; } + + /// + /// Gets or sets the policy rule. + /// + [JsonProperty(PropertyName = "properties.policyRule")] + public object PolicyRule { get; set; } + + /// + /// Gets or sets the policy definition metadata. Metadata is an open + /// ended object and is typically a collection of key value pairs. + /// + [JsonProperty(PropertyName = "properties.metadata")] + public object Metadata { get; set; } + + /// + /// Gets or sets the parameter definitions for parameters used in the + /// policy rule. The keys are the parameter names. + /// + [JsonProperty(PropertyName = "properties.parameters")] + public IDictionary Parameters { get; set; } + + /// + /// Gets the ID of the policy definition. + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; private set; } + + /// + /// Gets the name of the policy definition. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; private set; } + + /// + /// Gets the type of the resource + /// (Microsoft.Authorization/policyDefinitions). + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; private set; } + + /// + /// Gets the system metadata relating to this resource. + /// + [JsonProperty(PropertyName = "systemData")] + public SystemData SystemData { get; private set; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/PolicyDefinitionGroup.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/PolicyDefinitionGroup.cs new file mode 100644 index 0000000000000..06cecef62a535 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/PolicyDefinitionGroup.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.ResourceManager.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// The policy definition group. + /// + public partial class PolicyDefinitionGroup + { + /// + /// Initializes a new instance of the PolicyDefinitionGroup class. + /// + public PolicyDefinitionGroup() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the PolicyDefinitionGroup class. + /// + /// The name of the group. + /// The group's display name. + /// The group's category. + /// The group's description. + /// A resource ID of a resource that + /// contains additional metadata about the group. + public PolicyDefinitionGroup(string name, string displayName = default(string), string category = default(string), string description = default(string), string additionalMetadataId = default(string)) + { + Name = name; + DisplayName = displayName; + Category = category; + Description = description; + AdditionalMetadataId = additionalMetadataId; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the name of the group. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Gets or sets the group's display name. + /// + [JsonProperty(PropertyName = "displayName")] + public string DisplayName { get; set; } + + /// + /// Gets or sets the group's category. + /// + [JsonProperty(PropertyName = "category")] + public string Category { get; set; } + + /// + /// Gets or sets the group's description. + /// + [JsonProperty(PropertyName = "description")] + public string Description { get; set; } + + /// + /// Gets or sets a resource ID of a resource that contains additional + /// metadata about the group. + /// + [JsonProperty(PropertyName = "additionalMetadataId")] + public string AdditionalMetadataId { 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/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/PolicyDefinitionReference.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/PolicyDefinitionReference.cs new file mode 100644 index 0000000000000..89c7b1af2cb01 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/PolicyDefinitionReference.cs @@ -0,0 +1,100 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The policy definition reference. + /// + public partial class PolicyDefinitionReference + { + /// + /// Initializes a new instance of the PolicyDefinitionReference class. + /// + public PolicyDefinitionReference() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the PolicyDefinitionReference class. + /// + /// The ID of the policy definition or + /// policy set definition. + /// The parameter values for the referenced + /// policy rule. The keys are the parameter names. + /// A unique id (within the + /// policy set definition) for this policy definition + /// reference. + /// The name of the groups that this policy + /// definition reference belongs to. + public PolicyDefinitionReference(string policyDefinitionId, IDictionary parameters = default(IDictionary), string policyDefinitionReferenceId = default(string), IList groupNames = default(IList)) + { + PolicyDefinitionId = policyDefinitionId; + Parameters = parameters; + PolicyDefinitionReferenceId = policyDefinitionReferenceId; + GroupNames = groupNames; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the ID of the policy definition or policy set + /// definition. + /// + [JsonProperty(PropertyName = "policyDefinitionId")] + public string PolicyDefinitionId { get; set; } + + /// + /// Gets or sets the parameter values for the referenced policy rule. + /// The keys are the parameter names. + /// + [JsonProperty(PropertyName = "parameters")] + public IDictionary Parameters { get; set; } + + /// + /// Gets or sets a unique id (within the policy set definition) for + /// this policy definition reference. + /// + [JsonProperty(PropertyName = "policyDefinitionReferenceId")] + public string PolicyDefinitionReferenceId { get; set; } + + /// + /// Gets or sets the name of the groups that this policy definition + /// reference belongs to. + /// + [JsonProperty(PropertyName = "groupNames")] + public IList GroupNames { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (PolicyDefinitionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "PolicyDefinitionId"); + } + } + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/PolicyExemption.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/PolicyExemption.cs new file mode 100644 index 0000000000000..b73b71abdf016 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/PolicyExemption.cs @@ -0,0 +1,175 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The policy exemption. + /// + [Rest.Serialization.JsonTransformation] + public partial class PolicyExemption : IResource + { + /// + /// Initializes a new instance of the PolicyExemption class. + /// + public PolicyExemption() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the PolicyExemption class. + /// + /// The ID of the policy assignment + /// that is being exempted. + /// The policy exemption category. + /// Possible values are Waiver and Mitigated. Possible values include: + /// 'Waiver', 'Mitigated' + /// The policy definition + /// reference ID list when the associated policy assignment is an + /// assignment of a policy set definition. + /// The expiration date and time (in UTC ISO + /// 8601 format yyyy-MM-ddTHH:mm:ssZ) of the policy exemption. + /// The display name of the policy + /// exemption. + /// The description of the policy + /// exemption. + /// The policy exemption metadata. Metadata is + /// an open ended object and is typically a collection of key value + /// pairs. + /// Azure Resource Manager metadata containing + /// createdBy and modifiedBy information. + /// The ID of the policy exemption. + /// The name of the policy exemption. + /// The type of the resource + /// (Microsoft.Authorization/policyExemptions). + public PolicyExemption(string policyAssignmentId, string exemptionCategory, IList policyDefinitionReferenceIds = default(IList), System.DateTime? expiresOn = default(System.DateTime?), string displayName = default(string), string description = default(string), object metadata = default(object), SystemData systemData = default(SystemData), string id = default(string), string name = default(string), string type = default(string)) + { + PolicyAssignmentId = policyAssignmentId; + PolicyDefinitionReferenceIds = policyDefinitionReferenceIds; + ExemptionCategory = exemptionCategory; + ExpiresOn = expiresOn; + DisplayName = displayName; + Description = description; + Metadata = metadata; + SystemData = systemData; + Id = id; + Name = name; + Type = type; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the ID of the policy assignment that is being + /// exempted. + /// + [JsonProperty(PropertyName = "properties.policyAssignmentId")] + public string PolicyAssignmentId { get; set; } + + /// + /// Gets or sets the policy definition reference ID list when the + /// associated policy assignment is an assignment of a policy set + /// definition. + /// + [JsonProperty(PropertyName = "properties.policyDefinitionReferenceIds")] + public IList PolicyDefinitionReferenceIds { get; set; } + + /// + /// Gets or sets the policy exemption category. Possible values are + /// Waiver and Mitigated. Possible values include: 'Waiver', + /// 'Mitigated' + /// + [JsonProperty(PropertyName = "properties.exemptionCategory")] + public string ExemptionCategory { get; set; } + + /// + /// Gets or sets the expiration date and time (in UTC ISO 8601 format + /// yyyy-MM-ddTHH:mm:ssZ) of the policy exemption. + /// + [JsonProperty(PropertyName = "properties.expiresOn")] + public System.DateTime? ExpiresOn { get; set; } + + /// + /// Gets or sets the display name of the policy exemption. + /// + [JsonProperty(PropertyName = "properties.displayName")] + public string DisplayName { get; set; } + + /// + /// Gets or sets the description of the policy exemption. + /// + [JsonProperty(PropertyName = "properties.description")] + public string Description { get; set; } + + /// + /// Gets or sets the policy exemption metadata. Metadata is an open + /// ended object and is typically a collection of key value pairs. + /// + [JsonProperty(PropertyName = "properties.metadata")] + public object Metadata { get; set; } + + /// + /// Gets azure Resource Manager metadata containing createdBy and + /// modifiedBy information. + /// + [JsonProperty(PropertyName = "systemData")] + public SystemData SystemData { get; private set; } + + /// + /// Gets the ID of the policy exemption. + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; private set; } + + /// + /// Gets the name of the policy exemption. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; private set; } + + /// + /// Gets the type of the resource + /// (Microsoft.Authorization/policyExemptions). + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; private set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (PolicyAssignmentId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "PolicyAssignmentId"); + } + if (ExemptionCategory == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "ExemptionCategory"); + } + } + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/PolicySetDefinition.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/PolicySetDefinition.cs new file mode 100644 index 0000000000000..04282b24967a0 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/PolicySetDefinition.cs @@ -0,0 +1,189 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The policy set definition. + /// + [Rest.Serialization.JsonTransformation] + public partial class PolicySetDefinition : IResource + { + /// + /// Initializes a new instance of the PolicySetDefinition class. + /// + public PolicySetDefinition() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the PolicySetDefinition class. + /// + /// An array of policy definition + /// references. + /// The type of policy definition. Possible + /// values are NotSpecified, BuiltIn, Custom, and Static. Possible + /// values include: 'NotSpecified', 'BuiltIn', 'Custom', + /// 'Static' + /// The display name of the policy set + /// definition. + /// The policy set definition + /// description. + /// The policy set definition metadata. + /// Metadata is an open ended object and is typically a collection of + /// key value pairs. + /// The policy set definition parameters that + /// can be used in policy definition references. + /// The metadata describing groups + /// of policy definition references within the policy set + /// definition. + /// The ID of the policy set definition. + /// The name of the policy set definition. + /// The type of the resource + /// (Microsoft.Authorization/policySetDefinitions). + /// The system metadata relating to this + /// resource. + public PolicySetDefinition(IList policyDefinitions, string policyType = default(string), string displayName = default(string), string description = default(string), object metadata = default(object), IDictionary parameters = default(IDictionary), IList policyDefinitionGroups = default(IList), string id = default(string), string name = default(string), string type = default(string), SystemData systemData = default(SystemData)) + { + PolicyType = policyType; + DisplayName = displayName; + Description = description; + Metadata = metadata; + Parameters = parameters; + PolicyDefinitions = policyDefinitions; + PolicyDefinitionGroups = policyDefinitionGroups; + Id = id; + Name = name; + Type = type; + SystemData = systemData; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the type of policy definition. Possible values are + /// NotSpecified, BuiltIn, Custom, and Static. Possible values include: + /// 'NotSpecified', 'BuiltIn', 'Custom', 'Static' + /// + [JsonProperty(PropertyName = "properties.policyType")] + public string PolicyType { get; set; } + + /// + /// Gets or sets the display name of the policy set definition. + /// + [JsonProperty(PropertyName = "properties.displayName")] + public string DisplayName { get; set; } + + /// + /// Gets or sets the policy set definition description. + /// + [JsonProperty(PropertyName = "properties.description")] + public string Description { get; set; } + + /// + /// Gets or sets the policy set definition metadata. Metadata is an + /// open ended object and is typically a collection of key value pairs. + /// + [JsonProperty(PropertyName = "properties.metadata")] + public object Metadata { get; set; } + + /// + /// Gets or sets the policy set definition parameters that can be used + /// in policy definition references. + /// + [JsonProperty(PropertyName = "properties.parameters")] + public IDictionary Parameters { get; set; } + + /// + /// Gets or sets an array of policy definition references. + /// + [JsonProperty(PropertyName = "properties.policyDefinitions")] + public IList PolicyDefinitions { get; set; } + + /// + /// Gets or sets the metadata describing groups of policy definition + /// references within the policy set definition. + /// + [JsonProperty(PropertyName = "properties.policyDefinitionGroups")] + public IList PolicyDefinitionGroups { get; set; } + + /// + /// Gets the ID of the policy set definition. + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; private set; } + + /// + /// Gets the name of the policy set definition. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; private set; } + + /// + /// Gets the type of the resource + /// (Microsoft.Authorization/policySetDefinitions). + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; private set; } + + /// + /// Gets the system metadata relating to this resource. + /// + [JsonProperty(PropertyName = "systemData")] + public SystemData SystemData { get; private set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (PolicyDefinitions == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "PolicyDefinitions"); + } + if (PolicyDefinitions != null) + { + foreach (var element in PolicyDefinitions) + { + if (element != null) + { + element.Validate(); + } + } + } + if (PolicyDefinitionGroups != null) + { + foreach (var element1 in PolicyDefinitionGroups) + { + if (element1 != null) + { + element1.Validate(); + } + } + } + } + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/PolicyType.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/PolicyType.cs new file mode 100644 index 0000000000000..89cf1c16732f9 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/PolicyType.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.ResourceManager.Models +{ + + /// + /// Defines values for PolicyType. + /// + public static class PolicyType + { + public const string NotSpecified = "NotSpecified"; + public const string BuiltIn = "BuiltIn"; + public const string Custom = "Custom"; + public const string Static = "Static"; + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/PropertyChangeType.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/PropertyChangeType.cs new file mode 100644 index 0000000000000..bef9416ab982e --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/PropertyChangeType.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.ResourceManager.Models +{ + using Newtonsoft.Json; + using Newtonsoft.Json.Converters; + using System.Runtime; + using System.Runtime.Serialization; + + /// + /// Defines values for PropertyChangeType. + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum PropertyChangeType + { + /// + /// The property does not exist in the current state but is present in + /// the desired state. The property will be created when the deployment + /// is executed. + /// + [EnumMember(Value = "Create")] + Create, + /// + /// The property exists in the current state and is missing from the + /// desired state. It will be deleted when the deployment is executed. + /// + [EnumMember(Value = "Delete")] + Delete, + /// + /// The property exists in both current and desired state and is + /// different. The value of the property will change when the + /// deployment is executed. + /// + [EnumMember(Value = "Modify")] + Modify, + /// + /// The property is an array and contains nested changes. + /// + [EnumMember(Value = "Array")] + Array, + /// + /// The property will not be set or updated. + /// + [EnumMember(Value = "NoEffect")] + NoEffect + } + internal static class PropertyChangeTypeEnumExtension + { + internal static string ToSerializedValue(this PropertyChangeType? value) + { + return value == null ? null : ((PropertyChangeType)value).ToSerializedValue(); + } + + internal static string ToSerializedValue(this PropertyChangeType value) + { + switch( value ) + { + case PropertyChangeType.Create: + return "Create"; + case PropertyChangeType.Delete: + return "Delete"; + case PropertyChangeType.Modify: + return "Modify"; + case PropertyChangeType.Array: + return "Array"; + case PropertyChangeType.NoEffect: + return "NoEffect"; + } + return null; + } + + internal static PropertyChangeType? ParsePropertyChangeType(this string value) + { + switch( value ) + { + case "Create": + return PropertyChangeType.Create; + case "Delete": + return PropertyChangeType.Delete; + case "Modify": + return PropertyChangeType.Modify; + case "Array": + return PropertyChangeType.Array; + case "NoEffect": + return PropertyChangeType.NoEffect; + } + return null; + } + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/Provider.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/Provider.cs new file mode 100644 index 0000000000000..bcb0401fcbb4e --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/Provider.cs @@ -0,0 +1,101 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Resource provider information. + /// + public partial class Provider + { + /// + /// Initializes a new instance of the Provider class. + /// + public Provider() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Provider class. + /// + /// The provider ID. + /// The namespace of the resource + /// provider. + /// The registration state of the + /// resource provider. + /// The registration policy of the + /// resource provider. + /// The collection of provider resource + /// types. + /// The provider + /// authorization consent state. Possible values include: + /// 'NotSpecified', 'Required', 'NotRequired', 'Consented' + public Provider(string id = default(string), string namespaceProperty = default(string), string registrationState = default(string), string registrationPolicy = default(string), IList resourceTypes = default(IList), string providerAuthorizationConsentState = default(string)) + { + Id = id; + NamespaceProperty = namespaceProperty; + RegistrationState = registrationState; + RegistrationPolicy = registrationPolicy; + ResourceTypes = resourceTypes; + ProviderAuthorizationConsentState = providerAuthorizationConsentState; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the provider ID. + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; private set; } + + /// + /// Gets or sets the namespace of the resource provider. + /// + [JsonProperty(PropertyName = "namespace")] + public string NamespaceProperty { get; set; } + + /// + /// Gets the registration state of the resource provider. + /// + [JsonProperty(PropertyName = "registrationState")] + public string RegistrationState { get; private set; } + + /// + /// Gets the registration policy of the resource provider. + /// + [JsonProperty(PropertyName = "registrationPolicy")] + public string RegistrationPolicy { get; private set; } + + /// + /// Gets the collection of provider resource types. + /// + [JsonProperty(PropertyName = "resourceTypes")] + public IList ResourceTypes { get; private set; } + + /// + /// Gets or sets the provider authorization consent state. Possible + /// values include: 'NotSpecified', 'Required', 'NotRequired', + /// 'Consented' + /// + [JsonProperty(PropertyName = "providerAuthorizationConsentState")] + public string ProviderAuthorizationConsentState { get; set; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ProviderAuthorizationConsentState.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ProviderAuthorizationConsentState.cs new file mode 100644 index 0000000000000..c44db847e4e2c --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ProviderAuthorizationConsentState.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.ResourceManager.Models +{ + + /// + /// Defines values for ProviderAuthorizationConsentState. + /// + public static class ProviderAuthorizationConsentState + { + public const string NotSpecified = "NotSpecified"; + public const string Required = "Required"; + public const string NotRequired = "NotRequired"; + public const string Consented = "Consented"; + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ProviderConsentDefinition.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ProviderConsentDefinition.cs new file mode 100644 index 0000000000000..22733e8d9de79 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ProviderConsentDefinition.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.ResourceManager.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The provider consent. + /// + public partial class ProviderConsentDefinition + { + /// + /// Initializes a new instance of the ProviderConsentDefinition class. + /// + public ProviderConsentDefinition() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ProviderConsentDefinition class. + /// + /// A value indicating whether + /// authorization is consented or not. + public ProviderConsentDefinition(bool? consentToAuthorization = default(bool?)) + { + ConsentToAuthorization = consentToAuthorization; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets a value indicating whether authorization is consented + /// or not. + /// + [JsonProperty(PropertyName = "consentToAuthorization")] + public bool? ConsentToAuthorization { get; set; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ProviderExtendedLocation.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ProviderExtendedLocation.cs new file mode 100644 index 0000000000000..f7fae58826d28 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ProviderExtendedLocation.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.ResourceManager.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The provider extended location. + /// + public partial class ProviderExtendedLocation + { + /// + /// Initializes a new instance of the ProviderExtendedLocation class. + /// + public ProviderExtendedLocation() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ProviderExtendedLocation class. + /// + /// The azure location. + /// The extended location type. + /// The extended locations for the + /// azure location. + public ProviderExtendedLocation(string location = default(string), string type = default(string), IList extendedLocations = default(IList)) + { + Location = location; + Type = type; + ExtendedLocations = extendedLocations; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the azure location. + /// + [JsonProperty(PropertyName = "location")] + public string Location { get; set; } + + /// + /// Gets or sets the extended location type. + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; set; } + + /// + /// Gets or sets the extended locations for the azure location. + /// + [JsonProperty(PropertyName = "extendedLocations")] + public IList ExtendedLocations { get; set; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ProviderPermission.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ProviderPermission.cs new file mode 100644 index 0000000000000..fb490630d5aaa --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ProviderPermission.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.ResourceManager.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The provider permission + /// + public partial class ProviderPermission + { + /// + /// Initializes a new instance of the ProviderPermission class. + /// + public ProviderPermission() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ProviderPermission class. + /// + /// The application id. + /// Role definition properties. + /// Role definition + /// properties. + /// The provider + /// authorization consent state. Possible values include: + /// 'NotSpecified', 'Required', 'NotRequired', 'Consented' + public ProviderPermission(string applicationId = default(string), RoleDefinition roleDefinition = default(RoleDefinition), RoleDefinition managedByRoleDefinition = default(RoleDefinition), string providerAuthorizationConsentState = default(string)) + { + ApplicationId = applicationId; + RoleDefinition = roleDefinition; + ManagedByRoleDefinition = managedByRoleDefinition; + ProviderAuthorizationConsentState = providerAuthorizationConsentState; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the application id. + /// + [JsonProperty(PropertyName = "applicationId")] + public string ApplicationId { get; set; } + + /// + /// Gets or sets role definition properties. + /// + [JsonProperty(PropertyName = "roleDefinition")] + public RoleDefinition RoleDefinition { get; set; } + + /// + /// Gets or sets role definition properties. + /// + [JsonProperty(PropertyName = "managedByRoleDefinition")] + public RoleDefinition ManagedByRoleDefinition { get; set; } + + /// + /// Gets or sets the provider authorization consent state. Possible + /// values include: 'NotSpecified', 'Required', 'NotRequired', + /// 'Consented' + /// + [JsonProperty(PropertyName = "providerAuthorizationConsentState")] + public string ProviderAuthorizationConsentState { get; set; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ProviderPermissionListResult.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ProviderPermissionListResult.cs new file mode 100644 index 0000000000000..a85f988ee99f0 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ProviderPermissionListResult.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.ResourceManager.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// List of provider permissions. + /// + public partial class ProviderPermissionListResult + { + /// + /// Initializes a new instance of the ProviderPermissionListResult + /// class. + /// + public ProviderPermissionListResult() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ProviderPermissionListResult + /// class. + /// + /// An array of provider permissions. + /// The URL to use for getting the next set of + /// results. + public ProviderPermissionListResult(IList value = default(IList), string nextLink = default(string)) + { + Value = value; + NextLink = nextLink; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets an array of provider permissions. + /// + [JsonProperty(PropertyName = "value")] + public IList Value { get; set; } + + /// + /// Gets the URL to use for getting the next set of results. + /// + [JsonProperty(PropertyName = "nextLink")] + public string NextLink { get; private set; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ProviderRegistrationRequest.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ProviderRegistrationRequest.cs new file mode 100644 index 0000000000000..39bcdadfa5ecf --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ProviderRegistrationRequest.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.ResourceManager.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The provider registration definition. + /// + public partial class ProviderRegistrationRequest + { + /// + /// Initializes a new instance of the ProviderRegistrationRequest + /// class. + /// + public ProviderRegistrationRequest() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ProviderRegistrationRequest + /// class. + /// + /// The provider + /// consent. + public ProviderRegistrationRequest(ProviderConsentDefinition thirdPartyProviderConsent = default(ProviderConsentDefinition)) + { + ThirdPartyProviderConsent = thirdPartyProviderConsent; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the provider consent. + /// + [JsonProperty(PropertyName = "thirdPartyProviderConsent")] + public ProviderConsentDefinition ThirdPartyProviderConsent { get; set; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ProviderResourceType.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ProviderResourceType.cs new file mode 100644 index 0000000000000..55c4fadd90086 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ProviderResourceType.cs @@ -0,0 +1,131 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Resource type managed by the resource provider. + /// + public partial class ProviderResourceType + { + /// + /// Initializes a new instance of the ProviderResourceType class. + /// + public ProviderResourceType() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ProviderResourceType class. + /// + /// The resource type. + /// The collection of locations where this + /// resource type can be created. + /// The location mappings that are + /// supported by this resource type. + /// The aliases that are supported by this + /// resource type. + /// The API version. + /// The default API version. + /// The API profiles for the resource + /// provider. + /// The additional capabilities offered by + /// this resource type. + /// The properties. + public ProviderResourceType(string resourceType = default(string), IList locations = default(IList), IList locationMappings = default(IList), IList aliases = default(IList), IList apiVersions = default(IList), string defaultApiVersion = default(string), IList zoneMappings = default(IList), IList apiProfiles = default(IList), string capabilities = default(string), IDictionary properties = default(IDictionary)) + { + ResourceType = resourceType; + Locations = locations; + LocationMappings = locationMappings; + Aliases = aliases; + ApiVersions = apiVersions; + DefaultApiVersion = defaultApiVersion; + ZoneMappings = zoneMappings; + ApiProfiles = apiProfiles; + Capabilities = capabilities; + Properties = properties; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the resource type. + /// + [JsonProperty(PropertyName = "resourceType")] + public string ResourceType { get; set; } + + /// + /// Gets or sets the collection of locations where this resource type + /// can be created. + /// + [JsonProperty(PropertyName = "locations")] + public IList Locations { get; set; } + + /// + /// Gets or sets the location mappings that are supported by this + /// resource type. + /// + [JsonProperty(PropertyName = "locationMappings")] + public IList LocationMappings { get; set; } + + /// + /// Gets or sets the aliases that are supported by this resource type. + /// + [JsonProperty(PropertyName = "aliases")] + public IList Aliases { get; set; } + + /// + /// Gets or sets the API version. + /// + [JsonProperty(PropertyName = "apiVersions")] + public IList ApiVersions { get; set; } + + /// + /// Gets the default API version. + /// + [JsonProperty(PropertyName = "defaultApiVersion")] + public string DefaultApiVersion { get; private set; } + + /// + /// + [JsonProperty(PropertyName = "zoneMappings")] + public IList ZoneMappings { get; set; } + + /// + /// Gets the API profiles for the resource provider. + /// + [JsonProperty(PropertyName = "apiProfiles")] + public IList ApiProfiles { get; private set; } + + /// + /// Gets or sets the additional capabilities offered by this resource + /// type. + /// + [JsonProperty(PropertyName = "capabilities")] + public string Capabilities { get; set; } + + /// + /// Gets or sets the properties. + /// + [JsonProperty(PropertyName = "properties")] + public IDictionary Properties { get; set; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ProviderResourceTypeListResult.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ProviderResourceTypeListResult.cs new file mode 100644 index 0000000000000..1cfbf3a0dfb1c --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ProviderResourceTypeListResult.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.ResourceManager.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// List of resource types of a resource provider. + /// + public partial class ProviderResourceTypeListResult + { + /// + /// Initializes a new instance of the ProviderResourceTypeListResult + /// class. + /// + public ProviderResourceTypeListResult() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ProviderResourceTypeListResult + /// class. + /// + /// An array of resource types. + /// The URL to use for getting the next set of + /// results. + public ProviderResourceTypeListResult(IList value = default(IList), string nextLink = default(string)) + { + Value = value; + NextLink = nextLink; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets an array of resource types. + /// + [JsonProperty(PropertyName = "value")] + public IList Value { get; set; } + + /// + /// Gets the URL to use for getting the next set of results. + /// + [JsonProperty(PropertyName = "nextLink")] + public string NextLink { get; private set; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ProvisioningOperation.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ProvisioningOperation.cs new file mode 100644 index 0000000000000..7085942fbe337 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ProvisioningOperation.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.ResourceManager.Models +{ + using Newtonsoft.Json; + using Newtonsoft.Json.Converters; + using System.Runtime; + using System.Runtime.Serialization; + + /// + /// Defines values for ProvisioningOperation. + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum ProvisioningOperation + { + /// + /// The provisioning operation is not specified. + /// + [EnumMember(Value = "NotSpecified")] + NotSpecified, + /// + /// The provisioning operation is create. + /// + [EnumMember(Value = "Create")] + Create, + /// + /// The provisioning operation is delete. + /// + [EnumMember(Value = "Delete")] + Delete, + /// + /// The provisioning operation is waiting. + /// + [EnumMember(Value = "Waiting")] + Waiting, + /// + /// The provisioning operation is waiting Azure async operation. + /// + [EnumMember(Value = "AzureAsyncOperationWaiting")] + AzureAsyncOperationWaiting, + /// + /// The provisioning operation is waiting for resource cache. + /// + [EnumMember(Value = "ResourceCacheWaiting")] + ResourceCacheWaiting, + /// + /// The provisioning operation is action. + /// + [EnumMember(Value = "Action")] + Action, + /// + /// The provisioning operation is read. + /// + [EnumMember(Value = "Read")] + Read, + /// + /// The provisioning operation is evaluate output. + /// + [EnumMember(Value = "EvaluateDeploymentOutput")] + EvaluateDeploymentOutput, + /// + /// The provisioning operation is cleanup. This operation is part of + /// the 'complete' mode deployment. + /// + [EnumMember(Value = "DeploymentCleanup")] + DeploymentCleanup + } + internal static class ProvisioningOperationEnumExtension + { + internal static string ToSerializedValue(this ProvisioningOperation? value) + { + return value == null ? null : ((ProvisioningOperation)value).ToSerializedValue(); + } + + internal static string ToSerializedValue(this ProvisioningOperation value) + { + switch( value ) + { + case ProvisioningOperation.NotSpecified: + return "NotSpecified"; + case ProvisioningOperation.Create: + return "Create"; + case ProvisioningOperation.Delete: + return "Delete"; + case ProvisioningOperation.Waiting: + return "Waiting"; + case ProvisioningOperation.AzureAsyncOperationWaiting: + return "AzureAsyncOperationWaiting"; + case ProvisioningOperation.ResourceCacheWaiting: + return "ResourceCacheWaiting"; + case ProvisioningOperation.Action: + return "Action"; + case ProvisioningOperation.Read: + return "Read"; + case ProvisioningOperation.EvaluateDeploymentOutput: + return "EvaluateDeploymentOutput"; + case ProvisioningOperation.DeploymentCleanup: + return "DeploymentCleanup"; + } + return null; + } + + internal static ProvisioningOperation? ParseProvisioningOperation(this string value) + { + switch( value ) + { + case "NotSpecified": + return ProvisioningOperation.NotSpecified; + case "Create": + return ProvisioningOperation.Create; + case "Delete": + return ProvisioningOperation.Delete; + case "Waiting": + return ProvisioningOperation.Waiting; + case "AzureAsyncOperationWaiting": + return ProvisioningOperation.AzureAsyncOperationWaiting; + case "ResourceCacheWaiting": + return ProvisioningOperation.ResourceCacheWaiting; + case "Action": + return ProvisioningOperation.Action; + case "Read": + return ProvisioningOperation.Read; + case "EvaluateDeploymentOutput": + return ProvisioningOperation.EvaluateDeploymentOutput; + case "DeploymentCleanup": + return ProvisioningOperation.DeploymentCleanup; + } + return null; + } + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ProvisioningState.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ProvisioningState.cs new file mode 100644 index 0000000000000..bbc2e9705c0e7 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ProvisioningState.cs @@ -0,0 +1,32 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager.Models +{ + + /// + /// Defines values for ProvisioningState. + /// + public static class ProvisioningState + { + public const string NotSpecified = "NotSpecified"; + public const string Accepted = "Accepted"; + public const string Running = "Running"; + public const string Ready = "Ready"; + public const string Creating = "Creating"; + public const string Created = "Created"; + public const string Deleting = "Deleting"; + public const string Deleted = "Deleted"; + public const string Canceled = "Canceled"; + public const string Failed = "Failed"; + public const string Succeeded = "Succeeded"; + public const string Updating = "Updating"; + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ProxyResource.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ProxyResource.cs new file mode 100644 index 0000000000000..ab288fd901bc3 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ProxyResource.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.ResourceManager.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Newtonsoft.Json; + using System.Linq; + + /// + /// An Azure proxy resource. + /// + public partial class ProxyResource : IResource + { + /// + /// Initializes a new instance of the ProxyResource class. + /// + public ProxyResource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ProxyResource class. + /// + /// Azure resource Id. + /// Azure resource name. + /// Azure resource type. + public ProxyResource(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 azure resource Id. + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; private set; } + + /// + /// Gets azure resource name. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; private set; } + + /// + /// Gets azure resource type. + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; private set; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/RegionCategory.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/RegionCategory.cs new file mode 100644 index 0000000000000..9c63b1e310f98 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/RegionCategory.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.ResourceManager.Models +{ + + /// + /// Defines values for RegionCategory. + /// + public static class RegionCategory + { + public const string Recommended = "Recommended"; + public const string Extended = "Extended"; + public const string Other = "Other"; + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/RegionType.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/RegionType.cs new file mode 100644 index 0000000000000..5ff3250083654 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/RegionType.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.ResourceManager.Models +{ + + /// + /// Defines values for RegionType. + /// + public static class RegionType + { + public const string Physical = "Physical"; + public const string Logical = "Logical"; + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/Resource.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/Resource.cs new file mode 100644 index 0000000000000..456b5a05b5b9b --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/Resource.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.ResourceManager.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Specified resource. + /// + public partial class Resource : IResource + { + /// + /// Initializes a new instance of the Resource class. + /// + public Resource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Resource class. + /// + /// Resource ID + /// Resource name + /// Resource type + /// Resource location + /// Resource extended location. + /// Resource tags + public Resource(string id = default(string), string name = default(string), string type = default(string), string location = default(string), ExtendedLocation extendedLocation = default(ExtendedLocation), IDictionary tags = default(IDictionary)) + { + Id = id; + Name = name; + Type = type; + Location = location; + ExtendedLocation = extendedLocation; + Tags = tags; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets resource ID + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; private set; } + + /// + /// Gets resource name + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; private set; } + + /// + /// Gets resource type + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; private set; } + + /// + /// Gets or sets resource location + /// + [JsonProperty(PropertyName = "location")] + public string Location { get; set; } + + /// + /// Gets or sets resource extended location. + /// + [JsonProperty(PropertyName = "extendedLocation")] + public ExtendedLocation ExtendedLocation { get; set; } + + /// + /// Gets or sets resource tags + /// + [JsonProperty(PropertyName = "tags")] + public IDictionary Tags { get; set; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ResourceGroup.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ResourceGroup.cs new file mode 100644 index 0000000000000..23273f227166a --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ResourceGroup.cs @@ -0,0 +1,122 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Resource group information. + /// + public partial class ResourceGroup : IResource + { + /// + /// Initializes a new instance of the ResourceGroup class. + /// + public ResourceGroup() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ResourceGroup class. + /// + /// The location of the resource group. It + /// cannot be changed after the resource group has been created. It + /// must be one of the supported Azure locations. + /// The ID of the resource group. + /// The name of the resource group. + /// The type of the resource group. + /// The resource group properties. + /// The ID of the resource that manages this + /// resource group. + /// The tags attached to the resource group. + public ResourceGroup(string location, string id = default(string), string name = default(string), string type = default(string), ResourceGroupProperties properties = default(ResourceGroupProperties), string managedBy = default(string), IDictionary tags = default(IDictionary)) + { + Id = id; + Name = name; + Type = type; + Properties = properties; + Location = location; + ManagedBy = managedBy; + Tags = tags; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the ID of the resource group. + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; private set; } + + /// + /// Gets the name of the resource group. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; private set; } + + /// + /// Gets the type of the resource group. + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; private set; } + + /// + /// Gets or sets the resource group properties. + /// + [JsonProperty(PropertyName = "properties")] + public ResourceGroupProperties Properties { get; set; } + + /// + /// Gets or sets the location of the resource group. It cannot be + /// changed after the resource group has been created. It must be one + /// of the supported Azure locations. + /// + [JsonProperty(PropertyName = "location")] + public string Location { get; set; } + + /// + /// Gets or sets the ID of the resource that manages this resource + /// group. + /// + [JsonProperty(PropertyName = "managedBy")] + public string ManagedBy { get; set; } + + /// + /// Gets or sets the tags attached to the resource group. + /// + [JsonProperty(PropertyName = "tags")] + public IDictionary Tags { 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/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ResourceGroupExportResult.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ResourceGroupExportResult.cs new file mode 100644 index 0000000000000..482acb38db850 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ResourceGroupExportResult.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.ResourceManager.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Resource group export result. + /// + public partial class ResourceGroupExportResult + { + /// + /// Initializes a new instance of the ResourceGroupExportResult class. + /// + public ResourceGroupExportResult() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ResourceGroupExportResult class. + /// + /// The template content. + /// The template export error. + public ResourceGroupExportResult(object template = default(object), ErrorResponse error = default(ErrorResponse)) + { + Template = template; + Error = error; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the template content. + /// + [JsonProperty(PropertyName = "template")] + public object Template { get; set; } + + /// + /// Gets or sets the template export error. + /// + [JsonProperty(PropertyName = "error")] + public ErrorResponse Error { get; set; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ResourceGroupFilter.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ResourceGroupFilter.cs new file mode 100644 index 0000000000000..fbac36f76492e --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ResourceGroupFilter.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.ResourceManager.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Resource group filter. + /// + public partial class ResourceGroupFilter + { + /// + /// Initializes a new instance of the ResourceGroupFilter class. + /// + public ResourceGroupFilter() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ResourceGroupFilter class. + /// + /// The tag name. + /// The tag value. + public ResourceGroupFilter(string tagName = default(string), string tagValue = default(string)) + { + TagName = tagName; + TagValue = tagValue; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the tag name. + /// + [JsonProperty(PropertyName = "tagName")] + public string TagName { get; set; } + + /// + /// Gets or sets the tag value. + /// + [JsonProperty(PropertyName = "tagValue")] + public string TagValue { get; set; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ResourceGroupPatchable.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ResourceGroupPatchable.cs new file mode 100644 index 0000000000000..43a724e3411e2 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ResourceGroupPatchable.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.ResourceManager.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Resource group information. + /// + public partial class ResourceGroupPatchable + { + /// + /// Initializes a new instance of the ResourceGroupPatchable class. + /// + public ResourceGroupPatchable() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ResourceGroupPatchable class. + /// + /// The name of the resource group. + /// The resource group properties. + /// The ID of the resource that manages this + /// resource group. + /// The tags attached to the resource group. + public ResourceGroupPatchable(string name = default(string), ResourceGroupProperties properties = default(ResourceGroupProperties), string managedBy = default(string), IDictionary tags = default(IDictionary)) + { + Name = name; + Properties = properties; + ManagedBy = managedBy; + Tags = tags; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the name of the resource group. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Gets or sets the resource group properties. + /// + [JsonProperty(PropertyName = "properties")] + public ResourceGroupProperties Properties { get; set; } + + /// + /// Gets or sets the ID of the resource that manages this resource + /// group. + /// + [JsonProperty(PropertyName = "managedBy")] + public string ManagedBy { get; set; } + + /// + /// Gets or sets the tags attached to the resource group. + /// + [JsonProperty(PropertyName = "tags")] + public IDictionary Tags { get; set; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ResourceGroupProperties.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ResourceGroupProperties.cs new file mode 100644 index 0000000000000..ca4be497ba044 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ResourceGroupProperties.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.ResourceManager.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The resource group properties. + /// + public partial class ResourceGroupProperties + { + /// + /// Initializes a new instance of the ResourceGroupProperties class. + /// + public ResourceGroupProperties() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ResourceGroupProperties class. + /// + /// The provisioning state. + public ResourceGroupProperties(string provisioningState = default(string)) + { + ProvisioningState = provisioningState; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the provisioning state. + /// + [JsonProperty(PropertyName = "provisioningState")] + public string ProvisioningState { get; private set; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ResourceIdentityType.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ResourceIdentityType.cs new file mode 100644 index 0000000000000..e5b35fa10e5cf --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ResourceIdentityType.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.ResourceManager.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, + [EnumMember(Value = "UserAssigned")] + UserAssigned, + [EnumMember(Value = "SystemAssigned, UserAssigned")] + SystemAssignedUserAssigned, + [EnumMember(Value = "None")] + None + } + 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"; + case ResourceIdentityType.UserAssigned: + return "UserAssigned"; + case ResourceIdentityType.SystemAssignedUserAssigned: + return "SystemAssigned, UserAssigned"; + case ResourceIdentityType.None: + return "None"; + } + return null; + } + + internal static ResourceIdentityType? ParseResourceIdentityType(this string value) + { + switch( value ) + { + case "SystemAssigned": + return ResourceIdentityType.SystemAssigned; + case "UserAssigned": + return ResourceIdentityType.UserAssigned; + case "SystemAssigned, UserAssigned": + return ResourceIdentityType.SystemAssignedUserAssigned; + case "None": + return ResourceIdentityType.None; + } + return null; + } + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ResourceLink.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ResourceLink.cs new file mode 100644 index 0000000000000..e89c853f8d6ee --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ResourceLink.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.ResourceManager.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Newtonsoft.Json; + using System.Linq; + + /// + /// The resource link. + /// + public partial class ResourceLink : IResource + { + /// + /// Initializes a new instance of the ResourceLink class. + /// + public ResourceLink() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ResourceLink class. + /// + /// The fully qualified ID of the resource + /// link. + /// The name of the resource link. + /// The resource link object. + /// Properties for resource link. + public ResourceLink(string id = default(string), string name = default(string), object type = default(object), ResourceLinkProperties properties = default(ResourceLinkProperties)) + { + Id = id; + Name = name; + Type = type; + Properties = properties; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the fully qualified ID of the resource link. + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; private set; } + + /// + /// Gets the name of the resource link. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; private set; } + + /// + /// Gets the resource link object. + /// + [JsonProperty(PropertyName = "type")] + public object Type { get; private set; } + + /// + /// Gets or sets properties for resource link. + /// + [JsonProperty(PropertyName = "properties")] + public ResourceLinkProperties Properties { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Properties != null) + { + Properties.Validate(); + } + } + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ResourceLinkFilter.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ResourceLinkFilter.cs new file mode 100644 index 0000000000000..ac38b654ad126 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ResourceLinkFilter.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.ResourceManager.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Resource link filter. + /// + public partial class ResourceLinkFilter + { + /// + /// Initializes a new instance of the ResourceLinkFilter class. + /// + public ResourceLinkFilter() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ResourceLinkFilter class. + /// + /// The ID of the target resource. + public ResourceLinkFilter(string targetId) + { + TargetId = targetId; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the ID of the target resource. + /// + [JsonProperty(PropertyName = "targetId")] + public string TargetId { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (TargetId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "TargetId"); + } + } + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ResourceLinkProperties.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ResourceLinkProperties.cs new file mode 100644 index 0000000000000..e6bbfbcc6dacb --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ResourceLinkProperties.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.ResourceManager.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// The resource link properties. + /// + public partial class ResourceLinkProperties + { + /// + /// Initializes a new instance of the ResourceLinkProperties class. + /// + public ResourceLinkProperties() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ResourceLinkProperties class. + /// + /// The fully qualified ID of the target + /// resource in the link. + /// The fully qualified ID of the source + /// resource in the link. + /// Notes about the resource link. + public ResourceLinkProperties(string targetId, string sourceId = default(string), string notes = default(string)) + { + SourceId = sourceId; + TargetId = targetId; + Notes = notes; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the fully qualified ID of the source resource in the link. + /// + [JsonProperty(PropertyName = "sourceId")] + public string SourceId { get; private set; } + + /// + /// Gets or sets the fully qualified ID of the target resource in the + /// link. + /// + [JsonProperty(PropertyName = "targetId")] + public string TargetId { get; set; } + + /// + /// Gets or sets notes about the resource link. + /// + [JsonProperty(PropertyName = "notes")] + public string Notes { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (TargetId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "TargetId"); + } + } + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ResourceName.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ResourceName.cs new file mode 100644 index 0000000000000..ca2591d89888e --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ResourceName.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.ResourceManager.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Name and Type of the Resource + /// + public partial class ResourceName + { + /// + /// Initializes a new instance of the ResourceName class. + /// + public ResourceName() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ResourceName class. + /// + /// Name of the resource + /// The type of the resource + public ResourceName(string name, string type) + { + Name = name; + Type = type; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets name of the resource + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Gets or sets the type of the resource + /// + [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"); + } + if (Type == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Type"); + } + } + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ResourceNameStatus.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ResourceNameStatus.cs new file mode 100644 index 0000000000000..367ba715abef3 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ResourceNameStatus.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.ResourceManager.Models +{ + + /// + /// Defines values for ResourceNameStatus. + /// + public static class ResourceNameStatus + { + public const string Allowed = "Allowed"; + public const string Reserved = "Reserved"; + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ResourceProviderOperationDisplayProperties.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ResourceProviderOperationDisplayProperties.cs new file mode 100644 index 0000000000000..2a035a13eb860 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ResourceProviderOperationDisplayProperties.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.ResourceManager.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Resource provider operation's display properties. + /// + public partial class ResourceProviderOperationDisplayProperties + { + /// + /// Initializes a new instance of the + /// ResourceProviderOperationDisplayProperties class. + /// + public ResourceProviderOperationDisplayProperties() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// ResourceProviderOperationDisplayProperties class. + /// + /// Operation description. + /// Operation provider. + /// Operation resource. + /// Resource provider operation. + /// Operation description. + public ResourceProviderOperationDisplayProperties(string publisher = default(string), string provider = default(string), string resource = default(string), string operation = default(string), string description = default(string)) + { + Publisher = publisher; + Provider = provider; + Resource = resource; + Operation = operation; + Description = description; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets operation description. + /// + [JsonProperty(PropertyName = "publisher")] + public string Publisher { get; set; } + + /// + /// Gets or sets operation provider. + /// + [JsonProperty(PropertyName = "provider")] + public string Provider { get; set; } + + /// + /// Gets or sets operation resource. + /// + [JsonProperty(PropertyName = "resource")] + public string Resource { get; set; } + + /// + /// Gets or sets resource provider operation. + /// + [JsonProperty(PropertyName = "operation")] + public string Operation { get; set; } + + /// + /// Gets or sets operation description. + /// + [JsonProperty(PropertyName = "description")] + public string Description { get; set; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ResourceReference.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ResourceReference.cs new file mode 100644 index 0000000000000..9f469ac962856 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ResourceReference.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.ResourceManager.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The resource Id model. + /// + public partial class ResourceReference + { + /// + /// Initializes a new instance of the ResourceReference class. + /// + public ResourceReference() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ResourceReference class. + /// + /// The fully qualified resource Id. + public ResourceReference(string id = default(string)) + { + Id = id; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the fully qualified resource Id. + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; private set; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ResourceTypeAliases.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ResourceTypeAliases.cs new file mode 100644 index 0000000000000..f45eb11d398d5 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ResourceTypeAliases.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.ResourceManager.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The resource type aliases definition. + /// + public partial class ResourceTypeAliases + { + /// + /// Initializes a new instance of the ResourceTypeAliases class. + /// + public ResourceTypeAliases() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ResourceTypeAliases class. + /// + /// The resource type name. + /// The aliases for property names. + public ResourceTypeAliases(string resourceType = default(string), IList aliases = default(IList)) + { + ResourceType = resourceType; + Aliases = aliases; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the resource type name. + /// + [JsonProperty(PropertyName = "resourceType")] + public string ResourceType { get; set; } + + /// + /// Gets or sets the aliases for property names. + /// + [JsonProperty(PropertyName = "aliases")] + public IList Aliases { get; set; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ResourcesMoveInfo.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ResourcesMoveInfo.cs new file mode 100644 index 0000000000000..486ec8f4481c8 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ResourcesMoveInfo.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.ResourceManager.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Parameters of move resources. + /// + public partial class ResourcesMoveInfo + { + /// + /// Initializes a new instance of the ResourcesMoveInfo class. + /// + public ResourcesMoveInfo() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ResourcesMoveInfo class. + /// + /// The IDs of the resources. + /// The target resource + /// group. + public ResourcesMoveInfo(IList resources = default(IList), string targetResourceGroup = default(string)) + { + Resources = resources; + TargetResourceGroup = targetResourceGroup; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the IDs of the resources. + /// + [JsonProperty(PropertyName = "resources")] + public IList Resources { get; set; } + + /// + /// Gets or sets the target resource group. + /// + [JsonProperty(PropertyName = "targetResourceGroup")] + public string TargetResourceGroup { get; set; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/RoleDefinition.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/RoleDefinition.cs new file mode 100644 index 0000000000000..7800d695cb671 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/RoleDefinition.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.ResourceManager.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Role definition properties. + /// + public partial class RoleDefinition + { + /// + /// Initializes a new instance of the RoleDefinition class. + /// + public RoleDefinition() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the RoleDefinition class. + /// + /// The role definition ID. + /// The role definition name. + /// If this is a service role. + /// Role definition permissions. + /// Role definition assignable scopes. + public RoleDefinition(string id = default(string), string name = default(string), bool? isServiceRole = default(bool?), IList permissions = default(IList), IList scopes = default(IList)) + { + Id = id; + Name = name; + IsServiceRole = isServiceRole; + Permissions = permissions; + Scopes = scopes; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the role definition ID. + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; set; } + + /// + /// Gets or sets the role definition name. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Gets or sets if this is a service role. + /// + [JsonProperty(PropertyName = "isServiceRole")] + public bool? IsServiceRole { get; set; } + + /// + /// Gets or sets role definition permissions. + /// + [JsonProperty(PropertyName = "permissions")] + public IList Permissions { get; set; } + + /// + /// Gets or sets role definition assignable scopes. + /// + [JsonProperty(PropertyName = "scopes")] + public IList Scopes { get; set; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ScopedDeployment.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ScopedDeployment.cs new file mode 100644 index 0000000000000..194b172275875 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ScopedDeployment.cs @@ -0,0 +1,92 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Deployment operation parameters. + /// + public partial class ScopedDeployment + { + /// + /// Initializes a new instance of the ScopedDeployment class. + /// + public ScopedDeployment() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ScopedDeployment class. + /// + /// The location to store the deployment + /// data. + /// The deployment properties. + /// Deployment tags + public ScopedDeployment(string location, DeploymentProperties properties, IDictionary tags = default(IDictionary)) + { + Location = location; + Properties = properties; + Tags = tags; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the location to store the deployment data. + /// + [JsonProperty(PropertyName = "location")] + public string Location { get; set; } + + /// + /// Gets or sets the deployment properties. + /// + [JsonProperty(PropertyName = "properties")] + public DeploymentProperties Properties { get; set; } + + /// + /// Gets or sets deployment tags + /// + [JsonProperty(PropertyName = "tags")] + public IDictionary Tags { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Location == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Location"); + } + if (Properties == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Properties"); + } + if (Properties != null) + { + Properties.Validate(); + } + } + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ScopedDeploymentWhatIf.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ScopedDeploymentWhatIf.cs new file mode 100644 index 0000000000000..80ca6a56b0fc6 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ScopedDeploymentWhatIf.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.ResourceManager.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Deployment What-if operation parameters. + /// + public partial class ScopedDeploymentWhatIf + { + /// + /// Initializes a new instance of the ScopedDeploymentWhatIf class. + /// + public ScopedDeploymentWhatIf() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ScopedDeploymentWhatIf class. + /// + /// The location to store the deployment + /// data. + /// The deployment properties. + public ScopedDeploymentWhatIf(string location, DeploymentWhatIfProperties properties) + { + Location = location; + Properties = properties; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the location to store the deployment data. + /// + [JsonProperty(PropertyName = "location")] + public string Location { get; set; } + + /// + /// Gets or sets the deployment properties. + /// + [JsonProperty(PropertyName = "properties")] + public DeploymentWhatIfProperties Properties { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Location == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Location"); + } + if (Properties == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Properties"); + } + if (Properties != null) + { + Properties.Validate(); + } + } + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ScriptLog.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ScriptLog.cs new file mode 100644 index 0000000000000..68e5443e9b84a --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ScriptLog.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.ResourceManager.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Script execution log object. + /// + [Rest.Serialization.JsonTransformation] + public partial class ScriptLog : AzureResourceBase + { + /// + /// Initializes a new instance of the ScriptLog class. + /// + public ScriptLog() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ScriptLog class. + /// + /// String Id used to locate any resource on + /// Azure. + /// Name of this resource. + /// Type of this resource. + /// Script execution logs in text format. + public ScriptLog(string id = default(string), string name = default(string), string type = default(string), string log = default(string)) + : base(id, name, type) + { + Log = log; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets script execution logs in text format. + /// + [JsonProperty(PropertyName = "properties.log")] + public string Log { get; private set; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ScriptLogsList.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ScriptLogsList.cs new file mode 100644 index 0000000000000..018a175efbce3 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ScriptLogsList.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.ResourceManager.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Deployment script execution logs. + /// + public partial class ScriptLogsList + { + /// + /// Initializes a new instance of the ScriptLogsList class. + /// + public ScriptLogsList() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ScriptLogsList class. + /// + /// Deployment scripts logs. + public ScriptLogsList(IList value = default(IList)) + { + Value = value; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets deployment scripts logs. + /// + [JsonProperty(PropertyName = "value")] + public IList Value { get; set; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ScriptProvisioningState.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ScriptProvisioningState.cs new file mode 100644 index 0000000000000..9d90ff698d3bf --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ScriptProvisioningState.cs @@ -0,0 +1,26 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager.Models +{ + + /// + /// Defines values for ScriptProvisioningState. + /// + public static class ScriptProvisioningState + { + public const string Creating = "Creating"; + public const string ProvisioningResources = "ProvisioningResources"; + public const string Running = "Running"; + public const string Succeeded = "Succeeded"; + public const string Failed = "Failed"; + public const string Canceled = "Canceled"; + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ScriptStatus.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ScriptStatus.cs new file mode 100644 index 0000000000000..c976f9f28e06e --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ScriptStatus.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.ResourceManager.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Generic object modeling results of script execution. + /// + public partial class ScriptStatus + { + /// + /// Initializes a new instance of the ScriptStatus class. + /// + public ScriptStatus() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ScriptStatus class. + /// + /// ACI resource Id. + /// Storage account resource Id. + /// Start time of the script execution. + /// End time of the script execution. + /// Time the deployment script resource + /// will expire. + /// Error that is relayed from the script + /// execution. + public ScriptStatus(string containerInstanceId = default(string), string storageAccountId = default(string), System.DateTime? startTime = default(System.DateTime?), System.DateTime? endTime = default(System.DateTime?), System.DateTime? expirationTime = default(System.DateTime?), ErrorResponse error = default(ErrorResponse)) + { + ContainerInstanceId = containerInstanceId; + StorageAccountId = storageAccountId; + StartTime = startTime; + EndTime = endTime; + ExpirationTime = expirationTime; + Error = error; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets ACI resource Id. + /// + [JsonProperty(PropertyName = "containerInstanceId")] + public string ContainerInstanceId { get; private set; } + + /// + /// Gets storage account resource Id. + /// + [JsonProperty(PropertyName = "storageAccountId")] + public string StorageAccountId { get; private set; } + + /// + /// Gets start time of the script execution. + /// + [JsonProperty(PropertyName = "startTime")] + public System.DateTime? StartTime { get; private set; } + + /// + /// Gets end time of the script execution. + /// + [JsonProperty(PropertyName = "endTime")] + public System.DateTime? EndTime { get; private set; } + + /// + /// Gets time the deployment script resource will expire. + /// + [JsonProperty(PropertyName = "expirationTime")] + public System.DateTime? ExpirationTime { get; private set; } + + /// + /// Gets or sets error that is relayed from the script execution. + /// + [JsonProperty(PropertyName = "error")] + public ErrorResponse Error { get; set; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/Sku.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/Sku.cs new file mode 100644 index 0000000000000..c61194047f1d0 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/Sku.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.ResourceManager.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// SKU for the resource. + /// + public partial class Sku + { + /// + /// Initializes a new instance of the Sku class. + /// + public Sku() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Sku class. + /// + /// The SKU name. + /// The SKU tier. + /// The SKU size. + /// The SKU family. + /// The SKU model. + /// The SKU capacity. + public Sku(string name = default(string), string tier = default(string), string size = default(string), string family = default(string), string model = default(string), int? capacity = default(int?)) + { + Name = name; + Tier = tier; + Size = size; + Family = family; + Model = model; + Capacity = capacity; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the SKU name. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Gets or sets the SKU tier. + /// + [JsonProperty(PropertyName = "tier")] + public string Tier { get; set; } + + /// + /// Gets or sets the SKU size. + /// + [JsonProperty(PropertyName = "size")] + public string Size { get; set; } + + /// + /// Gets or sets the SKU family. + /// + [JsonProperty(PropertyName = "family")] + public string Family { get; set; } + + /// + /// Gets or sets the SKU model. + /// + [JsonProperty(PropertyName = "model")] + public string Model { get; set; } + + /// + /// Gets or sets the SKU capacity. + /// + [JsonProperty(PropertyName = "capacity")] + public int? Capacity { get; set; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/SpendingLimit.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/SpendingLimit.cs new file mode 100644 index 0000000000000..e839fbd1afda4 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/SpendingLimit.cs @@ -0,0 +1,66 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager.Models +{ + using Newtonsoft.Json; + using Newtonsoft.Json.Converters; + using System.Runtime; + using System.Runtime.Serialization; + + /// + /// Defines values for SpendingLimit. + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum SpendingLimit + { + [EnumMember(Value = "On")] + On, + [EnumMember(Value = "Off")] + Off, + [EnumMember(Value = "CurrentPeriodOff")] + CurrentPeriodOff + } + internal static class SpendingLimitEnumExtension + { + internal static string ToSerializedValue(this SpendingLimit? value) + { + return value == null ? null : ((SpendingLimit)value).ToSerializedValue(); + } + + internal static string ToSerializedValue(this SpendingLimit value) + { + switch( value ) + { + case SpendingLimit.On: + return "On"; + case SpendingLimit.Off: + return "Off"; + case SpendingLimit.CurrentPeriodOff: + return "CurrentPeriodOff"; + } + return null; + } + + internal static SpendingLimit? ParseSpendingLimit(this string value) + { + switch( value ) + { + case "On": + return SpendingLimit.On; + case "Off": + return SpendingLimit.Off; + case "CurrentPeriodOff": + return SpendingLimit.CurrentPeriodOff; + } + return null; + } + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/StatusMessage.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/StatusMessage.cs new file mode 100644 index 0000000000000..36164b1c507be --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/StatusMessage.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.ResourceManager.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Operation status message object. + /// + public partial class StatusMessage + { + /// + /// Initializes a new instance of the StatusMessage class. + /// + public StatusMessage() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the StatusMessage class. + /// + /// Status of the deployment operation. + /// The error reported by the operation. + public StatusMessage(string status = default(string), ErrorResponse error = default(ErrorResponse)) + { + Status = status; + Error = error; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets status of the deployment operation. + /// + [JsonProperty(PropertyName = "status")] + public string Status { get; set; } + + /// + /// Gets or sets the error reported by the operation. + /// + [JsonProperty(PropertyName = "error")] + public ErrorResponse Error { get; set; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/StorageAccountConfiguration.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/StorageAccountConfiguration.cs new file mode 100644 index 0000000000000..dbe18c41803c3 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/StorageAccountConfiguration.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.ResourceManager.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Settings to use an existing storage account. Valid storage account + /// kinds are: Storage, StorageV2 and FileStorage + /// + public partial class StorageAccountConfiguration + { + /// + /// Initializes a new instance of the StorageAccountConfiguration + /// class. + /// + public StorageAccountConfiguration() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the StorageAccountConfiguration + /// class. + /// + /// The storage account name. + /// The storage account access + /// key. + public StorageAccountConfiguration(string storageAccountName = default(string), string storageAccountKey = default(string)) + { + StorageAccountName = storageAccountName; + StorageAccountKey = storageAccountKey; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the storage account name. + /// + [JsonProperty(PropertyName = "storageAccountName")] + public string StorageAccountName { get; set; } + + /// + /// Gets or sets the storage account access key. + /// + [JsonProperty(PropertyName = "storageAccountKey")] + public string StorageAccountKey { get; set; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/SubResource.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/SubResource.cs new file mode 100644 index 0000000000000..f193d2772aa66 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/SubResource.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.ResourceManager.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Sub-resource. + /// + public partial class SubResource : IResource + { + /// + /// Initializes a new instance of the SubResource class. + /// + public SubResource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the SubResource class. + /// + /// Resource ID + public SubResource(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 + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; set; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/Subscription.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/Subscription.cs new file mode 100644 index 0000000000000..5aa0e57d36b91 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/Subscription.cs @@ -0,0 +1,133 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Subscription information. + /// + public partial class Subscription + { + /// + /// Initializes a new instance of the Subscription class. + /// + public Subscription() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Subscription class. + /// + /// The fully qualified ID for the subscription. For + /// example, + /// /subscriptions/00000000-0000-0000-0000-000000000000. + /// The subscription ID. + /// The subscription display name. + /// The subscription tenant ID. + /// The subscription state. Possible values are + /// Enabled, Warned, PastDue, Disabled, and Deleted. Possible values + /// include: 'Enabled', 'Warned', 'PastDue', 'Disabled', + /// 'Deleted' + /// The subscription + /// policies. + /// The authorization source of the + /// request. Valid values are one or more combinations of Legacy, + /// RoleBased, Bypassed, Direct and Management. For example, 'Legacy, + /// RoleBased'. + /// An array containing the tenants + /// managing the subscription. + /// The tags attached to the subscription. + public Subscription(string id = default(string), string subscriptionId = default(string), string displayName = default(string), string tenantId = default(string), SubscriptionState? state = default(SubscriptionState?), SubscriptionPolicies subscriptionPolicies = default(SubscriptionPolicies), string authorizationSource = default(string), IList managedByTenants = default(IList), IDictionary tags = default(IDictionary)) + { + Id = id; + SubscriptionId = subscriptionId; + DisplayName = displayName; + TenantId = tenantId; + State = state; + SubscriptionPolicies = subscriptionPolicies; + AuthorizationSource = authorizationSource; + ManagedByTenants = managedByTenants; + Tags = tags; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the fully qualified ID for the subscription. For example, + /// /subscriptions/00000000-0000-0000-0000-000000000000. + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; private set; } + + /// + /// Gets the subscription ID. + /// + [JsonProperty(PropertyName = "subscriptionId")] + public string SubscriptionId { get; private set; } + + /// + /// Gets the subscription display name. + /// + [JsonProperty(PropertyName = "displayName")] + public string DisplayName { get; private set; } + + /// + /// Gets the subscription tenant ID. + /// + [JsonProperty(PropertyName = "tenantId")] + public string TenantId { get; private set; } + + /// + /// Gets the subscription state. Possible values are Enabled, Warned, + /// PastDue, Disabled, and Deleted. Possible values include: 'Enabled', + /// 'Warned', 'PastDue', 'Disabled', 'Deleted' + /// + [JsonProperty(PropertyName = "state")] + public SubscriptionState? State { get; private set; } + + /// + /// Gets or sets the subscription policies. + /// + [JsonProperty(PropertyName = "subscriptionPolicies")] + public SubscriptionPolicies SubscriptionPolicies { get; set; } + + /// + /// Gets or sets the authorization source of the request. Valid values + /// are one or more combinations of Legacy, RoleBased, Bypassed, Direct + /// and Management. For example, 'Legacy, RoleBased'. + /// + [JsonProperty(PropertyName = "authorizationSource")] + public string AuthorizationSource { get; set; } + + /// + /// Gets or sets an array containing the tenants managing the + /// subscription. + /// + [JsonProperty(PropertyName = "managedByTenants")] + public IList ManagedByTenants { get; set; } + + /// + /// Gets or sets the tags attached to the subscription. + /// + [JsonProperty(PropertyName = "tags")] + public IDictionary Tags { get; set; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/SubscriptionFeatureRegistration.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/SubscriptionFeatureRegistration.cs new file mode 100644 index 0000000000000..7718967318c06 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/SubscriptionFeatureRegistration.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.ResourceManager.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Subscription feature registration details + /// + public partial class SubscriptionFeatureRegistration : ProxyResource + { + /// + /// Initializes a new instance of the SubscriptionFeatureRegistration + /// class. + /// + public SubscriptionFeatureRegistration() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the SubscriptionFeatureRegistration + /// class. + /// + /// Azure resource Id. + /// Azure resource name. + /// Azure resource type. + public SubscriptionFeatureRegistration(string id = default(string), string name = default(string), string type = default(string), SubscriptionFeatureRegistrationProperties properties = default(SubscriptionFeatureRegistrationProperties)) + : base(id, name, type) + { + Properties = properties; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// + [JsonProperty(PropertyName = "properties")] + public SubscriptionFeatureRegistrationProperties Properties { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Properties != null) + { + Properties.Validate(); + } + } + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/SubscriptionFeatureRegistrationApprovalType.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/SubscriptionFeatureRegistrationApprovalType.cs new file mode 100644 index 0000000000000..57183fc5dc292 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/SubscriptionFeatureRegistrationApprovalType.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.ResourceManager.Models +{ + + /// + /// Defines values for SubscriptionFeatureRegistrationApprovalType. + /// + public static class SubscriptionFeatureRegistrationApprovalType + { + public const string NotSpecified = "NotSpecified"; + public const string ApprovalRequired = "ApprovalRequired"; + public const string AutoApproval = "AutoApproval"; + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/SubscriptionFeatureRegistrationProperties.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/SubscriptionFeatureRegistrationProperties.cs new file mode 100644 index 0000000000000..c237a81eca8dd --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/SubscriptionFeatureRegistrationProperties.cs @@ -0,0 +1,189 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + public partial class SubscriptionFeatureRegistrationProperties + { + /// + /// Initializes a new instance of the + /// SubscriptionFeatureRegistrationProperties class. + /// + public SubscriptionFeatureRegistrationProperties() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// SubscriptionFeatureRegistrationProperties class. + /// + /// The tenantId. + /// The subscriptionId. + /// The featureName. + /// The featureDisplayName. + /// The providerNamespace. + /// The state. Possible values include: + /// 'NotSpecified', 'NotRegistered', 'Pending', 'Registering', + /// 'Registered', 'Unregistering', 'Unregistered' + /// Key-value pairs for meta data. + /// The feature release date. + /// The feature registration + /// date. + /// The feature documentation + /// link. + /// The feature approval type. Possible + /// values include: 'NotSpecified', 'ApprovalRequired', + /// 'AutoApproval' + /// Indicates whether + /// feature should be displayed in Portal. + /// The feature description. + public SubscriptionFeatureRegistrationProperties(string tenantId = default(string), string subscriptionId = default(string), string featureName = default(string), string displayName = default(string), string providerNamespace = default(string), string state = default(string), AuthorizationProfile authorizationProfile = default(AuthorizationProfile), IDictionary metadata = default(IDictionary), System.DateTime? releaseDate = default(System.DateTime?), System.DateTime? registrationDate = default(System.DateTime?), string documentationLink = default(string), string approvalType = default(string), bool? shouldFeatureDisplayInPortal = default(bool?), string description = default(string)) + { + TenantId = tenantId; + SubscriptionId = subscriptionId; + FeatureName = featureName; + DisplayName = displayName; + ProviderNamespace = providerNamespace; + State = state; + AuthorizationProfile = authorizationProfile; + Metadata = metadata; + ReleaseDate = releaseDate; + RegistrationDate = registrationDate; + DocumentationLink = documentationLink; + ApprovalType = approvalType; + ShouldFeatureDisplayInPortal = shouldFeatureDisplayInPortal; + Description = description; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the tenantId. + /// + [JsonProperty(PropertyName = "tenantId")] + public string TenantId { get; private set; } + + /// + /// Gets the subscriptionId. + /// + [JsonProperty(PropertyName = "subscriptionId")] + public string SubscriptionId { get; private set; } + + /// + /// Gets the featureName. + /// + [JsonProperty(PropertyName = "featureName")] + public string FeatureName { get; private set; } + + /// + /// Gets the featureDisplayName. + /// + [JsonProperty(PropertyName = "displayName")] + public string DisplayName { get; private set; } + + /// + /// Gets the providerNamespace. + /// + [JsonProperty(PropertyName = "providerNamespace")] + public string ProviderNamespace { get; private set; } + + /// + /// Gets or sets the state. Possible values include: 'NotSpecified', + /// 'NotRegistered', 'Pending', 'Registering', 'Registered', + /// 'Unregistering', 'Unregistered' + /// + [JsonProperty(PropertyName = "state")] + public string State { get; set; } + + /// + /// + [JsonProperty(PropertyName = "authorizationProfile")] + public AuthorizationProfile AuthorizationProfile { get; set; } + + /// + /// Gets or sets key-value pairs for meta data. + /// + [JsonProperty(PropertyName = "metadata")] + public IDictionary Metadata { get; set; } + + /// + /// Gets the feature release date. + /// + [JsonProperty(PropertyName = "releaseDate")] + public System.DateTime? ReleaseDate { get; private set; } + + /// + /// Gets the feature registration date. + /// + [JsonProperty(PropertyName = "registrationDate")] + public System.DateTime? RegistrationDate { get; private set; } + + /// + /// Gets the feature documentation link. + /// + [JsonProperty(PropertyName = "documentationLink")] + public string DocumentationLink { get; private set; } + + /// + /// Gets the feature approval type. Possible values include: + /// 'NotSpecified', 'ApprovalRequired', 'AutoApproval' + /// + [JsonProperty(PropertyName = "approvalType")] + public string ApprovalType { get; private set; } + + /// + /// Gets or sets indicates whether feature should be displayed in + /// Portal. + /// + [JsonProperty(PropertyName = "shouldFeatureDisplayInPortal")] + public bool? ShouldFeatureDisplayInPortal { get; set; } + + /// + /// Gets or sets the feature description. + /// + [JsonProperty(PropertyName = "description")] + public string Description { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (DocumentationLink != null) + { + if (DocumentationLink.Length > 1000) + { + throw new ValidationException(ValidationRules.MaxLength, "DocumentationLink", 1000); + } + } + if (Description != null) + { + if (Description.Length > 1000) + { + throw new ValidationException(ValidationRules.MaxLength, "Description", 1000); + } + } + } + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/SubscriptionFeatureRegistrationState.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/SubscriptionFeatureRegistrationState.cs new file mode 100644 index 0000000000000..269d56a31158d --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/SubscriptionFeatureRegistrationState.cs @@ -0,0 +1,27 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager.Models +{ + + /// + /// Defines values for SubscriptionFeatureRegistrationState. + /// + public static class SubscriptionFeatureRegistrationState + { + public const string NotSpecified = "NotSpecified"; + public const string NotRegistered = "NotRegistered"; + public const string Pending = "Pending"; + public const string Registering = "Registering"; + public const string Registered = "Registered"; + public const string Unregistering = "Unregistering"; + public const string Unregistered = "Unregistered"; + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/SubscriptionPolicies.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/SubscriptionPolicies.cs new file mode 100644 index 0000000000000..b98fb80edd07d --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/SubscriptionPolicies.cs @@ -0,0 +1,75 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Subscription policies. + /// + public partial class SubscriptionPolicies + { + /// + /// Initializes a new instance of the SubscriptionPolicies class. + /// + public SubscriptionPolicies() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the SubscriptionPolicies class. + /// + /// The subscription location + /// placement ID. The ID indicates which regions are visible for a + /// subscription. For example, a subscription with a location placement + /// Id of Public_2014-09-01 has access to Azure public regions. + /// The subscription quota ID. + /// The subscription spending limit. + /// Possible values include: 'On', 'Off', 'CurrentPeriodOff' + public SubscriptionPolicies(string locationPlacementId = default(string), string quotaId = default(string), SpendingLimit? spendingLimit = default(SpendingLimit?)) + { + LocationPlacementId = locationPlacementId; + QuotaId = quotaId; + SpendingLimit = spendingLimit; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the subscription location placement ID. The ID indicates which + /// regions are visible for a subscription. For example, a subscription + /// with a location placement Id of Public_2014-09-01 has access to + /// Azure public regions. + /// + [JsonProperty(PropertyName = "locationPlacementId")] + public string LocationPlacementId { get; private set; } + + /// + /// Gets the subscription quota ID. + /// + [JsonProperty(PropertyName = "quotaId")] + public string QuotaId { get; private set; } + + /// + /// Gets the subscription spending limit. Possible values include: + /// 'On', 'Off', 'CurrentPeriodOff' + /// + [JsonProperty(PropertyName = "spendingLimit")] + public SpendingLimit? SpendingLimit { get; private set; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/SubscriptionState.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/SubscriptionState.cs new file mode 100644 index 0000000000000..7f5f21e56aca3 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/SubscriptionState.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.ResourceManager.Models +{ + using Newtonsoft.Json; + using Newtonsoft.Json.Converters; + using System.Runtime; + using System.Runtime.Serialization; + + /// + /// Defines values for SubscriptionState. + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum SubscriptionState + { + [EnumMember(Value = "Enabled")] + Enabled, + [EnumMember(Value = "Warned")] + Warned, + [EnumMember(Value = "PastDue")] + PastDue, + [EnumMember(Value = "Disabled")] + Disabled, + [EnumMember(Value = "Deleted")] + Deleted + } + internal static class SubscriptionStateEnumExtension + { + internal static string ToSerializedValue(this SubscriptionState? value) + { + return value == null ? null : ((SubscriptionState)value).ToSerializedValue(); + } + + internal static string ToSerializedValue(this SubscriptionState value) + { + switch( value ) + { + case SubscriptionState.Enabled: + return "Enabled"; + case SubscriptionState.Warned: + return "Warned"; + case SubscriptionState.PastDue: + return "PastDue"; + case SubscriptionState.Disabled: + return "Disabled"; + case SubscriptionState.Deleted: + return "Deleted"; + } + return null; + } + + internal static SubscriptionState? ParseSubscriptionState(this string value) + { + switch( value ) + { + case "Enabled": + return SubscriptionState.Enabled; + case "Warned": + return SubscriptionState.Warned; + case "PastDue": + return SubscriptionState.PastDue; + case "Disabled": + return SubscriptionState.Disabled; + case "Deleted": + return SubscriptionState.Deleted; + } + return null; + } + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/SystemData.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/SystemData.cs new file mode 100644 index 0000000000000..e0f9fafbac84c --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/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.ResourceManager.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/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/TagCount.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/TagCount.cs new file mode 100644 index 0000000000000..fdcb67a3c80f6 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/TagCount.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.ResourceManager.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Tag count. + /// + public partial class TagCount + { + /// + /// Initializes a new instance of the TagCount class. + /// + public TagCount() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the TagCount class. + /// + /// Type of count. + /// Value of count. + public TagCount(string type = default(string), int? value = default(int?)) + { + Type = type; + Value = value; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets type of count. + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; set; } + + /// + /// Gets or sets value of count. + /// + [JsonProperty(PropertyName = "value")] + public int? Value { get; set; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/TagDetails.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/TagDetails.cs new file mode 100644 index 0000000000000..1d9c42db425f8 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/TagDetails.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.ResourceManager.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Tag details. + /// + public partial class TagDetails : IResource + { + /// + /// Initializes a new instance of the TagDetails class. + /// + public TagDetails() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the TagDetails class. + /// + /// The tag name ID. + /// The tag name. + /// The total number of resources that use the + /// resource tag. When a tag is initially created and has no associated + /// resources, the value is 0. + /// The list of tag values. + public TagDetails(string id = default(string), string tagName = default(string), TagCount count = default(TagCount), IList values = default(IList)) + { + Id = id; + TagName = tagName; + Count = count; + Values = values; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the tag name ID. + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; private set; } + + /// + /// Gets or sets the tag name. + /// + [JsonProperty(PropertyName = "tagName")] + public string TagName { get; set; } + + /// + /// Gets or sets the total number of resources that use the resource + /// tag. When a tag is initially created and has no associated + /// resources, the value is 0. + /// + [JsonProperty(PropertyName = "count")] + public TagCount Count { get; set; } + + /// + /// Gets or sets the list of tag values. + /// + [JsonProperty(PropertyName = "values")] + public IList Values { get; set; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/TagValue.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/TagValue.cs new file mode 100644 index 0000000000000..35960ee7ffc62 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/TagValue.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.ResourceManager.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Tag information. + /// + public partial class TagValue : IResource + { + /// + /// Initializes a new instance of the TagValue class. + /// + public TagValue() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the TagValue class. + /// + /// The tag value ID. + /// The tag value. + /// The tag value count. + public TagValue(string id = default(string), string tagValueProperty = default(string), TagCount count = default(TagCount)) + { + Id = id; + TagValueProperty = tagValueProperty; + Count = count; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the tag value ID. + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; private set; } + + /// + /// Gets or sets the tag value. + /// + [JsonProperty(PropertyName = "tagValue")] + public string TagValueProperty { get; set; } + + /// + /// Gets or sets the tag value count. + /// + [JsonProperty(PropertyName = "count")] + public TagCount Count { get; set; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/Tags.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/Tags.cs new file mode 100644 index 0000000000000..6d439197602c2 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/Tags.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.ResourceManager.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// A dictionary of name and value pairs. + /// + public partial class Tags + { + /// + /// Initializes a new instance of the Tags class. + /// + public Tags() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Tags class. + /// + public Tags(IDictionary tagsProperty = default(IDictionary)) + { + TagsProperty = tagsProperty; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// + [JsonProperty(PropertyName = "tags")] + public IDictionary TagsProperty { get; set; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/TagsPatchOperation.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/TagsPatchOperation.cs new file mode 100644 index 0000000000000..1b5268a74c233 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/TagsPatchOperation.cs @@ -0,0 +1,35 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager.Models +{ + + /// + /// Defines values for TagsPatchOperation. + /// + public static class TagsPatchOperation + { + /// + /// The 'replace' option replaces the entire set of existing tags with + /// a new set. + /// + public const string Replace = "Replace"; + /// + /// The 'merge' option allows adding tags with new names and updating + /// the values of tags with existing names. + /// + public const string Merge = "Merge"; + /// + /// The 'delete' option allows selectively deleting tags based on given + /// names or name/value pairs. + /// + public const string Delete = "Delete"; + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/TagsPatchResource.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/TagsPatchResource.cs new file mode 100644 index 0000000000000..5eed4fa2b62c9 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/TagsPatchResource.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.ResourceManager.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Wrapper resource for tags patch API request only. + /// + public partial class TagsPatchResource + { + /// + /// Initializes a new instance of the TagsPatchResource class. + /// + public TagsPatchResource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the TagsPatchResource class. + /// + /// The operation type for the patch API. + /// Possible values include: 'Replace', 'Merge', 'Delete' + /// The set of tags. + public TagsPatchResource(string operation = default(string), Tags properties = default(Tags)) + { + Operation = operation; + Properties = properties; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the operation type for the patch API. Possible values + /// include: 'Replace', 'Merge', 'Delete' + /// + [JsonProperty(PropertyName = "operation")] + public string Operation { get; set; } + + /// + /// Gets or sets the set of tags. + /// + [JsonProperty(PropertyName = "properties")] + public Tags Properties { get; set; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/TagsResource.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/TagsResource.cs new file mode 100644 index 0000000000000..d7e77a34645b2 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/TagsResource.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.ResourceManager.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Wrapper resource for tags API requests and responses. + /// + public partial class TagsResource : IResource + { + /// + /// Initializes a new instance of the TagsResource class. + /// + public TagsResource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the TagsResource class. + /// + /// The set of tags. + /// The ID of the tags wrapper resource. + /// The name of the tags wrapper resource. + /// The type of the tags wrapper resource. + public TagsResource(Tags properties, string id = default(string), string name = default(string), string type = default(string)) + { + Id = id; + Name = name; + Type = type; + Properties = properties; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the ID of the tags wrapper resource. + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; private set; } + + /// + /// Gets the name of the tags wrapper resource. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; private set; } + + /// + /// Gets the type of the tags wrapper resource. + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; private set; } + + /// + /// Gets or sets the set of tags. + /// + [JsonProperty(PropertyName = "properties")] + public Tags Properties { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Properties == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Properties"); + } + } + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/TargetResource.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/TargetResource.cs new file mode 100644 index 0000000000000..7e6640cb58316 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/TargetResource.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.ResourceManager.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Target resource. + /// + public partial class TargetResource + { + /// + /// Initializes a new instance of the TargetResource class. + /// + public TargetResource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the TargetResource class. + /// + /// The ID of the resource. + /// The name of the resource. + /// The type of the resource. + public TargetResource(string id = default(string), string resourceName = default(string), string resourceType = default(string)) + { + Id = id; + ResourceName = resourceName; + ResourceType = resourceType; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the ID of the resource. + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; set; } + + /// + /// Gets or sets the name of the resource. + /// + [JsonProperty(PropertyName = "resourceName")] + public string ResourceName { get; set; } + + /// + /// Gets or sets the type of the resource. + /// + [JsonProperty(PropertyName = "resourceType")] + public string ResourceType { get; set; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/TemplateHashResult.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/TemplateHashResult.cs new file mode 100644 index 0000000000000..4470f57a0b65d --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/TemplateHashResult.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.ResourceManager.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Result of the request to calculate template hash. It contains a string + /// of minified template and its hash. + /// + public partial class TemplateHashResult + { + /// + /// Initializes a new instance of the TemplateHashResult class. + /// + public TemplateHashResult() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the TemplateHashResult class. + /// + /// The minified template + /// string. + /// The template hash. + public TemplateHashResult(string minifiedTemplate = default(string), string templateHash = default(string)) + { + MinifiedTemplate = minifiedTemplate; + TemplateHash = templateHash; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the minified template string. + /// + [JsonProperty(PropertyName = "minifiedTemplate")] + public string MinifiedTemplate { get; set; } + + /// + /// Gets or sets the template hash. + /// + [JsonProperty(PropertyName = "templateHash")] + public string TemplateHash { get; set; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/TemplateLink.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/TemplateLink.cs new file mode 100644 index 0000000000000..614823222a152 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/TemplateLink.cs @@ -0,0 +1,101 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Entity representing the reference to the template. + /// + public partial class TemplateLink + { + /// + /// Initializes a new instance of the TemplateLink class. + /// + public TemplateLink() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the TemplateLink class. + /// + /// The URI of the template to deploy. Use either the + /// uri or id property, but not both. + /// The resource id of a Template Spec. Use either the + /// id or uri property, but not both. + /// The relativePath property can be used to + /// deploy a linked template at a location relative to the parent. If + /// the parent template was linked with a TemplateSpec, this will + /// reference an artifact in the TemplateSpec. If the parent was + /// linked with a URI, the child deployment will be a combination of + /// the parent and relativePath URIs + /// If included, must match the + /// ContentVersion in the template. + /// The query string (for example, a SAS + /// token) to be used with the templateLink URI. + public TemplateLink(string uri = default(string), string id = default(string), string relativePath = default(string), string contentVersion = default(string), string queryString = default(string)) + { + Uri = uri; + Id = id; + RelativePath = relativePath; + ContentVersion = contentVersion; + QueryString = queryString; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the URI of the template to deploy. Use either the uri + /// or id property, but not both. + /// + [JsonProperty(PropertyName = "uri")] + public string Uri { get; set; } + + /// + /// Gets or sets the resource id of a Template Spec. Use either the id + /// or uri property, but not both. + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; set; } + + /// + /// Gets or sets the relativePath property can be used to deploy a + /// linked template at a location relative to the parent. If the parent + /// template was linked with a TemplateSpec, this will reference an + /// artifact in the TemplateSpec. If the parent was linked with a URI, + /// the child deployment will be a combination of the parent and + /// relativePath URIs + /// + [JsonProperty(PropertyName = "relativePath")] + public string RelativePath { get; set; } + + /// + /// Gets or sets if included, must match the ContentVersion in the + /// template. + /// + [JsonProperty(PropertyName = "contentVersion")] + public string ContentVersion { get; set; } + + /// + /// Gets or sets the query string (for example, a SAS token) to be used + /// with the templateLink URI. + /// + [JsonProperty(PropertyName = "queryString")] + public string QueryString { get; set; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/TemplateSpec.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/TemplateSpec.cs new file mode 100644 index 0000000000000..1dfab791d11d8 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/TemplateSpec.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.ResourceManager.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Template Spec object. + /// + [Rest.Serialization.JsonTransformation] + public partial class TemplateSpec : AzureResourceBase + { + /// + /// Initializes a new instance of the TemplateSpec class. + /// + public TemplateSpec() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the TemplateSpec class. + /// + /// The location of the Template Spec. It cannot + /// be changed after Template Spec creation. It must be one of the + /// supported Azure locations. + /// String Id used to locate any resource on + /// Azure. + /// Name of this resource. + /// Type of this resource. + /// Azure Resource Manager metadata containing + /// createdBy and modifiedBy information. + /// Template Spec description. + /// Template Spec display name. + /// The Template Spec metadata. Metadata is an + /// open-ended object and is typically a collection of key-value + /// pairs. + /// High-level information about the versions + /// within this Template Spec. The keys are the version names. Only + /// populated if the $expand query parameter is set to + /// 'versions'. + /// Resource tags. + public TemplateSpec(string location, string id = default(string), string name = default(string), string type = default(string), SystemData systemData = default(SystemData), string description = default(string), string displayName = default(string), object metadata = default(object), IDictionary versions = default(IDictionary), IDictionary tags = default(IDictionary)) + : base(id, name, type, systemData) + { + Location = location; + Description = description; + DisplayName = displayName; + Metadata = metadata; + Versions = versions; + Tags = tags; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the location of the Template Spec. It cannot be + /// changed after Template Spec creation. It must be one of the + /// supported Azure locations. + /// + [JsonProperty(PropertyName = "location")] + public string Location { get; set; } + + /// + /// Gets or sets template Spec description. + /// + [JsonProperty(PropertyName = "properties.description")] + public string Description { get; set; } + + /// + /// Gets or sets template Spec display name. + /// + [JsonProperty(PropertyName = "properties.displayName")] + public string DisplayName { get; set; } + + /// + /// Gets or sets the Template Spec metadata. Metadata is an open-ended + /// object and is typically a collection of key-value pairs. + /// + [JsonProperty(PropertyName = "properties.metadata")] + public object Metadata { get; set; } + + /// + /// Gets high-level information about the versions within this Template + /// Spec. The keys are the version names. Only populated if the $expand + /// query parameter is set to 'versions'. + /// + [JsonProperty(PropertyName = "properties.versions")] + public IDictionary Versions { get; private set; } + + /// + /// Gets or sets resource tags. + /// + [JsonProperty(PropertyName = "tags")] + public IDictionary Tags { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Location == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Location"); + } + if (Description != null) + { + if (Description.Length > 4096) + { + throw new ValidationException(ValidationRules.MaxLength, "Description", 4096); + } + } + if (DisplayName != null) + { + if (DisplayName.Length > 64) + { + throw new ValidationException(ValidationRules.MaxLength, "DisplayName", 64); + } + } + } + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/TemplateSpecExpandKind.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/TemplateSpecExpandKind.cs new file mode 100644 index 0000000000000..1599db4ff5476 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/TemplateSpecExpandKind.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.ResourceManager.Models +{ + + /// + /// Defines values for TemplateSpecExpandKind. + /// + public static class TemplateSpecExpandKind + { + /// + /// Includes version information with the Template Spec. + /// + public const string Versions = "versions"; + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/TemplateSpecUpdateModel.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/TemplateSpecUpdateModel.cs new file mode 100644 index 0000000000000..0b1cd2c0c2562 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/TemplateSpecUpdateModel.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.ResourceManager.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Template Spec properties to be updated (only tags are currently + /// supported). + /// + public partial class TemplateSpecUpdateModel : AzureResourceBase + { + /// + /// Initializes a new instance of the TemplateSpecUpdateModel class. + /// + public TemplateSpecUpdateModel() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the TemplateSpecUpdateModel class. + /// + /// String Id used to locate any resource on + /// Azure. + /// Name of this resource. + /// Type of this resource. + /// Azure Resource Manager metadata containing + /// createdBy and modifiedBy information. + /// Resource tags. + public TemplateSpecUpdateModel(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; + 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/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/TemplateSpecVersion.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/TemplateSpecVersion.cs new file mode 100644 index 0000000000000..81537a820e1af --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/TemplateSpecVersion.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.ResourceManager.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Template Spec Version object. + /// + [Rest.Serialization.JsonTransformation] + public partial class TemplateSpecVersion : AzureResourceBase + { + /// + /// Initializes a new instance of the TemplateSpecVersion class. + /// + public TemplateSpecVersion() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the TemplateSpecVersion class. + /// + /// The location of the Template Spec Version. + /// It must match the location of the parent Template Spec. + /// String Id used to locate any resource on + /// Azure. + /// Name of this resource. + /// Type of this resource. + /// Azure Resource Manager metadata containing + /// createdBy and modifiedBy information. + /// Template Spec version + /// description. + /// An array of linked template + /// artifacts. + /// The version metadata. Metadata is an + /// open-ended object and is typically a collection of key-value + /// pairs. + /// The main Azure Resource Manager template + /// content. + /// The Azure Resource Manager template + /// UI definition content. + /// Resource tags. + public TemplateSpecVersion(string location, string id = default(string), string name = default(string), string type = default(string), SystemData systemData = default(SystemData), string description = default(string), IList linkedTemplates = default(IList), object metadata = default(object), object mainTemplate = default(object), object uiFormDefinition = default(object), IDictionary tags = default(IDictionary)) + : base(id, name, type, systemData) + { + Location = location; + Description = description; + LinkedTemplates = linkedTemplates; + Metadata = metadata; + MainTemplate = mainTemplate; + UiFormDefinition = uiFormDefinition; + Tags = tags; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the location of the Template Spec Version. It must + /// match the location of the parent Template Spec. + /// + [JsonProperty(PropertyName = "location")] + public string Location { get; set; } + + /// + /// Gets or sets template Spec version description. + /// + [JsonProperty(PropertyName = "properties.description")] + public string Description { get; set; } + + /// + /// Gets or sets an array of linked template artifacts. + /// + [JsonProperty(PropertyName = "properties.linkedTemplates")] + public IList LinkedTemplates { get; set; } + + /// + /// Gets or sets the version metadata. Metadata is an open-ended object + /// and is typically a collection of key-value pairs. + /// + [JsonProperty(PropertyName = "properties.metadata")] + public object Metadata { get; set; } + + /// + /// Gets or sets the main Azure Resource Manager template content. + /// + [JsonProperty(PropertyName = "properties.mainTemplate")] + public object MainTemplate { get; set; } + + /// + /// Gets or sets the Azure Resource Manager template UI definition + /// content. + /// + [JsonProperty(PropertyName = "properties.uiFormDefinition")] + public object UiFormDefinition { get; set; } + + /// + /// Gets or sets resource tags. + /// + [JsonProperty(PropertyName = "tags")] + public IDictionary Tags { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Location == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Location"); + } + if (Description != null) + { + if (Description.Length > 4096) + { + throw new ValidationException(ValidationRules.MaxLength, "Description", 4096); + } + } + if (LinkedTemplates != null) + { + foreach (var element in LinkedTemplates) + { + if (element != null) + { + element.Validate(); + } + } + } + } + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/TemplateSpecVersionInfo.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/TemplateSpecVersionInfo.cs new file mode 100644 index 0000000000000..d3d82e2dbe7d9 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/TemplateSpecVersionInfo.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.ResourceManager.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// High-level information about a Template Spec version. + /// + public partial class TemplateSpecVersionInfo + { + /// + /// Initializes a new instance of the TemplateSpecVersionInfo class. + /// + public TemplateSpecVersionInfo() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the TemplateSpecVersionInfo class. + /// + /// Template Spec version + /// description. + /// The timestamp of when the version was + /// created. + /// The timestamp of when the version was + /// last modified. + public TemplateSpecVersionInfo(string description = default(string), System.DateTime? timeCreated = default(System.DateTime?), System.DateTime? timeModified = default(System.DateTime?)) + { + Description = description; + TimeCreated = timeCreated; + TimeModified = timeModified; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets template Spec version description. + /// + [JsonProperty(PropertyName = "description")] + public string Description { get; private set; } + + /// + /// Gets the timestamp of when the version was created. + /// + [JsonProperty(PropertyName = "timeCreated")] + public System.DateTime? TimeCreated { get; private set; } + + /// + /// Gets the timestamp of when the version was last modified. + /// + [JsonProperty(PropertyName = "timeModified")] + public System.DateTime? TimeModified { get; private set; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/TemplateSpecVersionUpdateModel.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/TemplateSpecVersionUpdateModel.cs new file mode 100644 index 0000000000000..e359edac10179 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/TemplateSpecVersionUpdateModel.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.ResourceManager.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Template Spec Version properties to be updated (only tags are currently + /// supported). + /// + public partial class TemplateSpecVersionUpdateModel : AzureResourceBase + { + /// + /// Initializes a new instance of the TemplateSpecVersionUpdateModel + /// class. + /// + public TemplateSpecVersionUpdateModel() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the TemplateSpecVersionUpdateModel + /// class. + /// + /// String Id used to locate any resource on + /// Azure. + /// Name of this resource. + /// Type of this resource. + /// Azure Resource Manager metadata containing + /// createdBy and modifiedBy information. + /// Resource tags. + public TemplateSpecVersionUpdateModel(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; + 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/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/TemplateSpecsError.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/TemplateSpecsError.cs new file mode 100644 index 0000000000000..f9e6a3de06526 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/TemplateSpecsError.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.ResourceManager.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Template Specs error response. + /// + public partial class TemplateSpecsError + { + /// + /// Initializes a new instance of the TemplateSpecsError class. + /// + public TemplateSpecsError() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the TemplateSpecsError class. + /// + public TemplateSpecsError(ErrorResponse error = default(ErrorResponse)) + { + Error = error; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// + [JsonProperty(PropertyName = "error")] + public ErrorResponse Error { get; set; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/TemplateSpecsErrorException.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/TemplateSpecsErrorException.cs new file mode 100644 index 0000000000000..071c2e524716f --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/TemplateSpecsErrorException.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.ResourceManager.Models +{ + using Microsoft.Rest; + + /// + /// Exception thrown for an invalid response with TemplateSpecsError + /// information. + /// + public partial class TemplateSpecsErrorException : 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 TemplateSpecsError Body { get; set; } + + /// + /// Initializes a new instance of the TemplateSpecsErrorException class. + /// + public TemplateSpecsErrorException() + { + } + + /// + /// Initializes a new instance of the TemplateSpecsErrorException class. + /// + /// The exception message. + public TemplateSpecsErrorException(string message) + : this(message, null) + { + } + + /// + /// Initializes a new instance of the TemplateSpecsErrorException class. + /// + /// The exception message. + /// Inner exception. + public TemplateSpecsErrorException(string message, System.Exception innerException) + : base(message, innerException) + { + } + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/TenantCategory.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/TenantCategory.cs new file mode 100644 index 0000000000000..1d6f7dc343df3 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/TenantCategory.cs @@ -0,0 +1,66 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager.Models +{ + using Newtonsoft.Json; + using Newtonsoft.Json.Converters; + using System.Runtime; + using System.Runtime.Serialization; + + /// + /// Defines values for TenantCategory. + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum TenantCategory + { + [EnumMember(Value = "Home")] + Home, + [EnumMember(Value = "ProjectedBy")] + ProjectedBy, + [EnumMember(Value = "ManagedBy")] + ManagedBy + } + internal static class TenantCategoryEnumExtension + { + internal static string ToSerializedValue(this TenantCategory? value) + { + return value == null ? null : ((TenantCategory)value).ToSerializedValue(); + } + + internal static string ToSerializedValue(this TenantCategory value) + { + switch( value ) + { + case TenantCategory.Home: + return "Home"; + case TenantCategory.ProjectedBy: + return "ProjectedBy"; + case TenantCategory.ManagedBy: + return "ManagedBy"; + } + return null; + } + + internal static TenantCategory? ParseTenantCategory(this string value) + { + switch( value ) + { + case "Home": + return TenantCategory.Home; + case "ProjectedBy": + return TenantCategory.ProjectedBy; + case "ManagedBy": + return TenantCategory.ManagedBy; + } + return null; + } + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/TenantIdDescription.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/TenantIdDescription.cs new file mode 100644 index 0000000000000..c2d84fc0cdb37 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/TenantIdDescription.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.ResourceManager.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Tenant Id information. + /// + public partial class TenantIdDescription + { + /// + /// Initializes a new instance of the TenantIdDescription class. + /// + public TenantIdDescription() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the TenantIdDescription class. + /// + /// The fully qualified ID of the tenant. For example, + /// /tenants/00000000-0000-0000-0000-000000000000. + /// The tenant ID. For example, + /// 00000000-0000-0000-0000-000000000000. + /// Category of the tenant. Possible + /// values include: 'Home', 'ProjectedBy', 'ManagedBy' + /// Country/region name of the address for the + /// tenant. + /// Country/region abbreviation for the + /// tenant. + /// The display name of the tenant. + /// The list of domains for the tenant. + /// The default domain for the + /// tenant. + /// The tenant type. Only available for 'Home' + /// tenant category. + /// The tenant's branding logo URL. + /// Only available for 'Home' tenant category. + public TenantIdDescription(string id = default(string), string tenantId = default(string), TenantCategory? tenantCategory = default(TenantCategory?), string country = default(string), string countryCode = default(string), string displayName = default(string), IList domains = default(IList), string defaultDomain = default(string), string tenantType = default(string), string tenantBrandingLogoUrl = default(string)) + { + Id = id; + TenantId = tenantId; + TenantCategory = tenantCategory; + Country = country; + CountryCode = countryCode; + DisplayName = displayName; + Domains = domains; + DefaultDomain = defaultDomain; + TenantType = tenantType; + TenantBrandingLogoUrl = tenantBrandingLogoUrl; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the fully qualified ID of the tenant. For example, + /// /tenants/00000000-0000-0000-0000-000000000000. + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; private set; } + + /// + /// Gets the tenant ID. For example, + /// 00000000-0000-0000-0000-000000000000. + /// + [JsonProperty(PropertyName = "tenantId")] + public string TenantId { get; private set; } + + /// + /// Gets category of the tenant. Possible values include: 'Home', + /// 'ProjectedBy', 'ManagedBy' + /// + [JsonProperty(PropertyName = "tenantCategory")] + public TenantCategory? TenantCategory { get; private set; } + + /// + /// Gets country/region name of the address for the tenant. + /// + [JsonProperty(PropertyName = "country")] + public string Country { get; private set; } + + /// + /// Gets country/region abbreviation for the tenant. + /// + [JsonProperty(PropertyName = "countryCode")] + public string CountryCode { get; private set; } + + /// + /// Gets the display name of the tenant. + /// + [JsonProperty(PropertyName = "displayName")] + public string DisplayName { get; private set; } + + /// + /// Gets the list of domains for the tenant. + /// + [JsonProperty(PropertyName = "domains")] + public IList Domains { get; private set; } + + /// + /// Gets the default domain for the tenant. + /// + [JsonProperty(PropertyName = "defaultDomain")] + public string DefaultDomain { get; private set; } + + /// + /// Gets the tenant type. Only available for 'Home' tenant category. + /// + [JsonProperty(PropertyName = "tenantType")] + public string TenantType { get; private set; } + + /// + /// Gets the tenant's branding logo URL. Only available for 'Home' + /// tenant category. + /// + [JsonProperty(PropertyName = "tenantBrandingLogoUrl")] + public string TenantBrandingLogoUrl { get; private set; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/UserAssignedIdentity.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/UserAssignedIdentity.cs new file mode 100644 index 0000000000000..bbbd58dd0a9b2 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/UserAssignedIdentity.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.ResourceManager.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// User-assigned managed identity. + /// + public partial class UserAssignedIdentity + { + /// + /// Initializes a new instance of the UserAssignedIdentity class. + /// + public UserAssignedIdentity() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the UserAssignedIdentity class. + /// + /// Azure Active Directory principal ID + /// associated with this identity. + /// Client App Id associated with this + /// identity. + public UserAssignedIdentity(string principalId = default(string), string clientId = default(string)) + { + PrincipalId = principalId; + ClientId = clientId; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets azure Active Directory principal ID associated with this + /// identity. + /// + [JsonProperty(PropertyName = "principalId")] + public string PrincipalId { get; private set; } + + /// + /// Gets client App Id associated with this identity. + /// + [JsonProperty(PropertyName = "clientId")] + public string ClientId { get; private set; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/WhatIfChange.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/WhatIfChange.cs new file mode 100644 index 0000000000000..7a71e354bfa20 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/WhatIfChange.cs @@ -0,0 +1,130 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Information about a single resource change predicted by What-If + /// operation. + /// + public partial class WhatIfChange + { + /// + /// Initializes a new instance of the WhatIfChange class. + /// + public WhatIfChange() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the WhatIfChange class. + /// + /// Resource ID + /// Type of change that will be made to the + /// resource when the deployment is executed. Possible values include: + /// 'Create', 'Delete', 'Ignore', 'Deploy', 'NoChange', 'Modify', + /// 'Unsupported' + /// The explanation about why the + /// resource is unsupported by What-If. + /// The snapshot of the resource before the + /// deployment is executed. + /// The predicted snapshot of the resource after + /// the deployment is executed. + /// The predicted changes to resource + /// properties. + public WhatIfChange(string resourceId, ChangeType changeType, string unsupportedReason = default(string), object before = default(object), object after = default(object), IList delta = default(IList)) + { + ResourceId = resourceId; + ChangeType = changeType; + UnsupportedReason = unsupportedReason; + Before = before; + After = after; + Delta = delta; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets resource ID + /// + [JsonProperty(PropertyName = "resourceId")] + public string ResourceId { get; set; } + + /// + /// Gets or sets type of change that will be made to the resource when + /// the deployment is executed. Possible values include: 'Create', + /// 'Delete', 'Ignore', 'Deploy', 'NoChange', 'Modify', 'Unsupported' + /// + [JsonProperty(PropertyName = "changeType")] + public ChangeType ChangeType { get; set; } + + /// + /// Gets or sets the explanation about why the resource is unsupported + /// by What-If. + /// + [JsonProperty(PropertyName = "unsupportedReason")] + public string UnsupportedReason { get; set; } + + /// + /// Gets or sets the snapshot of the resource before the deployment is + /// executed. + /// + [JsonProperty(PropertyName = "before")] + public object Before { get; set; } + + /// + /// Gets or sets the predicted snapshot of the resource after the + /// deployment is executed. + /// + [JsonProperty(PropertyName = "after")] + public object After { get; set; } + + /// + /// Gets or sets the predicted changes to resource properties. + /// + [JsonProperty(PropertyName = "delta")] + public IList Delta { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (ResourceId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "ResourceId"); + } + if (Delta != null) + { + foreach (var element in Delta) + { + if (element != null) + { + element.Validate(); + } + } + } + } + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/WhatIfOperationResult.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/WhatIfOperationResult.cs new file mode 100644 index 0000000000000..228dda9b7e850 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/WhatIfOperationResult.cs @@ -0,0 +1,75 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Result of the What-If operation. Contains a list of predicted changes + /// and a URL link to get to the next set of results. + /// + [Rest.Serialization.JsonTransformation] + public partial class WhatIfOperationResult + { + /// + /// Initializes a new instance of the WhatIfOperationResult class. + /// + public WhatIfOperationResult() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the WhatIfOperationResult class. + /// + /// Status of the What-If operation. + /// List of resource changes predicted by What-If + /// operation. + /// Error when What-If operation fails. + public WhatIfOperationResult(string status = default(string), IList changes = default(IList), ErrorResponse error = default(ErrorResponse)) + { + Status = status; + Changes = changes; + Error = error; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets status of the What-If operation. + /// + [JsonProperty(PropertyName = "status")] + public string Status { get; set; } + + /// + /// Gets or sets list of resource changes predicted by What-If + /// operation. + /// + [JsonProperty(PropertyName = "properties.changes")] + public IList Changes { get; set; } + + /// + /// Gets or sets error when What-If operation fails. + /// + [JsonProperty(PropertyName = "error")] + public ErrorResponse Error { get; set; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/WhatIfPropertyChange.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/WhatIfPropertyChange.cs new file mode 100644 index 0000000000000..23c13817b1932 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/WhatIfPropertyChange.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.ResourceManager.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The predicted change to the resource property. + /// + public partial class WhatIfPropertyChange + { + /// + /// Initializes a new instance of the WhatIfPropertyChange class. + /// + public WhatIfPropertyChange() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the WhatIfPropertyChange class. + /// + /// The path of the property. + /// The type of property change. + /// Possible values include: 'Create', 'Delete', 'Modify', 'Array', + /// 'NoEffect' + /// The value of the property before the + /// deployment is executed. + /// The value of the property after the deployment + /// is executed. + /// Nested property changes. + public WhatIfPropertyChange(string path, PropertyChangeType propertyChangeType, object before = default(object), object after = default(object), IList children = default(IList)) + { + Path = path; + PropertyChangeType = propertyChangeType; + Before = before; + After = after; + Children = children; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the path of the property. + /// + [JsonProperty(PropertyName = "path")] + public string Path { get; set; } + + /// + /// Gets or sets the type of property change. Possible values include: + /// 'Create', 'Delete', 'Modify', 'Array', 'NoEffect' + /// + [JsonProperty(PropertyName = "propertyChangeType")] + public PropertyChangeType PropertyChangeType { get; set; } + + /// + /// Gets or sets the value of the property before the deployment is + /// executed. + /// + [JsonProperty(PropertyName = "before")] + public object Before { get; set; } + + /// + /// Gets or sets the value of the property after the deployment is + /// executed. + /// + [JsonProperty(PropertyName = "after")] + public object After { get; set; } + + /// + /// Gets or sets nested property changes. + /// + [JsonProperty(PropertyName = "children")] + public IList Children { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Path == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Path"); + } + if (Children != null) + { + foreach (var element in Children) + { + if (element != null) + { + element.Validate(); + } + } + } + } + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/WhatIfResultFormat.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/WhatIfResultFormat.cs new file mode 100644 index 0000000000000..90b203230afe4 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/WhatIfResultFormat.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.ResourceManager.Models +{ + using Newtonsoft.Json; + using Newtonsoft.Json.Converters; + using System.Runtime; + using System.Runtime.Serialization; + + /// + /// Defines values for WhatIfResultFormat. + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum WhatIfResultFormat + { + [EnumMember(Value = "ResourceIdOnly")] + ResourceIdOnly, + [EnumMember(Value = "FullResourcePayloads")] + FullResourcePayloads + } + internal static class WhatIfResultFormatEnumExtension + { + internal static string ToSerializedValue(this WhatIfResultFormat? value) + { + return value == null ? null : ((WhatIfResultFormat)value).ToSerializedValue(); + } + + internal static string ToSerializedValue(this WhatIfResultFormat value) + { + switch( value ) + { + case WhatIfResultFormat.ResourceIdOnly: + return "ResourceIdOnly"; + case WhatIfResultFormat.FullResourcePayloads: + return "FullResourcePayloads"; + } + return null; + } + + internal static WhatIfResultFormat? ParseWhatIfResultFormat(this string value) + { + switch( value ) + { + case "ResourceIdOnly": + return WhatIfResultFormat.ResourceIdOnly; + case "FullResourcePayloads": + return WhatIfResultFormat.FullResourcePayloads; + } + return null; + } + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ZoneMapping.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ZoneMapping.cs new file mode 100644 index 0000000000000..254f25f991247 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Models/ZoneMapping.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.ResourceManager.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + public partial class ZoneMapping + { + /// + /// Initializes a new instance of the ZoneMapping class. + /// + public ZoneMapping() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ZoneMapping class. + /// + /// The location of the zone mapping. + public ZoneMapping(string location = default(string), IList zones = default(IList)) + { + Location = location; + Zones = zones; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the location of the zone mapping. + /// + [JsonProperty(PropertyName = "location")] + public string Location { get; set; } + + /// + /// + [JsonProperty(PropertyName = "zones")] + public IList Zones { get; set; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Operations.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Operations.cs new file mode 100644 index 0000000000000..fe52289b96c7d --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/Operations.cs @@ -0,0 +1,400 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager +{ + 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(ManagementLinkClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the ManagementLinkClient + /// + public ManagementLinkClient Client { get; private set; } + + /// + /// Lists all of the available Microsoft.Resources 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"); + } + // 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.Resources/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 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; + } + + /// + /// Lists all of the available Microsoft.Resources REST API operations. + /// + /// + /// 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 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/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/OperationsExtensions.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/OperationsExtensions.cs new file mode 100644 index 0000000000000..ac83409fa4dc0 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/OperationsExtensions.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.ResourceManager +{ + 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 Microsoft.Resources REST API operations. + /// + /// + /// The operations group for this extension method. + /// + public static IPage List(this IOperations operations) + { + return operations.ListAsync().GetAwaiter().GetResult(); + } + + /// + /// Lists all of the available Microsoft.Resources 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; + } + } + + /// + /// Lists all of the available Microsoft.Resources REST API operations. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListNext(this IOperations operations, string nextPageLink) + { + return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Lists all of the available Microsoft.Resources REST API operations. + /// + /// + /// 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 IOperations 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/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/PolicyAssignmentsOperations.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/PolicyAssignmentsOperations.cs new file mode 100644 index 0000000000000..48328e9ff7575 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/PolicyAssignmentsOperations.cs @@ -0,0 +1,3428 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Microsoft.Rest.Azure.OData; + 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; + + /// + /// PolicyAssignmentsOperations operations. + /// + internal partial class PolicyAssignmentsOperations : IServiceOperations, IPolicyAssignmentsOperations + { + /// + /// Initializes a new instance of the PolicyAssignmentsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal PolicyAssignmentsOperations(PolicyClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the PolicyClient + /// + public PolicyClient Client { get; private set; } + + /// + /// Deletes a policy assignment. + /// + /// + /// This operation deletes a policy assignment, given its name and the scope it + /// was created in. The scope of a policy assignment is the part of its ID + /// preceding + /// '/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + /// + /// + /// The scope of the policy assignment. Valid scopes are: management group + /// (format: + /// '/providers/Microsoft.Management/managementGroups/{managementGroup}'), + /// subscription (format: '/subscriptions/{subscriptionId}'), resource group + /// (format: + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or + /// resource (format: + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' + /// + /// + /// The name of the policy assignment to delete. + /// + /// + /// 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> DeleteWithHttpMessagesAsync(string scope, string policyAssignmentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (scope == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "scope"); + } + if (policyAssignmentName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "policyAssignmentName"); + } + string apiVersion = "2021-06-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("scope", scope); + tracingParameters.Add("policyAssignmentName", policyAssignmentName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Delete", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}").ToString(); + _url = _url.Replace("{scope}", scope); + _url = _url.Replace("{policyAssignmentName}", System.Uri.EscapeDataString(policyAssignmentName)); + 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 != 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(); + } + // 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 policy assignment. + /// + /// + /// This operation creates or updates a policy assignment with the given scope + /// and name. Policy assignments apply to all resources contained within their + /// scope. For example, when you assign a policy at resource group scope, that + /// policy applies to all resources in the group. + /// + /// + /// The scope of the policy assignment. Valid scopes are: management group + /// (format: + /// '/providers/Microsoft.Management/managementGroups/{managementGroup}'), + /// subscription (format: '/subscriptions/{subscriptionId}'), resource group + /// (format: + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or + /// resource (format: + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' + /// + /// + /// The name of the policy assignment. + /// + /// + /// Parameters for the policy assignment. + /// + /// + /// 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> CreateWithHttpMessagesAsync(string scope, string policyAssignmentName, PolicyAssignment parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (scope == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "scope"); + } + if (policyAssignmentName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "policyAssignmentName"); + } + if (parameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); + } + string apiVersion = "2021-06-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("scope", scope); + tracingParameters.Add("policyAssignmentName", policyAssignmentName); + tracingParameters.Add("parameters", parameters); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Create", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}").ToString(); + _url = _url.Replace("{scope}", scope); + _url = _url.Replace("{policyAssignmentName}", System.Uri.EscapeDataString(policyAssignmentName)); + 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 != 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 == 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; + } + + /// + /// Retrieves a policy assignment. + /// + /// + /// This operation retrieves a single policy assignment, given its name and the + /// scope it was created at. + /// + /// + /// The scope of the policy assignment. Valid scopes are: management group + /// (format: + /// '/providers/Microsoft.Management/managementGroups/{managementGroup}'), + /// subscription (format: '/subscriptions/{subscriptionId}'), resource group + /// (format: + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or + /// resource (format: + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' + /// + /// + /// The name of the policy assignment to get. + /// + /// + /// 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 scope, string policyAssignmentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (scope == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "scope"); + } + if (policyAssignmentName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "policyAssignmentName"); + } + string apiVersion = "2021-06-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("scope", scope); + tracingParameters.Add("policyAssignmentName", policyAssignmentName); + 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("/") ? "" : "/")), "{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}").ToString(); + _url = _url.Replace("{scope}", scope); + _url = _url.Replace("{policyAssignmentName}", System.Uri.EscapeDataString(policyAssignmentName)); + 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 policy assignment. + /// + /// + /// This operation updates a policy assignment with the given scope and name. + /// Policy assignments apply to all resources contained within their scope. For + /// example, when you assign a policy at resource group scope, that policy + /// applies to all resources in the group. + /// + /// + /// The scope of the policy assignment. Valid scopes are: management group + /// (format: + /// '/providers/Microsoft.Management/managementGroups/{managementGroup}'), + /// subscription (format: '/subscriptions/{subscriptionId}'), resource group + /// (format: + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or + /// resource (format: + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' + /// + /// + /// The name of the policy assignment. + /// + /// + /// Parameters for policy assignment patch request. + /// + /// + /// 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> UpdateWithHttpMessagesAsync(string scope, string policyAssignmentName, PolicyAssignmentUpdate parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (scope == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "scope"); + } + if (policyAssignmentName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "policyAssignmentName"); + } + if (parameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); + } + string apiVersion = "2021-06-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("scope", scope); + tracingParameters.Add("policyAssignmentName", policyAssignmentName); + tracingParameters.Add("parameters", parameters); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Update", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}").ToString(); + _url = _url.Replace("{scope}", scope); + _url = _url.Replace("{policyAssignmentName}", System.Uri.EscapeDataString(policyAssignmentName)); + 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; + } + + /// + /// Retrieves all policy assignments that apply to a resource group. + /// + /// + /// This operation retrieves the list of all policy assignments associated with + /// the given resource group in the given subscription that match the optional + /// given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' + /// or 'policyDefinitionId eq '{value}''. If $filter is not provided, the + /// unfiltered list includes all policy assignments associated with the + /// resource group, including those that apply directly or apply from + /// containing scopes, as well as any applied to resources contained within the + /// resource group. If $filter=atScope() is provided, the returned list + /// includes all policy assignments that apply to the resource group, which is + /// everything in the unfiltered list except those applied to resources + /// contained within the resource group. If $filter=atExactScope() is provided, + /// the returned list only includes all policy assignments that at the resource + /// group. If $filter=policyDefinitionId eq '{value}' is provided, the returned + /// list includes all policy assignments of the policy definition whose id is + /// {value} that apply to the resource group. + /// + /// + /// The name of the resource group that contains policy assignments. + /// + /// + /// The filter to apply on the operation. Valid values for $filter are: + /// 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If + /// $filter is not provided, no filtering is performed. If $filter=atScope() is + /// provided, the returned list only includes all policy assignments that apply + /// to the scope, which is everything in the unfiltered list except those + /// applied to sub scopes contained within the given scope. If + /// $filter=atExactScope() is provided, the returned list only includes all + /// policy assignments that at the given scope. If $filter=policyDefinitionId + /// eq '{value}' is provided, the returned list includes all policy assignments + /// of the policy definition whose id is {value}. + /// + /// + /// Maximum number of records to return. When the $top filter is not provided, + /// it will return 500 records. + /// + /// + /// 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>> ListForResourceGroupWithHttpMessagesAsync(string resourceGroupName, string filter = default(string), int? top = default(int?), 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 (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (top > 1000) + { + throw new ValidationException(ValidationRules.InclusiveMaximum, "top", 1000); + } + if (top < 1) + { + throw new ValidationException(ValidationRules.InclusiveMinimum, "top", 1); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + string apiVersion = "2021-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("filter", filter); + tracingParameters.Add("top", top); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListForResourceGroup", 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.Authorization/policyAssignments").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (filter != null) + { + _queryParameters.Add(string.Format("$filter={0}", filter)); + } + if (top != null) + { + _queryParameters.Add(string.Format("$top={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(top, Client.SerializationSettings).Trim('"')))); + } + 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; + } + + /// + /// Retrieves all policy assignments that apply to a resource. + /// + /// + /// This operation retrieves the list of all policy assignments associated with + /// the specified resource in the given resource group and subscription that + /// match the optional given $filter. Valid values for $filter are: + /// 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If + /// $filter is not provided, the unfiltered list includes all policy + /// assignments associated with the resource, including those that apply + /// directly or from all containing scopes, as well as any applied to resources + /// contained within the resource. If $filter=atScope() is provided, the + /// returned list includes all policy assignments that apply to the resource, + /// which is everything in the unfiltered list except those applied to + /// resources contained within the resource. If $filter=atExactScope() is + /// provided, the returned list only includes all policy assignments that at + /// the resource level. If $filter=policyDefinitionId eq '{value}' is provided, + /// the returned list includes all policy assignments of the policy definition + /// whose id is {value} that apply to the resource. Three parameters plus the + /// resource name are used to identify a specific resource. If the resource is + /// not part of a parent resource (the more common case), the parent resource + /// path should not be provided (or provided as ''). For example a web app + /// could be specified as ({resourceProviderNamespace} == 'Microsoft.Web', + /// {parentResourcePath} == '', {resourceType} == 'sites', {resourceName} == + /// 'MyWebApp'). If the resource is part of a parent resource, then all + /// parameters should be provided. For example a virtual machine DNS name could + /// be specified as ({resourceProviderNamespace} == 'Microsoft.Compute', + /// {parentResourcePath} == 'virtualMachines/MyVirtualMachine', {resourceType} + /// == 'domainNames', {resourceName} == 'MyComputerName'). A convenient + /// alternative to providing the namespace and type name separately is to + /// provide both in the {resourceType} parameter, format: + /// ({resourceProviderNamespace} == '', {parentResourcePath} == '', + /// {resourceType} == 'Microsoft.Web/sites', {resourceName} == 'MyWebApp'). + /// + /// + /// The name of the resource group containing the resource. + /// + /// + /// The namespace of the resource provider. For example, the namespace of a + /// virtual machine is Microsoft.Compute (from + /// Microsoft.Compute/virtualMachines) + /// + /// + /// The parent resource path. Use empty string if there is none. + /// + /// + /// The resource type name. For example the type name of a web app is 'sites' + /// (from Microsoft.Web/sites). + /// + /// + /// The name of the resource. + /// + /// + /// OData parameters to apply to the 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>> ListForResourceWithHttpMessagesAsync(string resourceGroupName, string resourceProviderNamespace, string parentResourcePath, string resourceType, string resourceName, ODataQuery odataQuery = default(ODataQuery), 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 (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (resourceProviderNamespace == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceProviderNamespace"); + } + if (parentResourcePath == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "parentResourcePath"); + } + if (resourceType == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceType"); + } + if (resourceName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceName"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + string apiVersion = "2021-06-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("odataQuery", odataQuery); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("resourceProviderNamespace", resourceProviderNamespace); + tracingParameters.Add("parentResourcePath", parentResourcePath); + tracingParameters.Add("resourceType", resourceType); + tracingParameters.Add("resourceName", resourceName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListForResource", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{resourceProviderNamespace}", System.Uri.EscapeDataString(resourceProviderNamespace)); + _url = _url.Replace("{parentResourcePath}", parentResourcePath); + _url = _url.Replace("{resourceType}", resourceType); + _url = _url.Replace("{resourceName}", System.Uri.EscapeDataString(resourceName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (odataQuery != null) + { + var _odataFilter = odataQuery.ToString(); + if (!string.IsNullOrEmpty(_odataFilter)) + { + _queryParameters.Add(_odataFilter); + } + } + 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; + } + + /// + /// Retrieves all policy assignments that apply to a management group. + /// + /// + /// This operation retrieves the list of all policy assignments applicable to + /// the management group that match the given $filter. Valid values for $filter + /// are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If + /// $filter=atScope() is provided, the returned list includes all policy + /// assignments that are assigned to the management group or the management + /// group's ancestors. If $filter=atExactScope() is provided, the returned list + /// only includes all policy assignments that at the management group. If + /// $filter=policyDefinitionId eq '{value}' is provided, the returned list + /// includes all policy assignments of the policy definition whose id is + /// {value} that apply to the management group. + /// + /// + /// The ID of the management group. + /// + /// + /// The filter to apply on the operation. Valid values for $filter are: + /// 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If + /// $filter is not provided, no filtering is performed. If $filter=atScope() is + /// provided, the returned list only includes all policy assignments that apply + /// to the scope, which is everything in the unfiltered list except those + /// applied to sub scopes contained within the given scope. If + /// $filter=atExactScope() is provided, the returned list only includes all + /// policy assignments that at the given scope. If $filter=policyDefinitionId + /// eq '{value}' is provided, the returned list includes all policy assignments + /// of the policy definition whose id is {value}. + /// + /// + /// Maximum number of records to return. When the $top filter is not provided, + /// it will return 500 records. + /// + /// + /// 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>> ListForManagementGroupWithHttpMessagesAsync(string managementGroupId, string filter = default(string), int? top = default(int?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (managementGroupId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "managementGroupId"); + } + if (top > 1000) + { + throw new ValidationException(ValidationRules.InclusiveMaximum, "top", 1000); + } + if (top < 1) + { + throw new ValidationException(ValidationRules.InclusiveMinimum, "top", 1); + } + string apiVersion = "2021-06-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("managementGroupId", managementGroupId); + tracingParameters.Add("filter", filter); + tracingParameters.Add("top", top); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListForManagementGroup", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyAssignments").ToString(); + _url = _url.Replace("{managementGroupId}", System.Uri.EscapeDataString(managementGroupId)); + List _queryParameters = new List(); + if (filter != null) + { + _queryParameters.Add(string.Format("$filter={0}", filter)); + } + if (top != null) + { + _queryParameters.Add(string.Format("$top={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(top, Client.SerializationSettings).Trim('"')))); + } + 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; + } + + /// + /// Retrieves all policy assignments that apply to a subscription. + /// + /// + /// This operation retrieves the list of all policy assignments associated with + /// the given subscription that match the optional given $filter. Valid values + /// for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq + /// '{value}''. If $filter is not provided, the unfiltered list includes all + /// policy assignments associated with the subscription, including those that + /// apply directly or from management groups that contain the given + /// subscription, as well as any applied to objects contained within the + /// subscription. If $filter=atScope() is provided, the returned list includes + /// all policy assignments that apply to the subscription, which is everything + /// in the unfiltered list except those applied to objects contained within the + /// subscription. If $filter=atExactScope() is provided, the returned list only + /// includes all policy assignments that at the subscription. If + /// $filter=policyDefinitionId eq '{value}' is provided, the returned list + /// includes all policy assignments of the policy definition whose id is + /// {value}. + /// + /// + /// OData parameters to apply to the 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>> ListWithHttpMessagesAsync(ODataQuery odataQuery = default(ODataQuery), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + string apiVersion = "2021-06-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("odataQuery", odataQuery); + 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.Authorization/policyAssignments").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (odataQuery != null) + { + var _odataFilter = odataQuery.ToString(); + if (!string.IsNullOrEmpty(_odataFilter)) + { + _queryParameters.Add(_odataFilter); + } + } + 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; + } + + /// + /// Deletes a policy assignment. + /// + /// + /// This operation deletes the policy with the given ID. Policy assignment IDs + /// have this format: + /// '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + /// Valid formats for {scope} are: + /// '/providers/Microsoft.Management/managementGroups/{managementGroup}' + /// (management group), '/subscriptions/{subscriptionId}' (subscription), + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' + /// (resource group), or + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' + /// (resource). + /// + /// + /// The ID of the policy assignment to delete. Use the format + /// '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + /// + /// + /// 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> DeleteByIdWithHttpMessagesAsync(string policyAssignmentId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (policyAssignmentId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "policyAssignmentId"); + } + string apiVersion = "2021-06-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("policyAssignmentId", policyAssignmentId); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "DeleteById", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{policyAssignmentId}").ToString(); + _url = _url.Replace("{policyAssignmentId}", policyAssignmentId); + 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 != 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(); + } + // 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 policy assignment. + /// + /// + /// This operation creates or updates the policy assignment with the given ID. + /// Policy assignments made on a scope apply to all resources contained in that + /// scope. For example, when you assign a policy to a resource group that + /// policy applies to all resources in the group. Policy assignment IDs have + /// this format: + /// '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + /// Valid scopes are: management group (format: + /// '/providers/Microsoft.Management/managementGroups/{managementGroup}'), + /// subscription (format: '/subscriptions/{subscriptionId}'), resource group + /// (format: + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or + /// resource (format: + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + /// + /// + /// The ID of the policy assignment to create. Use the format + /// '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + /// + /// + /// Parameters for policy assignment. + /// + /// + /// 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> CreateByIdWithHttpMessagesAsync(string policyAssignmentId, PolicyAssignment parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (policyAssignmentId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "policyAssignmentId"); + } + if (parameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); + } + string apiVersion = "2021-06-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("policyAssignmentId", policyAssignmentId); + tracingParameters.Add("parameters", parameters); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "CreateById", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{policyAssignmentId}").ToString(); + _url = _url.Replace("{policyAssignmentId}", policyAssignmentId); + 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 != 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 == 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; + } + + /// + /// Retrieves the policy assignment with the given ID. + /// + /// + /// The operation retrieves the policy assignment with the given ID. Policy + /// assignment IDs have this format: + /// '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + /// Valid scopes are: management group (format: + /// '/providers/Microsoft.Management/managementGroups/{managementGroup}'), + /// subscription (format: '/subscriptions/{subscriptionId}'), resource group + /// (format: + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or + /// resource (format: + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + /// + /// + /// The ID of the policy assignment to get. Use the format + /// '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + /// + /// + /// 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> GetByIdWithHttpMessagesAsync(string policyAssignmentId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (policyAssignmentId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "policyAssignmentId"); + } + string apiVersion = "2021-06-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("policyAssignmentId", policyAssignmentId); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetById", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{policyAssignmentId}").ToString(); + _url = _url.Replace("{policyAssignmentId}", policyAssignmentId); + 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 policy assignment. + /// + /// + /// This operation updates the policy assignment with the given ID. Policy + /// assignments made on a scope apply to all resources contained in that scope. + /// For example, when you assign a policy to a resource group that policy + /// applies to all resources in the group. Policy assignment IDs have this + /// format: + /// '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + /// Valid scopes are: management group (format: + /// '/providers/Microsoft.Management/managementGroups/{managementGroup}'), + /// subscription (format: '/subscriptions/{subscriptionId}'), resource group + /// (format: + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or + /// resource (format: + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + /// + /// + /// The ID of the policy assignment to update. Use the format + /// '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + /// + /// + /// Parameters for policy assignment patch request. + /// + /// + /// 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> UpdateByIdWithHttpMessagesAsync(string policyAssignmentId, PolicyAssignmentUpdate parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (policyAssignmentId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "policyAssignmentId"); + } + if (parameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); + } + string apiVersion = "2021-06-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("policyAssignmentId", policyAssignmentId); + tracingParameters.Add("parameters", parameters); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "UpdateById", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{policyAssignmentId}").ToString(); + _url = _url.Replace("{policyAssignmentId}", policyAssignmentId); + 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; + } + + /// + /// Retrieves all policy assignments that apply to a resource group. + /// + /// + /// This operation retrieves the list of all policy assignments associated with + /// the given resource group in the given subscription that match the optional + /// given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' + /// or 'policyDefinitionId eq '{value}''. If $filter is not provided, the + /// unfiltered list includes all policy assignments associated with the + /// resource group, including those that apply directly or apply from + /// containing scopes, as well as any applied to resources contained within the + /// resource group. If $filter=atScope() is provided, the returned list + /// includes all policy assignments that apply to the resource group, which is + /// everything in the unfiltered list except those applied to resources + /// contained within the resource group. If $filter=atExactScope() is provided, + /// the returned list only includes all policy assignments that at the resource + /// group. If $filter=policyDefinitionId eq '{value}' is provided, the returned + /// list includes all policy assignments of the policy definition whose id is + /// {value} that apply to the 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>> ListForResourceGroupNextWithHttpMessagesAsync(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, "ListForResourceGroupNext", 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; + } + + /// + /// Retrieves all policy assignments that apply to a resource. + /// + /// + /// This operation retrieves the list of all policy assignments associated with + /// the specified resource in the given resource group and subscription that + /// match the optional given $filter. Valid values for $filter are: + /// 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If + /// $filter is not provided, the unfiltered list includes all policy + /// assignments associated with the resource, including those that apply + /// directly or from all containing scopes, as well as any applied to resources + /// contained within the resource. If $filter=atScope() is provided, the + /// returned list includes all policy assignments that apply to the resource, + /// which is everything in the unfiltered list except those applied to + /// resources contained within the resource. If $filter=atExactScope() is + /// provided, the returned list only includes all policy assignments that at + /// the resource level. If $filter=policyDefinitionId eq '{value}' is provided, + /// the returned list includes all policy assignments of the policy definition + /// whose id is {value} that apply to the resource. Three parameters plus the + /// resource name are used to identify a specific resource. If the resource is + /// not part of a parent resource (the more common case), the parent resource + /// path should not be provided (or provided as ''). For example a web app + /// could be specified as ({resourceProviderNamespace} == 'Microsoft.Web', + /// {parentResourcePath} == '', {resourceType} == 'sites', {resourceName} == + /// 'MyWebApp'). If the resource is part of a parent resource, then all + /// parameters should be provided. For example a virtual machine DNS name could + /// be specified as ({resourceProviderNamespace} == 'Microsoft.Compute', + /// {parentResourcePath} == 'virtualMachines/MyVirtualMachine', {resourceType} + /// == 'domainNames', {resourceName} == 'MyComputerName'). A convenient + /// alternative to providing the namespace and type name separately is to + /// provide both in the {resourceType} parameter, format: + /// ({resourceProviderNamespace} == '', {parentResourcePath} == '', + /// {resourceType} == 'Microsoft.Web/sites', {resourceName} == 'MyWebApp'). + /// + /// + /// 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>> ListForResourceNextWithHttpMessagesAsync(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, "ListForResourceNext", 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; + } + + /// + /// Retrieves all policy assignments that apply to a management group. + /// + /// + /// This operation retrieves the list of all policy assignments applicable to + /// the management group that match the given $filter. Valid values for $filter + /// are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If + /// $filter=atScope() is provided, the returned list includes all policy + /// assignments that are assigned to the management group or the management + /// group's ancestors. If $filter=atExactScope() is provided, the returned list + /// only includes all policy assignments that at the management group. If + /// $filter=policyDefinitionId eq '{value}' is provided, the returned list + /// includes all policy assignments of the policy definition whose id is + /// {value} that apply to the management 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>> ListForManagementGroupNextWithHttpMessagesAsync(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, "ListForManagementGroupNext", 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; + } + + /// + /// Retrieves all policy assignments that apply to a subscription. + /// + /// + /// This operation retrieves the list of all policy assignments associated with + /// the given subscription that match the optional given $filter. Valid values + /// for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq + /// '{value}''. If $filter is not provided, the unfiltered list includes all + /// policy assignments associated with the subscription, including those that + /// apply directly or from management groups that contain the given + /// subscription, as well as any applied to objects contained within the + /// subscription. If $filter=atScope() is provided, the returned list includes + /// all policy assignments that apply to the subscription, which is everything + /// in the unfiltered list except those applied to objects contained within the + /// subscription. If $filter=atExactScope() is provided, the returned list only + /// includes all policy assignments that at the subscription. If + /// $filter=policyDefinitionId eq '{value}' is provided, the returned list + /// includes all policy assignments of the policy definition whose id is + /// {value}. + /// + /// + /// 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 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/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/PolicyAssignmentsOperationsExtensions.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/PolicyAssignmentsOperationsExtensions.cs new file mode 100644 index 0000000000000..d2b95b081d10e --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/PolicyAssignmentsOperationsExtensions.cs @@ -0,0 +1,1242 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Microsoft.Rest.Azure.OData; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for PolicyAssignmentsOperations. + /// + public static partial class PolicyAssignmentsOperationsExtensions + { + /// + /// Deletes a policy assignment. + /// + /// + /// This operation deletes a policy assignment, given its name and the scope it + /// was created in. The scope of a policy assignment is the part of its ID + /// preceding + /// '/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope of the policy assignment. Valid scopes are: management group + /// (format: + /// '/providers/Microsoft.Management/managementGroups/{managementGroup}'), + /// subscription (format: '/subscriptions/{subscriptionId}'), resource group + /// (format: + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or + /// resource (format: + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' + /// + /// + /// The name of the policy assignment to delete. + /// + public static PolicyAssignment Delete(this IPolicyAssignmentsOperations operations, string scope, string policyAssignmentName) + { + return operations.DeleteAsync(scope, policyAssignmentName).GetAwaiter().GetResult(); + } + + /// + /// Deletes a policy assignment. + /// + /// + /// This operation deletes a policy assignment, given its name and the scope it + /// was created in. The scope of a policy assignment is the part of its ID + /// preceding + /// '/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope of the policy assignment. Valid scopes are: management group + /// (format: + /// '/providers/Microsoft.Management/managementGroups/{managementGroup}'), + /// subscription (format: '/subscriptions/{subscriptionId}'), resource group + /// (format: + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or + /// resource (format: + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' + /// + /// + /// The name of the policy assignment to delete. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this IPolicyAssignmentsOperations operations, string scope, string policyAssignmentName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.DeleteWithHttpMessagesAsync(scope, policyAssignmentName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Creates or updates a policy assignment. + /// + /// + /// This operation creates or updates a policy assignment with the given scope + /// and name. Policy assignments apply to all resources contained within their + /// scope. For example, when you assign a policy at resource group scope, that + /// policy applies to all resources in the group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope of the policy assignment. Valid scopes are: management group + /// (format: + /// '/providers/Microsoft.Management/managementGroups/{managementGroup}'), + /// subscription (format: '/subscriptions/{subscriptionId}'), resource group + /// (format: + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or + /// resource (format: + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' + /// + /// + /// The name of the policy assignment. + /// + /// + /// Parameters for the policy assignment. + /// + public static PolicyAssignment Create(this IPolicyAssignmentsOperations operations, string scope, string policyAssignmentName, PolicyAssignment parameters) + { + return operations.CreateAsync(scope, policyAssignmentName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Creates or updates a policy assignment. + /// + /// + /// This operation creates or updates a policy assignment with the given scope + /// and name. Policy assignments apply to all resources contained within their + /// scope. For example, when you assign a policy at resource group scope, that + /// policy applies to all resources in the group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope of the policy assignment. Valid scopes are: management group + /// (format: + /// '/providers/Microsoft.Management/managementGroups/{managementGroup}'), + /// subscription (format: '/subscriptions/{subscriptionId}'), resource group + /// (format: + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or + /// resource (format: + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' + /// + /// + /// The name of the policy assignment. + /// + /// + /// Parameters for the policy assignment. + /// + /// + /// The cancellation token. + /// + public static async Task CreateAsync(this IPolicyAssignmentsOperations operations, string scope, string policyAssignmentName, PolicyAssignment parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateWithHttpMessagesAsync(scope, policyAssignmentName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Retrieves a policy assignment. + /// + /// + /// This operation retrieves a single policy assignment, given its name and the + /// scope it was created at. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope of the policy assignment. Valid scopes are: management group + /// (format: + /// '/providers/Microsoft.Management/managementGroups/{managementGroup}'), + /// subscription (format: '/subscriptions/{subscriptionId}'), resource group + /// (format: + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or + /// resource (format: + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' + /// + /// + /// The name of the policy assignment to get. + /// + public static PolicyAssignment Get(this IPolicyAssignmentsOperations operations, string scope, string policyAssignmentName) + { + return operations.GetAsync(scope, policyAssignmentName).GetAwaiter().GetResult(); + } + + /// + /// Retrieves a policy assignment. + /// + /// + /// This operation retrieves a single policy assignment, given its name and the + /// scope it was created at. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope of the policy assignment. Valid scopes are: management group + /// (format: + /// '/providers/Microsoft.Management/managementGroups/{managementGroup}'), + /// subscription (format: '/subscriptions/{subscriptionId}'), resource group + /// (format: + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or + /// resource (format: + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' + /// + /// + /// The name of the policy assignment to get. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IPolicyAssignmentsOperations operations, string scope, string policyAssignmentName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(scope, policyAssignmentName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Updates a policy assignment. + /// + /// + /// This operation updates a policy assignment with the given scope and name. + /// Policy assignments apply to all resources contained within their scope. For + /// example, when you assign a policy at resource group scope, that policy + /// applies to all resources in the group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope of the policy assignment. Valid scopes are: management group + /// (format: + /// '/providers/Microsoft.Management/managementGroups/{managementGroup}'), + /// subscription (format: '/subscriptions/{subscriptionId}'), resource group + /// (format: + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or + /// resource (format: + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' + /// + /// + /// The name of the policy assignment. + /// + /// + /// Parameters for policy assignment patch request. + /// + public static PolicyAssignment Update(this IPolicyAssignmentsOperations operations, string scope, string policyAssignmentName, PolicyAssignmentUpdate parameters) + { + return operations.UpdateAsync(scope, policyAssignmentName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Updates a policy assignment. + /// + /// + /// This operation updates a policy assignment with the given scope and name. + /// Policy assignments apply to all resources contained within their scope. For + /// example, when you assign a policy at resource group scope, that policy + /// applies to all resources in the group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope of the policy assignment. Valid scopes are: management group + /// (format: + /// '/providers/Microsoft.Management/managementGroups/{managementGroup}'), + /// subscription (format: '/subscriptions/{subscriptionId}'), resource group + /// (format: + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or + /// resource (format: + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' + /// + /// + /// The name of the policy assignment. + /// + /// + /// Parameters for policy assignment patch request. + /// + /// + /// The cancellation token. + /// + public static async Task UpdateAsync(this IPolicyAssignmentsOperations operations, string scope, string policyAssignmentName, PolicyAssignmentUpdate parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.UpdateWithHttpMessagesAsync(scope, policyAssignmentName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Retrieves all policy assignments that apply to a resource group. + /// + /// + /// This operation retrieves the list of all policy assignments associated with + /// the given resource group in the given subscription that match the optional + /// given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' + /// or 'policyDefinitionId eq '{value}''. If $filter is not provided, the + /// unfiltered list includes all policy assignments associated with the + /// resource group, including those that apply directly or apply from + /// containing scopes, as well as any applied to resources contained within the + /// resource group. If $filter=atScope() is provided, the returned list + /// includes all policy assignments that apply to the resource group, which is + /// everything in the unfiltered list except those applied to resources + /// contained within the resource group. If $filter=atExactScope() is provided, + /// the returned list only includes all policy assignments that at the resource + /// group. If $filter=policyDefinitionId eq '{value}' is provided, the returned + /// list includes all policy assignments of the policy definition whose id is + /// {value} that apply to the resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group that contains policy assignments. + /// + /// + /// The filter to apply on the operation. Valid values for $filter are: + /// 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If + /// $filter is not provided, no filtering is performed. If $filter=atScope() is + /// provided, the returned list only includes all policy assignments that apply + /// to the scope, which is everything in the unfiltered list except those + /// applied to sub scopes contained within the given scope. If + /// $filter=atExactScope() is provided, the returned list only includes all + /// policy assignments that at the given scope. If $filter=policyDefinitionId + /// eq '{value}' is provided, the returned list includes all policy assignments + /// of the policy definition whose id is {value}. + /// + /// + /// Maximum number of records to return. When the $top filter is not provided, + /// it will return 500 records. + /// + public static IPage ListForResourceGroup(this IPolicyAssignmentsOperations operations, string resourceGroupName, string filter = default(string), int? top = default(int?)) + { + return operations.ListForResourceGroupAsync(resourceGroupName, filter, top).GetAwaiter().GetResult(); + } + + /// + /// Retrieves all policy assignments that apply to a resource group. + /// + /// + /// This operation retrieves the list of all policy assignments associated with + /// the given resource group in the given subscription that match the optional + /// given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' + /// or 'policyDefinitionId eq '{value}''. If $filter is not provided, the + /// unfiltered list includes all policy assignments associated with the + /// resource group, including those that apply directly or apply from + /// containing scopes, as well as any applied to resources contained within the + /// resource group. If $filter=atScope() is provided, the returned list + /// includes all policy assignments that apply to the resource group, which is + /// everything in the unfiltered list except those applied to resources + /// contained within the resource group. If $filter=atExactScope() is provided, + /// the returned list only includes all policy assignments that at the resource + /// group. If $filter=policyDefinitionId eq '{value}' is provided, the returned + /// list includes all policy assignments of the policy definition whose id is + /// {value} that apply to the resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group that contains policy assignments. + /// + /// + /// The filter to apply on the operation. Valid values for $filter are: + /// 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If + /// $filter is not provided, no filtering is performed. If $filter=atScope() is + /// provided, the returned list only includes all policy assignments that apply + /// to the scope, which is everything in the unfiltered list except those + /// applied to sub scopes contained within the given scope. If + /// $filter=atExactScope() is provided, the returned list only includes all + /// policy assignments that at the given scope. If $filter=policyDefinitionId + /// eq '{value}' is provided, the returned list includes all policy assignments + /// of the policy definition whose id is {value}. + /// + /// + /// Maximum number of records to return. When the $top filter is not provided, + /// it will return 500 records. + /// + /// + /// The cancellation token. + /// + public static async Task> ListForResourceGroupAsync(this IPolicyAssignmentsOperations operations, string resourceGroupName, string filter = default(string), int? top = default(int?), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListForResourceGroupWithHttpMessagesAsync(resourceGroupName, filter, top, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Retrieves all policy assignments that apply to a resource. + /// + /// + /// This operation retrieves the list of all policy assignments associated with + /// the specified resource in the given resource group and subscription that + /// match the optional given $filter. Valid values for $filter are: + /// 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If + /// $filter is not provided, the unfiltered list includes all policy + /// assignments associated with the resource, including those that apply + /// directly or from all containing scopes, as well as any applied to resources + /// contained within the resource. If $filter=atScope() is provided, the + /// returned list includes all policy assignments that apply to the resource, + /// which is everything in the unfiltered list except those applied to + /// resources contained within the resource. If $filter=atExactScope() is + /// provided, the returned list only includes all policy assignments that at + /// the resource level. If $filter=policyDefinitionId eq '{value}' is provided, + /// the returned list includes all policy assignments of the policy definition + /// whose id is {value} that apply to the resource. Three parameters plus the + /// resource name are used to identify a specific resource. If the resource is + /// not part of a parent resource (the more common case), the parent resource + /// path should not be provided (or provided as ''). For example a web app + /// could be specified as ({resourceProviderNamespace} == 'Microsoft.Web', + /// {parentResourcePath} == '', {resourceType} == 'sites', {resourceName} == + /// 'MyWebApp'). If the resource is part of a parent resource, then all + /// parameters should be provided. For example a virtual machine DNS name could + /// be specified as ({resourceProviderNamespace} == 'Microsoft.Compute', + /// {parentResourcePath} == 'virtualMachines/MyVirtualMachine', {resourceType} + /// == 'domainNames', {resourceName} == 'MyComputerName'). A convenient + /// alternative to providing the namespace and type name separately is to + /// provide both in the {resourceType} parameter, format: + /// ({resourceProviderNamespace} == '', {parentResourcePath} == '', + /// {resourceType} == 'Microsoft.Web/sites', {resourceName} == 'MyWebApp'). + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group containing the resource. + /// + /// + /// The namespace of the resource provider. For example, the namespace of a + /// virtual machine is Microsoft.Compute (from + /// Microsoft.Compute/virtualMachines) + /// + /// + /// The parent resource path. Use empty string if there is none. + /// + /// + /// The resource type name. For example the type name of a web app is 'sites' + /// (from Microsoft.Web/sites). + /// + /// + /// The name of the resource. + /// + /// + /// OData parameters to apply to the operation. + /// + public static IPage ListForResource(this IPolicyAssignmentsOperations operations, string resourceGroupName, string resourceProviderNamespace, string parentResourcePath, string resourceType, string resourceName, ODataQuery odataQuery = default(ODataQuery)) + { + return operations.ListForResourceAsync(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, odataQuery).GetAwaiter().GetResult(); + } + + /// + /// Retrieves all policy assignments that apply to a resource. + /// + /// + /// This operation retrieves the list of all policy assignments associated with + /// the specified resource in the given resource group and subscription that + /// match the optional given $filter. Valid values for $filter are: + /// 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If + /// $filter is not provided, the unfiltered list includes all policy + /// assignments associated with the resource, including those that apply + /// directly or from all containing scopes, as well as any applied to resources + /// contained within the resource. If $filter=atScope() is provided, the + /// returned list includes all policy assignments that apply to the resource, + /// which is everything in the unfiltered list except those applied to + /// resources contained within the resource. If $filter=atExactScope() is + /// provided, the returned list only includes all policy assignments that at + /// the resource level. If $filter=policyDefinitionId eq '{value}' is provided, + /// the returned list includes all policy assignments of the policy definition + /// whose id is {value} that apply to the resource. Three parameters plus the + /// resource name are used to identify a specific resource. If the resource is + /// not part of a parent resource (the more common case), the parent resource + /// path should not be provided (or provided as ''). For example a web app + /// could be specified as ({resourceProviderNamespace} == 'Microsoft.Web', + /// {parentResourcePath} == '', {resourceType} == 'sites', {resourceName} == + /// 'MyWebApp'). If the resource is part of a parent resource, then all + /// parameters should be provided. For example a virtual machine DNS name could + /// be specified as ({resourceProviderNamespace} == 'Microsoft.Compute', + /// {parentResourcePath} == 'virtualMachines/MyVirtualMachine', {resourceType} + /// == 'domainNames', {resourceName} == 'MyComputerName'). A convenient + /// alternative to providing the namespace and type name separately is to + /// provide both in the {resourceType} parameter, format: + /// ({resourceProviderNamespace} == '', {parentResourcePath} == '', + /// {resourceType} == 'Microsoft.Web/sites', {resourceName} == 'MyWebApp'). + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group containing the resource. + /// + /// + /// The namespace of the resource provider. For example, the namespace of a + /// virtual machine is Microsoft.Compute (from + /// Microsoft.Compute/virtualMachines) + /// + /// + /// The parent resource path. Use empty string if there is none. + /// + /// + /// The resource type name. For example the type name of a web app is 'sites' + /// (from Microsoft.Web/sites). + /// + /// + /// The name of the resource. + /// + /// + /// OData parameters to apply to the operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListForResourceAsync(this IPolicyAssignmentsOperations operations, string resourceGroupName, string resourceProviderNamespace, string parentResourcePath, string resourceType, string resourceName, ODataQuery odataQuery = default(ODataQuery), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListForResourceWithHttpMessagesAsync(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, odataQuery, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Retrieves all policy assignments that apply to a management group. + /// + /// + /// This operation retrieves the list of all policy assignments applicable to + /// the management group that match the given $filter. Valid values for $filter + /// are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If + /// $filter=atScope() is provided, the returned list includes all policy + /// assignments that are assigned to the management group or the management + /// group's ancestors. If $filter=atExactScope() is provided, the returned list + /// only includes all policy assignments that at the management group. If + /// $filter=policyDefinitionId eq '{value}' is provided, the returned list + /// includes all policy assignments of the policy definition whose id is + /// {value} that apply to the management group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The ID of the management group. + /// + /// + /// The filter to apply on the operation. Valid values for $filter are: + /// 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If + /// $filter is not provided, no filtering is performed. If $filter=atScope() is + /// provided, the returned list only includes all policy assignments that apply + /// to the scope, which is everything in the unfiltered list except those + /// applied to sub scopes contained within the given scope. If + /// $filter=atExactScope() is provided, the returned list only includes all + /// policy assignments that at the given scope. If $filter=policyDefinitionId + /// eq '{value}' is provided, the returned list includes all policy assignments + /// of the policy definition whose id is {value}. + /// + /// + /// Maximum number of records to return. When the $top filter is not provided, + /// it will return 500 records. + /// + public static IPage ListForManagementGroup(this IPolicyAssignmentsOperations operations, string managementGroupId, string filter = default(string), int? top = default(int?)) + { + return operations.ListForManagementGroupAsync(managementGroupId, filter, top).GetAwaiter().GetResult(); + } + + /// + /// Retrieves all policy assignments that apply to a management group. + /// + /// + /// This operation retrieves the list of all policy assignments applicable to + /// the management group that match the given $filter. Valid values for $filter + /// are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If + /// $filter=atScope() is provided, the returned list includes all policy + /// assignments that are assigned to the management group or the management + /// group's ancestors. If $filter=atExactScope() is provided, the returned list + /// only includes all policy assignments that at the management group. If + /// $filter=policyDefinitionId eq '{value}' is provided, the returned list + /// includes all policy assignments of the policy definition whose id is + /// {value} that apply to the management group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The ID of the management group. + /// + /// + /// The filter to apply on the operation. Valid values for $filter are: + /// 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If + /// $filter is not provided, no filtering is performed. If $filter=atScope() is + /// provided, the returned list only includes all policy assignments that apply + /// to the scope, which is everything in the unfiltered list except those + /// applied to sub scopes contained within the given scope. If + /// $filter=atExactScope() is provided, the returned list only includes all + /// policy assignments that at the given scope. If $filter=policyDefinitionId + /// eq '{value}' is provided, the returned list includes all policy assignments + /// of the policy definition whose id is {value}. + /// + /// + /// Maximum number of records to return. When the $top filter is not provided, + /// it will return 500 records. + /// + /// + /// The cancellation token. + /// + public static async Task> ListForManagementGroupAsync(this IPolicyAssignmentsOperations operations, string managementGroupId, string filter = default(string), int? top = default(int?), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListForManagementGroupWithHttpMessagesAsync(managementGroupId, filter, top, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Retrieves all policy assignments that apply to a subscription. + /// + /// + /// This operation retrieves the list of all policy assignments associated with + /// the given subscription that match the optional given $filter. Valid values + /// for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq + /// '{value}''. If $filter is not provided, the unfiltered list includes all + /// policy assignments associated with the subscription, including those that + /// apply directly or from management groups that contain the given + /// subscription, as well as any applied to objects contained within the + /// subscription. If $filter=atScope() is provided, the returned list includes + /// all policy assignments that apply to the subscription, which is everything + /// in the unfiltered list except those applied to objects contained within the + /// subscription. If $filter=atExactScope() is provided, the returned list only + /// includes all policy assignments that at the subscription. If + /// $filter=policyDefinitionId eq '{value}' is provided, the returned list + /// includes all policy assignments of the policy definition whose id is + /// {value}. + /// + /// + /// The operations group for this extension method. + /// + /// + /// OData parameters to apply to the operation. + /// + public static IPage List(this IPolicyAssignmentsOperations operations, ODataQuery odataQuery = default(ODataQuery)) + { + return operations.ListAsync(odataQuery).GetAwaiter().GetResult(); + } + + /// + /// Retrieves all policy assignments that apply to a subscription. + /// + /// + /// This operation retrieves the list of all policy assignments associated with + /// the given subscription that match the optional given $filter. Valid values + /// for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq + /// '{value}''. If $filter is not provided, the unfiltered list includes all + /// policy assignments associated with the subscription, including those that + /// apply directly or from management groups that contain the given + /// subscription, as well as any applied to objects contained within the + /// subscription. If $filter=atScope() is provided, the returned list includes + /// all policy assignments that apply to the subscription, which is everything + /// in the unfiltered list except those applied to objects contained within the + /// subscription. If $filter=atExactScope() is provided, the returned list only + /// includes all policy assignments that at the subscription. If + /// $filter=policyDefinitionId eq '{value}' is provided, the returned list + /// includes all policy assignments of the policy definition whose id is + /// {value}. + /// + /// + /// The operations group for this extension method. + /// + /// + /// OData parameters to apply to the operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAsync(this IPolicyAssignmentsOperations operations, ODataQuery odataQuery = default(ODataQuery), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(odataQuery, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes a policy assignment. + /// + /// + /// This operation deletes the policy with the given ID. Policy assignment IDs + /// have this format: + /// '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + /// Valid formats for {scope} are: + /// '/providers/Microsoft.Management/managementGroups/{managementGroup}' + /// (management group), '/subscriptions/{subscriptionId}' (subscription), + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' + /// (resource group), or + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' + /// (resource). + /// + /// + /// The operations group for this extension method. + /// + /// + /// The ID of the policy assignment to delete. Use the format + /// '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + /// + public static PolicyAssignment DeleteById(this IPolicyAssignmentsOperations operations, string policyAssignmentId) + { + return operations.DeleteByIdAsync(policyAssignmentId).GetAwaiter().GetResult(); + } + + /// + /// Deletes a policy assignment. + /// + /// + /// This operation deletes the policy with the given ID. Policy assignment IDs + /// have this format: + /// '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + /// Valid formats for {scope} are: + /// '/providers/Microsoft.Management/managementGroups/{managementGroup}' + /// (management group), '/subscriptions/{subscriptionId}' (subscription), + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' + /// (resource group), or + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' + /// (resource). + /// + /// + /// The operations group for this extension method. + /// + /// + /// The ID of the policy assignment to delete. Use the format + /// '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteByIdAsync(this IPolicyAssignmentsOperations operations, string policyAssignmentId, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.DeleteByIdWithHttpMessagesAsync(policyAssignmentId, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Creates or updates a policy assignment. + /// + /// + /// This operation creates or updates the policy assignment with the given ID. + /// Policy assignments made on a scope apply to all resources contained in that + /// scope. For example, when you assign a policy to a resource group that + /// policy applies to all resources in the group. Policy assignment IDs have + /// this format: + /// '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + /// Valid scopes are: management group (format: + /// '/providers/Microsoft.Management/managementGroups/{managementGroup}'), + /// subscription (format: '/subscriptions/{subscriptionId}'), resource group + /// (format: + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or + /// resource (format: + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The ID of the policy assignment to create. Use the format + /// '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + /// + /// + /// Parameters for policy assignment. + /// + public static PolicyAssignment CreateById(this IPolicyAssignmentsOperations operations, string policyAssignmentId, PolicyAssignment parameters) + { + return operations.CreateByIdAsync(policyAssignmentId, parameters).GetAwaiter().GetResult(); + } + + /// + /// Creates or updates a policy assignment. + /// + /// + /// This operation creates or updates the policy assignment with the given ID. + /// Policy assignments made on a scope apply to all resources contained in that + /// scope. For example, when you assign a policy to a resource group that + /// policy applies to all resources in the group. Policy assignment IDs have + /// this format: + /// '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + /// Valid scopes are: management group (format: + /// '/providers/Microsoft.Management/managementGroups/{managementGroup}'), + /// subscription (format: '/subscriptions/{subscriptionId}'), resource group + /// (format: + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or + /// resource (format: + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The ID of the policy assignment to create. Use the format + /// '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + /// + /// + /// Parameters for policy assignment. + /// + /// + /// The cancellation token. + /// + public static async Task CreateByIdAsync(this IPolicyAssignmentsOperations operations, string policyAssignmentId, PolicyAssignment parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateByIdWithHttpMessagesAsync(policyAssignmentId, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Retrieves the policy assignment with the given ID. + /// + /// + /// The operation retrieves the policy assignment with the given ID. Policy + /// assignment IDs have this format: + /// '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + /// Valid scopes are: management group (format: + /// '/providers/Microsoft.Management/managementGroups/{managementGroup}'), + /// subscription (format: '/subscriptions/{subscriptionId}'), resource group + /// (format: + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or + /// resource (format: + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The ID of the policy assignment to get. Use the format + /// '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + /// + public static PolicyAssignment GetById(this IPolicyAssignmentsOperations operations, string policyAssignmentId) + { + return operations.GetByIdAsync(policyAssignmentId).GetAwaiter().GetResult(); + } + + /// + /// Retrieves the policy assignment with the given ID. + /// + /// + /// The operation retrieves the policy assignment with the given ID. Policy + /// assignment IDs have this format: + /// '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + /// Valid scopes are: management group (format: + /// '/providers/Microsoft.Management/managementGroups/{managementGroup}'), + /// subscription (format: '/subscriptions/{subscriptionId}'), resource group + /// (format: + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or + /// resource (format: + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The ID of the policy assignment to get. Use the format + /// '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + /// + /// + /// The cancellation token. + /// + public static async Task GetByIdAsync(this IPolicyAssignmentsOperations operations, string policyAssignmentId, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetByIdWithHttpMessagesAsync(policyAssignmentId, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Updates a policy assignment. + /// + /// + /// This operation updates the policy assignment with the given ID. Policy + /// assignments made on a scope apply to all resources contained in that scope. + /// For example, when you assign a policy to a resource group that policy + /// applies to all resources in the group. Policy assignment IDs have this + /// format: + /// '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + /// Valid scopes are: management group (format: + /// '/providers/Microsoft.Management/managementGroups/{managementGroup}'), + /// subscription (format: '/subscriptions/{subscriptionId}'), resource group + /// (format: + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or + /// resource (format: + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The ID of the policy assignment to update. Use the format + /// '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + /// + /// + /// Parameters for policy assignment patch request. + /// + public static PolicyAssignment UpdateById(this IPolicyAssignmentsOperations operations, string policyAssignmentId, PolicyAssignmentUpdate parameters) + { + return operations.UpdateByIdAsync(policyAssignmentId, parameters).GetAwaiter().GetResult(); + } + + /// + /// Updates a policy assignment. + /// + /// + /// This operation updates the policy assignment with the given ID. Policy + /// assignments made on a scope apply to all resources contained in that scope. + /// For example, when you assign a policy to a resource group that policy + /// applies to all resources in the group. Policy assignment IDs have this + /// format: + /// '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + /// Valid scopes are: management group (format: + /// '/providers/Microsoft.Management/managementGroups/{managementGroup}'), + /// subscription (format: '/subscriptions/{subscriptionId}'), resource group + /// (format: + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or + /// resource (format: + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The ID of the policy assignment to update. Use the format + /// '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + /// + /// + /// Parameters for policy assignment patch request. + /// + /// + /// The cancellation token. + /// + public static async Task UpdateByIdAsync(this IPolicyAssignmentsOperations operations, string policyAssignmentId, PolicyAssignmentUpdate parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.UpdateByIdWithHttpMessagesAsync(policyAssignmentId, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Retrieves all policy assignments that apply to a resource group. + /// + /// + /// This operation retrieves the list of all policy assignments associated with + /// the given resource group in the given subscription that match the optional + /// given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' + /// or 'policyDefinitionId eq '{value}''. If $filter is not provided, the + /// unfiltered list includes all policy assignments associated with the + /// resource group, including those that apply directly or apply from + /// containing scopes, as well as any applied to resources contained within the + /// resource group. If $filter=atScope() is provided, the returned list + /// includes all policy assignments that apply to the resource group, which is + /// everything in the unfiltered list except those applied to resources + /// contained within the resource group. If $filter=atExactScope() is provided, + /// the returned list only includes all policy assignments that at the resource + /// group. If $filter=policyDefinitionId eq '{value}' is provided, the returned + /// list includes all policy assignments of the policy definition whose id is + /// {value} that apply to the resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListForResourceGroupNext(this IPolicyAssignmentsOperations operations, string nextPageLink) + { + return operations.ListForResourceGroupNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Retrieves all policy assignments that apply to a resource group. + /// + /// + /// This operation retrieves the list of all policy assignments associated with + /// the given resource group in the given subscription that match the optional + /// given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' + /// or 'policyDefinitionId eq '{value}''. If $filter is not provided, the + /// unfiltered list includes all policy assignments associated with the + /// resource group, including those that apply directly or apply from + /// containing scopes, as well as any applied to resources contained within the + /// resource group. If $filter=atScope() is provided, the returned list + /// includes all policy assignments that apply to the resource group, which is + /// everything in the unfiltered list except those applied to resources + /// contained within the resource group. If $filter=atExactScope() is provided, + /// the returned list only includes all policy assignments that at the resource + /// group. If $filter=policyDefinitionId eq '{value}' is provided, the returned + /// list includes all policy assignments of the policy definition whose id is + /// {value} that apply to the 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> ListForResourceGroupNextAsync(this IPolicyAssignmentsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListForResourceGroupNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Retrieves all policy assignments that apply to a resource. + /// + /// + /// This operation retrieves the list of all policy assignments associated with + /// the specified resource in the given resource group and subscription that + /// match the optional given $filter. Valid values for $filter are: + /// 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If + /// $filter is not provided, the unfiltered list includes all policy + /// assignments associated with the resource, including those that apply + /// directly or from all containing scopes, as well as any applied to resources + /// contained within the resource. If $filter=atScope() is provided, the + /// returned list includes all policy assignments that apply to the resource, + /// which is everything in the unfiltered list except those applied to + /// resources contained within the resource. If $filter=atExactScope() is + /// provided, the returned list only includes all policy assignments that at + /// the resource level. If $filter=policyDefinitionId eq '{value}' is provided, + /// the returned list includes all policy assignments of the policy definition + /// whose id is {value} that apply to the resource. Three parameters plus the + /// resource name are used to identify a specific resource. If the resource is + /// not part of a parent resource (the more common case), the parent resource + /// path should not be provided (or provided as ''). For example a web app + /// could be specified as ({resourceProviderNamespace} == 'Microsoft.Web', + /// {parentResourcePath} == '', {resourceType} == 'sites', {resourceName} == + /// 'MyWebApp'). If the resource is part of a parent resource, then all + /// parameters should be provided. For example a virtual machine DNS name could + /// be specified as ({resourceProviderNamespace} == 'Microsoft.Compute', + /// {parentResourcePath} == 'virtualMachines/MyVirtualMachine', {resourceType} + /// == 'domainNames', {resourceName} == 'MyComputerName'). A convenient + /// alternative to providing the namespace and type name separately is to + /// provide both in the {resourceType} parameter, format: + /// ({resourceProviderNamespace} == '', {parentResourcePath} == '', + /// {resourceType} == 'Microsoft.Web/sites', {resourceName} == 'MyWebApp'). + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListForResourceNext(this IPolicyAssignmentsOperations operations, string nextPageLink) + { + return operations.ListForResourceNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Retrieves all policy assignments that apply to a resource. + /// + /// + /// This operation retrieves the list of all policy assignments associated with + /// the specified resource in the given resource group and subscription that + /// match the optional given $filter. Valid values for $filter are: + /// 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If + /// $filter is not provided, the unfiltered list includes all policy + /// assignments associated with the resource, including those that apply + /// directly or from all containing scopes, as well as any applied to resources + /// contained within the resource. If $filter=atScope() is provided, the + /// returned list includes all policy assignments that apply to the resource, + /// which is everything in the unfiltered list except those applied to + /// resources contained within the resource. If $filter=atExactScope() is + /// provided, the returned list only includes all policy assignments that at + /// the resource level. If $filter=policyDefinitionId eq '{value}' is provided, + /// the returned list includes all policy assignments of the policy definition + /// whose id is {value} that apply to the resource. Three parameters plus the + /// resource name are used to identify a specific resource. If the resource is + /// not part of a parent resource (the more common case), the parent resource + /// path should not be provided (or provided as ''). For example a web app + /// could be specified as ({resourceProviderNamespace} == 'Microsoft.Web', + /// {parentResourcePath} == '', {resourceType} == 'sites', {resourceName} == + /// 'MyWebApp'). If the resource is part of a parent resource, then all + /// parameters should be provided. For example a virtual machine DNS name could + /// be specified as ({resourceProviderNamespace} == 'Microsoft.Compute', + /// {parentResourcePath} == 'virtualMachines/MyVirtualMachine', {resourceType} + /// == 'domainNames', {resourceName} == 'MyComputerName'). A convenient + /// alternative to providing the namespace and type name separately is to + /// provide both in the {resourceType} parameter, format: + /// ({resourceProviderNamespace} == '', {parentResourcePath} == '', + /// {resourceType} == 'Microsoft.Web/sites', {resourceName} == 'MyWebApp'). + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListForResourceNextAsync(this IPolicyAssignmentsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListForResourceNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Retrieves all policy assignments that apply to a management group. + /// + /// + /// This operation retrieves the list of all policy assignments applicable to + /// the management group that match the given $filter. Valid values for $filter + /// are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If + /// $filter=atScope() is provided, the returned list includes all policy + /// assignments that are assigned to the management group or the management + /// group's ancestors. If $filter=atExactScope() is provided, the returned list + /// only includes all policy assignments that at the management group. If + /// $filter=policyDefinitionId eq '{value}' is provided, the returned list + /// includes all policy assignments of the policy definition whose id is + /// {value} that apply to the management group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListForManagementGroupNext(this IPolicyAssignmentsOperations operations, string nextPageLink) + { + return operations.ListForManagementGroupNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Retrieves all policy assignments that apply to a management group. + /// + /// + /// This operation retrieves the list of all policy assignments applicable to + /// the management group that match the given $filter. Valid values for $filter + /// are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If + /// $filter=atScope() is provided, the returned list includes all policy + /// assignments that are assigned to the management group or the management + /// group's ancestors. If $filter=atExactScope() is provided, the returned list + /// only includes all policy assignments that at the management group. If + /// $filter=policyDefinitionId eq '{value}' is provided, the returned list + /// includes all policy assignments of the policy definition whose id is + /// {value} that apply to the management 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> ListForManagementGroupNextAsync(this IPolicyAssignmentsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListForManagementGroupNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Retrieves all policy assignments that apply to a subscription. + /// + /// + /// This operation retrieves the list of all policy assignments associated with + /// the given subscription that match the optional given $filter. Valid values + /// for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq + /// '{value}''. If $filter is not provided, the unfiltered list includes all + /// policy assignments associated with the subscription, including those that + /// apply directly or from management groups that contain the given + /// subscription, as well as any applied to objects contained within the + /// subscription. If $filter=atScope() is provided, the returned list includes + /// all policy assignments that apply to the subscription, which is everything + /// in the unfiltered list except those applied to objects contained within the + /// subscription. If $filter=atExactScope() is provided, the returned list only + /// includes all policy assignments that at the subscription. If + /// $filter=policyDefinitionId eq '{value}' is provided, the returned list + /// includes all policy assignments of the policy definition whose id is + /// {value}. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListNext(this IPolicyAssignmentsOperations operations, string nextPageLink) + { + return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Retrieves all policy assignments that apply to a subscription. + /// + /// + /// This operation retrieves the list of all policy assignments associated with + /// the given subscription that match the optional given $filter. Valid values + /// for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq + /// '{value}''. If $filter is not provided, the unfiltered list includes all + /// policy assignments associated with the subscription, including those that + /// apply directly or from management groups that contain the given + /// subscription, as well as any applied to objects contained within the + /// subscription. If $filter=atScope() is provided, the returned list includes + /// all policy assignments that apply to the subscription, which is everything + /// in the unfiltered list except those applied to objects contained within the + /// subscription. If $filter=atExactScope() is provided, the returned list only + /// includes all policy assignments that at the subscription. If + /// $filter=policyDefinitionId eq '{value}' is provided, the returned list + /// includes all policy assignments of the policy definition whose id is + /// {value}. + /// + /// + /// 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 IPolicyAssignmentsOperations 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/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/PolicyClient.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/PolicyClient.cs new file mode 100644 index 0000000000000..23185f10a2bae --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/PolicyClient.cs @@ -0,0 +1,375 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager +{ + 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; + + public partial class PolicyClient : ServiceClient, IPolicyClient, 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 IDataPolicyManifestsOperations. + /// + public virtual IDataPolicyManifestsOperations DataPolicyManifests { get; private set; } + + /// + /// Gets the IPolicyAssignmentsOperations. + /// + public virtual IPolicyAssignmentsOperations PolicyAssignments { get; private set; } + + /// + /// Gets the IPolicyDefinitionsOperations. + /// + public virtual IPolicyDefinitionsOperations PolicyDefinitions { get; private set; } + + /// + /// Gets the IPolicySetDefinitionsOperations. + /// + public virtual IPolicySetDefinitionsOperations PolicySetDefinitions { get; private set; } + + /// + /// Gets the IPolicyExemptionsOperations. + /// + public virtual IPolicyExemptionsOperations PolicyExemptions { get; private set; } + + /// + /// Initializes a new instance of the PolicyClient class. + /// + /// + /// HttpClient to be used + /// + /// + /// True: will dispose the provided httpClient on calling PolicyClient.Dispose(). False: will not dispose provided httpClient + protected PolicyClient(HttpClient httpClient, bool disposeHttpClient) : base(httpClient, disposeHttpClient) + { + Initialize(); + } + + /// + /// Initializes a new instance of the PolicyClient class. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + protected PolicyClient(params DelegatingHandler[] handlers) : base(handlers) + { + Initialize(); + } + + /// + /// Initializes a new instance of the PolicyClient class. + /// + /// + /// Optional. The http client handler used to handle http transport. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + protected PolicyClient(HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : base(rootHandler, handlers) + { + Initialize(); + } + + /// + /// Initializes a new instance of the PolicyClient 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 PolicyClient(System.Uri baseUri, params DelegatingHandler[] handlers) : this(handlers) + { + if (baseUri == null) + { + throw new System.ArgumentNullException("baseUri"); + } + BaseUri = baseUri; + } + + /// + /// Initializes a new instance of the PolicyClient 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 PolicyClient(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 PolicyClient 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 PolicyClient(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 PolicyClient class. + /// + /// + /// Required. Credentials needed for the client to connect to Azure. + /// + /// + /// HttpClient to be used + /// + /// + /// True: will dispose the provided httpClient on calling PolicyClient.Dispose(). False: will not dispose provided httpClient + /// + /// Thrown when a required parameter is null + /// + public PolicyClient(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 PolicyClient 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 PolicyClient(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 PolicyClient 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 PolicyClient(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 PolicyClient 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 PolicyClient(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() + { + DataPolicyManifests = new DataPolicyManifestsOperations(this); + PolicyAssignments = new PolicyAssignmentsOperations(this); + PolicyDefinitions = new PolicyDefinitionsOperations(this); + PolicySetDefinitions = new PolicySetDefinitionsOperations(this); + PolicyExemptions = new PolicyExemptionsOperations(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() + } + }; + CustomInitialize(); + DeserializationSettings.Converters.Add(new TransformationJsonConverter()); + DeserializationSettings.Converters.Add(new CloudErrorJsonConverter()); + } + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/PolicyDefinitionsOperations.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/PolicyDefinitionsOperations.cs new file mode 100644 index 0000000000000..1ae8c70f02033 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/PolicyDefinitionsOperations.cs @@ -0,0 +1,2590 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager +{ + 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; + + /// + /// PolicyDefinitionsOperations operations. + /// + internal partial class PolicyDefinitionsOperations : IServiceOperations, IPolicyDefinitionsOperations + { + /// + /// Initializes a new instance of the PolicyDefinitionsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal PolicyDefinitionsOperations(PolicyClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the PolicyClient + /// + public PolicyClient Client { get; private set; } + + /// + /// Creates or updates a policy definition in a subscription. + /// + /// + /// This operation creates or updates a policy definition in the given + /// subscription with the given name. + /// + /// + /// The name of the policy definition to create. + /// + /// + /// The policy definition properties. + /// + /// + /// 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> CreateOrUpdateWithHttpMessagesAsync(string policyDefinitionName, PolicyDefinition parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (policyDefinitionName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "policyDefinitionName"); + } + if (parameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + string apiVersion = "2021-06-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("policyDefinitionName", policyDefinitionName); + tracingParameters.Add("parameters", parameters); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "CreateOrUpdate", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}").ToString(); + _url = _url.Replace("{policyDefinitionName}", System.Uri.EscapeDataString(policyDefinitionName)); + _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 != 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 == 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 policy definition in a subscription. + /// + /// + /// This operation deletes the policy definition in the given subscription with + /// the given name. + /// + /// + /// The name of the policy definition to delete. + /// + /// + /// 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 DeleteWithHttpMessagesAsync(string policyDefinitionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (policyDefinitionName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "policyDefinitionName"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + string apiVersion = "2021-06-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("policyDefinitionName", policyDefinitionName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Delete", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}").ToString(); + _url = _url.Replace("{policyDefinitionName}", System.Uri.EscapeDataString(policyDefinitionName)); + _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 != 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; + } + + /// + /// Retrieves a policy definition in a subscription. + /// + /// + /// This operation retrieves the policy definition in the given subscription + /// with the given name. + /// + /// + /// The name of the policy definition to get. + /// + /// + /// 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 policyDefinitionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (policyDefinitionName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "policyDefinitionName"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + string apiVersion = "2021-06-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("policyDefinitionName", policyDefinitionName); + 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}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}").ToString(); + _url = _url.Replace("{policyDefinitionName}", System.Uri.EscapeDataString(policyDefinitionName)); + _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; + } + + /// + /// Retrieves a built-in policy definition. + /// + /// + /// This operation retrieves the built-in policy definition with the given + /// name. + /// + /// + /// The name of the built-in policy definition to get. + /// + /// + /// 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> GetBuiltInWithHttpMessagesAsync(string policyDefinitionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (policyDefinitionName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "policyDefinitionName"); + } + string apiVersion = "2021-06-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("policyDefinitionName", policyDefinitionName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetBuiltIn", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}").ToString(); + _url = _url.Replace("{policyDefinitionName}", System.Uri.EscapeDataString(policyDefinitionName)); + 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 policy definition in a management group. + /// + /// + /// This operation creates or updates a policy definition in the given + /// management group with the given name. + /// + /// + /// The name of the policy definition to create. + /// + /// + /// The policy definition properties. + /// + /// + /// The ID of the management group. + /// + /// + /// 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> CreateOrUpdateAtManagementGroupWithHttpMessagesAsync(string policyDefinitionName, PolicyDefinition parameters, string managementGroupId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (policyDefinitionName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "policyDefinitionName"); + } + if (parameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); + } + if (managementGroupId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "managementGroupId"); + } + string apiVersion = "2021-06-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("policyDefinitionName", policyDefinitionName); + tracingParameters.Add("parameters", parameters); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("managementGroupId", managementGroupId); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "CreateOrUpdateAtManagementGroup", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}").ToString(); + _url = _url.Replace("{policyDefinitionName}", System.Uri.EscapeDataString(policyDefinitionName)); + _url = _url.Replace("{managementGroupId}", System.Uri.EscapeDataString(managementGroupId)); + 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 != 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 == 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 policy definition in a management group. + /// + /// + /// This operation deletes the policy definition in the given management group + /// with the given name. + /// + /// + /// The name of the policy definition to delete. + /// + /// + /// The ID of the management group. + /// + /// + /// 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 DeleteAtManagementGroupWithHttpMessagesAsync(string policyDefinitionName, string managementGroupId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (policyDefinitionName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "policyDefinitionName"); + } + if (managementGroupId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "managementGroupId"); + } + string apiVersion = "2021-06-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("policyDefinitionName", policyDefinitionName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("managementGroupId", managementGroupId); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "DeleteAtManagementGroup", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}").ToString(); + _url = _url.Replace("{policyDefinitionName}", System.Uri.EscapeDataString(policyDefinitionName)); + _url = _url.Replace("{managementGroupId}", System.Uri.EscapeDataString(managementGroupId)); + 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 != 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; + } + + /// + /// Retrieve a policy definition in a management group. + /// + /// + /// This operation retrieves the policy definition in the given management + /// group with the given name. + /// + /// + /// The name of the policy definition to get. + /// + /// + /// The ID of the management group. + /// + /// + /// 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> GetAtManagementGroupWithHttpMessagesAsync(string policyDefinitionName, string managementGroupId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (policyDefinitionName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "policyDefinitionName"); + } + if (managementGroupId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "managementGroupId"); + } + string apiVersion = "2021-06-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("policyDefinitionName", policyDefinitionName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("managementGroupId", managementGroupId); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetAtManagementGroup", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}").ToString(); + _url = _url.Replace("{policyDefinitionName}", System.Uri.EscapeDataString(policyDefinitionName)); + _url = _url.Replace("{managementGroupId}", System.Uri.EscapeDataString(managementGroupId)); + 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; + } + + /// + /// Retrieves policy definitions in a subscription + /// + /// + /// This operation retrieves a list of all the policy definitions in a given + /// subscription that match the optional given $filter. Valid values for + /// $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq + /// '{value}''. If $filter is not provided, the unfiltered list includes all + /// policy definitions associated with the subscription, including those that + /// apply directly or from management groups that contain the given + /// subscription. If $filter=atExactScope() is provided, the returned list only + /// includes all policy definitions that at the given subscription. If + /// $filter='policyType -eq {value}' is provided, the returned list only + /// includes all policy definitions whose type match the {value}. Possible + /// policyType values are NotSpecified, BuiltIn, Custom, and Static. If + /// $filter='category -eq {value}' is provided, the returned list only includes + /// all policy definitions whose category match the {value}. + /// + /// + /// The filter to apply on the operation. Valid values for $filter are: + /// 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If + /// $filter is not provided, no filtering is performed. If + /// $filter=atExactScope() is provided, the returned list only includes all + /// policy definitions that at the given scope. If $filter='policyType -eq + /// {value}' is provided, the returned list only includes all policy + /// definitions whose type match the {value}. Possible policyType values are + /// NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq + /// {value}' is provided, the returned list only includes all policy + /// definitions whose category match the {value}. + /// + /// + /// Maximum number of records to return. When the $top filter is not provided, + /// it will return 500 records. + /// + /// + /// 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 filter = default(string), int? top = default(int?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (top > 1000) + { + throw new ValidationException(ValidationRules.InclusiveMaximum, "top", 1000); + } + if (top < 1) + { + throw new ValidationException(ValidationRules.InclusiveMinimum, "top", 1); + } + string apiVersion = "2021-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("filter", filter); + tracingParameters.Add("top", top); + 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.Authorization/policyDefinitions").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 (filter != null) + { + _queryParameters.Add(string.Format("$filter={0}", filter)); + } + if (top != null) + { + _queryParameters.Add(string.Format("$top={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(top, Client.SerializationSettings).Trim('"')))); + } + 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 built-in policy definitions + /// + /// + /// This operation retrieves a list of all the built-in policy definitions that + /// match the optional given $filter. If $filter='policyType -eq {value}' is + /// provided, the returned list only includes all built-in policy definitions + /// whose type match the {value}. Possible policyType values are NotSpecified, + /// BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, + /// the returned list only includes all built-in policy definitions whose + /// category match the {value}. + /// + /// + /// The filter to apply on the operation. Valid values for $filter are: + /// 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If + /// $filter is not provided, no filtering is performed. If + /// $filter=atExactScope() is provided, the returned list only includes all + /// policy definitions that at the given scope. If $filter='policyType -eq + /// {value}' is provided, the returned list only includes all policy + /// definitions whose type match the {value}. Possible policyType values are + /// NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq + /// {value}' is provided, the returned list only includes all policy + /// definitions whose category match the {value}. + /// + /// + /// Maximum number of records to return. When the $top filter is not provided, + /// it will return 500 records. + /// + /// + /// 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>> ListBuiltInWithHttpMessagesAsync(string filter = default(string), int? top = default(int?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (top > 1000) + { + throw new ValidationException(ValidationRules.InclusiveMaximum, "top", 1000); + } + if (top < 1) + { + throw new ValidationException(ValidationRules.InclusiveMinimum, "top", 1); + } + string apiVersion = "2021-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("filter", filter); + tracingParameters.Add("top", top); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListBuiltIn", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Authorization/policyDefinitions").ToString(); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (filter != null) + { + _queryParameters.Add(string.Format("$filter={0}", filter)); + } + if (top != null) + { + _queryParameters.Add(string.Format("$top={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(top, Client.SerializationSettings).Trim('"')))); + } + 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 policy definitions in a management group + /// + /// + /// This operation retrieves a list of all the policy definitions in a given + /// management group that match the optional given $filter. Valid values for + /// $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq + /// '{value}''. If $filter is not provided, the unfiltered list includes all + /// policy definitions associated with the management group, including those + /// that apply directly or from management groups that contain the given + /// management group. If $filter=atExactScope() is provided, the returned list + /// only includes all policy definitions that at the given management group. If + /// $filter='policyType -eq {value}' is provided, the returned list only + /// includes all policy definitions whose type match the {value}. Possible + /// policyType values are NotSpecified, BuiltIn, Custom, and Static. If + /// $filter='category -eq {value}' is provided, the returned list only includes + /// all policy definitions whose category match the {value}. + /// + /// + /// The ID of the management group. + /// + /// + /// The filter to apply on the operation. Valid values for $filter are: + /// 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If + /// $filter is not provided, no filtering is performed. If + /// $filter=atExactScope() is provided, the returned list only includes all + /// policy definitions that at the given scope. If $filter='policyType -eq + /// {value}' is provided, the returned list only includes all policy + /// definitions whose type match the {value}. Possible policyType values are + /// NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq + /// {value}' is provided, the returned list only includes all policy + /// definitions whose category match the {value}. + /// + /// + /// Maximum number of records to return. When the $top filter is not provided, + /// it will return 500 records. + /// + /// + /// 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>> ListByManagementGroupWithHttpMessagesAsync(string managementGroupId, string filter = default(string), int? top = default(int?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (managementGroupId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "managementGroupId"); + } + if (top > 1000) + { + throw new ValidationException(ValidationRules.InclusiveMaximum, "top", 1000); + } + if (top < 1) + { + throw new ValidationException(ValidationRules.InclusiveMinimum, "top", 1); + } + string apiVersion = "2021-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("managementGroupId", managementGroupId); + tracingParameters.Add("filter", filter); + tracingParameters.Add("top", top); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByManagementGroup", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions").ToString(); + _url = _url.Replace("{managementGroupId}", System.Uri.EscapeDataString(managementGroupId)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (filter != null) + { + _queryParameters.Add(string.Format("$filter={0}", filter)); + } + if (top != null) + { + _queryParameters.Add(string.Format("$top={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(top, Client.SerializationSettings).Trim('"')))); + } + 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; + } + + /// + /// Retrieves policy definitions in a subscription + /// + /// + /// This operation retrieves a list of all the policy definitions in a given + /// subscription that match the optional given $filter. Valid values for + /// $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq + /// '{value}''. If $filter is not provided, the unfiltered list includes all + /// policy definitions associated with the subscription, including those that + /// apply directly or from management groups that contain the given + /// subscription. If $filter=atExactScope() is provided, the returned list only + /// includes all policy definitions that at the given subscription. If + /// $filter='policyType -eq {value}' is provided, the returned list only + /// includes all policy definitions whose type match the {value}. Possible + /// policyType values are NotSpecified, BuiltIn, Custom, and Static. If + /// $filter='category -eq {value}' is provided, the returned list only includes + /// all policy definitions whose category match the {value}. + /// + /// + /// 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 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 built-in policy definitions + /// + /// + /// This operation retrieves a list of all the built-in policy definitions that + /// match the optional given $filter. If $filter='policyType -eq {value}' is + /// provided, the returned list only includes all built-in policy definitions + /// whose type match the {value}. Possible policyType values are NotSpecified, + /// BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, + /// the returned list only includes all built-in policy definitions whose + /// category match the {value}. + /// + /// + /// 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>> ListBuiltInNextWithHttpMessagesAsync(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, "ListBuiltInNext", 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; + } + + /// + /// Retrieve policy definitions in a management group + /// + /// + /// This operation retrieves a list of all the policy definitions in a given + /// management group that match the optional given $filter. Valid values for + /// $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq + /// '{value}''. If $filter is not provided, the unfiltered list includes all + /// policy definitions associated with the management group, including those + /// that apply directly or from management groups that contain the given + /// management group. If $filter=atExactScope() is provided, the returned list + /// only includes all policy definitions that at the given management group. If + /// $filter='policyType -eq {value}' is provided, the returned list only + /// includes all policy definitions whose type match the {value}. Possible + /// policyType values are NotSpecified, BuiltIn, Custom, and Static. If + /// $filter='category -eq {value}' is provided, the returned list only includes + /// all policy definitions whose category match the {value}. + /// + /// + /// 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>> ListByManagementGroupNextWithHttpMessagesAsync(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, "ListByManagementGroupNext", 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/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/PolicyDefinitionsOperationsExtensions.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/PolicyDefinitionsOperationsExtensions.cs new file mode 100644 index 0000000000000..582ce3393981f --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/PolicyDefinitionsOperationsExtensions.cs @@ -0,0 +1,787 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for PolicyDefinitionsOperations. + /// + public static partial class PolicyDefinitionsOperationsExtensions + { + /// + /// Creates or updates a policy definition in a subscription. + /// + /// + /// This operation creates or updates a policy definition in the given + /// subscription with the given name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the policy definition to create. + /// + /// + /// The policy definition properties. + /// + public static PolicyDefinition CreateOrUpdate(this IPolicyDefinitionsOperations operations, string policyDefinitionName, PolicyDefinition parameters) + { + return operations.CreateOrUpdateAsync(policyDefinitionName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Creates or updates a policy definition in a subscription. + /// + /// + /// This operation creates or updates a policy definition in the given + /// subscription with the given name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the policy definition to create. + /// + /// + /// The policy definition properties. + /// + /// + /// The cancellation token. + /// + public static async Task CreateOrUpdateAsync(this IPolicyDefinitionsOperations operations, string policyDefinitionName, PolicyDefinition parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(policyDefinitionName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes a policy definition in a subscription. + /// + /// + /// This operation deletes the policy definition in the given subscription with + /// the given name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the policy definition to delete. + /// + public static void Delete(this IPolicyDefinitionsOperations operations, string policyDefinitionName) + { + operations.DeleteAsync(policyDefinitionName).GetAwaiter().GetResult(); + } + + /// + /// Deletes a policy definition in a subscription. + /// + /// + /// This operation deletes the policy definition in the given subscription with + /// the given name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the policy definition to delete. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this IPolicyDefinitionsOperations operations, string policyDefinitionName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(policyDefinitionName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Retrieves a policy definition in a subscription. + /// + /// + /// This operation retrieves the policy definition in the given subscription + /// with the given name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the policy definition to get. + /// + public static PolicyDefinition Get(this IPolicyDefinitionsOperations operations, string policyDefinitionName) + { + return operations.GetAsync(policyDefinitionName).GetAwaiter().GetResult(); + } + + /// + /// Retrieves a policy definition in a subscription. + /// + /// + /// This operation retrieves the policy definition in the given subscription + /// with the given name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the policy definition to get. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IPolicyDefinitionsOperations operations, string policyDefinitionName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(policyDefinitionName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Retrieves a built-in policy definition. + /// + /// + /// This operation retrieves the built-in policy definition with the given + /// name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the built-in policy definition to get. + /// + public static PolicyDefinition GetBuiltIn(this IPolicyDefinitionsOperations operations, string policyDefinitionName) + { + return operations.GetBuiltInAsync(policyDefinitionName).GetAwaiter().GetResult(); + } + + /// + /// Retrieves a built-in policy definition. + /// + /// + /// This operation retrieves the built-in policy definition with the given + /// name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the built-in policy definition to get. + /// + /// + /// The cancellation token. + /// + public static async Task GetBuiltInAsync(this IPolicyDefinitionsOperations operations, string policyDefinitionName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetBuiltInWithHttpMessagesAsync(policyDefinitionName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Creates or updates a policy definition in a management group. + /// + /// + /// This operation creates or updates a policy definition in the given + /// management group with the given name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the policy definition to create. + /// + /// + /// The policy definition properties. + /// + /// + /// The ID of the management group. + /// + public static PolicyDefinition CreateOrUpdateAtManagementGroup(this IPolicyDefinitionsOperations operations, string policyDefinitionName, PolicyDefinition parameters, string managementGroupId) + { + return operations.CreateOrUpdateAtManagementGroupAsync(policyDefinitionName, parameters, managementGroupId).GetAwaiter().GetResult(); + } + + /// + /// Creates or updates a policy definition in a management group. + /// + /// + /// This operation creates or updates a policy definition in the given + /// management group with the given name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the policy definition to create. + /// + /// + /// The policy definition properties. + /// + /// + /// The ID of the management group. + /// + /// + /// The cancellation token. + /// + public static async Task CreateOrUpdateAtManagementGroupAsync(this IPolicyDefinitionsOperations operations, string policyDefinitionName, PolicyDefinition parameters, string managementGroupId, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateAtManagementGroupWithHttpMessagesAsync(policyDefinitionName, parameters, managementGroupId, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes a policy definition in a management group. + /// + /// + /// This operation deletes the policy definition in the given management group + /// with the given name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the policy definition to delete. + /// + /// + /// The ID of the management group. + /// + public static void DeleteAtManagementGroup(this IPolicyDefinitionsOperations operations, string policyDefinitionName, string managementGroupId) + { + operations.DeleteAtManagementGroupAsync(policyDefinitionName, managementGroupId).GetAwaiter().GetResult(); + } + + /// + /// Deletes a policy definition in a management group. + /// + /// + /// This operation deletes the policy definition in the given management group + /// with the given name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the policy definition to delete. + /// + /// + /// The ID of the management group. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAtManagementGroupAsync(this IPolicyDefinitionsOperations operations, string policyDefinitionName, string managementGroupId, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteAtManagementGroupWithHttpMessagesAsync(policyDefinitionName, managementGroupId, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Retrieve a policy definition in a management group. + /// + /// + /// This operation retrieves the policy definition in the given management + /// group with the given name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the policy definition to get. + /// + /// + /// The ID of the management group. + /// + public static PolicyDefinition GetAtManagementGroup(this IPolicyDefinitionsOperations operations, string policyDefinitionName, string managementGroupId) + { + return operations.GetAtManagementGroupAsync(policyDefinitionName, managementGroupId).GetAwaiter().GetResult(); + } + + /// + /// Retrieve a policy definition in a management group. + /// + /// + /// This operation retrieves the policy definition in the given management + /// group with the given name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the policy definition to get. + /// + /// + /// The ID of the management group. + /// + /// + /// The cancellation token. + /// + public static async Task GetAtManagementGroupAsync(this IPolicyDefinitionsOperations operations, string policyDefinitionName, string managementGroupId, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetAtManagementGroupWithHttpMessagesAsync(policyDefinitionName, managementGroupId, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Retrieves policy definitions in a subscription + /// + /// + /// This operation retrieves a list of all the policy definitions in a given + /// subscription that match the optional given $filter. Valid values for + /// $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq + /// '{value}''. If $filter is not provided, the unfiltered list includes all + /// policy definitions associated with the subscription, including those that + /// apply directly or from management groups that contain the given + /// subscription. If $filter=atExactScope() is provided, the returned list only + /// includes all policy definitions that at the given subscription. If + /// $filter='policyType -eq {value}' is provided, the returned list only + /// includes all policy definitions whose type match the {value}. Possible + /// policyType values are NotSpecified, BuiltIn, Custom, and Static. If + /// $filter='category -eq {value}' is provided, the returned list only includes + /// all policy definitions whose category match the {value}. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The filter to apply on the operation. Valid values for $filter are: + /// 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If + /// $filter is not provided, no filtering is performed. If + /// $filter=atExactScope() is provided, the returned list only includes all + /// policy definitions that at the given scope. If $filter='policyType -eq + /// {value}' is provided, the returned list only includes all policy + /// definitions whose type match the {value}. Possible policyType values are + /// NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq + /// {value}' is provided, the returned list only includes all policy + /// definitions whose category match the {value}. + /// + /// + /// Maximum number of records to return. When the $top filter is not provided, + /// it will return 500 records. + /// + public static IPage List(this IPolicyDefinitionsOperations operations, string filter = default(string), int? top = default(int?)) + { + return operations.ListAsync(filter, top).GetAwaiter().GetResult(); + } + + /// + /// Retrieves policy definitions in a subscription + /// + /// + /// This operation retrieves a list of all the policy definitions in a given + /// subscription that match the optional given $filter. Valid values for + /// $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq + /// '{value}''. If $filter is not provided, the unfiltered list includes all + /// policy definitions associated with the subscription, including those that + /// apply directly or from management groups that contain the given + /// subscription. If $filter=atExactScope() is provided, the returned list only + /// includes all policy definitions that at the given subscription. If + /// $filter='policyType -eq {value}' is provided, the returned list only + /// includes all policy definitions whose type match the {value}. Possible + /// policyType values are NotSpecified, BuiltIn, Custom, and Static. If + /// $filter='category -eq {value}' is provided, the returned list only includes + /// all policy definitions whose category match the {value}. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The filter to apply on the operation. Valid values for $filter are: + /// 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If + /// $filter is not provided, no filtering is performed. If + /// $filter=atExactScope() is provided, the returned list only includes all + /// policy definitions that at the given scope. If $filter='policyType -eq + /// {value}' is provided, the returned list only includes all policy + /// definitions whose type match the {value}. Possible policyType values are + /// NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq + /// {value}' is provided, the returned list only includes all policy + /// definitions whose category match the {value}. + /// + /// + /// Maximum number of records to return. When the $top filter is not provided, + /// it will return 500 records. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAsync(this IPolicyDefinitionsOperations operations, string filter = default(string), int? top = default(int?), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(filter, top, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Retrieve built-in policy definitions + /// + /// + /// This operation retrieves a list of all the built-in policy definitions that + /// match the optional given $filter. If $filter='policyType -eq {value}' is + /// provided, the returned list only includes all built-in policy definitions + /// whose type match the {value}. Possible policyType values are NotSpecified, + /// BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, + /// the returned list only includes all built-in policy definitions whose + /// category match the {value}. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The filter to apply on the operation. Valid values for $filter are: + /// 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If + /// $filter is not provided, no filtering is performed. If + /// $filter=atExactScope() is provided, the returned list only includes all + /// policy definitions that at the given scope. If $filter='policyType -eq + /// {value}' is provided, the returned list only includes all policy + /// definitions whose type match the {value}. Possible policyType values are + /// NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq + /// {value}' is provided, the returned list only includes all policy + /// definitions whose category match the {value}. + /// + /// + /// Maximum number of records to return. When the $top filter is not provided, + /// it will return 500 records. + /// + public static IPage ListBuiltIn(this IPolicyDefinitionsOperations operations, string filter = default(string), int? top = default(int?)) + { + return operations.ListBuiltInAsync(filter, top).GetAwaiter().GetResult(); + } + + /// + /// Retrieve built-in policy definitions + /// + /// + /// This operation retrieves a list of all the built-in policy definitions that + /// match the optional given $filter. If $filter='policyType -eq {value}' is + /// provided, the returned list only includes all built-in policy definitions + /// whose type match the {value}. Possible policyType values are NotSpecified, + /// BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, + /// the returned list only includes all built-in policy definitions whose + /// category match the {value}. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The filter to apply on the operation. Valid values for $filter are: + /// 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If + /// $filter is not provided, no filtering is performed. If + /// $filter=atExactScope() is provided, the returned list only includes all + /// policy definitions that at the given scope. If $filter='policyType -eq + /// {value}' is provided, the returned list only includes all policy + /// definitions whose type match the {value}. Possible policyType values are + /// NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq + /// {value}' is provided, the returned list only includes all policy + /// definitions whose category match the {value}. + /// + /// + /// Maximum number of records to return. When the $top filter is not provided, + /// it will return 500 records. + /// + /// + /// The cancellation token. + /// + public static async Task> ListBuiltInAsync(this IPolicyDefinitionsOperations operations, string filter = default(string), int? top = default(int?), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListBuiltInWithHttpMessagesAsync(filter, top, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Retrieve policy definitions in a management group + /// + /// + /// This operation retrieves a list of all the policy definitions in a given + /// management group that match the optional given $filter. Valid values for + /// $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq + /// '{value}''. If $filter is not provided, the unfiltered list includes all + /// policy definitions associated with the management group, including those + /// that apply directly or from management groups that contain the given + /// management group. If $filter=atExactScope() is provided, the returned list + /// only includes all policy definitions that at the given management group. If + /// $filter='policyType -eq {value}' is provided, the returned list only + /// includes all policy definitions whose type match the {value}. Possible + /// policyType values are NotSpecified, BuiltIn, Custom, and Static. If + /// $filter='category -eq {value}' is provided, the returned list only includes + /// all policy definitions whose category match the {value}. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The ID of the management group. + /// + /// + /// The filter to apply on the operation. Valid values for $filter are: + /// 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If + /// $filter is not provided, no filtering is performed. If + /// $filter=atExactScope() is provided, the returned list only includes all + /// policy definitions that at the given scope. If $filter='policyType -eq + /// {value}' is provided, the returned list only includes all policy + /// definitions whose type match the {value}. Possible policyType values are + /// NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq + /// {value}' is provided, the returned list only includes all policy + /// definitions whose category match the {value}. + /// + /// + /// Maximum number of records to return. When the $top filter is not provided, + /// it will return 500 records. + /// + public static IPage ListByManagementGroup(this IPolicyDefinitionsOperations operations, string managementGroupId, string filter = default(string), int? top = default(int?)) + { + return operations.ListByManagementGroupAsync(managementGroupId, filter, top).GetAwaiter().GetResult(); + } + + /// + /// Retrieve policy definitions in a management group + /// + /// + /// This operation retrieves a list of all the policy definitions in a given + /// management group that match the optional given $filter. Valid values for + /// $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq + /// '{value}''. If $filter is not provided, the unfiltered list includes all + /// policy definitions associated with the management group, including those + /// that apply directly or from management groups that contain the given + /// management group. If $filter=atExactScope() is provided, the returned list + /// only includes all policy definitions that at the given management group. If + /// $filter='policyType -eq {value}' is provided, the returned list only + /// includes all policy definitions whose type match the {value}. Possible + /// policyType values are NotSpecified, BuiltIn, Custom, and Static. If + /// $filter='category -eq {value}' is provided, the returned list only includes + /// all policy definitions whose category match the {value}. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The ID of the management group. + /// + /// + /// The filter to apply on the operation. Valid values for $filter are: + /// 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If + /// $filter is not provided, no filtering is performed. If + /// $filter=atExactScope() is provided, the returned list only includes all + /// policy definitions that at the given scope. If $filter='policyType -eq + /// {value}' is provided, the returned list only includes all policy + /// definitions whose type match the {value}. Possible policyType values are + /// NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq + /// {value}' is provided, the returned list only includes all policy + /// definitions whose category match the {value}. + /// + /// + /// Maximum number of records to return. When the $top filter is not provided, + /// it will return 500 records. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByManagementGroupAsync(this IPolicyDefinitionsOperations operations, string managementGroupId, string filter = default(string), int? top = default(int?), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByManagementGroupWithHttpMessagesAsync(managementGroupId, filter, top, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Retrieves policy definitions in a subscription + /// + /// + /// This operation retrieves a list of all the policy definitions in a given + /// subscription that match the optional given $filter. Valid values for + /// $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq + /// '{value}''. If $filter is not provided, the unfiltered list includes all + /// policy definitions associated with the subscription, including those that + /// apply directly or from management groups that contain the given + /// subscription. If $filter=atExactScope() is provided, the returned list only + /// includes all policy definitions that at the given subscription. If + /// $filter='policyType -eq {value}' is provided, the returned list only + /// includes all policy definitions whose type match the {value}. Possible + /// policyType values are NotSpecified, BuiltIn, Custom, and Static. If + /// $filter='category -eq {value}' is provided, the returned list only includes + /// all policy definitions whose category match the {value}. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListNext(this IPolicyDefinitionsOperations operations, string nextPageLink) + { + return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Retrieves policy definitions in a subscription + /// + /// + /// This operation retrieves a list of all the policy definitions in a given + /// subscription that match the optional given $filter. Valid values for + /// $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq + /// '{value}''. If $filter is not provided, the unfiltered list includes all + /// policy definitions associated with the subscription, including those that + /// apply directly or from management groups that contain the given + /// subscription. If $filter=atExactScope() is provided, the returned list only + /// includes all policy definitions that at the given subscription. If + /// $filter='policyType -eq {value}' is provided, the returned list only + /// includes all policy definitions whose type match the {value}. Possible + /// policyType values are NotSpecified, BuiltIn, Custom, and Static. If + /// $filter='category -eq {value}' is provided, the returned list only includes + /// all policy definitions whose category match the {value}. + /// + /// + /// 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 IPolicyDefinitionsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Retrieve built-in policy definitions + /// + /// + /// This operation retrieves a list of all the built-in policy definitions that + /// match the optional given $filter. If $filter='policyType -eq {value}' is + /// provided, the returned list only includes all built-in policy definitions + /// whose type match the {value}. Possible policyType values are NotSpecified, + /// BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, + /// the returned list only includes all built-in policy definitions whose + /// category match the {value}. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListBuiltInNext(this IPolicyDefinitionsOperations operations, string nextPageLink) + { + return operations.ListBuiltInNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Retrieve built-in policy definitions + /// + /// + /// This operation retrieves a list of all the built-in policy definitions that + /// match the optional given $filter. If $filter='policyType -eq {value}' is + /// provided, the returned list only includes all built-in policy definitions + /// whose type match the {value}. Possible policyType values are NotSpecified, + /// BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, + /// the returned list only includes all built-in policy definitions whose + /// category match the {value}. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListBuiltInNextAsync(this IPolicyDefinitionsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListBuiltInNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Retrieve policy definitions in a management group + /// + /// + /// This operation retrieves a list of all the policy definitions in a given + /// management group that match the optional given $filter. Valid values for + /// $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq + /// '{value}''. If $filter is not provided, the unfiltered list includes all + /// policy definitions associated with the management group, including those + /// that apply directly or from management groups that contain the given + /// management group. If $filter=atExactScope() is provided, the returned list + /// only includes all policy definitions that at the given management group. If + /// $filter='policyType -eq {value}' is provided, the returned list only + /// includes all policy definitions whose type match the {value}. Possible + /// policyType values are NotSpecified, BuiltIn, Custom, and Static. If + /// $filter='category -eq {value}' is provided, the returned list only includes + /// all policy definitions whose category match the {value}. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListByManagementGroupNext(this IPolicyDefinitionsOperations operations, string nextPageLink) + { + return operations.ListByManagementGroupNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Retrieve policy definitions in a management group + /// + /// + /// This operation retrieves a list of all the policy definitions in a given + /// management group that match the optional given $filter. Valid values for + /// $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq + /// '{value}''. If $filter is not provided, the unfiltered list includes all + /// policy definitions associated with the management group, including those + /// that apply directly or from management groups that contain the given + /// management group. If $filter=atExactScope() is provided, the returned list + /// only includes all policy definitions that at the given management group. If + /// $filter='policyType -eq {value}' is provided, the returned list only + /// includes all policy definitions whose type match the {value}. Possible + /// policyType values are NotSpecified, BuiltIn, Custom, and Static. If + /// $filter='category -eq {value}' is provided, the returned list only includes + /// all policy definitions whose category match the {value}. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByManagementGroupNextAsync(this IPolicyDefinitionsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByManagementGroupNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/PolicyExemptionsOperations.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/PolicyExemptionsOperations.cs new file mode 100644 index 0000000000000..4ce0e3bd4a77c --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/PolicyExemptionsOperations.cs @@ -0,0 +1,2353 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager +{ + 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; + + /// + /// PolicyExemptionsOperations operations. + /// + internal partial class PolicyExemptionsOperations : IServiceOperations, IPolicyExemptionsOperations + { + /// + /// Initializes a new instance of the PolicyExemptionsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal PolicyExemptionsOperations(PolicyClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the PolicyClient + /// + public PolicyClient Client { get; private set; } + + /// + /// Deletes a policy exemption. + /// + /// + /// This operation deletes a policy exemption, given its name and the scope it + /// was created in. The scope of a policy exemption is the part of its ID + /// preceding + /// '/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}'. + /// + /// + /// The scope of the policy exemption. Valid scopes are: management group + /// (format: + /// '/providers/Microsoft.Management/managementGroups/{managementGroup}'), + /// subscription (format: '/subscriptions/{subscriptionId}'), resource group + /// (format: + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or + /// resource (format: + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' + /// + /// + /// The name of the policy exemption to delete. + /// + /// + /// 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 DeleteWithHttpMessagesAsync(string scope, string policyExemptionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (scope == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "scope"); + } + if (policyExemptionName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "policyExemptionName"); + } + string apiVersion = "2020-07-01-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("scope", scope); + tracingParameters.Add("policyExemptionName", policyExemptionName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Delete", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{scope}/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}").ToString(); + _url = _url.Replace("{scope}", scope); + _url = _url.Replace("{policyExemptionName}", System.Uri.EscapeDataString(policyExemptionName)); + 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 != 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; + } + + /// + /// Creates or updates a policy exemption. + /// + /// + /// This operation creates or updates a policy exemption with the given scope + /// and name. Policy exemptions apply to all resources contained within their + /// scope. For example, when you create a policy exemption at resource group + /// scope for a policy assignment at the same or above level, the exemption + /// exempts to all applicable resources in the resource group. + /// + /// + /// The scope of the policy exemption. Valid scopes are: management group + /// (format: + /// '/providers/Microsoft.Management/managementGroups/{managementGroup}'), + /// subscription (format: '/subscriptions/{subscriptionId}'), resource group + /// (format: + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or + /// resource (format: + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' + /// + /// + /// The name of the policy exemption to delete. + /// + /// + /// Parameters for the policy exemption. + /// + /// + /// 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> CreateOrUpdateWithHttpMessagesAsync(string scope, string policyExemptionName, PolicyExemption parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (scope == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "scope"); + } + if (policyExemptionName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "policyExemptionName"); + } + if (parameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); + } + if (parameters != null) + { + parameters.Validate(); + } + string apiVersion = "2020-07-01-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("scope", scope); + tracingParameters.Add("policyExemptionName", policyExemptionName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("parameters", parameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "CreateOrUpdate", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{scope}/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}").ToString(); + _url = _url.Replace("{scope}", scope); + _url = _url.Replace("{policyExemptionName}", System.Uri.EscapeDataString(policyExemptionName)); + 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) + { + 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; + } + + /// + /// Retrieves a policy exemption. + /// + /// + /// This operation retrieves a single policy exemption, given its name and the + /// scope it was created at. + /// + /// + /// The scope of the policy exemption. Valid scopes are: management group + /// (format: + /// '/providers/Microsoft.Management/managementGroups/{managementGroup}'), + /// subscription (format: '/subscriptions/{subscriptionId}'), resource group + /// (format: + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or + /// resource (format: + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' + /// + /// + /// The name of the policy exemption to delete. + /// + /// + /// 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 scope, string policyExemptionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (scope == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "scope"); + } + if (policyExemptionName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "policyExemptionName"); + } + string apiVersion = "2020-07-01-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("scope", scope); + tracingParameters.Add("policyExemptionName", policyExemptionName); + 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("/") ? "" : "/")), "{scope}/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}").ToString(); + _url = _url.Replace("{scope}", scope); + _url = _url.Replace("{policyExemptionName}", System.Uri.EscapeDataString(policyExemptionName)); + 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; + } + + /// + /// Retrieves all policy exemptions that apply to a subscription. + /// + /// + /// This operation retrieves the list of all policy exemptions associated with + /// the given subscription that match the optional given $filter. Valid values + /// for $filter are: 'atScope()', 'atExactScope()', 'excludeExpired()' or + /// 'policyAssignmentId eq '{value}''. If $filter is not provided, the + /// unfiltered list includes all policy exemptions associated with the + /// subscription, including those that apply directly or from management groups + /// that contain the given subscription, as well as any applied to objects + /// contained within the subscription. + /// + /// + /// The filter to apply on the operation. Valid values for $filter are: + /// 'atScope()', 'atExactScope()', 'excludeExpired()' or 'policyAssignmentId eq + /// '{value}''. If $filter is not provided, no filtering is performed. If + /// $filter is not provided, the unfiltered list includes all policy exemptions + /// associated with the scope, including those that apply directly or apply + /// from containing scopes. If $filter=atScope() is provided, the returned list + /// only includes all policy exemptions that apply to the scope, which is + /// everything in the unfiltered list except those applied to sub scopes + /// contained within the given scope. If $filter=atExactScope() is provided, + /// the returned list only includes all policy exemptions that at the given + /// scope. If $filter=excludeExpired() is provided, the returned list only + /// includes all policy exemptions that either haven't expired or didn't set + /// expiration date. If $filter=policyAssignmentId eq '{value}' is provided. + /// the returned list only includes all policy exemptions that are associated + /// with the give policyAssignmentId. + /// + /// + /// 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 filter = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + string apiVersion = "2020-07-01-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("filter", filter); + 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.Authorization/policyExemptions").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (filter != null) + { + _queryParameters.Add(string.Format("$filter={0}", filter)); + } + 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; + } + + /// + /// Retrieves all policy exemptions that apply to a resource group. + /// + /// + /// This operation retrieves the list of all policy exemptions associated with + /// the given resource group in the given subscription that match the optional + /// given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()', + /// 'excludeExpired()' or 'policyAssignmentId eq '{value}''. If $filter is not + /// provided, the unfiltered list includes all policy exemptions associated + /// with the resource group, including those that apply directly or apply from + /// containing scopes, as well as any applied to resources contained within the + /// resource group. + /// + /// + /// The name of the resource group containing the resource. + /// + /// + /// The filter to apply on the operation. Valid values for $filter are: + /// 'atScope()', 'atExactScope()', 'excludeExpired()' or 'policyAssignmentId eq + /// '{value}''. If $filter is not provided, no filtering is performed. If + /// $filter is not provided, the unfiltered list includes all policy exemptions + /// associated with the scope, including those that apply directly or apply + /// from containing scopes. If $filter=atScope() is provided, the returned list + /// only includes all policy exemptions that apply to the scope, which is + /// everything in the unfiltered list except those applied to sub scopes + /// contained within the given scope. If $filter=atExactScope() is provided, + /// the returned list only includes all policy exemptions that at the given + /// scope. If $filter=excludeExpired() is provided, the returned list only + /// includes all policy exemptions that either haven't expired or didn't set + /// expiration date. If $filter=policyAssignmentId eq '{value}' is provided. + /// the returned list only includes all policy exemptions that are associated + /// with the give policyAssignmentId. + /// + /// + /// 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>> ListForResourceGroupWithHttpMessagesAsync(string resourceGroupName, string filter = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + 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 (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + string apiVersion = "2020-07-01-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("filter", filter); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListForResourceGroup", 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.Authorization/policyExemptions").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + List _queryParameters = new List(); + if (filter != null) + { + _queryParameters.Add(string.Format("$filter={0}", filter)); + } + 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; + } + + /// + /// Retrieves all policy exemptions that apply to a resource. + /// + /// + /// This operation retrieves the list of all policy exemptions associated with + /// the specified resource in the given resource group and subscription that + /// match the optional given $filter. Valid values for $filter are: + /// 'atScope()', 'atExactScope()', 'excludeExpired()' or 'policyAssignmentId eq + /// '{value}''. If $filter is not provided, the unfiltered list includes all + /// policy exemptions associated with the resource, including those that apply + /// directly or from all containing scopes, as well as any applied to resources + /// contained within the resource. Three parameters plus the resource name are + /// used to identify a specific resource. If the resource is not part of a + /// parent resource (the more common case), the parent resource path should not + /// be provided (or provided as ''). For example a web app could be specified + /// as ({resourceProviderNamespace} == 'Microsoft.Web', {parentResourcePath} == + /// '', {resourceType} == 'sites', {resourceName} == 'MyWebApp'). If the + /// resource is part of a parent resource, then all parameters should be + /// provided. For example a virtual machine DNS name could be specified as + /// ({resourceProviderNamespace} == 'Microsoft.Compute', {parentResourcePath} + /// == 'virtualMachines/MyVirtualMachine', {resourceType} == 'domainNames', + /// {resourceName} == 'MyComputerName'). A convenient alternative to providing + /// the namespace and type name separately is to provide both in the + /// {resourceType} parameter, format: ({resourceProviderNamespace} == '', + /// {parentResourcePath} == '', {resourceType} == 'Microsoft.Web/sites', + /// {resourceName} == 'MyWebApp'). + /// + /// + /// The name of the resource group containing the resource. + /// + /// + /// The namespace of the resource provider. For example, the namespace of a + /// virtual machine is Microsoft.Compute (from + /// Microsoft.Compute/virtualMachines) + /// + /// + /// The parent resource path. Use empty string if there is none. + /// + /// + /// The resource type name. For example the type name of a web app is 'sites' + /// (from Microsoft.Web/sites). + /// + /// + /// The name of the resource. + /// + /// + /// The filter to apply on the operation. Valid values for $filter are: + /// 'atScope()', 'atExactScope()', 'excludeExpired()' or 'policyAssignmentId eq + /// '{value}''. If $filter is not provided, no filtering is performed. If + /// $filter is not provided, the unfiltered list includes all policy exemptions + /// associated with the scope, including those that apply directly or apply + /// from containing scopes. If $filter=atScope() is provided, the returned list + /// only includes all policy exemptions that apply to the scope, which is + /// everything in the unfiltered list except those applied to sub scopes + /// contained within the given scope. If $filter=atExactScope() is provided, + /// the returned list only includes all policy exemptions that at the given + /// scope. If $filter=excludeExpired() is provided, the returned list only + /// includes all policy exemptions that either haven't expired or didn't set + /// expiration date. If $filter=policyAssignmentId eq '{value}' is provided. + /// the returned list only includes all policy exemptions that are associated + /// with the give policyAssignmentId. + /// + /// + /// 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>> ListForResourceWithHttpMessagesAsync(string resourceGroupName, string resourceProviderNamespace, string parentResourcePath, string resourceType, string resourceName, string filter = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + 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 (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (resourceProviderNamespace == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceProviderNamespace"); + } + if (parentResourcePath == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "parentResourcePath"); + } + if (resourceType == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceType"); + } + if (resourceName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceName"); + } + string apiVersion = "2020-07-01-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("resourceProviderNamespace", resourceProviderNamespace); + tracingParameters.Add("parentResourcePath", parentResourcePath); + tracingParameters.Add("resourceType", resourceType); + tracingParameters.Add("resourceName", resourceName); + tracingParameters.Add("filter", filter); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListForResource", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyExemptions").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{resourceProviderNamespace}", System.Uri.EscapeDataString(resourceProviderNamespace)); + _url = _url.Replace("{parentResourcePath}", parentResourcePath); + _url = _url.Replace("{resourceType}", resourceType); + _url = _url.Replace("{resourceName}", System.Uri.EscapeDataString(resourceName)); + List _queryParameters = new List(); + if (filter != null) + { + _queryParameters.Add(string.Format("$filter={0}", filter)); + } + 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; + } + + /// + /// Retrieves all policy exemptions that apply to a management group. + /// + /// + /// This operation retrieves the list of all policy exemptions applicable to + /// the management group that match the given $filter. Valid values for $filter + /// are: 'atScope()', 'atExactScope()', 'excludeExpired()' or + /// 'policyAssignmentId eq '{value}''. If $filter=atScope() is provided, the + /// returned list includes all policy exemptions that are assigned to the + /// management group or the management group's ancestors. + /// + /// + /// The ID of the management group. + /// + /// + /// The filter to apply on the operation. Valid values for $filter are: + /// 'atScope()', 'atExactScope()', 'excludeExpired()' or 'policyAssignmentId eq + /// '{value}''. If $filter is not provided, no filtering is performed. If + /// $filter is not provided, the unfiltered list includes all policy exemptions + /// associated with the scope, including those that apply directly or apply + /// from containing scopes. If $filter=atScope() is provided, the returned list + /// only includes all policy exemptions that apply to the scope, which is + /// everything in the unfiltered list except those applied to sub scopes + /// contained within the given scope. If $filter=atExactScope() is provided, + /// the returned list only includes all policy exemptions that at the given + /// scope. If $filter=excludeExpired() is provided, the returned list only + /// includes all policy exemptions that either haven't expired or didn't set + /// expiration date. If $filter=policyAssignmentId eq '{value}' is provided. + /// the returned list only includes all policy exemptions that are associated + /// with the give policyAssignmentId. + /// + /// + /// 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>> ListForManagementGroupWithHttpMessagesAsync(string managementGroupId, string filter = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (managementGroupId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "managementGroupId"); + } + string apiVersion = "2020-07-01-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("managementGroupId", managementGroupId); + tracingParameters.Add("filter", filter); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListForManagementGroup", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyExemptions").ToString(); + _url = _url.Replace("{managementGroupId}", System.Uri.EscapeDataString(managementGroupId)); + List _queryParameters = new List(); + if (filter != null) + { + _queryParameters.Add(string.Format("$filter={0}", filter)); + } + 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; + } + + /// + /// Retrieves all policy exemptions that apply to a subscription. + /// + /// + /// This operation retrieves the list of all policy exemptions associated with + /// the given subscription that match the optional given $filter. Valid values + /// for $filter are: 'atScope()', 'atExactScope()', 'excludeExpired()' or + /// 'policyAssignmentId eq '{value}''. If $filter is not provided, the + /// unfiltered list includes all policy exemptions associated with the + /// subscription, including those that apply directly or from management groups + /// that contain the given subscription, as well as any applied to objects + /// contained within the 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 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; + } + + /// + /// Retrieves all policy exemptions that apply to a resource group. + /// + /// + /// This operation retrieves the list of all policy exemptions associated with + /// the given resource group in the given subscription that match the optional + /// given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()', + /// 'excludeExpired()' or 'policyAssignmentId eq '{value}''. If $filter is not + /// provided, the unfiltered list includes all policy exemptions associated + /// with the resource group, including those that apply directly or apply from + /// containing scopes, as well as any applied to resources contained within the + /// 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>> ListForResourceGroupNextWithHttpMessagesAsync(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, "ListForResourceGroupNext", 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; + } + + /// + /// Retrieves all policy exemptions that apply to a resource. + /// + /// + /// This operation retrieves the list of all policy exemptions associated with + /// the specified resource in the given resource group and subscription that + /// match the optional given $filter. Valid values for $filter are: + /// 'atScope()', 'atExactScope()', 'excludeExpired()' or 'policyAssignmentId eq + /// '{value}''. If $filter is not provided, the unfiltered list includes all + /// policy exemptions associated with the resource, including those that apply + /// directly or from all containing scopes, as well as any applied to resources + /// contained within the resource. Three parameters plus the resource name are + /// used to identify a specific resource. If the resource is not part of a + /// parent resource (the more common case), the parent resource path should not + /// be provided (or provided as ''). For example a web app could be specified + /// as ({resourceProviderNamespace} == 'Microsoft.Web', {parentResourcePath} == + /// '', {resourceType} == 'sites', {resourceName} == 'MyWebApp'). If the + /// resource is part of a parent resource, then all parameters should be + /// provided. For example a virtual machine DNS name could be specified as + /// ({resourceProviderNamespace} == 'Microsoft.Compute', {parentResourcePath} + /// == 'virtualMachines/MyVirtualMachine', {resourceType} == 'domainNames', + /// {resourceName} == 'MyComputerName'). A convenient alternative to providing + /// the namespace and type name separately is to provide both in the + /// {resourceType} parameter, format: ({resourceProviderNamespace} == '', + /// {parentResourcePath} == '', {resourceType} == 'Microsoft.Web/sites', + /// {resourceName} == 'MyWebApp'). + /// + /// + /// 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>> ListForResourceNextWithHttpMessagesAsync(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, "ListForResourceNext", 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; + } + + /// + /// Retrieves all policy exemptions that apply to a management group. + /// + /// + /// This operation retrieves the list of all policy exemptions applicable to + /// the management group that match the given $filter. Valid values for $filter + /// are: 'atScope()', 'atExactScope()', 'excludeExpired()' or + /// 'policyAssignmentId eq '{value}''. If $filter=atScope() is provided, the + /// returned list includes all policy exemptions that are assigned to the + /// management group or the management group's ancestors. + /// + /// + /// 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>> ListForManagementGroupNextWithHttpMessagesAsync(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, "ListForManagementGroupNext", 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/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/PolicyExemptionsOperationsExtensions.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/PolicyExemptionsOperationsExtensions.cs new file mode 100644 index 0000000000000..250cb6d468efd --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/PolicyExemptionsOperationsExtensions.cs @@ -0,0 +1,864 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for PolicyExemptionsOperations. + /// + public static partial class PolicyExemptionsOperationsExtensions + { + /// + /// Deletes a policy exemption. + /// + /// + /// This operation deletes a policy exemption, given its name and the scope it + /// was created in. The scope of a policy exemption is the part of its ID + /// preceding + /// '/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}'. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope of the policy exemption. Valid scopes are: management group + /// (format: + /// '/providers/Microsoft.Management/managementGroups/{managementGroup}'), + /// subscription (format: '/subscriptions/{subscriptionId}'), resource group + /// (format: + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or + /// resource (format: + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' + /// + /// + /// The name of the policy exemption to delete. + /// + public static void Delete(this IPolicyExemptionsOperations operations, string scope, string policyExemptionName) + { + operations.DeleteAsync(scope, policyExemptionName).GetAwaiter().GetResult(); + } + + /// + /// Deletes a policy exemption. + /// + /// + /// This operation deletes a policy exemption, given its name and the scope it + /// was created in. The scope of a policy exemption is the part of its ID + /// preceding + /// '/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}'. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope of the policy exemption. Valid scopes are: management group + /// (format: + /// '/providers/Microsoft.Management/managementGroups/{managementGroup}'), + /// subscription (format: '/subscriptions/{subscriptionId}'), resource group + /// (format: + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or + /// resource (format: + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' + /// + /// + /// The name of the policy exemption to delete. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this IPolicyExemptionsOperations operations, string scope, string policyExemptionName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(scope, policyExemptionName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Creates or updates a policy exemption. + /// + /// + /// This operation creates or updates a policy exemption with the given scope + /// and name. Policy exemptions apply to all resources contained within their + /// scope. For example, when you create a policy exemption at resource group + /// scope for a policy assignment at the same or above level, the exemption + /// exempts to all applicable resources in the resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope of the policy exemption. Valid scopes are: management group + /// (format: + /// '/providers/Microsoft.Management/managementGroups/{managementGroup}'), + /// subscription (format: '/subscriptions/{subscriptionId}'), resource group + /// (format: + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or + /// resource (format: + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' + /// + /// + /// The name of the policy exemption to delete. + /// + /// + /// Parameters for the policy exemption. + /// + public static PolicyExemption CreateOrUpdate(this IPolicyExemptionsOperations operations, string scope, string policyExemptionName, PolicyExemption parameters) + { + return operations.CreateOrUpdateAsync(scope, policyExemptionName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Creates or updates a policy exemption. + /// + /// + /// This operation creates or updates a policy exemption with the given scope + /// and name. Policy exemptions apply to all resources contained within their + /// scope. For example, when you create a policy exemption at resource group + /// scope for a policy assignment at the same or above level, the exemption + /// exempts to all applicable resources in the resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope of the policy exemption. Valid scopes are: management group + /// (format: + /// '/providers/Microsoft.Management/managementGroups/{managementGroup}'), + /// subscription (format: '/subscriptions/{subscriptionId}'), resource group + /// (format: + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or + /// resource (format: + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' + /// + /// + /// The name of the policy exemption to delete. + /// + /// + /// Parameters for the policy exemption. + /// + /// + /// The cancellation token. + /// + public static async Task CreateOrUpdateAsync(this IPolicyExemptionsOperations operations, string scope, string policyExemptionName, PolicyExemption parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(scope, policyExemptionName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Retrieves a policy exemption. + /// + /// + /// This operation retrieves a single policy exemption, given its name and the + /// scope it was created at. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope of the policy exemption. Valid scopes are: management group + /// (format: + /// '/providers/Microsoft.Management/managementGroups/{managementGroup}'), + /// subscription (format: '/subscriptions/{subscriptionId}'), resource group + /// (format: + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or + /// resource (format: + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' + /// + /// + /// The name of the policy exemption to delete. + /// + public static PolicyExemption Get(this IPolicyExemptionsOperations operations, string scope, string policyExemptionName) + { + return operations.GetAsync(scope, policyExemptionName).GetAwaiter().GetResult(); + } + + /// + /// Retrieves a policy exemption. + /// + /// + /// This operation retrieves a single policy exemption, given its name and the + /// scope it was created at. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope of the policy exemption. Valid scopes are: management group + /// (format: + /// '/providers/Microsoft.Management/managementGroups/{managementGroup}'), + /// subscription (format: '/subscriptions/{subscriptionId}'), resource group + /// (format: + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or + /// resource (format: + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' + /// + /// + /// The name of the policy exemption to delete. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IPolicyExemptionsOperations operations, string scope, string policyExemptionName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(scope, policyExemptionName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Retrieves all policy exemptions that apply to a subscription. + /// + /// + /// This operation retrieves the list of all policy exemptions associated with + /// the given subscription that match the optional given $filter. Valid values + /// for $filter are: 'atScope()', 'atExactScope()', 'excludeExpired()' or + /// 'policyAssignmentId eq '{value}''. If $filter is not provided, the + /// unfiltered list includes all policy exemptions associated with the + /// subscription, including those that apply directly or from management groups + /// that contain the given subscription, as well as any applied to objects + /// contained within the subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The filter to apply on the operation. Valid values for $filter are: + /// 'atScope()', 'atExactScope()', 'excludeExpired()' or 'policyAssignmentId eq + /// '{value}''. If $filter is not provided, no filtering is performed. If + /// $filter is not provided, the unfiltered list includes all policy exemptions + /// associated with the scope, including those that apply directly or apply + /// from containing scopes. If $filter=atScope() is provided, the returned list + /// only includes all policy exemptions that apply to the scope, which is + /// everything in the unfiltered list except those applied to sub scopes + /// contained within the given scope. If $filter=atExactScope() is provided, + /// the returned list only includes all policy exemptions that at the given + /// scope. If $filter=excludeExpired() is provided, the returned list only + /// includes all policy exemptions that either haven't expired or didn't set + /// expiration date. If $filter=policyAssignmentId eq '{value}' is provided. + /// the returned list only includes all policy exemptions that are associated + /// with the give policyAssignmentId. + /// + public static IPage List(this IPolicyExemptionsOperations operations, string filter = default(string)) + { + return operations.ListAsync(filter).GetAwaiter().GetResult(); + } + + /// + /// Retrieves all policy exemptions that apply to a subscription. + /// + /// + /// This operation retrieves the list of all policy exemptions associated with + /// the given subscription that match the optional given $filter. Valid values + /// for $filter are: 'atScope()', 'atExactScope()', 'excludeExpired()' or + /// 'policyAssignmentId eq '{value}''. If $filter is not provided, the + /// unfiltered list includes all policy exemptions associated with the + /// subscription, including those that apply directly or from management groups + /// that contain the given subscription, as well as any applied to objects + /// contained within the subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The filter to apply on the operation. Valid values for $filter are: + /// 'atScope()', 'atExactScope()', 'excludeExpired()' or 'policyAssignmentId eq + /// '{value}''. If $filter is not provided, no filtering is performed. If + /// $filter is not provided, the unfiltered list includes all policy exemptions + /// associated with the scope, including those that apply directly or apply + /// from containing scopes. If $filter=atScope() is provided, the returned list + /// only includes all policy exemptions that apply to the scope, which is + /// everything in the unfiltered list except those applied to sub scopes + /// contained within the given scope. If $filter=atExactScope() is provided, + /// the returned list only includes all policy exemptions that at the given + /// scope. If $filter=excludeExpired() is provided, the returned list only + /// includes all policy exemptions that either haven't expired or didn't set + /// expiration date. If $filter=policyAssignmentId eq '{value}' is provided. + /// the returned list only includes all policy exemptions that are associated + /// with the give policyAssignmentId. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAsync(this IPolicyExemptionsOperations operations, string filter = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(filter, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Retrieves all policy exemptions that apply to a resource group. + /// + /// + /// This operation retrieves the list of all policy exemptions associated with + /// the given resource group in the given subscription that match the optional + /// given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()', + /// 'excludeExpired()' or 'policyAssignmentId eq '{value}''. If $filter is not + /// provided, the unfiltered list includes all policy exemptions associated + /// with the resource group, including those that apply directly or apply from + /// containing scopes, as well as any applied to resources contained within the + /// resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group containing the resource. + /// + /// + /// The filter to apply on the operation. Valid values for $filter are: + /// 'atScope()', 'atExactScope()', 'excludeExpired()' or 'policyAssignmentId eq + /// '{value}''. If $filter is not provided, no filtering is performed. If + /// $filter is not provided, the unfiltered list includes all policy exemptions + /// associated with the scope, including those that apply directly or apply + /// from containing scopes. If $filter=atScope() is provided, the returned list + /// only includes all policy exemptions that apply to the scope, which is + /// everything in the unfiltered list except those applied to sub scopes + /// contained within the given scope. If $filter=atExactScope() is provided, + /// the returned list only includes all policy exemptions that at the given + /// scope. If $filter=excludeExpired() is provided, the returned list only + /// includes all policy exemptions that either haven't expired or didn't set + /// expiration date. If $filter=policyAssignmentId eq '{value}' is provided. + /// the returned list only includes all policy exemptions that are associated + /// with the give policyAssignmentId. + /// + public static IPage ListForResourceGroup(this IPolicyExemptionsOperations operations, string resourceGroupName, string filter = default(string)) + { + return operations.ListForResourceGroupAsync(resourceGroupName, filter).GetAwaiter().GetResult(); + } + + /// + /// Retrieves all policy exemptions that apply to a resource group. + /// + /// + /// This operation retrieves the list of all policy exemptions associated with + /// the given resource group in the given subscription that match the optional + /// given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()', + /// 'excludeExpired()' or 'policyAssignmentId eq '{value}''. If $filter is not + /// provided, the unfiltered list includes all policy exemptions associated + /// with the resource group, including those that apply directly or apply from + /// containing scopes, as well as any applied to resources contained within the + /// resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group containing the resource. + /// + /// + /// The filter to apply on the operation. Valid values for $filter are: + /// 'atScope()', 'atExactScope()', 'excludeExpired()' or 'policyAssignmentId eq + /// '{value}''. If $filter is not provided, no filtering is performed. If + /// $filter is not provided, the unfiltered list includes all policy exemptions + /// associated with the scope, including those that apply directly or apply + /// from containing scopes. If $filter=atScope() is provided, the returned list + /// only includes all policy exemptions that apply to the scope, which is + /// everything in the unfiltered list except those applied to sub scopes + /// contained within the given scope. If $filter=atExactScope() is provided, + /// the returned list only includes all policy exemptions that at the given + /// scope. If $filter=excludeExpired() is provided, the returned list only + /// includes all policy exemptions that either haven't expired or didn't set + /// expiration date. If $filter=policyAssignmentId eq '{value}' is provided. + /// the returned list only includes all policy exemptions that are associated + /// with the give policyAssignmentId. + /// + /// + /// The cancellation token. + /// + public static async Task> ListForResourceGroupAsync(this IPolicyExemptionsOperations operations, string resourceGroupName, string filter = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListForResourceGroupWithHttpMessagesAsync(resourceGroupName, filter, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Retrieves all policy exemptions that apply to a resource. + /// + /// + /// This operation retrieves the list of all policy exemptions associated with + /// the specified resource in the given resource group and subscription that + /// match the optional given $filter. Valid values for $filter are: + /// 'atScope()', 'atExactScope()', 'excludeExpired()' or 'policyAssignmentId eq + /// '{value}''. If $filter is not provided, the unfiltered list includes all + /// policy exemptions associated with the resource, including those that apply + /// directly or from all containing scopes, as well as any applied to resources + /// contained within the resource. Three parameters plus the resource name are + /// used to identify a specific resource. If the resource is not part of a + /// parent resource (the more common case), the parent resource path should not + /// be provided (or provided as ''). For example a web app could be specified + /// as ({resourceProviderNamespace} == 'Microsoft.Web', {parentResourcePath} == + /// '', {resourceType} == 'sites', {resourceName} == 'MyWebApp'). If the + /// resource is part of a parent resource, then all parameters should be + /// provided. For example a virtual machine DNS name could be specified as + /// ({resourceProviderNamespace} == 'Microsoft.Compute', {parentResourcePath} + /// == 'virtualMachines/MyVirtualMachine', {resourceType} == 'domainNames', + /// {resourceName} == 'MyComputerName'). A convenient alternative to providing + /// the namespace and type name separately is to provide both in the + /// {resourceType} parameter, format: ({resourceProviderNamespace} == '', + /// {parentResourcePath} == '', {resourceType} == 'Microsoft.Web/sites', + /// {resourceName} == 'MyWebApp'). + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group containing the resource. + /// + /// + /// The namespace of the resource provider. For example, the namespace of a + /// virtual machine is Microsoft.Compute (from + /// Microsoft.Compute/virtualMachines) + /// + /// + /// The parent resource path. Use empty string if there is none. + /// + /// + /// The resource type name. For example the type name of a web app is 'sites' + /// (from Microsoft.Web/sites). + /// + /// + /// The name of the resource. + /// + /// + /// The filter to apply on the operation. Valid values for $filter are: + /// 'atScope()', 'atExactScope()', 'excludeExpired()' or 'policyAssignmentId eq + /// '{value}''. If $filter is not provided, no filtering is performed. If + /// $filter is not provided, the unfiltered list includes all policy exemptions + /// associated with the scope, including those that apply directly or apply + /// from containing scopes. If $filter=atScope() is provided, the returned list + /// only includes all policy exemptions that apply to the scope, which is + /// everything in the unfiltered list except those applied to sub scopes + /// contained within the given scope. If $filter=atExactScope() is provided, + /// the returned list only includes all policy exemptions that at the given + /// scope. If $filter=excludeExpired() is provided, the returned list only + /// includes all policy exemptions that either haven't expired or didn't set + /// expiration date. If $filter=policyAssignmentId eq '{value}' is provided. + /// the returned list only includes all policy exemptions that are associated + /// with the give policyAssignmentId. + /// + public static IPage ListForResource(this IPolicyExemptionsOperations operations, string resourceGroupName, string resourceProviderNamespace, string parentResourcePath, string resourceType, string resourceName, string filter = default(string)) + { + return operations.ListForResourceAsync(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, filter).GetAwaiter().GetResult(); + } + + /// + /// Retrieves all policy exemptions that apply to a resource. + /// + /// + /// This operation retrieves the list of all policy exemptions associated with + /// the specified resource in the given resource group and subscription that + /// match the optional given $filter. Valid values for $filter are: + /// 'atScope()', 'atExactScope()', 'excludeExpired()' or 'policyAssignmentId eq + /// '{value}''. If $filter is not provided, the unfiltered list includes all + /// policy exemptions associated with the resource, including those that apply + /// directly or from all containing scopes, as well as any applied to resources + /// contained within the resource. Three parameters plus the resource name are + /// used to identify a specific resource. If the resource is not part of a + /// parent resource (the more common case), the parent resource path should not + /// be provided (or provided as ''). For example a web app could be specified + /// as ({resourceProviderNamespace} == 'Microsoft.Web', {parentResourcePath} == + /// '', {resourceType} == 'sites', {resourceName} == 'MyWebApp'). If the + /// resource is part of a parent resource, then all parameters should be + /// provided. For example a virtual machine DNS name could be specified as + /// ({resourceProviderNamespace} == 'Microsoft.Compute', {parentResourcePath} + /// == 'virtualMachines/MyVirtualMachine', {resourceType} == 'domainNames', + /// {resourceName} == 'MyComputerName'). A convenient alternative to providing + /// the namespace and type name separately is to provide both in the + /// {resourceType} parameter, format: ({resourceProviderNamespace} == '', + /// {parentResourcePath} == '', {resourceType} == 'Microsoft.Web/sites', + /// {resourceName} == 'MyWebApp'). + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group containing the resource. + /// + /// + /// The namespace of the resource provider. For example, the namespace of a + /// virtual machine is Microsoft.Compute (from + /// Microsoft.Compute/virtualMachines) + /// + /// + /// The parent resource path. Use empty string if there is none. + /// + /// + /// The resource type name. For example the type name of a web app is 'sites' + /// (from Microsoft.Web/sites). + /// + /// + /// The name of the resource. + /// + /// + /// The filter to apply on the operation. Valid values for $filter are: + /// 'atScope()', 'atExactScope()', 'excludeExpired()' or 'policyAssignmentId eq + /// '{value}''. If $filter is not provided, no filtering is performed. If + /// $filter is not provided, the unfiltered list includes all policy exemptions + /// associated with the scope, including those that apply directly or apply + /// from containing scopes. If $filter=atScope() is provided, the returned list + /// only includes all policy exemptions that apply to the scope, which is + /// everything in the unfiltered list except those applied to sub scopes + /// contained within the given scope. If $filter=atExactScope() is provided, + /// the returned list only includes all policy exemptions that at the given + /// scope. If $filter=excludeExpired() is provided, the returned list only + /// includes all policy exemptions that either haven't expired or didn't set + /// expiration date. If $filter=policyAssignmentId eq '{value}' is provided. + /// the returned list only includes all policy exemptions that are associated + /// with the give policyAssignmentId. + /// + /// + /// The cancellation token. + /// + public static async Task> ListForResourceAsync(this IPolicyExemptionsOperations operations, string resourceGroupName, string resourceProviderNamespace, string parentResourcePath, string resourceType, string resourceName, string filter = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListForResourceWithHttpMessagesAsync(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, filter, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Retrieves all policy exemptions that apply to a management group. + /// + /// + /// This operation retrieves the list of all policy exemptions applicable to + /// the management group that match the given $filter. Valid values for $filter + /// are: 'atScope()', 'atExactScope()', 'excludeExpired()' or + /// 'policyAssignmentId eq '{value}''. If $filter=atScope() is provided, the + /// returned list includes all policy exemptions that are assigned to the + /// management group or the management group's ancestors. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The ID of the management group. + /// + /// + /// The filter to apply on the operation. Valid values for $filter are: + /// 'atScope()', 'atExactScope()', 'excludeExpired()' or 'policyAssignmentId eq + /// '{value}''. If $filter is not provided, no filtering is performed. If + /// $filter is not provided, the unfiltered list includes all policy exemptions + /// associated with the scope, including those that apply directly or apply + /// from containing scopes. If $filter=atScope() is provided, the returned list + /// only includes all policy exemptions that apply to the scope, which is + /// everything in the unfiltered list except those applied to sub scopes + /// contained within the given scope. If $filter=atExactScope() is provided, + /// the returned list only includes all policy exemptions that at the given + /// scope. If $filter=excludeExpired() is provided, the returned list only + /// includes all policy exemptions that either haven't expired or didn't set + /// expiration date. If $filter=policyAssignmentId eq '{value}' is provided. + /// the returned list only includes all policy exemptions that are associated + /// with the give policyAssignmentId. + /// + public static IPage ListForManagementGroup(this IPolicyExemptionsOperations operations, string managementGroupId, string filter = default(string)) + { + return operations.ListForManagementGroupAsync(managementGroupId, filter).GetAwaiter().GetResult(); + } + + /// + /// Retrieves all policy exemptions that apply to a management group. + /// + /// + /// This operation retrieves the list of all policy exemptions applicable to + /// the management group that match the given $filter. Valid values for $filter + /// are: 'atScope()', 'atExactScope()', 'excludeExpired()' or + /// 'policyAssignmentId eq '{value}''. If $filter=atScope() is provided, the + /// returned list includes all policy exemptions that are assigned to the + /// management group or the management group's ancestors. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The ID of the management group. + /// + /// + /// The filter to apply on the operation. Valid values for $filter are: + /// 'atScope()', 'atExactScope()', 'excludeExpired()' or 'policyAssignmentId eq + /// '{value}''. If $filter is not provided, no filtering is performed. If + /// $filter is not provided, the unfiltered list includes all policy exemptions + /// associated with the scope, including those that apply directly or apply + /// from containing scopes. If $filter=atScope() is provided, the returned list + /// only includes all policy exemptions that apply to the scope, which is + /// everything in the unfiltered list except those applied to sub scopes + /// contained within the given scope. If $filter=atExactScope() is provided, + /// the returned list only includes all policy exemptions that at the given + /// scope. If $filter=excludeExpired() is provided, the returned list only + /// includes all policy exemptions that either haven't expired or didn't set + /// expiration date. If $filter=policyAssignmentId eq '{value}' is provided. + /// the returned list only includes all policy exemptions that are associated + /// with the give policyAssignmentId. + /// + /// + /// The cancellation token. + /// + public static async Task> ListForManagementGroupAsync(this IPolicyExemptionsOperations operations, string managementGroupId, string filter = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListForManagementGroupWithHttpMessagesAsync(managementGroupId, filter, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Retrieves all policy exemptions that apply to a subscription. + /// + /// + /// This operation retrieves the list of all policy exemptions associated with + /// the given subscription that match the optional given $filter. Valid values + /// for $filter are: 'atScope()', 'atExactScope()', 'excludeExpired()' or + /// 'policyAssignmentId eq '{value}''. If $filter is not provided, the + /// unfiltered list includes all policy exemptions associated with the + /// subscription, including those that apply directly or from management groups + /// that contain the given subscription, as well as any applied to objects + /// contained within the subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListNext(this IPolicyExemptionsOperations operations, string nextPageLink) + { + return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Retrieves all policy exemptions that apply to a subscription. + /// + /// + /// This operation retrieves the list of all policy exemptions associated with + /// the given subscription that match the optional given $filter. Valid values + /// for $filter are: 'atScope()', 'atExactScope()', 'excludeExpired()' or + /// 'policyAssignmentId eq '{value}''. If $filter is not provided, the + /// unfiltered list includes all policy exemptions associated with the + /// subscription, including those that apply directly or from management groups + /// that contain the given subscription, as well as any applied to objects + /// contained within the 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 IPolicyExemptionsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Retrieves all policy exemptions that apply to a resource group. + /// + /// + /// This operation retrieves the list of all policy exemptions associated with + /// the given resource group in the given subscription that match the optional + /// given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()', + /// 'excludeExpired()' or 'policyAssignmentId eq '{value}''. If $filter is not + /// provided, the unfiltered list includes all policy exemptions associated + /// with the resource group, including those that apply directly or apply from + /// containing scopes, as well as any applied to resources contained within the + /// resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListForResourceGroupNext(this IPolicyExemptionsOperations operations, string nextPageLink) + { + return operations.ListForResourceGroupNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Retrieves all policy exemptions that apply to a resource group. + /// + /// + /// This operation retrieves the list of all policy exemptions associated with + /// the given resource group in the given subscription that match the optional + /// given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()', + /// 'excludeExpired()' or 'policyAssignmentId eq '{value}''. If $filter is not + /// provided, the unfiltered list includes all policy exemptions associated + /// with the resource group, including those that apply directly or apply from + /// containing scopes, as well as any applied to resources contained within the + /// 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> ListForResourceGroupNextAsync(this IPolicyExemptionsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListForResourceGroupNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Retrieves all policy exemptions that apply to a resource. + /// + /// + /// This operation retrieves the list of all policy exemptions associated with + /// the specified resource in the given resource group and subscription that + /// match the optional given $filter. Valid values for $filter are: + /// 'atScope()', 'atExactScope()', 'excludeExpired()' or 'policyAssignmentId eq + /// '{value}''. If $filter is not provided, the unfiltered list includes all + /// policy exemptions associated with the resource, including those that apply + /// directly or from all containing scopes, as well as any applied to resources + /// contained within the resource. Three parameters plus the resource name are + /// used to identify a specific resource. If the resource is not part of a + /// parent resource (the more common case), the parent resource path should not + /// be provided (or provided as ''). For example a web app could be specified + /// as ({resourceProviderNamespace} == 'Microsoft.Web', {parentResourcePath} == + /// '', {resourceType} == 'sites', {resourceName} == 'MyWebApp'). If the + /// resource is part of a parent resource, then all parameters should be + /// provided. For example a virtual machine DNS name could be specified as + /// ({resourceProviderNamespace} == 'Microsoft.Compute', {parentResourcePath} + /// == 'virtualMachines/MyVirtualMachine', {resourceType} == 'domainNames', + /// {resourceName} == 'MyComputerName'). A convenient alternative to providing + /// the namespace and type name separately is to provide both in the + /// {resourceType} parameter, format: ({resourceProviderNamespace} == '', + /// {parentResourcePath} == '', {resourceType} == 'Microsoft.Web/sites', + /// {resourceName} == 'MyWebApp'). + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListForResourceNext(this IPolicyExemptionsOperations operations, string nextPageLink) + { + return operations.ListForResourceNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Retrieves all policy exemptions that apply to a resource. + /// + /// + /// This operation retrieves the list of all policy exemptions associated with + /// the specified resource in the given resource group and subscription that + /// match the optional given $filter. Valid values for $filter are: + /// 'atScope()', 'atExactScope()', 'excludeExpired()' or 'policyAssignmentId eq + /// '{value}''. If $filter is not provided, the unfiltered list includes all + /// policy exemptions associated with the resource, including those that apply + /// directly or from all containing scopes, as well as any applied to resources + /// contained within the resource. Three parameters plus the resource name are + /// used to identify a specific resource. If the resource is not part of a + /// parent resource (the more common case), the parent resource path should not + /// be provided (or provided as ''). For example a web app could be specified + /// as ({resourceProviderNamespace} == 'Microsoft.Web', {parentResourcePath} == + /// '', {resourceType} == 'sites', {resourceName} == 'MyWebApp'). If the + /// resource is part of a parent resource, then all parameters should be + /// provided. For example a virtual machine DNS name could be specified as + /// ({resourceProviderNamespace} == 'Microsoft.Compute', {parentResourcePath} + /// == 'virtualMachines/MyVirtualMachine', {resourceType} == 'domainNames', + /// {resourceName} == 'MyComputerName'). A convenient alternative to providing + /// the namespace and type name separately is to provide both in the + /// {resourceType} parameter, format: ({resourceProviderNamespace} == '', + /// {parentResourcePath} == '', {resourceType} == 'Microsoft.Web/sites', + /// {resourceName} == 'MyWebApp'). + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListForResourceNextAsync(this IPolicyExemptionsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListForResourceNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Retrieves all policy exemptions that apply to a management group. + /// + /// + /// This operation retrieves the list of all policy exemptions applicable to + /// the management group that match the given $filter. Valid values for $filter + /// are: 'atScope()', 'atExactScope()', 'excludeExpired()' or + /// 'policyAssignmentId eq '{value}''. If $filter=atScope() is provided, the + /// returned list includes all policy exemptions that are assigned to the + /// management group or the management group's ancestors. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListForManagementGroupNext(this IPolicyExemptionsOperations operations, string nextPageLink) + { + return operations.ListForManagementGroupNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Retrieves all policy exemptions that apply to a management group. + /// + /// + /// This operation retrieves the list of all policy exemptions applicable to + /// the management group that match the given $filter. Valid values for $filter + /// are: 'atScope()', 'atExactScope()', 'excludeExpired()' or + /// 'policyAssignmentId eq '{value}''. If $filter=atScope() is provided, the + /// returned list includes all policy exemptions that are assigned to the + /// management group or the management group's ancestors. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListForManagementGroupNextAsync(this IPolicyExemptionsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListForManagementGroupNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/PolicySetDefinitionsOperations.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/PolicySetDefinitionsOperations.cs new file mode 100644 index 0000000000000..fd22a1421eff7 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/PolicySetDefinitionsOperations.cs @@ -0,0 +1,2628 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager +{ + 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; + + /// + /// PolicySetDefinitionsOperations operations. + /// + internal partial class PolicySetDefinitionsOperations : IServiceOperations, IPolicySetDefinitionsOperations + { + /// + /// Initializes a new instance of the PolicySetDefinitionsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal PolicySetDefinitionsOperations(PolicyClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the PolicyClient + /// + public PolicyClient Client { get; private set; } + + /// + /// Creates or updates a policy set definition. + /// + /// + /// This operation creates or updates a policy set definition in the given + /// subscription with the given name. + /// + /// + /// The name of the policy set definition to create. + /// + /// + /// The policy set definition properties. + /// + /// + /// 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> CreateOrUpdateWithHttpMessagesAsync(string policySetDefinitionName, PolicySetDefinition parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (policySetDefinitionName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "policySetDefinitionName"); + } + 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"); + } + string apiVersion = "2021-06-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("policySetDefinitionName", policySetDefinitionName); + tracingParameters.Add("parameters", parameters); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "CreateOrUpdate", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}").ToString(); + _url = _url.Replace("{policySetDefinitionName}", System.Uri.EscapeDataString(policySetDefinitionName)); + _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 != 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; + } + + /// + /// Deletes a policy set definition. + /// + /// + /// This operation deletes the policy set definition in the given subscription + /// with the given name. + /// + /// + /// The name of the policy set definition to delete. + /// + /// + /// 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 DeleteWithHttpMessagesAsync(string policySetDefinitionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (policySetDefinitionName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "policySetDefinitionName"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + string apiVersion = "2021-06-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("policySetDefinitionName", policySetDefinitionName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Delete", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}").ToString(); + _url = _url.Replace("{policySetDefinitionName}", System.Uri.EscapeDataString(policySetDefinitionName)); + _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 != 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; + } + + /// + /// Retrieves a policy set definition. + /// + /// + /// This operation retrieves the policy set definition in the given + /// subscription with the given name. + /// + /// + /// The name of the policy set definition to get. + /// + /// + /// 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 policySetDefinitionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (policySetDefinitionName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "policySetDefinitionName"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + string apiVersion = "2021-06-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("policySetDefinitionName", policySetDefinitionName); + 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}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}").ToString(); + _url = _url.Replace("{policySetDefinitionName}", System.Uri.EscapeDataString(policySetDefinitionName)); + _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; + } + + /// + /// Retrieves a built in policy set definition. + /// + /// + /// This operation retrieves the built-in policy set definition with the given + /// name. + /// + /// + /// The name of the policy set definition to get. + /// + /// + /// 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> GetBuiltInWithHttpMessagesAsync(string policySetDefinitionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (policySetDefinitionName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "policySetDefinitionName"); + } + string apiVersion = "2021-06-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("policySetDefinitionName", policySetDefinitionName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetBuiltIn", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}").ToString(); + _url = _url.Replace("{policySetDefinitionName}", System.Uri.EscapeDataString(policySetDefinitionName)); + 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; + } + + /// + /// Retrieves the policy set definitions for a subscription. + /// + /// + /// This operation retrieves a list of all the policy set definitions in a + /// given subscription that match the optional given $filter. Valid values for + /// $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq + /// '{value}''. If $filter is not provided, the unfiltered list includes all + /// policy set definitions associated with the subscription, including those + /// that apply directly or from management groups that contain the given + /// subscription. If $filter=atExactScope() is provided, the returned list only + /// includes all policy set definitions that at the given subscription. If + /// $filter='policyType -eq {value}' is provided, the returned list only + /// includes all policy set definitions whose type match the {value}. Possible + /// policyType values are NotSpecified, BuiltIn and Custom. If + /// $filter='category -eq {value}' is provided, the returned list only includes + /// all policy set definitions whose category match the {value}. + /// + /// + /// The filter to apply on the operation. Valid values for $filter are: + /// 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If + /// $filter is not provided, no filtering is performed. If + /// $filter=atExactScope() is provided, the returned list only includes all + /// policy set definitions that at the given scope. If $filter='policyType -eq + /// {value}' is provided, the returned list only includes all policy set + /// definitions whose type match the {value}. Possible policyType values are + /// NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq + /// {value}' is provided, the returned list only includes all policy set + /// definitions whose category match the {value}. + /// + /// + /// Maximum number of records to return. When the $top filter is not provided, + /// it will return 500 records. + /// + /// + /// 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 filter = default(string), int? top = default(int?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (top > 1000) + { + throw new ValidationException(ValidationRules.InclusiveMaximum, "top", 1000); + } + if (top < 1) + { + throw new ValidationException(ValidationRules.InclusiveMinimum, "top", 1); + } + string apiVersion = "2021-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("filter", filter); + tracingParameters.Add("top", top); + 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.Authorization/policySetDefinitions").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 (filter != null) + { + _queryParameters.Add(string.Format("$filter={0}", filter)); + } + if (top != null) + { + _queryParameters.Add(string.Format("$top={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(top, Client.SerializationSettings).Trim('"')))); + } + 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; + } + + /// + /// Retrieves built-in policy set definitions. + /// + /// + /// This operation retrieves a list of all the built-in policy set definitions + /// that match the optional given $filter. If $filter='category -eq {value}' is + /// provided, the returned list only includes all built-in policy set + /// definitions whose category match the {value}. + /// + /// + /// The filter to apply on the operation. Valid values for $filter are: + /// 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If + /// $filter is not provided, no filtering is performed. If + /// $filter=atExactScope() is provided, the returned list only includes all + /// policy set definitions that at the given scope. If $filter='policyType -eq + /// {value}' is provided, the returned list only includes all policy set + /// definitions whose type match the {value}. Possible policyType values are + /// NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq + /// {value}' is provided, the returned list only includes all policy set + /// definitions whose category match the {value}. + /// + /// + /// Maximum number of records to return. When the $top filter is not provided, + /// it will return 500 records. + /// + /// + /// 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>> ListBuiltInWithHttpMessagesAsync(string filter = default(string), int? top = default(int?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (top > 1000) + { + throw new ValidationException(ValidationRules.InclusiveMaximum, "top", 1000); + } + if (top < 1) + { + throw new ValidationException(ValidationRules.InclusiveMinimum, "top", 1); + } + string apiVersion = "2021-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("filter", filter); + tracingParameters.Add("top", top); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListBuiltIn", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Authorization/policySetDefinitions").ToString(); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (filter != null) + { + _queryParameters.Add(string.Format("$filter={0}", filter)); + } + if (top != null) + { + _queryParameters.Add(string.Format("$top={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(top, Client.SerializationSettings).Trim('"')))); + } + 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 policy set definition. + /// + /// + /// This operation creates or updates a policy set definition in the given + /// management group with the given name. + /// + /// + /// The name of the policy set definition to create. + /// + /// + /// The policy set definition properties. + /// + /// + /// The ID of the management group. + /// + /// + /// 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> CreateOrUpdateAtManagementGroupWithHttpMessagesAsync(string policySetDefinitionName, PolicySetDefinition parameters, string managementGroupId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (policySetDefinitionName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "policySetDefinitionName"); + } + if (parameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); + } + if (parameters != null) + { + parameters.Validate(); + } + if (managementGroupId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "managementGroupId"); + } + string apiVersion = "2021-06-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("policySetDefinitionName", policySetDefinitionName); + tracingParameters.Add("parameters", parameters); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("managementGroupId", managementGroupId); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "CreateOrUpdateAtManagementGroup", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}").ToString(); + _url = _url.Replace("{policySetDefinitionName}", System.Uri.EscapeDataString(policySetDefinitionName)); + _url = _url.Replace("{managementGroupId}", System.Uri.EscapeDataString(managementGroupId)); + 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) + { + 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 policy set definition. + /// + /// + /// This operation deletes the policy set definition in the given management + /// group with the given name. + /// + /// + /// The name of the policy set definition to delete. + /// + /// + /// The ID of the management group. + /// + /// + /// 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 DeleteAtManagementGroupWithHttpMessagesAsync(string policySetDefinitionName, string managementGroupId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (policySetDefinitionName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "policySetDefinitionName"); + } + if (managementGroupId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "managementGroupId"); + } + string apiVersion = "2021-06-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("policySetDefinitionName", policySetDefinitionName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("managementGroupId", managementGroupId); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "DeleteAtManagementGroup", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}").ToString(); + _url = _url.Replace("{policySetDefinitionName}", System.Uri.EscapeDataString(policySetDefinitionName)); + _url = _url.Replace("{managementGroupId}", System.Uri.EscapeDataString(managementGroupId)); + 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 != 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; + } + + /// + /// Retrieves a policy set definition. + /// + /// + /// This operation retrieves the policy set definition in the given management + /// group with the given name. + /// + /// + /// The name of the policy set definition to get. + /// + /// + /// The ID of the management group. + /// + /// + /// 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> GetAtManagementGroupWithHttpMessagesAsync(string policySetDefinitionName, string managementGroupId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (policySetDefinitionName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "policySetDefinitionName"); + } + if (managementGroupId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "managementGroupId"); + } + string apiVersion = "2021-06-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("policySetDefinitionName", policySetDefinitionName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("managementGroupId", managementGroupId); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetAtManagementGroup", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}").ToString(); + _url = _url.Replace("{policySetDefinitionName}", System.Uri.EscapeDataString(policySetDefinitionName)); + _url = _url.Replace("{managementGroupId}", System.Uri.EscapeDataString(managementGroupId)); + 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; + } + + /// + /// Retrieves all policy set definitions in management group. + /// + /// + /// This operation retrieves a list of all the policy set definitions in a + /// given management group that match the optional given $filter. Valid values + /// for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq + /// '{value}''. If $filter is not provided, the unfiltered list includes all + /// policy set definitions associated with the management group, including + /// those that apply directly or from management groups that contain the given + /// management group. If $filter=atExactScope() is provided, the returned list + /// only includes all policy set definitions that at the given management + /// group. If $filter='policyType -eq {value}' is provided, the returned list + /// only includes all policy set definitions whose type match the {value}. + /// Possible policyType values are NotSpecified, BuiltIn and Custom. If + /// $filter='category -eq {value}' is provided, the returned list only includes + /// all policy set definitions whose category match the {value}. + /// + /// + /// The ID of the management group. + /// + /// + /// The filter to apply on the operation. Valid values for $filter are: + /// 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If + /// $filter is not provided, no filtering is performed. If + /// $filter=atExactScope() is provided, the returned list only includes all + /// policy set definitions that at the given scope. If $filter='policyType -eq + /// {value}' is provided, the returned list only includes all policy set + /// definitions whose type match the {value}. Possible policyType values are + /// NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq + /// {value}' is provided, the returned list only includes all policy set + /// definitions whose category match the {value}. + /// + /// + /// Maximum number of records to return. When the $top filter is not provided, + /// it will return 500 records. + /// + /// + /// 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>> ListByManagementGroupWithHttpMessagesAsync(string managementGroupId, string filter = default(string), int? top = default(int?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (managementGroupId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "managementGroupId"); + } + if (top > 1000) + { + throw new ValidationException(ValidationRules.InclusiveMaximum, "top", 1000); + } + if (top < 1) + { + throw new ValidationException(ValidationRules.InclusiveMinimum, "top", 1); + } + string apiVersion = "2021-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("managementGroupId", managementGroupId); + tracingParameters.Add("filter", filter); + tracingParameters.Add("top", top); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByManagementGroup", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions").ToString(); + _url = _url.Replace("{managementGroupId}", System.Uri.EscapeDataString(managementGroupId)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (filter != null) + { + _queryParameters.Add(string.Format("$filter={0}", filter)); + } + if (top != null) + { + _queryParameters.Add(string.Format("$top={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(top, Client.SerializationSettings).Trim('"')))); + } + 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; + } + + /// + /// Retrieves the policy set definitions for a subscription. + /// + /// + /// This operation retrieves a list of all the policy set definitions in a + /// given subscription that match the optional given $filter. Valid values for + /// $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq + /// '{value}''. If $filter is not provided, the unfiltered list includes all + /// policy set definitions associated with the subscription, including those + /// that apply directly or from management groups that contain the given + /// subscription. If $filter=atExactScope() is provided, the returned list only + /// includes all policy set definitions that at the given subscription. If + /// $filter='policyType -eq {value}' is provided, the returned list only + /// includes all policy set definitions whose type match the {value}. Possible + /// policyType values are NotSpecified, BuiltIn and Custom. If + /// $filter='category -eq {value}' is provided, the returned list only includes + /// all policy set definitions whose category match the {value}. + /// + /// + /// 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 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; + } + + /// + /// Retrieves built-in policy set definitions. + /// + /// + /// This operation retrieves a list of all the built-in policy set definitions + /// that match the optional given $filter. If $filter='category -eq {value}' is + /// provided, the returned list only includes all built-in policy set + /// definitions whose category match the {value}. + /// + /// + /// 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>> ListBuiltInNextWithHttpMessagesAsync(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, "ListBuiltInNext", 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; + } + + /// + /// Retrieves all policy set definitions in management group. + /// + /// + /// This operation retrieves a list of all the policy set definitions in a + /// given management group that match the optional given $filter. Valid values + /// for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq + /// '{value}''. If $filter is not provided, the unfiltered list includes all + /// policy set definitions associated with the management group, including + /// those that apply directly or from management groups that contain the given + /// management group. If $filter=atExactScope() is provided, the returned list + /// only includes all policy set definitions that at the given management + /// group. If $filter='policyType -eq {value}' is provided, the returned list + /// only includes all policy set definitions whose type match the {value}. + /// Possible policyType values are NotSpecified, BuiltIn and Custom. If + /// $filter='category -eq {value}' is provided, the returned list only includes + /// all policy set definitions whose category match the {value}. + /// + /// + /// 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>> ListByManagementGroupNextWithHttpMessagesAsync(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, "ListByManagementGroupNext", 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/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/PolicySetDefinitionsOperationsExtensions.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/PolicySetDefinitionsOperationsExtensions.cs new file mode 100644 index 0000000000000..c978d5991be6f --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/PolicySetDefinitionsOperationsExtensions.cs @@ -0,0 +1,775 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for PolicySetDefinitionsOperations. + /// + public static partial class PolicySetDefinitionsOperationsExtensions + { + /// + /// Creates or updates a policy set definition. + /// + /// + /// This operation creates or updates a policy set definition in the given + /// subscription with the given name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the policy set definition to create. + /// + /// + /// The policy set definition properties. + /// + public static PolicySetDefinition CreateOrUpdate(this IPolicySetDefinitionsOperations operations, string policySetDefinitionName, PolicySetDefinition parameters) + { + return operations.CreateOrUpdateAsync(policySetDefinitionName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Creates or updates a policy set definition. + /// + /// + /// This operation creates or updates a policy set definition in the given + /// subscription with the given name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the policy set definition to create. + /// + /// + /// The policy set definition properties. + /// + /// + /// The cancellation token. + /// + public static async Task CreateOrUpdateAsync(this IPolicySetDefinitionsOperations operations, string policySetDefinitionName, PolicySetDefinition parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(policySetDefinitionName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes a policy set definition. + /// + /// + /// This operation deletes the policy set definition in the given subscription + /// with the given name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the policy set definition to delete. + /// + public static void Delete(this IPolicySetDefinitionsOperations operations, string policySetDefinitionName) + { + operations.DeleteAsync(policySetDefinitionName).GetAwaiter().GetResult(); + } + + /// + /// Deletes a policy set definition. + /// + /// + /// This operation deletes the policy set definition in the given subscription + /// with the given name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the policy set definition to delete. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this IPolicySetDefinitionsOperations operations, string policySetDefinitionName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(policySetDefinitionName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Retrieves a policy set definition. + /// + /// + /// This operation retrieves the policy set definition in the given + /// subscription with the given name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the policy set definition to get. + /// + public static PolicySetDefinition Get(this IPolicySetDefinitionsOperations operations, string policySetDefinitionName) + { + return operations.GetAsync(policySetDefinitionName).GetAwaiter().GetResult(); + } + + /// + /// Retrieves a policy set definition. + /// + /// + /// This operation retrieves the policy set definition in the given + /// subscription with the given name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the policy set definition to get. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IPolicySetDefinitionsOperations operations, string policySetDefinitionName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(policySetDefinitionName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Retrieves a built in policy set definition. + /// + /// + /// This operation retrieves the built-in policy set definition with the given + /// name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the policy set definition to get. + /// + public static PolicySetDefinition GetBuiltIn(this IPolicySetDefinitionsOperations operations, string policySetDefinitionName) + { + return operations.GetBuiltInAsync(policySetDefinitionName).GetAwaiter().GetResult(); + } + + /// + /// Retrieves a built in policy set definition. + /// + /// + /// This operation retrieves the built-in policy set definition with the given + /// name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the policy set definition to get. + /// + /// + /// The cancellation token. + /// + public static async Task GetBuiltInAsync(this IPolicySetDefinitionsOperations operations, string policySetDefinitionName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetBuiltInWithHttpMessagesAsync(policySetDefinitionName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Retrieves the policy set definitions for a subscription. + /// + /// + /// This operation retrieves a list of all the policy set definitions in a + /// given subscription that match the optional given $filter. Valid values for + /// $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq + /// '{value}''. If $filter is not provided, the unfiltered list includes all + /// policy set definitions associated with the subscription, including those + /// that apply directly or from management groups that contain the given + /// subscription. If $filter=atExactScope() is provided, the returned list only + /// includes all policy set definitions that at the given subscription. If + /// $filter='policyType -eq {value}' is provided, the returned list only + /// includes all policy set definitions whose type match the {value}. Possible + /// policyType values are NotSpecified, BuiltIn and Custom. If + /// $filter='category -eq {value}' is provided, the returned list only includes + /// all policy set definitions whose category match the {value}. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The filter to apply on the operation. Valid values for $filter are: + /// 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If + /// $filter is not provided, no filtering is performed. If + /// $filter=atExactScope() is provided, the returned list only includes all + /// policy set definitions that at the given scope. If $filter='policyType -eq + /// {value}' is provided, the returned list only includes all policy set + /// definitions whose type match the {value}. Possible policyType values are + /// NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq + /// {value}' is provided, the returned list only includes all policy set + /// definitions whose category match the {value}. + /// + /// + /// Maximum number of records to return. When the $top filter is not provided, + /// it will return 500 records. + /// + public static IPage List(this IPolicySetDefinitionsOperations operations, string filter = default(string), int? top = default(int?)) + { + return operations.ListAsync(filter, top).GetAwaiter().GetResult(); + } + + /// + /// Retrieves the policy set definitions for a subscription. + /// + /// + /// This operation retrieves a list of all the policy set definitions in a + /// given subscription that match the optional given $filter. Valid values for + /// $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq + /// '{value}''. If $filter is not provided, the unfiltered list includes all + /// policy set definitions associated with the subscription, including those + /// that apply directly or from management groups that contain the given + /// subscription. If $filter=atExactScope() is provided, the returned list only + /// includes all policy set definitions that at the given subscription. If + /// $filter='policyType -eq {value}' is provided, the returned list only + /// includes all policy set definitions whose type match the {value}. Possible + /// policyType values are NotSpecified, BuiltIn and Custom. If + /// $filter='category -eq {value}' is provided, the returned list only includes + /// all policy set definitions whose category match the {value}. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The filter to apply on the operation. Valid values for $filter are: + /// 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If + /// $filter is not provided, no filtering is performed. If + /// $filter=atExactScope() is provided, the returned list only includes all + /// policy set definitions that at the given scope. If $filter='policyType -eq + /// {value}' is provided, the returned list only includes all policy set + /// definitions whose type match the {value}. Possible policyType values are + /// NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq + /// {value}' is provided, the returned list only includes all policy set + /// definitions whose category match the {value}. + /// + /// + /// Maximum number of records to return. When the $top filter is not provided, + /// it will return 500 records. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAsync(this IPolicySetDefinitionsOperations operations, string filter = default(string), int? top = default(int?), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(filter, top, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Retrieves built-in policy set definitions. + /// + /// + /// This operation retrieves a list of all the built-in policy set definitions + /// that match the optional given $filter. If $filter='category -eq {value}' is + /// provided, the returned list only includes all built-in policy set + /// definitions whose category match the {value}. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The filter to apply on the operation. Valid values for $filter are: + /// 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If + /// $filter is not provided, no filtering is performed. If + /// $filter=atExactScope() is provided, the returned list only includes all + /// policy set definitions that at the given scope. If $filter='policyType -eq + /// {value}' is provided, the returned list only includes all policy set + /// definitions whose type match the {value}. Possible policyType values are + /// NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq + /// {value}' is provided, the returned list only includes all policy set + /// definitions whose category match the {value}. + /// + /// + /// Maximum number of records to return. When the $top filter is not provided, + /// it will return 500 records. + /// + public static IPage ListBuiltIn(this IPolicySetDefinitionsOperations operations, string filter = default(string), int? top = default(int?)) + { + return operations.ListBuiltInAsync(filter, top).GetAwaiter().GetResult(); + } + + /// + /// Retrieves built-in policy set definitions. + /// + /// + /// This operation retrieves a list of all the built-in policy set definitions + /// that match the optional given $filter. If $filter='category -eq {value}' is + /// provided, the returned list only includes all built-in policy set + /// definitions whose category match the {value}. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The filter to apply on the operation. Valid values for $filter are: + /// 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If + /// $filter is not provided, no filtering is performed. If + /// $filter=atExactScope() is provided, the returned list only includes all + /// policy set definitions that at the given scope. If $filter='policyType -eq + /// {value}' is provided, the returned list only includes all policy set + /// definitions whose type match the {value}. Possible policyType values are + /// NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq + /// {value}' is provided, the returned list only includes all policy set + /// definitions whose category match the {value}. + /// + /// + /// Maximum number of records to return. When the $top filter is not provided, + /// it will return 500 records. + /// + /// + /// The cancellation token. + /// + public static async Task> ListBuiltInAsync(this IPolicySetDefinitionsOperations operations, string filter = default(string), int? top = default(int?), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListBuiltInWithHttpMessagesAsync(filter, top, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Creates or updates a policy set definition. + /// + /// + /// This operation creates or updates a policy set definition in the given + /// management group with the given name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the policy set definition to create. + /// + /// + /// The policy set definition properties. + /// + /// + /// The ID of the management group. + /// + public static PolicySetDefinition CreateOrUpdateAtManagementGroup(this IPolicySetDefinitionsOperations operations, string policySetDefinitionName, PolicySetDefinition parameters, string managementGroupId) + { + return operations.CreateOrUpdateAtManagementGroupAsync(policySetDefinitionName, parameters, managementGroupId).GetAwaiter().GetResult(); + } + + /// + /// Creates or updates a policy set definition. + /// + /// + /// This operation creates or updates a policy set definition in the given + /// management group with the given name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the policy set definition to create. + /// + /// + /// The policy set definition properties. + /// + /// + /// The ID of the management group. + /// + /// + /// The cancellation token. + /// + public static async Task CreateOrUpdateAtManagementGroupAsync(this IPolicySetDefinitionsOperations operations, string policySetDefinitionName, PolicySetDefinition parameters, string managementGroupId, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateAtManagementGroupWithHttpMessagesAsync(policySetDefinitionName, parameters, managementGroupId, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes a policy set definition. + /// + /// + /// This operation deletes the policy set definition in the given management + /// group with the given name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the policy set definition to delete. + /// + /// + /// The ID of the management group. + /// + public static void DeleteAtManagementGroup(this IPolicySetDefinitionsOperations operations, string policySetDefinitionName, string managementGroupId) + { + operations.DeleteAtManagementGroupAsync(policySetDefinitionName, managementGroupId).GetAwaiter().GetResult(); + } + + /// + /// Deletes a policy set definition. + /// + /// + /// This operation deletes the policy set definition in the given management + /// group with the given name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the policy set definition to delete. + /// + /// + /// The ID of the management group. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAtManagementGroupAsync(this IPolicySetDefinitionsOperations operations, string policySetDefinitionName, string managementGroupId, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteAtManagementGroupWithHttpMessagesAsync(policySetDefinitionName, managementGroupId, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Retrieves a policy set definition. + /// + /// + /// This operation retrieves the policy set definition in the given management + /// group with the given name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the policy set definition to get. + /// + /// + /// The ID of the management group. + /// + public static PolicySetDefinition GetAtManagementGroup(this IPolicySetDefinitionsOperations operations, string policySetDefinitionName, string managementGroupId) + { + return operations.GetAtManagementGroupAsync(policySetDefinitionName, managementGroupId).GetAwaiter().GetResult(); + } + + /// + /// Retrieves a policy set definition. + /// + /// + /// This operation retrieves the policy set definition in the given management + /// group with the given name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the policy set definition to get. + /// + /// + /// The ID of the management group. + /// + /// + /// The cancellation token. + /// + public static async Task GetAtManagementGroupAsync(this IPolicySetDefinitionsOperations operations, string policySetDefinitionName, string managementGroupId, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetAtManagementGroupWithHttpMessagesAsync(policySetDefinitionName, managementGroupId, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Retrieves all policy set definitions in management group. + /// + /// + /// This operation retrieves a list of all the policy set definitions in a + /// given management group that match the optional given $filter. Valid values + /// for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq + /// '{value}''. If $filter is not provided, the unfiltered list includes all + /// policy set definitions associated with the management group, including + /// those that apply directly or from management groups that contain the given + /// management group. If $filter=atExactScope() is provided, the returned list + /// only includes all policy set definitions that at the given management + /// group. If $filter='policyType -eq {value}' is provided, the returned list + /// only includes all policy set definitions whose type match the {value}. + /// Possible policyType values are NotSpecified, BuiltIn and Custom. If + /// $filter='category -eq {value}' is provided, the returned list only includes + /// all policy set definitions whose category match the {value}. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The ID of the management group. + /// + /// + /// The filter to apply on the operation. Valid values for $filter are: + /// 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If + /// $filter is not provided, no filtering is performed. If + /// $filter=atExactScope() is provided, the returned list only includes all + /// policy set definitions that at the given scope. If $filter='policyType -eq + /// {value}' is provided, the returned list only includes all policy set + /// definitions whose type match the {value}. Possible policyType values are + /// NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq + /// {value}' is provided, the returned list only includes all policy set + /// definitions whose category match the {value}. + /// + /// + /// Maximum number of records to return. When the $top filter is not provided, + /// it will return 500 records. + /// + public static IPage ListByManagementGroup(this IPolicySetDefinitionsOperations operations, string managementGroupId, string filter = default(string), int? top = default(int?)) + { + return operations.ListByManagementGroupAsync(managementGroupId, filter, top).GetAwaiter().GetResult(); + } + + /// + /// Retrieves all policy set definitions in management group. + /// + /// + /// This operation retrieves a list of all the policy set definitions in a + /// given management group that match the optional given $filter. Valid values + /// for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq + /// '{value}''. If $filter is not provided, the unfiltered list includes all + /// policy set definitions associated with the management group, including + /// those that apply directly or from management groups that contain the given + /// management group. If $filter=atExactScope() is provided, the returned list + /// only includes all policy set definitions that at the given management + /// group. If $filter='policyType -eq {value}' is provided, the returned list + /// only includes all policy set definitions whose type match the {value}. + /// Possible policyType values are NotSpecified, BuiltIn and Custom. If + /// $filter='category -eq {value}' is provided, the returned list only includes + /// all policy set definitions whose category match the {value}. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The ID of the management group. + /// + /// + /// The filter to apply on the operation. Valid values for $filter are: + /// 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If + /// $filter is not provided, no filtering is performed. If + /// $filter=atExactScope() is provided, the returned list only includes all + /// policy set definitions that at the given scope. If $filter='policyType -eq + /// {value}' is provided, the returned list only includes all policy set + /// definitions whose type match the {value}. Possible policyType values are + /// NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq + /// {value}' is provided, the returned list only includes all policy set + /// definitions whose category match the {value}. + /// + /// + /// Maximum number of records to return. When the $top filter is not provided, + /// it will return 500 records. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByManagementGroupAsync(this IPolicySetDefinitionsOperations operations, string managementGroupId, string filter = default(string), int? top = default(int?), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByManagementGroupWithHttpMessagesAsync(managementGroupId, filter, top, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Retrieves the policy set definitions for a subscription. + /// + /// + /// This operation retrieves a list of all the policy set definitions in a + /// given subscription that match the optional given $filter. Valid values for + /// $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq + /// '{value}''. If $filter is not provided, the unfiltered list includes all + /// policy set definitions associated with the subscription, including those + /// that apply directly or from management groups that contain the given + /// subscription. If $filter=atExactScope() is provided, the returned list only + /// includes all policy set definitions that at the given subscription. If + /// $filter='policyType -eq {value}' is provided, the returned list only + /// includes all policy set definitions whose type match the {value}. Possible + /// policyType values are NotSpecified, BuiltIn and Custom. If + /// $filter='category -eq {value}' is provided, the returned list only includes + /// all policy set definitions whose category match the {value}. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListNext(this IPolicySetDefinitionsOperations operations, string nextPageLink) + { + return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Retrieves the policy set definitions for a subscription. + /// + /// + /// This operation retrieves a list of all the policy set definitions in a + /// given subscription that match the optional given $filter. Valid values for + /// $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq + /// '{value}''. If $filter is not provided, the unfiltered list includes all + /// policy set definitions associated with the subscription, including those + /// that apply directly or from management groups that contain the given + /// subscription. If $filter=atExactScope() is provided, the returned list only + /// includes all policy set definitions that at the given subscription. If + /// $filter='policyType -eq {value}' is provided, the returned list only + /// includes all policy set definitions whose type match the {value}. Possible + /// policyType values are NotSpecified, BuiltIn and Custom. If + /// $filter='category -eq {value}' is provided, the returned list only includes + /// all policy set definitions whose category match the {value}. + /// + /// + /// 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 IPolicySetDefinitionsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Retrieves built-in policy set definitions. + /// + /// + /// This operation retrieves a list of all the built-in policy set definitions + /// that match the optional given $filter. If $filter='category -eq {value}' is + /// provided, the returned list only includes all built-in policy set + /// definitions whose category match the {value}. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListBuiltInNext(this IPolicySetDefinitionsOperations operations, string nextPageLink) + { + return operations.ListBuiltInNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Retrieves built-in policy set definitions. + /// + /// + /// This operation retrieves a list of all the built-in policy set definitions + /// that match the optional given $filter. If $filter='category -eq {value}' is + /// provided, the returned list only includes all built-in policy set + /// definitions whose category match the {value}. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListBuiltInNextAsync(this IPolicySetDefinitionsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListBuiltInNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Retrieves all policy set definitions in management group. + /// + /// + /// This operation retrieves a list of all the policy set definitions in a + /// given management group that match the optional given $filter. Valid values + /// for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq + /// '{value}''. If $filter is not provided, the unfiltered list includes all + /// policy set definitions associated with the management group, including + /// those that apply directly or from management groups that contain the given + /// management group. If $filter=atExactScope() is provided, the returned list + /// only includes all policy set definitions that at the given management + /// group. If $filter='policyType -eq {value}' is provided, the returned list + /// only includes all policy set definitions whose type match the {value}. + /// Possible policyType values are NotSpecified, BuiltIn and Custom. If + /// $filter='category -eq {value}' is provided, the returned list only includes + /// all policy set definitions whose category match the {value}. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListByManagementGroupNext(this IPolicySetDefinitionsOperations operations, string nextPageLink) + { + return operations.ListByManagementGroupNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Retrieves all policy set definitions in management group. + /// + /// + /// This operation retrieves a list of all the policy set definitions in a + /// given management group that match the optional given $filter. Valid values + /// for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq + /// '{value}''. If $filter is not provided, the unfiltered list includes all + /// policy set definitions associated with the management group, including + /// those that apply directly or from management groups that contain the given + /// management group. If $filter=atExactScope() is provided, the returned list + /// only includes all policy set definitions that at the given management + /// group. If $filter='policyType -eq {value}' is provided, the returned list + /// only includes all policy set definitions whose type match the {value}. + /// Possible policyType values are NotSpecified, BuiltIn and Custom. If + /// $filter='category -eq {value}' is provided, the returned list only includes + /// all policy set definitions whose category match the {value}. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByManagementGroupNextAsync(this IPolicySetDefinitionsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByManagementGroupNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/ProviderResourceTypesOperations.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/ProviderResourceTypesOperations.cs new file mode 100644 index 0000000000000..495dd4be0e9c9 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/ProviderResourceTypesOperations.cs @@ -0,0 +1,250 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager +{ + 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; + + /// + /// ProviderResourceTypesOperations operations. + /// + internal partial class ProviderResourceTypesOperations : IServiceOperations, IProviderResourceTypesOperations + { + /// + /// Initializes a new instance of the ProviderResourceTypesOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal ProviderResourceTypesOperations(ResourceManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the ResourceManagementClient + /// + public ResourceManagementClient Client { get; private set; } + + /// + /// List the resource types for a specified resource provider. + /// + /// + /// The namespace of the resource provider. + /// + /// + /// The $expand query parameter. For example, to include property aliases in + /// response, use $expand=resourceTypes/aliases. + /// + /// + /// 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 resourceProviderNamespace, string expand = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceProviderNamespace == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceProviderNamespace"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("expand", expand); + tracingParameters.Add("resourceProviderNamespace", resourceProviderNamespace); + 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/{resourceProviderNamespace}/resourceTypes").ToString(); + _url = _url.Replace("{resourceProviderNamespace}", System.Uri.EscapeDataString(resourceProviderNamespace)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (expand != null) + { + _queryParameters.Add(string.Format("$expand={0}", System.Uri.EscapeDataString(expand))); + } + 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 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/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/ProviderResourceTypesOperationsExtensions.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/ProviderResourceTypesOperationsExtensions.cs new file mode 100644 index 0000000000000..cf6f5f0b20333 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/ProviderResourceTypesOperationsExtensions.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.ResourceManager +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for ProviderResourceTypesOperations. + /// + public static partial class ProviderResourceTypesOperationsExtensions + { + /// + /// List the resource types for a specified resource provider. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The namespace of the resource provider. + /// + /// + /// The $expand query parameter. For example, to include property aliases in + /// response, use $expand=resourceTypes/aliases. + /// + public static ProviderResourceTypeListResult List(this IProviderResourceTypesOperations operations, string resourceProviderNamespace, string expand = default(string)) + { + return operations.ListAsync(resourceProviderNamespace, expand).GetAwaiter().GetResult(); + } + + /// + /// List the resource types for a specified resource provider. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The namespace of the resource provider. + /// + /// + /// The $expand query parameter. For example, to include property aliases in + /// response, use $expand=resourceTypes/aliases. + /// + /// + /// The cancellation token. + /// + public static async Task ListAsync(this IProviderResourceTypesOperations operations, string resourceProviderNamespace, string expand = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(resourceProviderNamespace, expand, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/ProvidersOperations.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/ProvidersOperations.cs new file mode 100644 index 0000000000000..bad541e2ec4ff --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/ProvidersOperations.cs @@ -0,0 +1,1912 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager +{ + 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; + + /// + /// ProvidersOperations operations. + /// + internal partial class ProvidersOperations : IServiceOperations, IProvidersOperations + { + /// + /// Initializes a new instance of the ProvidersOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal ProvidersOperations(ResourceManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the ResourceManagementClient + /// + public ResourceManagementClient Client { get; private set; } + + /// + /// Unregisters a subscription from a resource provider. + /// + /// + /// The namespace of the resource provider to unregister. + /// + /// + /// 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> UnregisterWithHttpMessagesAsync(string resourceProviderNamespace, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceProviderNamespace == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceProviderNamespace"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceProviderNamespace", resourceProviderNamespace); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Unregister", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister").ToString(); + _url = _url.Replace("{resourceProviderNamespace}", System.Uri.EscapeDataString(resourceProviderNamespace)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + 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) + { + 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; + } + + /// + /// Registers a management group with a resource provider. + /// + /// + /// The namespace of the resource provider to register. + /// + /// + /// The management group ID. + /// + /// + /// 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 RegisterAtManagementGroupScopeWithHttpMessagesAsync(string resourceProviderNamespace, string groupId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceProviderNamespace == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceProviderNamespace"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (groupId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "groupId"); + } + if (groupId != null) + { + if (groupId.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "groupId", 90); + } + if (groupId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "groupId", 1); + } + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceProviderNamespace", resourceProviderNamespace); + tracingParameters.Add("groupId", groupId); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "RegisterAtManagementGroupScope", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Management/managementGroups/{groupId}/providers/{resourceProviderNamespace}/register").ToString(); + _url = _url.Replace("{resourceProviderNamespace}", System.Uri.EscapeDataString(resourceProviderNamespace)); + _url = _url.Replace("{groupId}", System.Uri.EscapeDataString(groupId)); + 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) + { + 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; + } + + /// + /// Get the provider permissions. + /// + /// + /// The namespace of the resource provider. + /// + /// + /// 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> ProviderPermissionsWithHttpMessagesAsync(string resourceProviderNamespace, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceProviderNamespace == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceProviderNamespace"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceProviderNamespace", resourceProviderNamespace); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ProviderPermissions", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/providerPermissions").ToString(); + _url = _url.Replace("{resourceProviderNamespace}", System.Uri.EscapeDataString(resourceProviderNamespace)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + 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 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; + } + + /// + /// Registers a subscription with a resource provider. + /// + /// + /// The namespace of the resource provider to register. + /// + /// + /// The third party consent for S2S. + /// + /// + /// 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> RegisterWithHttpMessagesAsync(string resourceProviderNamespace, ProviderRegistrationRequest properties = default(ProviderRegistrationRequest), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceProviderNamespace == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceProviderNamespace"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceProviderNamespace", resourceProviderNamespace); + tracingParameters.Add("properties", properties); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Register", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register").ToString(); + _url = _url.Replace("{resourceProviderNamespace}", System.Uri.EscapeDataString(resourceProviderNamespace)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + 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(properties != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(properties, 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 resource providers for a subscription. + /// + /// + /// The properties to include in the results. For example, use + /// &$expand=metadata in the query string to retrieve resource provider + /// metadata. To include property aliases in response, use + /// $expand=resourceTypes/aliases. + /// + /// + /// 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 expand = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("expand", expand); + 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").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (expand != null) + { + _queryParameters.Add(string.Format("$expand={0}", System.Uri.EscapeDataString(expand))); + } + 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 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 resource providers for the tenant. + /// + /// + /// The properties to include in the results. For example, use + /// &$expand=metadata in the query string to retrieve resource provider + /// metadata. To include property aliases in response, use + /// $expand=resourceTypes/aliases. + /// + /// + /// 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>> ListAtTenantScopeWithHttpMessagesAsync(string expand = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("expand", expand); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListAtTenantScope", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers").ToString(); + List _queryParameters = new List(); + if (expand != null) + { + _queryParameters.Add(string.Format("$expand={0}", System.Uri.EscapeDataString(expand))); + } + 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 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 specified resource provider. + /// + /// + /// The namespace of the resource provider. + /// + /// + /// The $expand query parameter. For example, to include property aliases in + /// response, use $expand=resourceTypes/aliases. + /// + /// + /// 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 resourceProviderNamespace, string expand = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceProviderNamespace == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceProviderNamespace"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("expand", expand); + tracingParameters.Add("resourceProviderNamespace", resourceProviderNamespace); + 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/{resourceProviderNamespace}").ToString(); + _url = _url.Replace("{resourceProviderNamespace}", System.Uri.EscapeDataString(resourceProviderNamespace)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (expand != null) + { + _queryParameters.Add(string.Format("$expand={0}", System.Uri.EscapeDataString(expand))); + } + 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 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 specified resource provider at the tenant level. + /// + /// + /// The namespace of the resource provider. + /// + /// + /// The $expand query parameter. For example, to include property aliases in + /// response, use $expand=resourceTypes/aliases. + /// + /// + /// 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> GetAtTenantScopeWithHttpMessagesAsync(string resourceProviderNamespace, string expand = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceProviderNamespace == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceProviderNamespace"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("expand", expand); + tracingParameters.Add("resourceProviderNamespace", resourceProviderNamespace); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetAtTenantScope", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/{resourceProviderNamespace}").ToString(); + _url = _url.Replace("{resourceProviderNamespace}", System.Uri.EscapeDataString(resourceProviderNamespace)); + List _queryParameters = new List(); + if (expand != null) + { + _queryParameters.Add(string.Format("$expand={0}", System.Uri.EscapeDataString(expand))); + } + 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 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 resource providers for 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 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 resource providers for the tenant. + /// + /// + /// 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>> ListAtTenantScopeNextWithHttpMessagesAsync(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, "ListAtTenantScopeNext", 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/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/ProvidersOperationsExtensions.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/ProvidersOperationsExtensions.cs new file mode 100644 index 0000000000000..e632636ec4f62 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/ProvidersOperationsExtensions.cs @@ -0,0 +1,402 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for ProvidersOperations. + /// + public static partial class ProvidersOperationsExtensions + { + /// + /// Unregisters a subscription from a resource provider. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The namespace of the resource provider to unregister. + /// + public static Provider Unregister(this IProvidersOperations operations, string resourceProviderNamespace) + { + return operations.UnregisterAsync(resourceProviderNamespace).GetAwaiter().GetResult(); + } + + /// + /// Unregisters a subscription from a resource provider. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The namespace of the resource provider to unregister. + /// + /// + /// The cancellation token. + /// + public static async Task UnregisterAsync(this IProvidersOperations operations, string resourceProviderNamespace, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.UnregisterWithHttpMessagesAsync(resourceProviderNamespace, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Registers a management group with a resource provider. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The namespace of the resource provider to register. + /// + /// + /// The management group ID. + /// + public static void RegisterAtManagementGroupScope(this IProvidersOperations operations, string resourceProviderNamespace, string groupId) + { + operations.RegisterAtManagementGroupScopeAsync(resourceProviderNamespace, groupId).GetAwaiter().GetResult(); + } + + /// + /// Registers a management group with a resource provider. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The namespace of the resource provider to register. + /// + /// + /// The management group ID. + /// + /// + /// The cancellation token. + /// + public static async Task RegisterAtManagementGroupScopeAsync(this IProvidersOperations operations, string resourceProviderNamespace, string groupId, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.RegisterAtManagementGroupScopeWithHttpMessagesAsync(resourceProviderNamespace, groupId, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Get the provider permissions. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The namespace of the resource provider. + /// + public static ProviderPermissionListResult ProviderPermissions(this IProvidersOperations operations, string resourceProviderNamespace) + { + return operations.ProviderPermissionsAsync(resourceProviderNamespace).GetAwaiter().GetResult(); + } + + /// + /// Get the provider permissions. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The namespace of the resource provider. + /// + /// + /// The cancellation token. + /// + public static async Task ProviderPermissionsAsync(this IProvidersOperations operations, string resourceProviderNamespace, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ProviderPermissionsWithHttpMessagesAsync(resourceProviderNamespace, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Registers a subscription with a resource provider. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The namespace of the resource provider to register. + /// + /// + /// The third party consent for S2S. + /// + public static Provider Register(this IProvidersOperations operations, string resourceProviderNamespace, ProviderRegistrationRequest properties = default(ProviderRegistrationRequest)) + { + return operations.RegisterAsync(resourceProviderNamespace, properties).GetAwaiter().GetResult(); + } + + /// + /// Registers a subscription with a resource provider. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The namespace of the resource provider to register. + /// + /// + /// The third party consent for S2S. + /// + /// + /// The cancellation token. + /// + public static async Task RegisterAsync(this IProvidersOperations operations, string resourceProviderNamespace, ProviderRegistrationRequest properties = default(ProviderRegistrationRequest), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.RegisterWithHttpMessagesAsync(resourceProviderNamespace, properties, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets all resource providers for a subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The properties to include in the results. For example, use + /// &$expand=metadata in the query string to retrieve resource provider + /// metadata. To include property aliases in response, use + /// $expand=resourceTypes/aliases. + /// + public static IPage List(this IProvidersOperations operations, string expand = default(string)) + { + return operations.ListAsync(expand).GetAwaiter().GetResult(); + } + + /// + /// Gets all resource providers for a subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The properties to include in the results. For example, use + /// &$expand=metadata in the query string to retrieve resource provider + /// metadata. To include property aliases in response, use + /// $expand=resourceTypes/aliases. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAsync(this IProvidersOperations operations, string expand = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(expand, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets all resource providers for the tenant. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The properties to include in the results. For example, use + /// &$expand=metadata in the query string to retrieve resource provider + /// metadata. To include property aliases in response, use + /// $expand=resourceTypes/aliases. + /// + public static IPage ListAtTenantScope(this IProvidersOperations operations, string expand = default(string)) + { + return operations.ListAtTenantScopeAsync(expand).GetAwaiter().GetResult(); + } + + /// + /// Gets all resource providers for the tenant. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The properties to include in the results. For example, use + /// &$expand=metadata in the query string to retrieve resource provider + /// metadata. To include property aliases in response, use + /// $expand=resourceTypes/aliases. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAtTenantScopeAsync(this IProvidersOperations operations, string expand = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListAtTenantScopeWithHttpMessagesAsync(expand, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets the specified resource provider. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The namespace of the resource provider. + /// + /// + /// The $expand query parameter. For example, to include property aliases in + /// response, use $expand=resourceTypes/aliases. + /// + public static Provider Get(this IProvidersOperations operations, string resourceProviderNamespace, string expand = default(string)) + { + return operations.GetAsync(resourceProviderNamespace, expand).GetAwaiter().GetResult(); + } + + /// + /// Gets the specified resource provider. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The namespace of the resource provider. + /// + /// + /// The $expand query parameter. For example, to include property aliases in + /// response, use $expand=resourceTypes/aliases. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IProvidersOperations operations, string resourceProviderNamespace, string expand = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceProviderNamespace, expand, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets the specified resource provider at the tenant level. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The namespace of the resource provider. + /// + /// + /// The $expand query parameter. For example, to include property aliases in + /// response, use $expand=resourceTypes/aliases. + /// + public static Provider GetAtTenantScope(this IProvidersOperations operations, string resourceProviderNamespace, string expand = default(string)) + { + return operations.GetAtTenantScopeAsync(resourceProviderNamespace, expand).GetAwaiter().GetResult(); + } + + /// + /// Gets the specified resource provider at the tenant level. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The namespace of the resource provider. + /// + /// + /// The $expand query parameter. For example, to include property aliases in + /// response, use $expand=resourceTypes/aliases. + /// + /// + /// The cancellation token. + /// + public static async Task GetAtTenantScopeAsync(this IProvidersOperations operations, string resourceProviderNamespace, string expand = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetAtTenantScopeWithHttpMessagesAsync(resourceProviderNamespace, expand, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets all resource providers for a subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListNext(this IProvidersOperations operations, string nextPageLink) + { + return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Gets all resource providers for 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 IProvidersOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets all resource providers for the tenant. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListAtTenantScopeNext(this IProvidersOperations operations, string nextPageLink) + { + return operations.ListAtTenantScopeNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Gets all resource providers for the tenant. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAtTenantScopeNextAsync(this IProvidersOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListAtTenantScopeNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/ResourceGroupsOperations.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/ResourceGroupsOperations.cs new file mode 100644 index 0000000000000..dbf5f667ad6aa --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/ResourceGroupsOperations.cs @@ -0,0 +1,1722 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Microsoft.Rest.Azure.OData; + 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; + + /// + /// ResourceGroupsOperations operations. + /// + internal partial class ResourceGroupsOperations : IServiceOperations, IResourceGroupsOperations + { + /// + /// Initializes a new instance of the ResourceGroupsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal ResourceGroupsOperations(ResourceManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the ResourceManagementClient + /// + public ResourceManagementClient Client { get; private set; } + + /// + /// Checks whether a resource group exists. + /// + /// + /// The name of the resource group to check. 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 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> CheckExistenceWithHttpMessagesAsync(string resourceGroupName, 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 (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + // 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, "CheckExistence", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + 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("HEAD"); + _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, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 204 && (int)_statusCode != 404) + { + 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; + _result.Body = _statusCode == System.Net.HttpStatusCode.NoContent; + 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; + } + + /// + /// Creates or updates a resource group. + /// + /// + /// The name of the resource group to create or update. Can include + /// alphanumeric, underscore, parentheses, hyphen, period (except at end), and + /// Unicode characters that match the allowed characters. + /// + /// + /// Parameters supplied to the create or update a resource group. + /// + /// + /// 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> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, ResourceGroup 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 (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (parameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); + } + if (parameters != null) + { + parameters.Validate(); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("parameters", parameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "CreateOrUpdate", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + 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 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 resource group. + /// + /// + /// When you delete a resource group, all of its resources are also deleted. + /// Deleting a resource group deletes all of its template deployments and + /// currently stored operations. + /// + /// + /// The name of the resource group to delete. The name is case insensitive. + /// + /// + /// The resource types you want to force delete. Currently, only the following + /// is supported: + /// forceDeletionTypes=Microsoft.Compute/virtualMachines,Microsoft.Compute/virtualMachineScaleSets + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task DeleteWithHttpMessagesAsync(string resourceGroupName, string forceDeletionTypes = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginDeleteWithHttpMessagesAsync(resourceGroupName, forceDeletionTypes, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets a resource group. + /// + /// + /// The name of the resource group to get. 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> GetWithHttpMessagesAsync(string resourceGroupName, 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 (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + // 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, "Get", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + 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 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 resource group. + /// + /// + /// Resource groups can be updated through a simple PATCH operation to a group + /// address. The format of the request is the same as that for creating a + /// resource group. If a field is unspecified, the current value is retained. + /// + /// + /// The name of the resource group to update. The name is case insensitive. + /// + /// + /// Parameters supplied to update a resource group. + /// + /// + /// 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> UpdateWithHttpMessagesAsync(string resourceGroupName, ResourceGroupPatchable 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 (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (parameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("parameters", parameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Update", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + 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) + { + 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; + } + + /// + /// Captures the specified resource group as a template. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Parameters for exporting the template. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> ExportTemplateWithHttpMessagesAsync(string resourceGroupName, ExportTemplateRequest parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginExportTemplateWithHttpMessagesAsync(resourceGroupName, parameters, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets all the resource groups for a subscription. + /// + /// + /// OData parameters to apply to the 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>> ListWithHttpMessagesAsync(ODataQuery odataQuery = default(ODataQuery), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("odataQuery", odataQuery); + 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").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (odataQuery != null) + { + var _odataFilter = odataQuery.ToString(); + if (!string.IsNullOrEmpty(_odataFilter)) + { + _queryParameters.Add(_odataFilter); + } + } + 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 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 resource group. + /// + /// + /// When you delete a resource group, all of its resources are also deleted. + /// Deleting a resource group deletes all of its template deployments and + /// currently stored operations. + /// + /// + /// The name of the resource group to delete. The name is case insensitive. + /// + /// + /// The resource types you want to force delete. Currently, only the following + /// is supported: + /// forceDeletionTypes=Microsoft.Compute/virtualMachines,Microsoft.Compute/virtualMachineScaleSets + /// + /// + /// 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 forceDeletionTypes = default(string), 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 (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("forceDeletionTypes", forceDeletionTypes); + 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}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (forceDeletionTypes != null) + { + _queryParameters.Add(string.Format("forceDeletionTypes={0}", System.Uri.EscapeDataString(forceDeletionTypes))); + } + 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) + { + 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; + } + + /// + /// Captures the specified resource group as a template. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Parameters for exporting the template. + /// + /// + /// 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> BeginExportTemplateWithHttpMessagesAsync(string resourceGroupName, ExportTemplateRequest parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + 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 (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (parameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("parameters", parameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginExportTemplate", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _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("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(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; + } + + /// + /// Gets all the resource groups for 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 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/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/ResourceGroupsOperationsExtensions.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/ResourceGroupsOperationsExtensions.cs new file mode 100644 index 0000000000000..e0b1aad6ea6f8 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/ResourceGroupsOperationsExtensions.cs @@ -0,0 +1,438 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Microsoft.Rest.Azure.OData; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for ResourceGroupsOperations. + /// + public static partial class ResourceGroupsOperationsExtensions + { + /// + /// Checks whether a resource group exists. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to check. The name is case insensitive. + /// + public static bool CheckExistence(this IResourceGroupsOperations operations, string resourceGroupName) + { + return operations.CheckExistenceAsync(resourceGroupName).GetAwaiter().GetResult(); + } + + /// + /// Checks whether a resource group exists. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to check. The name is case insensitive. + /// + /// + /// The cancellation token. + /// + public static async Task CheckExistenceAsync(this IResourceGroupsOperations operations, string resourceGroupName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CheckExistenceWithHttpMessagesAsync(resourceGroupName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Creates or updates a resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to create or update. Can include + /// alphanumeric, underscore, parentheses, hyphen, period (except at end), and + /// Unicode characters that match the allowed characters. + /// + /// + /// Parameters supplied to the create or update a resource group. + /// + public static ResourceGroup CreateOrUpdate(this IResourceGroupsOperations operations, string resourceGroupName, ResourceGroup parameters) + { + return operations.CreateOrUpdateAsync(resourceGroupName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Creates or updates a resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to create or update. Can include + /// alphanumeric, underscore, parentheses, hyphen, period (except at end), and + /// Unicode characters that match the allowed characters. + /// + /// + /// Parameters supplied to the create or update a resource group. + /// + /// + /// The cancellation token. + /// + public static async Task CreateOrUpdateAsync(this IResourceGroupsOperations operations, string resourceGroupName, ResourceGroup parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes a resource group. + /// + /// + /// When you delete a resource group, all of its resources are also deleted. + /// Deleting a resource group deletes all of its template deployments and + /// currently stored operations. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to delete. The name is case insensitive. + /// + /// + /// The resource types you want to force delete. Currently, only the following + /// is supported: + /// forceDeletionTypes=Microsoft.Compute/virtualMachines,Microsoft.Compute/virtualMachineScaleSets + /// + public static void Delete(this IResourceGroupsOperations operations, string resourceGroupName, string forceDeletionTypes = default(string)) + { + operations.DeleteAsync(resourceGroupName, forceDeletionTypes).GetAwaiter().GetResult(); + } + + /// + /// Deletes a resource group. + /// + /// + /// When you delete a resource group, all of its resources are also deleted. + /// Deleting a resource group deletes all of its template deployments and + /// currently stored operations. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to delete. The name is case insensitive. + /// + /// + /// The resource types you want to force delete. Currently, only the following + /// is supported: + /// forceDeletionTypes=Microsoft.Compute/virtualMachines,Microsoft.Compute/virtualMachineScaleSets + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this IResourceGroupsOperations operations, string resourceGroupName, string forceDeletionTypes = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, forceDeletionTypes, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Gets a resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to get. The name is case insensitive. + /// + public static ResourceGroup Get(this IResourceGroupsOperations operations, string resourceGroupName) + { + return operations.GetAsync(resourceGroupName).GetAwaiter().GetResult(); + } + + /// + /// Gets a resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to get. The name is case insensitive. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IResourceGroupsOperations operations, string resourceGroupName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Updates a resource group. + /// + /// + /// Resource groups can be updated through a simple PATCH operation to a group + /// address. The format of the request is the same as that for creating a + /// resource group. If a field is unspecified, the current value is retained. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to update. The name is case insensitive. + /// + /// + /// Parameters supplied to update a resource group. + /// + public static ResourceGroup Update(this IResourceGroupsOperations operations, string resourceGroupName, ResourceGroupPatchable parameters) + { + return operations.UpdateAsync(resourceGroupName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Updates a resource group. + /// + /// + /// Resource groups can be updated through a simple PATCH operation to a group + /// address. The format of the request is the same as that for creating a + /// resource group. If a field is unspecified, the current value is retained. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to update. The name is case insensitive. + /// + /// + /// Parameters supplied to update a resource group. + /// + /// + /// The cancellation token. + /// + public static async Task UpdateAsync(this IResourceGroupsOperations operations, string resourceGroupName, ResourceGroupPatchable parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.UpdateWithHttpMessagesAsync(resourceGroupName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Captures the specified resource group as a template. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Parameters for exporting the template. + /// + public static ResourceGroupExportResult ExportTemplate(this IResourceGroupsOperations operations, string resourceGroupName, ExportTemplateRequest parameters) + { + return operations.ExportTemplateAsync(resourceGroupName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Captures the specified resource group as a template. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Parameters for exporting the template. + /// + /// + /// The cancellation token. + /// + public static async Task ExportTemplateAsync(this IResourceGroupsOperations operations, string resourceGroupName, ExportTemplateRequest parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ExportTemplateWithHttpMessagesAsync(resourceGroupName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets all the resource groups for a subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// OData parameters to apply to the operation. + /// + public static IPage List(this IResourceGroupsOperations operations, ODataQuery odataQuery = default(ODataQuery)) + { + return operations.ListAsync(odataQuery).GetAwaiter().GetResult(); + } + + /// + /// Gets all the resource groups for a subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// OData parameters to apply to the operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAsync(this IResourceGroupsOperations operations, ODataQuery odataQuery = default(ODataQuery), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(odataQuery, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes a resource group. + /// + /// + /// When you delete a resource group, all of its resources are also deleted. + /// Deleting a resource group deletes all of its template deployments and + /// currently stored operations. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to delete. The name is case insensitive. + /// + /// + /// The resource types you want to force delete. Currently, only the following + /// is supported: + /// forceDeletionTypes=Microsoft.Compute/virtualMachines,Microsoft.Compute/virtualMachineScaleSets + /// + public static void BeginDelete(this IResourceGroupsOperations operations, string resourceGroupName, string forceDeletionTypes = default(string)) + { + operations.BeginDeleteAsync(resourceGroupName, forceDeletionTypes).GetAwaiter().GetResult(); + } + + /// + /// Deletes a resource group. + /// + /// + /// When you delete a resource group, all of its resources are also deleted. + /// Deleting a resource group deletes all of its template deployments and + /// currently stored operations. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group to delete. The name is case insensitive. + /// + /// + /// The resource types you want to force delete. Currently, only the following + /// is supported: + /// forceDeletionTypes=Microsoft.Compute/virtualMachines,Microsoft.Compute/virtualMachineScaleSets + /// + /// + /// The cancellation token. + /// + public static async Task BeginDeleteAsync(this IResourceGroupsOperations operations, string resourceGroupName, string forceDeletionTypes = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.BeginDeleteWithHttpMessagesAsync(resourceGroupName, forceDeletionTypes, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Captures the specified resource group as a template. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Parameters for exporting the template. + /// + public static ResourceGroupExportResult BeginExportTemplate(this IResourceGroupsOperations operations, string resourceGroupName, ExportTemplateRequest parameters) + { + return operations.BeginExportTemplateAsync(resourceGroupName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Captures the specified resource group as a template. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Parameters for exporting the template. + /// + /// + /// The cancellation token. + /// + public static async Task BeginExportTemplateAsync(this IResourceGroupsOperations operations, string resourceGroupName, ExportTemplateRequest parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginExportTemplateWithHttpMessagesAsync(resourceGroupName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets all the resource groups for a subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListNext(this IResourceGroupsOperations operations, string nextPageLink) + { + return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Gets all the resource groups for 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 IResourceGroupsOperations 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/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/ResourceLinksOperations.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/ResourceLinksOperations.cs new file mode 100644 index 0000000000000..a11bf997da2fe --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/ResourceLinksOperations.cs @@ -0,0 +1,1356 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Microsoft.Rest.Azure.OData; + 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; + + /// + /// ResourceLinksOperations operations. + /// + internal partial class ResourceLinksOperations : IServiceOperations, IResourceLinksOperations + { + /// + /// Initializes a new instance of the ResourceLinksOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal ResourceLinksOperations(ManagementLinkClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the ManagementLinkClient + /// + public ManagementLinkClient Client { get; private set; } + + /// + /// Deletes a resource link with the specified ID. + /// + /// + /// The fully qualified ID of the resource link. Use the format, + /// /subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/{provider-namespace}/{resource-type}/{resource-name}/Microsoft.Resources/links/{link-name}. + /// For example, + /// /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup/Microsoft.Web/sites/mySite/Microsoft.Resources/links/myLink + /// + /// + /// 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 DeleteWithHttpMessagesAsync(string linkId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (linkId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "linkId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("linkId", linkId); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Delete", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{linkId}").ToString(); + _url = _url.Replace("{linkId}", linkId); + 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 != 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; + } + + /// + /// Creates or updates a resource link between the specified resources. + /// + /// + /// The fully qualified ID of the resource link. Use the format, + /// /subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/{provider-namespace}/{resource-type}/{resource-name}/Microsoft.Resources/links/{link-name}. + /// For example, + /// /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup/Microsoft.Web/sites/mySite/Microsoft.Resources/links/myLink + /// + /// + /// Parameters for creating or updating a resource link. + /// + /// + /// 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> CreateOrUpdateWithHttpMessagesAsync(string linkId, ResourceLink parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (linkId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "linkId"); + } + if (parameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); + } + if (parameters != null) + { + parameters.Validate(); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("linkId", linkId); + tracingParameters.Add("parameters", parameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "CreateOrUpdate", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{linkId}").ToString(); + _url = _url.Replace("{linkId}", linkId); + 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 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; + } + + /// + /// Gets a resource link with the specified ID. + /// + /// + /// The fully qualified Id of the resource link. For example, + /// /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup/Microsoft.Web/sites/mySite/Microsoft.Resources/links/myLink + /// + /// + /// 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 linkId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (linkId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "linkId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("linkId", linkId); + 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("/") ? "" : "/")), "{linkId}").ToString(); + _url = _url.Replace("{linkId}", linkId); + 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 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 the linked resources for the subscription. + /// + /// + /// OData parameters to apply to the 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>> ListAtSubscriptionWithHttpMessagesAsync(ODataQuery odataQuery = default(ODataQuery), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("odataQuery", odataQuery); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListAtSubscription", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Resources/links").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (odataQuery != null) + { + var _odataFilter = odataQuery.ToString(); + if (!string.IsNullOrEmpty(_odataFilter)) + { + _queryParameters.Add(_odataFilter); + } + } + 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 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 list of resource links at and below the specified source scope. + /// + /// + /// The fully qualified ID of the scope for getting the resource links. For + /// example, to list resource links at and under a resource group, set the + /// scope to + /// /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup. + /// + /// + /// OData parameters to apply to the 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>> ListAtSourceScopeWithHttpMessagesAsync(string scope, ODataQuery odataQuery = default(ODataQuery), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (scope == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "scope"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("odataQuery", odataQuery); + tracingParameters.Add("scope", scope); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListAtSourceScope", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{scope}/providers/Microsoft.Resources/links").ToString(); + _url = _url.Replace("{scope}", scope); + List _queryParameters = new List(); + if (odataQuery != null) + { + var _odataFilter = odataQuery.ToString(); + if (!string.IsNullOrEmpty(_odataFilter)) + { + _queryParameters.Add(_odataFilter); + } + } + 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 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 the linked resources for the 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>> ListAtSubscriptionNextWithHttpMessagesAsync(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, "ListAtSubscriptionNext", 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; + } + + /// + /// Gets a list of resource links at and below the specified source scope. + /// + /// + /// 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>> ListAtSourceScopeNextWithHttpMessagesAsync(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, "ListAtSourceScopeNext", 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/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/ResourceLinksOperationsExtensions.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/ResourceLinksOperationsExtensions.cs new file mode 100644 index 0000000000000..0f8d42239e7c1 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/ResourceLinksOperationsExtensions.cs @@ -0,0 +1,293 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Microsoft.Rest.Azure.OData; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for ResourceLinksOperations. + /// + public static partial class ResourceLinksOperationsExtensions + { + /// + /// Deletes a resource link with the specified ID. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The fully qualified ID of the resource link. Use the format, + /// /subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/{provider-namespace}/{resource-type}/{resource-name}/Microsoft.Resources/links/{link-name}. + /// For example, + /// /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup/Microsoft.Web/sites/mySite/Microsoft.Resources/links/myLink + /// + public static void Delete(this IResourceLinksOperations operations, string linkId) + { + operations.DeleteAsync(linkId).GetAwaiter().GetResult(); + } + + /// + /// Deletes a resource link with the specified ID. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The fully qualified ID of the resource link. Use the format, + /// /subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/{provider-namespace}/{resource-type}/{resource-name}/Microsoft.Resources/links/{link-name}. + /// For example, + /// /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup/Microsoft.Web/sites/mySite/Microsoft.Resources/links/myLink + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this IResourceLinksOperations operations, string linkId, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(linkId, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Creates or updates a resource link between the specified resources. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The fully qualified ID of the resource link. Use the format, + /// /subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/{provider-namespace}/{resource-type}/{resource-name}/Microsoft.Resources/links/{link-name}. + /// For example, + /// /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup/Microsoft.Web/sites/mySite/Microsoft.Resources/links/myLink + /// + /// + /// Parameters for creating or updating a resource link. + /// + public static ResourceLink CreateOrUpdate(this IResourceLinksOperations operations, string linkId, ResourceLink parameters) + { + return operations.CreateOrUpdateAsync(linkId, parameters).GetAwaiter().GetResult(); + } + + /// + /// Creates or updates a resource link between the specified resources. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The fully qualified ID of the resource link. Use the format, + /// /subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/{provider-namespace}/{resource-type}/{resource-name}/Microsoft.Resources/links/{link-name}. + /// For example, + /// /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup/Microsoft.Web/sites/mySite/Microsoft.Resources/links/myLink + /// + /// + /// Parameters for creating or updating a resource link. + /// + /// + /// The cancellation token. + /// + public static async Task CreateOrUpdateAsync(this IResourceLinksOperations operations, string linkId, ResourceLink parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(linkId, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets a resource link with the specified ID. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The fully qualified Id of the resource link. For example, + /// /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup/Microsoft.Web/sites/mySite/Microsoft.Resources/links/myLink + /// + public static ResourceLink Get(this IResourceLinksOperations operations, string linkId) + { + return operations.GetAsync(linkId).GetAwaiter().GetResult(); + } + + /// + /// Gets a resource link with the specified ID. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The fully qualified Id of the resource link. For example, + /// /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup/Microsoft.Web/sites/mySite/Microsoft.Resources/links/myLink + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IResourceLinksOperations operations, string linkId, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(linkId, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets all the linked resources for the subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// OData parameters to apply to the operation. + /// + public static IPage ListAtSubscription(this IResourceLinksOperations operations, ODataQuery odataQuery = default(ODataQuery)) + { + return operations.ListAtSubscriptionAsync(odataQuery).GetAwaiter().GetResult(); + } + + /// + /// Gets all the linked resources for the subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// OData parameters to apply to the operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAtSubscriptionAsync(this IResourceLinksOperations operations, ODataQuery odataQuery = default(ODataQuery), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListAtSubscriptionWithHttpMessagesAsync(odataQuery, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets a list of resource links at and below the specified source scope. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The fully qualified ID of the scope for getting the resource links. For + /// example, to list resource links at and under a resource group, set the + /// scope to + /// /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup. + /// + /// + /// OData parameters to apply to the operation. + /// + public static IPage ListAtSourceScope(this IResourceLinksOperations operations, string scope, ODataQuery odataQuery = default(ODataQuery)) + { + return operations.ListAtSourceScopeAsync(scope, odataQuery).GetAwaiter().GetResult(); + } + + /// + /// Gets a list of resource links at and below the specified source scope. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The fully qualified ID of the scope for getting the resource links. For + /// example, to list resource links at and under a resource group, set the + /// scope to + /// /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup. + /// + /// + /// OData parameters to apply to the operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAtSourceScopeAsync(this IResourceLinksOperations operations, string scope, ODataQuery odataQuery = default(ODataQuery), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListAtSourceScopeWithHttpMessagesAsync(scope, odataQuery, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets all the linked resources for the subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListAtSubscriptionNext(this IResourceLinksOperations operations, string nextPageLink) + { + return operations.ListAtSubscriptionNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Gets all the linked resources for the 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> ListAtSubscriptionNextAsync(this IResourceLinksOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListAtSubscriptionNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets a list of resource links at and below the specified source scope. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListAtSourceScopeNext(this IResourceLinksOperations operations, string nextPageLink) + { + return operations.ListAtSourceScopeNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Gets a list of resource links at and below the specified source scope. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAtSourceScopeNextAsync(this IResourceLinksOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListAtSourceScopeNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/ResourceManagementClient.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/ResourceManagementClient.cs new file mode 100644 index 0000000000000..abcaa04fcf165 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/ResourceManagementClient.cs @@ -0,0 +1,402 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager +{ + 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; + + /// + /// Provides operations for working with resources and resource groups. + /// + public partial class ResourceManagementClient : ServiceClient, IResourceManagementClient, 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 Microsoft Azure subscription ID. + /// + public string 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 IOperations. + /// + public virtual IOperations Operations { get; private set; } + + /// + /// Gets the IDeploymentsOperations. + /// + public virtual IDeploymentsOperations Deployments { get; private set; } + + /// + /// Gets the IProvidersOperations. + /// + public virtual IProvidersOperations Providers { get; private set; } + + /// + /// Gets the IProviderResourceTypesOperations. + /// + public virtual IProviderResourceTypesOperations ProviderResourceTypes { get; private set; } + + /// + /// Gets the IResourcesOperations. + /// + public virtual IResourcesOperations Resources { get; private set; } + + /// + /// Gets the IResourceGroupsOperations. + /// + public virtual IResourceGroupsOperations ResourceGroups { get; private set; } + + /// + /// Gets the ITagsOperations. + /// + public virtual ITagsOperations Tags { get; private set; } + + /// + /// Gets the IDeploymentOperations. + /// + public virtual IDeploymentOperations DeploymentOperations { get; private set; } + + /// + /// Initializes a new instance of the ResourceManagementClient class. + /// + /// + /// HttpClient to be used + /// + /// + /// True: will dispose the provided httpClient on calling ResourceManagementClient.Dispose(). False: will not dispose provided httpClient + protected ResourceManagementClient(HttpClient httpClient, bool disposeHttpClient) : base(httpClient, disposeHttpClient) + { + Initialize(); + } + + /// + /// Initializes a new instance of the ResourceManagementClient class. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + protected ResourceManagementClient(params DelegatingHandler[] handlers) : base(handlers) + { + Initialize(); + } + + /// + /// Initializes a new instance of the ResourceManagementClient class. + /// + /// + /// Optional. The http client handler used to handle http transport. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + protected ResourceManagementClient(HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : base(rootHandler, handlers) + { + Initialize(); + } + + /// + /// Initializes a new instance of the ResourceManagementClient 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 ResourceManagementClient(System.Uri baseUri, params DelegatingHandler[] handlers) : this(handlers) + { + if (baseUri == null) + { + throw new System.ArgumentNullException("baseUri"); + } + BaseUri = baseUri; + } + + /// + /// Initializes a new instance of the ResourceManagementClient 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 ResourceManagementClient(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 ResourceManagementClient 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 ResourceManagementClient(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 ResourceManagementClient class. + /// + /// + /// Required. Credentials needed for the client to connect to Azure. + /// + /// + /// HttpClient to be used + /// + /// + /// True: will dispose the provided httpClient on calling ResourceManagementClient.Dispose(). False: will not dispose provided httpClient + /// + /// Thrown when a required parameter is null + /// + public ResourceManagementClient(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 ResourceManagementClient 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 ResourceManagementClient(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 ResourceManagementClient 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 ResourceManagementClient(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 ResourceManagementClient 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 ResourceManagementClient(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() + { + Operations = new Operations(this); + Deployments = new DeploymentsOperations(this); + Providers = new ProvidersOperations(this); + ProviderResourceTypes = new ProviderResourceTypesOperations(this); + Resources = new ResourcesOperations(this); + ResourceGroups = new ResourceGroupsOperations(this); + Tags = new TagsOperations(this); + DeploymentOperations = new DeploymentOperations(this); + BaseUri = new System.Uri("https://management.azure.com"); + ApiVersion = "2021-04-01"; + 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/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/ResourcesOperations.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/ResourcesOperations.cs new file mode 100644 index 0000000000000..1ae244d478eb8 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/ResourcesOperations.cs @@ -0,0 +1,3639 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Microsoft.Rest.Azure.OData; + 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; + + /// + /// ResourcesOperations operations. + /// + internal partial class ResourcesOperations : IServiceOperations, IResourcesOperations + { + /// + /// Initializes a new instance of the ResourcesOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal ResourcesOperations(ResourceManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the ResourceManagementClient + /// + public ResourceManagementClient Client { get; private set; } + + /// + /// Get all the resources for a resource group. + /// + /// + /// The resource group with the resources to get. + /// + /// + /// OData parameters to apply to the 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>> ListByResourceGroupWithHttpMessagesAsync(string resourceGroupName, ODataQuery odataQuery = default(ODataQuery), 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 (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("odataQuery", odataQuery); + 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}/resources").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (odataQuery != null) + { + var _odataFilter = odataQuery.ToString(); + if (!string.IsNullOrEmpty(_odataFilter)) + { + _queryParameters.Add(_odataFilter); + } + } + 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 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; + } + + /// + /// Moves resources from one resource group to another resource group. + /// + /// + /// The resources to be moved must be in the same source resource group in the + /// source subscription being used. The target resource group may be in a + /// different subscription. When moving resources, both the source group and + /// the target group are locked for the duration of the operation. Write and + /// delete operations are blocked on the groups until the move completes. + /// + /// + /// The name of the resource group from the source subscription containing the + /// resources to be moved. + /// + /// + /// Parameters for moving resources. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task MoveResourcesWithHttpMessagesAsync(string sourceResourceGroupName, ResourcesMoveInfo parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginMoveResourcesWithHttpMessagesAsync(sourceResourceGroupName, parameters, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Validates whether resources can be moved from one resource group to another + /// resource group. + /// + /// + /// This operation checks whether the specified resources can be moved to the + /// target. The resources to be moved must be in the same source resource group + /// in the source subscription being used. The target resource group may be in + /// a different subscription. If validation succeeds, it returns HTTP response + /// code 204 (no content). If validation fails, it returns HTTP response code + /// 409 (Conflict) with an error message. Retrieve the URL in the Location + /// header value to check the result of the long-running operation. + /// + /// + /// The name of the resource group from the source subscription containing the + /// resources to be validated for move. + /// + /// + /// Parameters for moving resources. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task ValidateMoveResourcesWithHttpMessagesAsync(string sourceResourceGroupName, ResourcesMoveInfo parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginValidateMoveResourcesWithHttpMessagesAsync(sourceResourceGroupName, parameters, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get all the resources in a subscription. + /// + /// + /// OData parameters to apply to the 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>> ListWithHttpMessagesAsync(ODataQuery odataQuery = default(ODataQuery), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("odataQuery", odataQuery); + 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}/resources").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (odataQuery != null) + { + var _odataFilter = odataQuery.ToString(); + if (!string.IsNullOrEmpty(_odataFilter)) + { + _queryParameters.Add(_odataFilter); + } + } + 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 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; + } + + /// + /// Checks whether a resource exists. + /// + /// + /// The name of the resource group containing the resource to check. The name + /// is case insensitive. + /// + /// + /// The resource provider of the resource to check. + /// + /// + /// The parent resource identity. + /// + /// + /// The resource type. + /// + /// + /// The name of the resource to check whether it exists. + /// + /// + /// The API version to use for the operation. + /// + /// + /// 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> CheckExistenceWithHttpMessagesAsync(string resourceGroupName, string resourceProviderNamespace, string parentResourcePath, string resourceType, string resourceName, string apiVersion, 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 (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (resourceProviderNamespace == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceProviderNamespace"); + } + if (parentResourcePath == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "parentResourcePath"); + } + if (resourceType == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceType"); + } + if (resourceName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceName"); + } + if (apiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "apiVersion"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("resourceProviderNamespace", resourceProviderNamespace); + tracingParameters.Add("parentResourcePath", parentResourcePath); + tracingParameters.Add("resourceType", resourceType); + tracingParameters.Add("resourceName", resourceName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "CheckExistence", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{resourceProviderNamespace}", System.Uri.EscapeDataString(resourceProviderNamespace)); + _url = _url.Replace("{parentResourcePath}", parentResourcePath); + _url = _url.Replace("{resourceType}", resourceType); + _url = _url.Replace("{resourceName}", System.Uri.EscapeDataString(resourceName)); + _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("HEAD"); + _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, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 204 && (int)_statusCode != 404) + { + 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; + _result.Body = _statusCode == System.Net.HttpStatusCode.NoContent; + 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; + } + + /// + /// Deletes a resource. + /// + /// + /// The name of the resource group that contains the resource to delete. The + /// name is case insensitive. + /// + /// + /// The namespace of the resource provider. + /// + /// + /// The parent resource identity. + /// + /// + /// The resource type. + /// + /// + /// The name of the resource to delete. + /// + /// + /// The API version to use for the operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task DeleteWithHttpMessagesAsync(string resourceGroupName, string resourceProviderNamespace, string parentResourcePath, string resourceType, string resourceName, string apiVersion, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginDeleteWithHttpMessagesAsync(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Creates a resource. + /// + /// + /// The name of the resource group for the resource. The name is case + /// insensitive. + /// + /// + /// The namespace of the resource provider. + /// + /// + /// The parent resource identity. + /// + /// + /// The resource type of the resource to create. + /// + /// + /// The name of the resource to create. + /// + /// + /// The API version to use for the operation. + /// + /// + /// Parameters for creating or updating the resource. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string resourceProviderNamespace, string parentResourcePath, string resourceType, string resourceName, string apiVersion, GenericResource parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion, parameters, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Updates a resource. + /// + /// + /// The name of the resource group for the resource. The name is case + /// insensitive. + /// + /// + /// The namespace of the resource provider. + /// + /// + /// The parent resource identity. + /// + /// + /// The resource type of the resource to update. + /// + /// + /// The name of the resource to update. + /// + /// + /// The API version to use for the operation. + /// + /// + /// Parameters for updating the resource. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> UpdateWithHttpMessagesAsync(string resourceGroupName, string resourceProviderNamespace, string parentResourcePath, string resourceType, string resourceName, string apiVersion, GenericResource parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginUpdateWithHttpMessagesAsync(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion, parameters, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets a resource. + /// + /// + /// The name of the resource group containing the resource to get. The name is + /// case insensitive. + /// + /// + /// The namespace of the resource provider. + /// + /// + /// The parent resource identity. + /// + /// + /// The resource type of the resource. + /// + /// + /// The name of the resource to get. + /// + /// + /// The API version to use for the 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> GetWithHttpMessagesAsync(string resourceGroupName, string resourceProviderNamespace, string parentResourcePath, string resourceType, string resourceName, string apiVersion, 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 (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (resourceProviderNamespace == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceProviderNamespace"); + } + if (parentResourcePath == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "parentResourcePath"); + } + if (resourceType == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceType"); + } + if (resourceName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceName"); + } + if (apiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "apiVersion"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("resourceProviderNamespace", resourceProviderNamespace); + tracingParameters.Add("parentResourcePath", parentResourcePath); + tracingParameters.Add("resourceType", resourceType); + tracingParameters.Add("resourceName", resourceName); + 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/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{resourceProviderNamespace}", System.Uri.EscapeDataString(resourceProviderNamespace)); + _url = _url.Replace("{parentResourcePath}", parentResourcePath); + _url = _url.Replace("{resourceType}", resourceType); + _url = _url.Replace("{resourceName}", System.Uri.EscapeDataString(resourceName)); + _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; + } + + /// + /// Checks by ID whether a resource exists. + /// + /// + /// The fully qualified ID of the resource, including the resource name and + /// resource type. Use the format, + /// /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name} + /// + /// + /// The API version to use for the operation. + /// + /// + /// 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> CheckExistenceByIdWithHttpMessagesAsync(string resourceId, string apiVersion, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceId"); + } + if (apiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "apiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceId", resourceId); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "CheckExistenceById", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{resourceId}").ToString(); + _url = _url.Replace("{resourceId}", resourceId); + 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("HEAD"); + _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, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 204 && (int)_statusCode != 404) + { + 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; + _result.Body = _statusCode == System.Net.HttpStatusCode.NoContent; + 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; + } + + /// + /// Deletes a resource by ID. + /// + /// + /// The fully qualified ID of the resource, including the resource name and + /// resource type. Use the format, + /// /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name} + /// + /// + /// The API version to use for the operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task DeleteByIdWithHttpMessagesAsync(string resourceId, string apiVersion, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginDeleteByIdWithHttpMessagesAsync(resourceId, apiVersion, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Create a resource by ID. + /// + /// + /// The fully qualified ID of the resource, including the resource name and + /// resource type. Use the format, + /// /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name} + /// + /// + /// The API version to use for the operation. + /// + /// + /// Create or update resource parameters. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> CreateOrUpdateByIdWithHttpMessagesAsync(string resourceId, string apiVersion, GenericResource parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginCreateOrUpdateByIdWithHttpMessagesAsync(resourceId, apiVersion, parameters, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Updates a resource by ID. + /// + /// + /// The fully qualified ID of the resource, including the resource name and + /// resource type. Use the format, + /// /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name} + /// + /// + /// The API version to use for the operation. + /// + /// + /// Update resource parameters. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> UpdateByIdWithHttpMessagesAsync(string resourceId, string apiVersion, GenericResource parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginUpdateByIdWithHttpMessagesAsync(resourceId, apiVersion, parameters, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets a resource by ID. + /// + /// + /// The fully qualified ID of the resource, including the resource name and + /// resource type. Use the format, + /// /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name} + /// + /// + /// The API version to use for the 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> GetByIdWithHttpMessagesAsync(string resourceId, string apiVersion, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceId"); + } + if (apiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "apiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceId", resourceId); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetById", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{resourceId}").ToString(); + _url = _url.Replace("{resourceId}", resourceId); + 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; + } + + /// + /// Moves resources from one resource group to another resource group. + /// + /// + /// The resources to be moved must be in the same source resource group in the + /// source subscription being used. The target resource group may be in a + /// different subscription. When moving resources, both the source group and + /// the target group are locked for the duration of the operation. Write and + /// delete operations are blocked on the groups until the move completes. + /// + /// + /// The name of the resource group from the source subscription containing the + /// resources to be moved. + /// + /// + /// Parameters for moving resources. + /// + /// + /// 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 BeginMoveResourcesWithHttpMessagesAsync(string sourceResourceGroupName, ResourcesMoveInfo parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (sourceResourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "sourceResourceGroupName"); + } + if (sourceResourceGroupName != null) + { + if (sourceResourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "sourceResourceGroupName", 90); + } + if (sourceResourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "sourceResourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(sourceResourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "sourceResourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (parameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("sourceResourceGroupName", sourceResourceGroupName); + tracingParameters.Add("parameters", parameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginMoveResources", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources").ToString(); + _url = _url.Replace("{sourceResourceGroupName}", System.Uri.EscapeDataString(sourceResourceGroupName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + 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(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 != 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; + } + + /// + /// Validates whether resources can be moved from one resource group to another + /// resource group. + /// + /// + /// This operation checks whether the specified resources can be moved to the + /// target. The resources to be moved must be in the same source resource group + /// in the source subscription being used. The target resource group may be in + /// a different subscription. If validation succeeds, it returns HTTP response + /// code 204 (no content). If validation fails, it returns HTTP response code + /// 409 (Conflict) with an error message. Retrieve the URL in the Location + /// header value to check the result of the long-running operation. + /// + /// + /// The name of the resource group from the source subscription containing the + /// resources to be validated for move. + /// + /// + /// Parameters for moving resources. + /// + /// + /// 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 BeginValidateMoveResourcesWithHttpMessagesAsync(string sourceResourceGroupName, ResourcesMoveInfo parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (sourceResourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "sourceResourceGroupName"); + } + if (sourceResourceGroupName != null) + { + if (sourceResourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "sourceResourceGroupName", 90); + } + if (sourceResourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "sourceResourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(sourceResourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "sourceResourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (parameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("sourceResourceGroupName", sourceResourceGroupName); + tracingParameters.Add("parameters", parameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginValidateMoveResources", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources").ToString(); + _url = _url.Replace("{sourceResourceGroupName}", System.Uri.EscapeDataString(sourceResourceGroupName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + 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(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 != 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; + } + + /// + /// Deletes a resource. + /// + /// + /// The name of the resource group that contains the resource to delete. The + /// name is case insensitive. + /// + /// + /// The namespace of the resource provider. + /// + /// + /// The parent resource identity. + /// + /// + /// The resource type. + /// + /// + /// The name of the resource to delete. + /// + /// + /// The API version to use for the operation. + /// + /// + /// 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 resourceProviderNamespace, string parentResourcePath, string resourceType, string resourceName, string apiVersion, 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 (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (resourceProviderNamespace == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceProviderNamespace"); + } + if (parentResourcePath == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "parentResourcePath"); + } + if (resourceType == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceType"); + } + if (resourceName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceName"); + } + if (apiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "apiVersion"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("resourceProviderNamespace", resourceProviderNamespace); + tracingParameters.Add("parentResourcePath", parentResourcePath); + tracingParameters.Add("resourceType", resourceType); + tracingParameters.Add("resourceName", resourceName); + 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/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{resourceProviderNamespace}", System.Uri.EscapeDataString(resourceProviderNamespace)); + _url = _url.Replace("{parentResourcePath}", parentResourcePath); + _url = _url.Replace("{resourceType}", resourceType); + _url = _url.Replace("{resourceName}", System.Uri.EscapeDataString(resourceName)); + _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; + } + + /// + /// Creates a resource. + /// + /// + /// The name of the resource group for the resource. The name is case + /// insensitive. + /// + /// + /// The namespace of the resource provider. + /// + /// + /// The parent resource identity. + /// + /// + /// The resource type of the resource to create. + /// + /// + /// The name of the resource to create. + /// + /// + /// The API version to use for the operation. + /// + /// + /// Parameters for creating or updating the 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> BeginCreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string resourceProviderNamespace, string parentResourcePath, string resourceType, string resourceName, string apiVersion, GenericResource 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 (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (resourceProviderNamespace == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceProviderNamespace"); + } + if (parentResourcePath == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "parentResourcePath"); + } + if (resourceType == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceType"); + } + if (resourceName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceName"); + } + if (apiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "apiVersion"); + } + 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"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("resourceProviderNamespace", resourceProviderNamespace); + tracingParameters.Add("parentResourcePath", parentResourcePath); + tracingParameters.Add("resourceType", resourceType); + tracingParameters.Add("resourceName", resourceName); + tracingParameters.Add("apiVersion", apiVersion); + 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/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{resourceProviderNamespace}", System.Uri.EscapeDataString(resourceProviderNamespace)); + _url = _url.Replace("{parentResourcePath}", parentResourcePath); + _url = _url.Replace("{resourceType}", resourceType); + _url = _url.Replace("{resourceName}", System.Uri.EscapeDataString(resourceName)); + _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 != 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 a resource. + /// + /// + /// The name of the resource group for the resource. The name is case + /// insensitive. + /// + /// + /// The namespace of the resource provider. + /// + /// + /// The parent resource identity. + /// + /// + /// The resource type of the resource to update. + /// + /// + /// The name of the resource to update. + /// + /// + /// The API version to use for the operation. + /// + /// + /// Parameters for updating the 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> BeginUpdateWithHttpMessagesAsync(string resourceGroupName, string resourceProviderNamespace, string parentResourcePath, string resourceType, string resourceName, string apiVersion, GenericResource 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 (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (resourceProviderNamespace == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceProviderNamespace"); + } + if (parentResourcePath == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "parentResourcePath"); + } + if (resourceType == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceType"); + } + if (resourceName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceName"); + } + if (apiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "apiVersion"); + } + if (parameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("resourceProviderNamespace", resourceProviderNamespace); + tracingParameters.Add("parentResourcePath", parentResourcePath); + tracingParameters.Add("resourceType", resourceType); + tracingParameters.Add("resourceName", resourceName); + tracingParameters.Add("apiVersion", apiVersion); + 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/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{resourceProviderNamespace}", System.Uri.EscapeDataString(resourceProviderNamespace)); + _url = _url.Replace("{parentResourcePath}", parentResourcePath); + _url = _url.Replace("{resourceType}", resourceType); + _url = _url.Replace("{resourceName}", System.Uri.EscapeDataString(resourceName)); + _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("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 resource by ID. + /// + /// + /// The fully qualified ID of the resource, including the resource name and + /// resource type. Use the format, + /// /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name} + /// + /// + /// The API version to use for the operation. + /// + /// + /// 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 BeginDeleteByIdWithHttpMessagesAsync(string resourceId, string apiVersion, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceId"); + } + if (apiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "apiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceId", resourceId); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginDeleteById", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{resourceId}").ToString(); + _url = _url.Replace("{resourceId}", resourceId); + 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; + } + + /// + /// Create a resource by ID. + /// + /// + /// The fully qualified ID of the resource, including the resource name and + /// resource type. Use the format, + /// /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name} + /// + /// + /// The API version to use for the operation. + /// + /// + /// Create or update resource parameters. + /// + /// + /// 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> BeginCreateOrUpdateByIdWithHttpMessagesAsync(string resourceId, string apiVersion, GenericResource parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceId"); + } + if (apiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "apiVersion"); + } + if (parameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); + } + if (parameters != null) + { + parameters.Validate(); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceId", resourceId); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("parameters", parameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginCreateOrUpdateById", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{resourceId}").ToString(); + _url = _url.Replace("{resourceId}", resourceId); + 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 a resource by ID. + /// + /// + /// The fully qualified ID of the resource, including the resource name and + /// resource type. Use the format, + /// /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name} + /// + /// + /// The API version to use for the operation. + /// + /// + /// Update resource parameters. + /// + /// + /// 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> BeginUpdateByIdWithHttpMessagesAsync(string resourceId, string apiVersion, GenericResource parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceId"); + } + if (apiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "apiVersion"); + } + if (parameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceId", resourceId); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("parameters", parameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginUpdateById", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{resourceId}").ToString(); + _url = _url.Replace("{resourceId}", resourceId); + 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; + } + + /// + /// Get all the resources for 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 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 all the resources 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 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/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/ResourcesOperationsExtensions.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/ResourcesOperationsExtensions.cs new file mode 100644 index 0000000000000..bafe0c72b45ed --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/ResourcesOperationsExtensions.cs @@ -0,0 +1,1308 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Microsoft.Rest.Azure.OData; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for ResourcesOperations. + /// + public static partial class ResourcesOperationsExtensions + { + /// + /// Get all the resources for a resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The resource group with the resources to get. + /// + /// + /// OData parameters to apply to the operation. + /// + public static IPage ListByResourceGroup(this IResourcesOperations operations, string resourceGroupName, ODataQuery odataQuery = default(ODataQuery)) + { + return operations.ListByResourceGroupAsync(resourceGroupName, odataQuery).GetAwaiter().GetResult(); + } + + /// + /// Get all the resources for a resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The resource group with the resources to get. + /// + /// + /// OData parameters to apply to the operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByResourceGroupAsync(this IResourcesOperations operations, string resourceGroupName, ODataQuery odataQuery = default(ODataQuery), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByResourceGroupWithHttpMessagesAsync(resourceGroupName, odataQuery, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Moves resources from one resource group to another resource group. + /// + /// + /// The resources to be moved must be in the same source resource group in the + /// source subscription being used. The target resource group may be in a + /// different subscription. When moving resources, both the source group and + /// the target group are locked for the duration of the operation. Write and + /// delete operations are blocked on the groups until the move completes. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group from the source subscription containing the + /// resources to be moved. + /// + /// + /// Parameters for moving resources. + /// + public static void MoveResources(this IResourcesOperations operations, string sourceResourceGroupName, ResourcesMoveInfo parameters) + { + operations.MoveResourcesAsync(sourceResourceGroupName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Moves resources from one resource group to another resource group. + /// + /// + /// The resources to be moved must be in the same source resource group in the + /// source subscription being used. The target resource group may be in a + /// different subscription. When moving resources, both the source group and + /// the target group are locked for the duration of the operation. Write and + /// delete operations are blocked on the groups until the move completes. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group from the source subscription containing the + /// resources to be moved. + /// + /// + /// Parameters for moving resources. + /// + /// + /// The cancellation token. + /// + public static async Task MoveResourcesAsync(this IResourcesOperations operations, string sourceResourceGroupName, ResourcesMoveInfo parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.MoveResourcesWithHttpMessagesAsync(sourceResourceGroupName, parameters, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Validates whether resources can be moved from one resource group to another + /// resource group. + /// + /// + /// This operation checks whether the specified resources can be moved to the + /// target. The resources to be moved must be in the same source resource group + /// in the source subscription being used. The target resource group may be in + /// a different subscription. If validation succeeds, it returns HTTP response + /// code 204 (no content). If validation fails, it returns HTTP response code + /// 409 (Conflict) with an error message. Retrieve the URL in the Location + /// header value to check the result of the long-running operation. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group from the source subscription containing the + /// resources to be validated for move. + /// + /// + /// Parameters for moving resources. + /// + public static void ValidateMoveResources(this IResourcesOperations operations, string sourceResourceGroupName, ResourcesMoveInfo parameters) + { + operations.ValidateMoveResourcesAsync(sourceResourceGroupName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Validates whether resources can be moved from one resource group to another + /// resource group. + /// + /// + /// This operation checks whether the specified resources can be moved to the + /// target. The resources to be moved must be in the same source resource group + /// in the source subscription being used. The target resource group may be in + /// a different subscription. If validation succeeds, it returns HTTP response + /// code 204 (no content). If validation fails, it returns HTTP response code + /// 409 (Conflict) with an error message. Retrieve the URL in the Location + /// header value to check the result of the long-running operation. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group from the source subscription containing the + /// resources to be validated for move. + /// + /// + /// Parameters for moving resources. + /// + /// + /// The cancellation token. + /// + public static async Task ValidateMoveResourcesAsync(this IResourcesOperations operations, string sourceResourceGroupName, ResourcesMoveInfo parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.ValidateMoveResourcesWithHttpMessagesAsync(sourceResourceGroupName, parameters, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Get all the resources in a subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// OData parameters to apply to the operation. + /// + public static IPage List(this IResourcesOperations operations, ODataQuery odataQuery = default(ODataQuery)) + { + return operations.ListAsync(odataQuery).GetAwaiter().GetResult(); + } + + /// + /// Get all the resources in a subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// OData parameters to apply to the operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAsync(this IResourcesOperations operations, ODataQuery odataQuery = default(ODataQuery), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(odataQuery, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Checks whether a resource exists. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group containing the resource to check. The name + /// is case insensitive. + /// + /// + /// The resource provider of the resource to check. + /// + /// + /// The parent resource identity. + /// + /// + /// The resource type. + /// + /// + /// The name of the resource to check whether it exists. + /// + /// + /// The API version to use for the operation. + /// + public static bool CheckExistence(this IResourcesOperations operations, string resourceGroupName, string resourceProviderNamespace, string parentResourcePath, string resourceType, string resourceName, string apiVersion) + { + return operations.CheckExistenceAsync(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion).GetAwaiter().GetResult(); + } + + /// + /// Checks whether a resource exists. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group containing the resource to check. The name + /// is case insensitive. + /// + /// + /// The resource provider of the resource to check. + /// + /// + /// The parent resource identity. + /// + /// + /// The resource type. + /// + /// + /// The name of the resource to check whether it exists. + /// + /// + /// The API version to use for the operation. + /// + /// + /// The cancellation token. + /// + public static async Task CheckExistenceAsync(this IResourcesOperations operations, string resourceGroupName, string resourceProviderNamespace, string parentResourcePath, string resourceType, string resourceName, string apiVersion, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CheckExistenceWithHttpMessagesAsync(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes a resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group that contains the resource to delete. The + /// name is case insensitive. + /// + /// + /// The namespace of the resource provider. + /// + /// + /// The parent resource identity. + /// + /// + /// The resource type. + /// + /// + /// The name of the resource to delete. + /// + /// + /// The API version to use for the operation. + /// + public static void Delete(this IResourcesOperations operations, string resourceGroupName, string resourceProviderNamespace, string parentResourcePath, string resourceType, string resourceName, string apiVersion) + { + operations.DeleteAsync(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion).GetAwaiter().GetResult(); + } + + /// + /// Deletes a resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group that contains the resource to delete. The + /// name is case insensitive. + /// + /// + /// The namespace of the resource provider. + /// + /// + /// The parent resource identity. + /// + /// + /// The resource type. + /// + /// + /// The name of the resource to delete. + /// + /// + /// The API version to use for the operation. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this IResourcesOperations operations, string resourceGroupName, string resourceProviderNamespace, string parentResourcePath, string resourceType, string resourceName, string apiVersion, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Creates a resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group for the resource. The name is case + /// insensitive. + /// + /// + /// The namespace of the resource provider. + /// + /// + /// The parent resource identity. + /// + /// + /// The resource type of the resource to create. + /// + /// + /// The name of the resource to create. + /// + /// + /// The API version to use for the operation. + /// + /// + /// Parameters for creating or updating the resource. + /// + public static GenericResource CreateOrUpdate(this IResourcesOperations operations, string resourceGroupName, string resourceProviderNamespace, string parentResourcePath, string resourceType, string resourceName, string apiVersion, GenericResource parameters) + { + return operations.CreateOrUpdateAsync(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion, parameters).GetAwaiter().GetResult(); + } + + /// + /// Creates a resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group for the resource. The name is case + /// insensitive. + /// + /// + /// The namespace of the resource provider. + /// + /// + /// The parent resource identity. + /// + /// + /// The resource type of the resource to create. + /// + /// + /// The name of the resource to create. + /// + /// + /// The API version to use for the operation. + /// + /// + /// Parameters for creating or updating the resource. + /// + /// + /// The cancellation token. + /// + public static async Task CreateOrUpdateAsync(this IResourcesOperations operations, string resourceGroupName, string resourceProviderNamespace, string parentResourcePath, string resourceType, string resourceName, string apiVersion, GenericResource parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Updates a resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group for the resource. The name is case + /// insensitive. + /// + /// + /// The namespace of the resource provider. + /// + /// + /// The parent resource identity. + /// + /// + /// The resource type of the resource to update. + /// + /// + /// The name of the resource to update. + /// + /// + /// The API version to use for the operation. + /// + /// + /// Parameters for updating the resource. + /// + public static GenericResource Update(this IResourcesOperations operations, string resourceGroupName, string resourceProviderNamespace, string parentResourcePath, string resourceType, string resourceName, string apiVersion, GenericResource parameters) + { + return operations.UpdateAsync(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion, parameters).GetAwaiter().GetResult(); + } + + /// + /// Updates a resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group for the resource. The name is case + /// insensitive. + /// + /// + /// The namespace of the resource provider. + /// + /// + /// The parent resource identity. + /// + /// + /// The resource type of the resource to update. + /// + /// + /// The name of the resource to update. + /// + /// + /// The API version to use for the operation. + /// + /// + /// Parameters for updating the resource. + /// + /// + /// The cancellation token. + /// + public static async Task UpdateAsync(this IResourcesOperations operations, string resourceGroupName, string resourceProviderNamespace, string parentResourcePath, string resourceType, string resourceName, string apiVersion, GenericResource parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.UpdateWithHttpMessagesAsync(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets a resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group containing the resource to get. The name is + /// case insensitive. + /// + /// + /// The namespace of the resource provider. + /// + /// + /// The parent resource identity. + /// + /// + /// The resource type of the resource. + /// + /// + /// The name of the resource to get. + /// + /// + /// The API version to use for the operation. + /// + public static GenericResource Get(this IResourcesOperations operations, string resourceGroupName, string resourceProviderNamespace, string parentResourcePath, string resourceType, string resourceName, string apiVersion) + { + return operations.GetAsync(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion).GetAwaiter().GetResult(); + } + + /// + /// Gets a resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group containing the resource to get. The name is + /// case insensitive. + /// + /// + /// The namespace of the resource provider. + /// + /// + /// The parent resource identity. + /// + /// + /// The resource type of the resource. + /// + /// + /// The name of the resource to get. + /// + /// + /// The API version to use for the operation. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IResourcesOperations operations, string resourceGroupName, string resourceProviderNamespace, string parentResourcePath, string resourceType, string resourceName, string apiVersion, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Checks by ID whether a resource exists. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The fully qualified ID of the resource, including the resource name and + /// resource type. Use the format, + /// /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name} + /// + /// + /// The API version to use for the operation. + /// + public static bool CheckExistenceById(this IResourcesOperations operations, string resourceId, string apiVersion) + { + return operations.CheckExistenceByIdAsync(resourceId, apiVersion).GetAwaiter().GetResult(); + } + + /// + /// Checks by ID whether a resource exists. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The fully qualified ID of the resource, including the resource name and + /// resource type. Use the format, + /// /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name} + /// + /// + /// The API version to use for the operation. + /// + /// + /// The cancellation token. + /// + public static async Task CheckExistenceByIdAsync(this IResourcesOperations operations, string resourceId, string apiVersion, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CheckExistenceByIdWithHttpMessagesAsync(resourceId, apiVersion, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes a resource by ID. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The fully qualified ID of the resource, including the resource name and + /// resource type. Use the format, + /// /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name} + /// + /// + /// The API version to use for the operation. + /// + public static void DeleteById(this IResourcesOperations operations, string resourceId, string apiVersion) + { + operations.DeleteByIdAsync(resourceId, apiVersion).GetAwaiter().GetResult(); + } + + /// + /// Deletes a resource by ID. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The fully qualified ID of the resource, including the resource name and + /// resource type. Use the format, + /// /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name} + /// + /// + /// The API version to use for the operation. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteByIdAsync(this IResourcesOperations operations, string resourceId, string apiVersion, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteByIdWithHttpMessagesAsync(resourceId, apiVersion, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Create a resource by ID. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The fully qualified ID of the resource, including the resource name and + /// resource type. Use the format, + /// /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name} + /// + /// + /// The API version to use for the operation. + /// + /// + /// Create or update resource parameters. + /// + public static GenericResource CreateOrUpdateById(this IResourcesOperations operations, string resourceId, string apiVersion, GenericResource parameters) + { + return operations.CreateOrUpdateByIdAsync(resourceId, apiVersion, parameters).GetAwaiter().GetResult(); + } + + /// + /// Create a resource by ID. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The fully qualified ID of the resource, including the resource name and + /// resource type. Use the format, + /// /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name} + /// + /// + /// The API version to use for the operation. + /// + /// + /// Create or update resource parameters. + /// + /// + /// The cancellation token. + /// + public static async Task CreateOrUpdateByIdAsync(this IResourcesOperations operations, string resourceId, string apiVersion, GenericResource parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateByIdWithHttpMessagesAsync(resourceId, apiVersion, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Updates a resource by ID. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The fully qualified ID of the resource, including the resource name and + /// resource type. Use the format, + /// /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name} + /// + /// + /// The API version to use for the operation. + /// + /// + /// Update resource parameters. + /// + public static GenericResource UpdateById(this IResourcesOperations operations, string resourceId, string apiVersion, GenericResource parameters) + { + return operations.UpdateByIdAsync(resourceId, apiVersion, parameters).GetAwaiter().GetResult(); + } + + /// + /// Updates a resource by ID. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The fully qualified ID of the resource, including the resource name and + /// resource type. Use the format, + /// /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name} + /// + /// + /// The API version to use for the operation. + /// + /// + /// Update resource parameters. + /// + /// + /// The cancellation token. + /// + public static async Task UpdateByIdAsync(this IResourcesOperations operations, string resourceId, string apiVersion, GenericResource parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.UpdateByIdWithHttpMessagesAsync(resourceId, apiVersion, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets a resource by ID. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The fully qualified ID of the resource, including the resource name and + /// resource type. Use the format, + /// /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name} + /// + /// + /// The API version to use for the operation. + /// + public static GenericResource GetById(this IResourcesOperations operations, string resourceId, string apiVersion) + { + return operations.GetByIdAsync(resourceId, apiVersion).GetAwaiter().GetResult(); + } + + /// + /// Gets a resource by ID. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The fully qualified ID of the resource, including the resource name and + /// resource type. Use the format, + /// /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name} + /// + /// + /// The API version to use for the operation. + /// + /// + /// The cancellation token. + /// + public static async Task GetByIdAsync(this IResourcesOperations operations, string resourceId, string apiVersion, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetByIdWithHttpMessagesAsync(resourceId, apiVersion, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Moves resources from one resource group to another resource group. + /// + /// + /// The resources to be moved must be in the same source resource group in the + /// source subscription being used. The target resource group may be in a + /// different subscription. When moving resources, both the source group and + /// the target group are locked for the duration of the operation. Write and + /// delete operations are blocked on the groups until the move completes. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group from the source subscription containing the + /// resources to be moved. + /// + /// + /// Parameters for moving resources. + /// + public static void BeginMoveResources(this IResourcesOperations operations, string sourceResourceGroupName, ResourcesMoveInfo parameters) + { + operations.BeginMoveResourcesAsync(sourceResourceGroupName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Moves resources from one resource group to another resource group. + /// + /// + /// The resources to be moved must be in the same source resource group in the + /// source subscription being used. The target resource group may be in a + /// different subscription. When moving resources, both the source group and + /// the target group are locked for the duration of the operation. Write and + /// delete operations are blocked on the groups until the move completes. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group from the source subscription containing the + /// resources to be moved. + /// + /// + /// Parameters for moving resources. + /// + /// + /// The cancellation token. + /// + public static async Task BeginMoveResourcesAsync(this IResourcesOperations operations, string sourceResourceGroupName, ResourcesMoveInfo parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.BeginMoveResourcesWithHttpMessagesAsync(sourceResourceGroupName, parameters, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Validates whether resources can be moved from one resource group to another + /// resource group. + /// + /// + /// This operation checks whether the specified resources can be moved to the + /// target. The resources to be moved must be in the same source resource group + /// in the source subscription being used. The target resource group may be in + /// a different subscription. If validation succeeds, it returns HTTP response + /// code 204 (no content). If validation fails, it returns HTTP response code + /// 409 (Conflict) with an error message. Retrieve the URL in the Location + /// header value to check the result of the long-running operation. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group from the source subscription containing the + /// resources to be validated for move. + /// + /// + /// Parameters for moving resources. + /// + public static void BeginValidateMoveResources(this IResourcesOperations operations, string sourceResourceGroupName, ResourcesMoveInfo parameters) + { + operations.BeginValidateMoveResourcesAsync(sourceResourceGroupName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Validates whether resources can be moved from one resource group to another + /// resource group. + /// + /// + /// This operation checks whether the specified resources can be moved to the + /// target. The resources to be moved must be in the same source resource group + /// in the source subscription being used. The target resource group may be in + /// a different subscription. If validation succeeds, it returns HTTP response + /// code 204 (no content). If validation fails, it returns HTTP response code + /// 409 (Conflict) with an error message. Retrieve the URL in the Location + /// header value to check the result of the long-running operation. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group from the source subscription containing the + /// resources to be validated for move. + /// + /// + /// Parameters for moving resources. + /// + /// + /// The cancellation token. + /// + public static async Task BeginValidateMoveResourcesAsync(this IResourcesOperations operations, string sourceResourceGroupName, ResourcesMoveInfo parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.BeginValidateMoveResourcesWithHttpMessagesAsync(sourceResourceGroupName, parameters, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Deletes a resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group that contains the resource to delete. The + /// name is case insensitive. + /// + /// + /// The namespace of the resource provider. + /// + /// + /// The parent resource identity. + /// + /// + /// The resource type. + /// + /// + /// The name of the resource to delete. + /// + /// + /// The API version to use for the operation. + /// + public static void BeginDelete(this IResourcesOperations operations, string resourceGroupName, string resourceProviderNamespace, string parentResourcePath, string resourceType, string resourceName, string apiVersion) + { + operations.BeginDeleteAsync(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion).GetAwaiter().GetResult(); + } + + /// + /// Deletes a resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group that contains the resource to delete. The + /// name is case insensitive. + /// + /// + /// The namespace of the resource provider. + /// + /// + /// The parent resource identity. + /// + /// + /// The resource type. + /// + /// + /// The name of the resource to delete. + /// + /// + /// The API version to use for the operation. + /// + /// + /// The cancellation token. + /// + public static async Task BeginDeleteAsync(this IResourcesOperations operations, string resourceGroupName, string resourceProviderNamespace, string parentResourcePath, string resourceType, string resourceName, string apiVersion, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.BeginDeleteWithHttpMessagesAsync(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Creates a resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group for the resource. The name is case + /// insensitive. + /// + /// + /// The namespace of the resource provider. + /// + /// + /// The parent resource identity. + /// + /// + /// The resource type of the resource to create. + /// + /// + /// The name of the resource to create. + /// + /// + /// The API version to use for the operation. + /// + /// + /// Parameters for creating or updating the resource. + /// + public static GenericResource BeginCreateOrUpdate(this IResourcesOperations operations, string resourceGroupName, string resourceProviderNamespace, string parentResourcePath, string resourceType, string resourceName, string apiVersion, GenericResource parameters) + { + return operations.BeginCreateOrUpdateAsync(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion, parameters).GetAwaiter().GetResult(); + } + + /// + /// Creates a resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group for the resource. The name is case + /// insensitive. + /// + /// + /// The namespace of the resource provider. + /// + /// + /// The parent resource identity. + /// + /// + /// The resource type of the resource to create. + /// + /// + /// The name of the resource to create. + /// + /// + /// The API version to use for the operation. + /// + /// + /// Parameters for creating or updating the resource. + /// + /// + /// The cancellation token. + /// + public static async Task BeginCreateOrUpdateAsync(this IResourcesOperations operations, string resourceGroupName, string resourceProviderNamespace, string parentResourcePath, string resourceType, string resourceName, string apiVersion, GenericResource parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Updates a resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group for the resource. The name is case + /// insensitive. + /// + /// + /// The namespace of the resource provider. + /// + /// + /// The parent resource identity. + /// + /// + /// The resource type of the resource to update. + /// + /// + /// The name of the resource to update. + /// + /// + /// The API version to use for the operation. + /// + /// + /// Parameters for updating the resource. + /// + public static GenericResource BeginUpdate(this IResourcesOperations operations, string resourceGroupName, string resourceProviderNamespace, string parentResourcePath, string resourceType, string resourceName, string apiVersion, GenericResource parameters) + { + return operations.BeginUpdateAsync(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion, parameters).GetAwaiter().GetResult(); + } + + /// + /// Updates a resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group for the resource. The name is case + /// insensitive. + /// + /// + /// The namespace of the resource provider. + /// + /// + /// The parent resource identity. + /// + /// + /// The resource type of the resource to update. + /// + /// + /// The name of the resource to update. + /// + /// + /// The API version to use for the operation. + /// + /// + /// Parameters for updating the resource. + /// + /// + /// The cancellation token. + /// + public static async Task BeginUpdateAsync(this IResourcesOperations operations, string resourceGroupName, string resourceProviderNamespace, string parentResourcePath, string resourceType, string resourceName, string apiVersion, GenericResource parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginUpdateWithHttpMessagesAsync(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes a resource by ID. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The fully qualified ID of the resource, including the resource name and + /// resource type. Use the format, + /// /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name} + /// + /// + /// The API version to use for the operation. + /// + public static void BeginDeleteById(this IResourcesOperations operations, string resourceId, string apiVersion) + { + operations.BeginDeleteByIdAsync(resourceId, apiVersion).GetAwaiter().GetResult(); + } + + /// + /// Deletes a resource by ID. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The fully qualified ID of the resource, including the resource name and + /// resource type. Use the format, + /// /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name} + /// + /// + /// The API version to use for the operation. + /// + /// + /// The cancellation token. + /// + public static async Task BeginDeleteByIdAsync(this IResourcesOperations operations, string resourceId, string apiVersion, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.BeginDeleteByIdWithHttpMessagesAsync(resourceId, apiVersion, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Create a resource by ID. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The fully qualified ID of the resource, including the resource name and + /// resource type. Use the format, + /// /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name} + /// + /// + /// The API version to use for the operation. + /// + /// + /// Create or update resource parameters. + /// + public static GenericResource BeginCreateOrUpdateById(this IResourcesOperations operations, string resourceId, string apiVersion, GenericResource parameters) + { + return operations.BeginCreateOrUpdateByIdAsync(resourceId, apiVersion, parameters).GetAwaiter().GetResult(); + } + + /// + /// Create a resource by ID. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The fully qualified ID of the resource, including the resource name and + /// resource type. Use the format, + /// /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name} + /// + /// + /// The API version to use for the operation. + /// + /// + /// Create or update resource parameters. + /// + /// + /// The cancellation token. + /// + public static async Task BeginCreateOrUpdateByIdAsync(this IResourcesOperations operations, string resourceId, string apiVersion, GenericResource parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginCreateOrUpdateByIdWithHttpMessagesAsync(resourceId, apiVersion, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Updates a resource by ID. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The fully qualified ID of the resource, including the resource name and + /// resource type. Use the format, + /// /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name} + /// + /// + /// The API version to use for the operation. + /// + /// + /// Update resource parameters. + /// + public static GenericResource BeginUpdateById(this IResourcesOperations operations, string resourceId, string apiVersion, GenericResource parameters) + { + return operations.BeginUpdateByIdAsync(resourceId, apiVersion, parameters).GetAwaiter().GetResult(); + } + + /// + /// Updates a resource by ID. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The fully qualified ID of the resource, including the resource name and + /// resource type. Use the format, + /// /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name} + /// + /// + /// The API version to use for the operation. + /// + /// + /// Update resource parameters. + /// + /// + /// The cancellation token. + /// + public static async Task BeginUpdateByIdAsync(this IResourcesOperations operations, string resourceId, string apiVersion, GenericResource parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginUpdateByIdWithHttpMessagesAsync(resourceId, apiVersion, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get all the resources for 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 IResourcesOperations operations, string nextPageLink) + { + return operations.ListByResourceGroupNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Get all the resources for 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 IResourcesOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByResourceGroupNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get all the resources 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 IResourcesOperations operations, string nextPageLink) + { + return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Get all the resources 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 IResourcesOperations 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/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/SdkInfo_DeploymentScriptsClient.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/SdkInfo_DeploymentScriptsClient.cs new file mode 100644 index 0000000000000..f30f968a6e28e --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/SdkInfo_DeploymentScriptsClient.cs @@ -0,0 +1,27 @@ + +// +// 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.ResourceManager +{ + using System; + using System.Collections.Generic; + using System.Linq; + + internal static partial class SdkInfo + { + public static IEnumerable> ApiInfo_DeploymentScriptsClient + { + get + { + return new Tuple[] + { + new Tuple("Resources", "DeploymentScripts", "2020-10-01"), + }.AsEnumerable(); + } + } + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/SdkInfo_FeatureClient.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/SdkInfo_FeatureClient.cs new file mode 100644 index 0000000000000..16b90d9298ecb --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/SdkInfo_FeatureClient.cs @@ -0,0 +1,29 @@ + +// +// 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.ResourceManager +{ + using System; + using System.Collections.Generic; + using System.Linq; + + internal static partial class SdkInfo + { + public static IEnumerable> ApiInfo_FeatureClient + { + get + { + return new Tuple[] + { + new Tuple("Features", "Features", "2021-07-01"), + new Tuple("Features", "ListOperations", "2021-07-01"), + new Tuple("Features", "SubscriptionFeatureRegistrations", "2021-07-01"), + }.AsEnumerable(); + } + } + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/SdkInfo_ManagementLinkClient.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/SdkInfo_ManagementLinkClient.cs new file mode 100644 index 0000000000000..e1479f25f8c45 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/SdkInfo_ManagementLinkClient.cs @@ -0,0 +1,29 @@ + +// +// 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.ResourceManager +{ + using System; + using System.Collections.Generic; + using System.Linq; + + internal static partial class SdkInfo + { + public static IEnumerable> ApiInfo_ManagementLinkClient + { + get + { + return new Tuple[] + { + new Tuple("ManagementLinkClient", "ResourceLinks", "2016-09-01"), + new Tuple("Resources", "Operations", "2016-09-01"), + new Tuple("Resources", "ResourceLinks", "2016-09-01"), + }.AsEnumerable(); + } + } + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/SdkInfo_ManagementLockClient.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/SdkInfo_ManagementLockClient.cs new file mode 100644 index 0000000000000..3466056fa81e7 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/SdkInfo_ManagementLockClient.cs @@ -0,0 +1,28 @@ + +// +// 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.ResourceManager +{ + using System; + using System.Collections.Generic; + using System.Linq; + + internal static partial class SdkInfo + { + public static IEnumerable> ApiInfo_ManagementLockClient + { + get + { + return new Tuple[] + { + new Tuple("Authorization", "AuthorizationOperations", "2020-05-01"), + new Tuple("Authorization", "ManagementLocks", "2020-05-01"), + }.AsEnumerable(); + } + } + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/SdkInfo_PolicyClient.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/SdkInfo_PolicyClient.cs new file mode 100644 index 0000000000000..c148d705027ec --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/SdkInfo_PolicyClient.cs @@ -0,0 +1,36 @@ + +// +// 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.ResourceManager +{ + using System; + using System.Collections.Generic; + using System.Linq; + + internal static partial class SdkInfo + { + public static IEnumerable> ApiInfo_PolicyClient + { + get + { + return new Tuple[] + { + new Tuple("Authorization", "DataPolicyManifests", "2020-09-01"), + new Tuple("Authorization", "PolicyAssignments", "2021-06-01"), + new Tuple("Authorization", "PolicyDefinitions", "2021-06-01"), + new Tuple("Authorization", "PolicyExemptions", "2020-07-01-preview"), + new Tuple("Authorization", "PolicySetDefinitions", "2021-06-01"), + new Tuple("Management", "PolicyAssignments", "2021-06-01"), + new Tuple("Management", "PolicyDefinitions", "2021-06-01"), + new Tuple("Management", "PolicyExemptions", "2020-07-01-preview"), + new Tuple("Management", "PolicySetDefinitions", "2021-06-01"), + new Tuple("PolicyClient", "PolicyAssignments", "2021-06-01"), + }.AsEnumerable(); + } + } + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/SdkInfo_ResourceManagementClient.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/SdkInfo_ResourceManagementClient.cs new file mode 100644 index 0000000000000..1b869c613da47 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/SdkInfo_ResourceManagementClient.cs @@ -0,0 +1,39 @@ + +// +// 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.ResourceManager +{ + using System; + using System.Collections.Generic; + using System.Linq; + + internal static partial class SdkInfo + { + public static IEnumerable> ApiInfo_ResourceManagementClient + { + get + { + return new Tuple[] + { + new Tuple("Management", "DeploymentOperations", "2021-04-01"), + new Tuple("Management", "Deployments", "2021-04-01"), + new Tuple("Management", "Providers", "2021-04-01"), + new Tuple("ResourceManagementClient", "DeploymentOperations", "2021-04-01"), + new Tuple("ResourceManagementClient", "ProviderResourceTypes", "2021-04-01"), + new Tuple("ResourceManagementClient", "Providers", "2021-04-01"), + new Tuple("ResourceManagementClient", "ResourceGroups", "2021-04-01"), + new Tuple("ResourceManagementClient", "Resources", "2021-04-01"), + new Tuple("ResourceManagementClient", "Tags", "2021-04-01"), + new Tuple("Resources", "DeploymentOperations", "2021-04-01"), + new Tuple("Resources", "Deployments", "2021-04-01"), + new Tuple("Resources", "Operations", "2021-04-01"), + new Tuple("Resources", "Tags", "2021-04-01"), + }.AsEnumerable(); + } + } + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/SdkInfo_SubscriptionClient.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/SdkInfo_SubscriptionClient.cs new file mode 100644 index 0000000000000..27f040a6c86cf --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/SdkInfo_SubscriptionClient.cs @@ -0,0 +1,30 @@ + +// +// 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.ResourceManager +{ + using System; + using System.Collections.Generic; + using System.Linq; + + internal static partial class SdkInfo + { + public static IEnumerable> ApiInfo_SubscriptionClient + { + get + { + return new Tuple[] + { + new Tuple("Resources", "Subscriptions", "2021-01-01"), + new Tuple("Resources", "checkResourceName", "2021-01-01"), + new Tuple("SubscriptionClient", "Subscriptions", "2021-01-01"), + new Tuple("SubscriptionClient", "Tenants", "2021-01-01"), + }.AsEnumerable(); + } + } + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/SdkInfo_TemplateSpecsClient.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/SdkInfo_TemplateSpecsClient.cs new file mode 100644 index 0000000000000..f24fdb9042958 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/SdkInfo_TemplateSpecsClient.cs @@ -0,0 +1,28 @@ + +// +// 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.ResourceManager +{ + using System; + using System.Collections.Generic; + using System.Linq; + + internal static partial class SdkInfo + { + public static IEnumerable> ApiInfo_TemplateSpecsClient + { + get + { + return new Tuple[] + { + new Tuple("Resources", "TemplateSpecVersions", "2021-05-01"), + new Tuple("Resources", "TemplateSpecs", "2021-05-01"), + }.AsEnumerable(); + } + } + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/SubscriptionClient.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/SubscriptionClient.cs new file mode 100644 index 0000000000000..49ddcd336c409 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/SubscriptionClient.cs @@ -0,0 +1,555 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager +{ + 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; + + /// + /// All resource groups and resources exist within subscriptions. These + /// operation enable you get information about your subscriptions and + /// tenants. A tenant is a dedicated instance of Azure Active Directory + /// (Azure AD) for your organization. + /// + public partial class SubscriptionClient : ServiceClient, ISubscriptionClient, 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 API version to use for the 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 ISubscriptionsOperations. + /// + public virtual ISubscriptionsOperations Subscriptions { get; private set; } + + /// + /// Gets the ITenantsOperations. + /// + public virtual ITenantsOperations Tenants { get; private set; } + + /// + /// Initializes a new instance of the SubscriptionClient class. + /// + /// + /// HttpClient to be used + /// + /// + /// True: will dispose the provided httpClient on calling SubscriptionClient.Dispose(). False: will not dispose provided httpClient + protected SubscriptionClient(HttpClient httpClient, bool disposeHttpClient) : base(httpClient, disposeHttpClient) + { + Initialize(); + } + + /// + /// Initializes a new instance of the SubscriptionClient class. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + protected SubscriptionClient(params DelegatingHandler[] handlers) : base(handlers) + { + Initialize(); + } + + /// + /// Initializes a new instance of the SubscriptionClient class. + /// + /// + /// Optional. The http client handler used to handle http transport. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + protected SubscriptionClient(HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : base(rootHandler, handlers) + { + Initialize(); + } + + /// + /// Initializes a new instance of the SubscriptionClient 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 SubscriptionClient(System.Uri baseUri, params DelegatingHandler[] handlers) : this(handlers) + { + if (baseUri == null) + { + throw new System.ArgumentNullException("baseUri"); + } + BaseUri = baseUri; + } + + /// + /// Initializes a new instance of the SubscriptionClient 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 SubscriptionClient(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 SubscriptionClient 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 SubscriptionClient(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 SubscriptionClient class. + /// + /// + /// Required. Credentials needed for the client to connect to Azure. + /// + /// + /// HttpClient to be used + /// + /// + /// True: will dispose the provided httpClient on calling SubscriptionClient.Dispose(). False: will not dispose provided httpClient + /// + /// Thrown when a required parameter is null + /// + public SubscriptionClient(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 SubscriptionClient 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 SubscriptionClient(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 SubscriptionClient 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 SubscriptionClient(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 SubscriptionClient 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 SubscriptionClient(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() + { + Subscriptions = new SubscriptionsOperations(this); + Tenants = new TenantsOperations(this); + BaseUri = new System.Uri("https://management.azure.com"); + ApiVersion = "2021-01-01"; + 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() + } + }; + 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 CloudErrorJsonConverter()); + } + /// + /// Checks resource name validity + /// + /// + /// A resource name is valid if it is not a reserved word, does not contains a + /// reserved word and does not start with a reserved word + /// + /// + /// Resource object with values for resource name and resource type + /// + /// + /// 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> CheckResourceNameWithHttpMessagesAsync(ResourceName resourceNameDefinition = default(ResourceName), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceNameDefinition != null) + { + resourceNameDefinition.Validate(); + } + if (ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceNameDefinition", resourceNameDefinition); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "CheckResourceName", tracingParameters); + } + // Construct URL + var _baseUrl = BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Resources/checkResourceName").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("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; + if(resourceNameDefinition != null) + { + _requestContent = SafeJsonConvert.SerializeObject(resourceNameDefinition, 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 (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; + } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/SubscriptionClientExtensions.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/SubscriptionClientExtensions.cs new file mode 100644 index 0000000000000..f641420a8f726 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/SubscriptionClientExtensions.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.ResourceManager +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for SubscriptionClient. + /// + public static partial class SubscriptionClientExtensions + { + /// + /// Checks resource name validity + /// + /// + /// A resource name is valid if it is not a reserved word, does not contains a + /// reserved word and does not start with a reserved word + /// + /// + /// The operations group for this extension method. + /// + /// + /// Resource object with values for resource name and resource type + /// + public static CheckResourceNameResult CheckResourceName(this ISubscriptionClient operations, ResourceName resourceNameDefinition = default(ResourceName)) + { + return operations.CheckResourceNameAsync(resourceNameDefinition).GetAwaiter().GetResult(); + } + + /// + /// Checks resource name validity + /// + /// + /// A resource name is valid if it is not a reserved word, does not contains a + /// reserved word and does not start with a reserved word + /// + /// + /// The operations group for this extension method. + /// + /// + /// Resource object with values for resource name and resource type + /// + /// + /// The cancellation token. + /// + public static async Task CheckResourceNameAsync(this ISubscriptionClient operations, ResourceName resourceNameDefinition = default(ResourceName), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CheckResourceNameWithHttpMessagesAsync(resourceNameDefinition, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/SubscriptionFeatureRegistrationsOperations.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/SubscriptionFeatureRegistrationsOperations.cs new file mode 100644 index 0000000000000..4b151de1a3c0e --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/SubscriptionFeatureRegistrationsOperations.cs @@ -0,0 +1,1313 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager +{ + 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; + + /// + /// SubscriptionFeatureRegistrationsOperations operations. + /// + internal partial class SubscriptionFeatureRegistrationsOperations : IServiceOperations, ISubscriptionFeatureRegistrationsOperations + { + /// + /// Initializes a new instance of the SubscriptionFeatureRegistrationsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal SubscriptionFeatureRegistrationsOperations(FeatureClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the FeatureClient + /// + public FeatureClient Client { get; private set; } + + /// + /// Returns a feature registration + /// + /// + /// The provider namespace. + /// + /// + /// The feature 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 providerNamespace, string featureName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (providerNamespace == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "providerNamespace"); + } + if (featureName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "featureName"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("providerNamespace", providerNamespace); + tracingParameters.Add("featureName", featureName); + 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.Features/featureProviders/{providerNamespace}/subscriptionFeatureRegistrations/{featureName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{providerNamespace}", System.Uri.EscapeDataString(providerNamespace)); + _url = _url.Replace("{featureName}", System.Uri.EscapeDataString(featureName)); + 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; + } + + /// + /// Create or update a feature registration. + /// + /// + /// The provider namespace. + /// + /// + /// The feature name. + /// + /// + /// Subscription Feature Registration Type details. + /// + /// + /// 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> CreateOrUpdateWithHttpMessagesAsync(string providerNamespace, string featureName, SubscriptionFeatureRegistration subscriptionFeatureRegistrationType = default(SubscriptionFeatureRegistration), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (providerNamespace == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "providerNamespace"); + } + if (featureName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "featureName"); + } + if (subscriptionFeatureRegistrationType != null) + { + subscriptionFeatureRegistrationType.Validate(); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("providerNamespace", providerNamespace); + tracingParameters.Add("featureName", featureName); + tracingParameters.Add("subscriptionFeatureRegistrationType", subscriptionFeatureRegistrationType); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "CreateOrUpdate", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Features/featureProviders/{providerNamespace}/subscriptionFeatureRegistrations/{featureName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{providerNamespace}", System.Uri.EscapeDataString(providerNamespace)); + _url = _url.Replace("{featureName}", System.Uri.EscapeDataString(featureName)); + 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(subscriptionFeatureRegistrationType != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(subscriptionFeatureRegistrationType, 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; + } + + /// + /// Deletes a feature registration + /// + /// + /// The provider namespace. + /// + /// + /// The feature name. + /// + /// + /// 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 DeleteWithHttpMessagesAsync(string providerNamespace, string featureName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (providerNamespace == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "providerNamespace"); + } + if (featureName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "featureName"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("providerNamespace", providerNamespace); + tracingParameters.Add("featureName", featureName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Delete", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Features/featureProviders/{providerNamespace}/subscriptionFeatureRegistrations/{featureName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{providerNamespace}", System.Uri.EscapeDataString(providerNamespace)); + _url = _url.Replace("{featureName}", System.Uri.EscapeDataString(featureName)); + 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 != 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 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; + } + + /// + /// Returns subscription feature registrations for given subscription and + /// provider namespace. + /// + /// + /// The provider namespace. + /// + /// + /// 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>> ListBySubscriptionWithHttpMessagesAsync(string providerNamespace, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (providerNamespace == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "providerNamespace"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("providerNamespace", providerNamespace); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListBySubscription", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Features/featureProviders/{providerNamespace}/subscriptionFeatureRegistrations").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{providerNamespace}", System.Uri.EscapeDataString(providerNamespace)); + 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; + } + + /// + /// Returns subscription feature registrations for 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>> ListAllBySubscriptionWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + // 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, "ListAllBySubscription", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Features/subscriptionFeatureRegistrations").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + 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; + } + + /// + /// Returns subscription feature registrations for given subscription and + /// provider namespace. + /// + /// + /// 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>> ListBySubscriptionNextWithHttpMessagesAsync(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, "ListBySubscriptionNext", 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; + } + + /// + /// Returns subscription feature registrations for given 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>> ListAllBySubscriptionNextWithHttpMessagesAsync(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, "ListAllBySubscriptionNext", 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/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/SubscriptionFeatureRegistrationsOperationsExtensions.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/SubscriptionFeatureRegistrationsOperationsExtensions.cs new file mode 100644 index 0000000000000..adccb98e4903d --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/SubscriptionFeatureRegistrationsOperationsExtensions.cs @@ -0,0 +1,282 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for SubscriptionFeatureRegistrationsOperations. + /// + public static partial class SubscriptionFeatureRegistrationsOperationsExtensions + { + /// + /// Returns a feature registration + /// + /// + /// The operations group for this extension method. + /// + /// + /// The provider namespace. + /// + /// + /// The feature name. + /// + public static SubscriptionFeatureRegistration Get(this ISubscriptionFeatureRegistrationsOperations operations, string providerNamespace, string featureName) + { + return operations.GetAsync(providerNamespace, featureName).GetAwaiter().GetResult(); + } + + /// + /// Returns a feature registration + /// + /// + /// The operations group for this extension method. + /// + /// + /// The provider namespace. + /// + /// + /// The feature name. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this ISubscriptionFeatureRegistrationsOperations operations, string providerNamespace, string featureName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(providerNamespace, featureName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Create or update a feature registration. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The provider namespace. + /// + /// + /// The feature name. + /// + /// + /// Subscription Feature Registration Type details. + /// + public static SubscriptionFeatureRegistration CreateOrUpdate(this ISubscriptionFeatureRegistrationsOperations operations, string providerNamespace, string featureName, SubscriptionFeatureRegistration subscriptionFeatureRegistrationType = default(SubscriptionFeatureRegistration)) + { + return operations.CreateOrUpdateAsync(providerNamespace, featureName, subscriptionFeatureRegistrationType).GetAwaiter().GetResult(); + } + + /// + /// Create or update a feature registration. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The provider namespace. + /// + /// + /// The feature name. + /// + /// + /// Subscription Feature Registration Type details. + /// + /// + /// The cancellation token. + /// + public static async Task CreateOrUpdateAsync(this ISubscriptionFeatureRegistrationsOperations operations, string providerNamespace, string featureName, SubscriptionFeatureRegistration subscriptionFeatureRegistrationType = default(SubscriptionFeatureRegistration), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(providerNamespace, featureName, subscriptionFeatureRegistrationType, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes a feature registration + /// + /// + /// The operations group for this extension method. + /// + /// + /// The provider namespace. + /// + /// + /// The feature name. + /// + public static void Delete(this ISubscriptionFeatureRegistrationsOperations operations, string providerNamespace, string featureName) + { + operations.DeleteAsync(providerNamespace, featureName).GetAwaiter().GetResult(); + } + + /// + /// Deletes a feature registration + /// + /// + /// The operations group for this extension method. + /// + /// + /// The provider namespace. + /// + /// + /// The feature name. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this ISubscriptionFeatureRegistrationsOperations operations, string providerNamespace, string featureName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(providerNamespace, featureName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Returns subscription feature registrations for given subscription and + /// provider namespace. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The provider namespace. + /// + public static IPage ListBySubscription(this ISubscriptionFeatureRegistrationsOperations operations, string providerNamespace) + { + return operations.ListBySubscriptionAsync(providerNamespace).GetAwaiter().GetResult(); + } + + /// + /// Returns subscription feature registrations for given subscription and + /// provider namespace. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The provider namespace. + /// + /// + /// The cancellation token. + /// + public static async Task> ListBySubscriptionAsync(this ISubscriptionFeatureRegistrationsOperations operations, string providerNamespace, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListBySubscriptionWithHttpMessagesAsync(providerNamespace, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Returns subscription feature registrations for given subscription. + /// + /// + /// The operations group for this extension method. + /// + public static IPage ListAllBySubscription(this ISubscriptionFeatureRegistrationsOperations operations) + { + return operations.ListAllBySubscriptionAsync().GetAwaiter().GetResult(); + } + + /// + /// Returns subscription feature registrations for given subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAllBySubscriptionAsync(this ISubscriptionFeatureRegistrationsOperations operations, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListAllBySubscriptionWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Returns subscription feature registrations for given subscription and + /// provider namespace. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListBySubscriptionNext(this ISubscriptionFeatureRegistrationsOperations operations, string nextPageLink) + { + return operations.ListBySubscriptionNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Returns subscription feature registrations for given subscription and + /// provider namespace. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListBySubscriptionNextAsync(this ISubscriptionFeatureRegistrationsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListBySubscriptionNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Returns subscription feature registrations for given subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListAllBySubscriptionNext(this ISubscriptionFeatureRegistrationsOperations operations, string nextPageLink) + { + return operations.ListAllBySubscriptionNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Returns subscription feature registrations for given 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> ListAllBySubscriptionNextAsync(this ISubscriptionFeatureRegistrationsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListAllBySubscriptionNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/SubscriptionsOperations.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/SubscriptionsOperations.cs new file mode 100644 index 0000000000000..1f3d48aea240e --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/SubscriptionsOperations.cs @@ -0,0 +1,968 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager +{ + 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; + + /// + /// SubscriptionsOperations operations. + /// + internal partial class SubscriptionsOperations : IServiceOperations, ISubscriptionsOperations + { + /// + /// Initializes a new instance of the SubscriptionsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal SubscriptionsOperations(SubscriptionClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the SubscriptionClient + /// + public SubscriptionClient Client { get; private set; } + + /// + /// Gets all available geo-locations. + /// + /// + /// This operation provides all the locations that are available for resource + /// providers; however, each resource provider may support a subset of this + /// list. + /// + /// + /// The ID of the target subscription. + /// + /// + /// Whether to include extended locations. + /// + /// + /// 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>> ListLocationsWithHttpMessagesAsync(string subscriptionId, bool? includeExtendedLocations = default(bool?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (subscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "subscriptionId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("subscriptionId", subscriptionId); + tracingParameters.Add("includeExtendedLocations", includeExtendedLocations); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListLocations", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/locations").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(subscriptionId)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (includeExtendedLocations != null) + { + _queryParameters.Add(string.Format("includeExtendedLocations={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(includeExtendedLocations, Client.SerializationSettings).Trim('"')))); + } + 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 details about a specified subscription. + /// + /// + /// The ID of the target 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> GetWithHttpMessagesAsync(string subscriptionId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (subscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "subscriptionId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("subscriptionId", subscriptionId); + 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}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(subscriptionId)); + 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 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 subscriptions for a tenant. + /// + /// + /// 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"); + } + // 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").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 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; + } + + /// + /// Compares a subscriptions logical zone mapping + /// + /// + /// The ID of the target subscription. + /// + /// + /// Parameters for checking zone peers. + /// + /// + /// 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> CheckZonePeersWithHttpMessagesAsync(string subscriptionId, CheckZonePeersRequest parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (subscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "subscriptionId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (parameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("subscriptionId", subscriptionId); + tracingParameters.Add("parameters", parameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "CheckZonePeers", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Resources/checkZonePeers/").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(subscriptionId)); + 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(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 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 all subscriptions for a tenant. + /// + /// + /// 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 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/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/SubscriptionsOperationsExtensions.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/SubscriptionsOperationsExtensions.cs new file mode 100644 index 0000000000000..519ef0ca18d26 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/SubscriptionsOperationsExtensions.cs @@ -0,0 +1,213 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager +{ + 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 SubscriptionsOperations. + /// + public static partial class SubscriptionsOperationsExtensions + { + /// + /// Gets all available geo-locations. + /// + /// + /// This operation provides all the locations that are available for resource + /// providers; however, each resource provider may support a subset of this + /// list. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The ID of the target subscription. + /// + /// + /// Whether to include extended locations. + /// + public static IEnumerable ListLocations(this ISubscriptionsOperations operations, string subscriptionId, bool? includeExtendedLocations = default(bool?)) + { + return operations.ListLocationsAsync(subscriptionId, includeExtendedLocations).GetAwaiter().GetResult(); + } + + /// + /// Gets all available geo-locations. + /// + /// + /// This operation provides all the locations that are available for resource + /// providers; however, each resource provider may support a subset of this + /// list. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The ID of the target subscription. + /// + /// + /// Whether to include extended locations. + /// + /// + /// The cancellation token. + /// + public static async Task> ListLocationsAsync(this ISubscriptionsOperations operations, string subscriptionId, bool? includeExtendedLocations = default(bool?), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListLocationsWithHttpMessagesAsync(subscriptionId, includeExtendedLocations, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets details about a specified subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The ID of the target subscription. + /// + public static Subscription Get(this ISubscriptionsOperations operations, string subscriptionId) + { + return operations.GetAsync(subscriptionId).GetAwaiter().GetResult(); + } + + /// + /// Gets details about a specified subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The ID of the target subscription. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this ISubscriptionsOperations operations, string subscriptionId, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(subscriptionId, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets all subscriptions for a tenant. + /// + /// + /// The operations group for this extension method. + /// + public static IPage List(this ISubscriptionsOperations operations) + { + return operations.ListAsync().GetAwaiter().GetResult(); + } + + /// + /// Gets all subscriptions for a tenant. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAsync(this ISubscriptionsOperations operations, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Compares a subscriptions logical zone mapping + /// + /// + /// The operations group for this extension method. + /// + /// + /// The ID of the target subscription. + /// + /// + /// Parameters for checking zone peers. + /// + public static CheckZonePeersResult CheckZonePeers(this ISubscriptionsOperations operations, string subscriptionId, CheckZonePeersRequest parameters) + { + return operations.CheckZonePeersAsync(subscriptionId, parameters).GetAwaiter().GetResult(); + } + + /// + /// Compares a subscriptions logical zone mapping + /// + /// + /// The operations group for this extension method. + /// + /// + /// The ID of the target subscription. + /// + /// + /// Parameters for checking zone peers. + /// + /// + /// The cancellation token. + /// + public static async Task CheckZonePeersAsync(this ISubscriptionsOperations operations, string subscriptionId, CheckZonePeersRequest parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CheckZonePeersWithHttpMessagesAsync(subscriptionId, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets all subscriptions for a tenant. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListNext(this ISubscriptionsOperations operations, string nextPageLink) + { + return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Gets all subscriptions for a tenant. + /// + /// + /// 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 ISubscriptionsOperations 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/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/TagsOperations.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/TagsOperations.cs new file mode 100644 index 0000000000000..79cd11ffc4764 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/TagsOperations.cs @@ -0,0 +1,1950 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager +{ + 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; + + /// + /// TagsOperations operations. + /// + internal partial class TagsOperations : IServiceOperations, ITagsOperations + { + /// + /// Initializes a new instance of the TagsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal TagsOperations(ResourceManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the ResourceManagementClient + /// + public ResourceManagementClient Client { get; private set; } + + /// + /// Deletes a predefined tag value for a predefined tag name. + /// + /// + /// This operation allows deleting a value from the list of predefined values + /// for an existing predefined tag name. The value being deleted must not be in + /// use as a tag value for the given tag name for any resource. + /// + /// + /// The name of the tag. + /// + /// + /// The value of the tag to delete. + /// + /// + /// 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 DeleteValueWithHttpMessagesAsync(string tagName, string tagValue, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (tagName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "tagName"); + } + if (tagValue == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "tagValue"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("tagName", tagName); + tracingParameters.Add("tagValue", tagValue); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "DeleteValue", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}").ToString(); + _url = _url.Replace("{tagName}", System.Uri.EscapeDataString(tagName)); + _url = _url.Replace("{tagValue}", System.Uri.EscapeDataString(tagValue)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + 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 != 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; + } + + /// + /// Creates a predefined value for a predefined tag name. + /// + /// + /// This operation allows adding a value to the list of predefined values for + /// an existing predefined tag name. A tag value can have a maximum of 256 + /// characters. + /// + /// + /// The name of the tag. + /// + /// + /// The value of the tag to create. + /// + /// + /// 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> CreateOrUpdateValueWithHttpMessagesAsync(string tagName, string tagValue, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (tagName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "tagName"); + } + if (tagValue == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "tagValue"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("tagName", tagName); + tracingParameters.Add("tagValue", tagValue); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "CreateOrUpdateValue", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}").ToString(); + _url = _url.Replace("{tagName}", System.Uri.EscapeDataString(tagName)); + _url = _url.Replace("{tagValue}", System.Uri.EscapeDataString(tagValue)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + 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; + // 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; + } + + /// + /// Creates a predefined tag name. + /// + /// + /// This operation allows adding a name to the list of predefined tag names for + /// the given subscription. A tag name can have a maximum of 512 characters and + /// is case-insensitive. Tag names cannot have the following prefixes which are + /// reserved for Azure use: 'microsoft', 'azure', 'windows'. + /// + /// + /// The name of the tag to create. + /// + /// + /// 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> CreateOrUpdateWithHttpMessagesAsync(string tagName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (tagName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "tagName"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("tagName", tagName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "CreateOrUpdate", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/tagNames/{tagName}").ToString(); + _url = _url.Replace("{tagName}", System.Uri.EscapeDataString(tagName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + 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; + // 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; + } + + /// + /// Deletes a predefined tag name. + /// + /// + /// This operation allows deleting a name from the list of predefined tag names + /// for the given subscription. The name being deleted must not be in use as a + /// tag name for any resource. All predefined values for the given name must + /// have already been deleted. + /// + /// + /// The name of the tag. + /// + /// + /// 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 DeleteWithHttpMessagesAsync(string tagName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (tagName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "tagName"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("tagName", tagName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Delete", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/tagNames/{tagName}").ToString(); + _url = _url.Replace("{tagName}", System.Uri.EscapeDataString(tagName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + 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 != 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 summary of tag usage under the subscription. + /// + /// + /// This operation performs a union of predefined tags, resource tags, resource + /// group tags and subscription tags, and returns a summary of usage for each + /// tag name and value under the given subscription. In case of a large number + /// of tags, this operation may return a previously cached result. + /// + /// + /// 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.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + // 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}/tagNames").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + 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 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 the entire set of tags on a resource or subscription. + /// + /// + /// This operation allows adding or replacing the entire set of tags on the + /// specified resource or subscription. The specified entity can have a maximum + /// of 50 tags. + /// + /// + /// The resource scope. + /// + /// + /// + /// + /// 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> CreateOrUpdateAtScopeWithHttpMessagesAsync(string scope, TagsResource parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (scope == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "scope"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (parameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); + } + if (parameters != null) + { + parameters.Validate(); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("scope", scope); + tracingParameters.Add("parameters", parameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "CreateOrUpdateAtScope", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{scope}/providers/Microsoft.Resources/tags/default").ToString(); + _url = _url.Replace("{scope}", scope); + 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) + { + 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; + } + + /// + /// Selectively updates the set of tags on a resource or subscription. + /// + /// + /// This operation allows replacing, merging or selectively deleting tags on + /// the specified resource or subscription. The specified entity can have a + /// maximum of 50 tags at the end of the operation. The 'replace' option + /// replaces the entire set of existing tags with a new set. The 'merge' option + /// allows adding tags with new names and updating the values of tags with + /// existing names. The 'delete' option allows selectively deleting tags based + /// on given names or name/value pairs. + /// + /// + /// The resource scope. + /// + /// + /// + /// + /// 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> UpdateAtScopeWithHttpMessagesAsync(string scope, TagsPatchResource parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (scope == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "scope"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (parameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("scope", scope); + tracingParameters.Add("parameters", parameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "UpdateAtScope", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{scope}/providers/Microsoft.Resources/tags/default").ToString(); + _url = _url.Replace("{scope}", scope); + 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) + { + 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 entire set of tags on a resource or subscription. + /// + /// + /// The resource scope. + /// + /// + /// 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> GetAtScopeWithHttpMessagesAsync(string scope, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (scope == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "scope"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("scope", scope); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetAtScope", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{scope}/providers/Microsoft.Resources/tags/default").ToString(); + _url = _url.Replace("{scope}", scope); + 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 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 the entire set of tags on a resource or subscription. + /// + /// + /// The resource scope. + /// + /// + /// 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 DeleteAtScopeWithHttpMessagesAsync(string scope, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (scope == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "scope"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("scope", scope); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "DeleteAtScope", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{scope}/providers/Microsoft.Resources/tags/default").ToString(); + _url = _url.Replace("{scope}", scope); + 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) + { + 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 summary of tag usage under the subscription. + /// + /// + /// This operation performs a union of predefined tags, resource tags, resource + /// group tags and subscription tags, and returns a summary of usage for each + /// tag name and value under the given subscription. In case of a large number + /// of tags, this operation may return a previously cached 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) + { + 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/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/TagsOperationsExtensions.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/TagsOperationsExtensions.cs new file mode 100644 index 0000000000000..5c520586c26d3 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/TagsOperationsExtensions.cs @@ -0,0 +1,466 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for TagsOperations. + /// + public static partial class TagsOperationsExtensions + { + /// + /// Deletes a predefined tag value for a predefined tag name. + /// + /// + /// This operation allows deleting a value from the list of predefined values + /// for an existing predefined tag name. The value being deleted must not be in + /// use as a tag value for the given tag name for any resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the tag. + /// + /// + /// The value of the tag to delete. + /// + public static void DeleteValue(this ITagsOperations operations, string tagName, string tagValue) + { + operations.DeleteValueAsync(tagName, tagValue).GetAwaiter().GetResult(); + } + + /// + /// Deletes a predefined tag value for a predefined tag name. + /// + /// + /// This operation allows deleting a value from the list of predefined values + /// for an existing predefined tag name. The value being deleted must not be in + /// use as a tag value for the given tag name for any resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the tag. + /// + /// + /// The value of the tag to delete. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteValueAsync(this ITagsOperations operations, string tagName, string tagValue, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteValueWithHttpMessagesAsync(tagName, tagValue, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Creates a predefined value for a predefined tag name. + /// + /// + /// This operation allows adding a value to the list of predefined values for + /// an existing predefined tag name. A tag value can have a maximum of 256 + /// characters. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the tag. + /// + /// + /// The value of the tag to create. + /// + public static TagValue CreateOrUpdateValue(this ITagsOperations operations, string tagName, string tagValue) + { + return operations.CreateOrUpdateValueAsync(tagName, tagValue).GetAwaiter().GetResult(); + } + + /// + /// Creates a predefined value for a predefined tag name. + /// + /// + /// This operation allows adding a value to the list of predefined values for + /// an existing predefined tag name. A tag value can have a maximum of 256 + /// characters. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the tag. + /// + /// + /// The value of the tag to create. + /// + /// + /// The cancellation token. + /// + public static async Task CreateOrUpdateValueAsync(this ITagsOperations operations, string tagName, string tagValue, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateValueWithHttpMessagesAsync(tagName, tagValue, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Creates a predefined tag name. + /// + /// + /// This operation allows adding a name to the list of predefined tag names for + /// the given subscription. A tag name can have a maximum of 512 characters and + /// is case-insensitive. Tag names cannot have the following prefixes which are + /// reserved for Azure use: 'microsoft', 'azure', 'windows'. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the tag to create. + /// + public static TagDetails CreateOrUpdate(this ITagsOperations operations, string tagName) + { + return operations.CreateOrUpdateAsync(tagName).GetAwaiter().GetResult(); + } + + /// + /// Creates a predefined tag name. + /// + /// + /// This operation allows adding a name to the list of predefined tag names for + /// the given subscription. A tag name can have a maximum of 512 characters and + /// is case-insensitive. Tag names cannot have the following prefixes which are + /// reserved for Azure use: 'microsoft', 'azure', 'windows'. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the tag to create. + /// + /// + /// The cancellation token. + /// + public static async Task CreateOrUpdateAsync(this ITagsOperations operations, string tagName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(tagName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes a predefined tag name. + /// + /// + /// This operation allows deleting a name from the list of predefined tag names + /// for the given subscription. The name being deleted must not be in use as a + /// tag name for any resource. All predefined values for the given name must + /// have already been deleted. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the tag. + /// + public static void Delete(this ITagsOperations operations, string tagName) + { + operations.DeleteAsync(tagName).GetAwaiter().GetResult(); + } + + /// + /// Deletes a predefined tag name. + /// + /// + /// This operation allows deleting a name from the list of predefined tag names + /// for the given subscription. The name being deleted must not be in use as a + /// tag name for any resource. All predefined values for the given name must + /// have already been deleted. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the tag. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this ITagsOperations operations, string tagName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(tagName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Gets a summary of tag usage under the subscription. + /// + /// + /// This operation performs a union of predefined tags, resource tags, resource + /// group tags and subscription tags, and returns a summary of usage for each + /// tag name and value under the given subscription. In case of a large number + /// of tags, this operation may return a previously cached result. + /// + /// + /// The operations group for this extension method. + /// + public static IPage List(this ITagsOperations operations) + { + return operations.ListAsync().GetAwaiter().GetResult(); + } + + /// + /// Gets a summary of tag usage under the subscription. + /// + /// + /// This operation performs a union of predefined tags, resource tags, resource + /// group tags and subscription tags, and returns a summary of usage for each + /// tag name and value under the given subscription. In case of a large number + /// of tags, this operation may return a previously cached result. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAsync(this ITagsOperations operations, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Creates or updates the entire set of tags on a resource or subscription. + /// + /// + /// This operation allows adding or replacing the entire set of tags on the + /// specified resource or subscription. The specified entity can have a maximum + /// of 50 tags. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The resource scope. + /// + /// + /// + public static TagsResource CreateOrUpdateAtScope(this ITagsOperations operations, string scope, TagsResource parameters) + { + return operations.CreateOrUpdateAtScopeAsync(scope, parameters).GetAwaiter().GetResult(); + } + + /// + /// Creates or updates the entire set of tags on a resource or subscription. + /// + /// + /// This operation allows adding or replacing the entire set of tags on the + /// specified resource or subscription. The specified entity can have a maximum + /// of 50 tags. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The resource scope. + /// + /// + /// + /// + /// The cancellation token. + /// + public static async Task CreateOrUpdateAtScopeAsync(this ITagsOperations operations, string scope, TagsResource parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateAtScopeWithHttpMessagesAsync(scope, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Selectively updates the set of tags on a resource or subscription. + /// + /// + /// This operation allows replacing, merging or selectively deleting tags on + /// the specified resource or subscription. The specified entity can have a + /// maximum of 50 tags at the end of the operation. The 'replace' option + /// replaces the entire set of existing tags with a new set. The 'merge' option + /// allows adding tags with new names and updating the values of tags with + /// existing names. The 'delete' option allows selectively deleting tags based + /// on given names or name/value pairs. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The resource scope. + /// + /// + /// + public static TagsResource UpdateAtScope(this ITagsOperations operations, string scope, TagsPatchResource parameters) + { + return operations.UpdateAtScopeAsync(scope, parameters).GetAwaiter().GetResult(); + } + + /// + /// Selectively updates the set of tags on a resource or subscription. + /// + /// + /// This operation allows replacing, merging or selectively deleting tags on + /// the specified resource or subscription. The specified entity can have a + /// maximum of 50 tags at the end of the operation. The 'replace' option + /// replaces the entire set of existing tags with a new set. The 'merge' option + /// allows adding tags with new names and updating the values of tags with + /// existing names. The 'delete' option allows selectively deleting tags based + /// on given names or name/value pairs. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The resource scope. + /// + /// + /// + /// + /// The cancellation token. + /// + public static async Task UpdateAtScopeAsync(this ITagsOperations operations, string scope, TagsPatchResource parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.UpdateAtScopeWithHttpMessagesAsync(scope, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets the entire set of tags on a resource or subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The resource scope. + /// + public static TagsResource GetAtScope(this ITagsOperations operations, string scope) + { + return operations.GetAtScopeAsync(scope).GetAwaiter().GetResult(); + } + + /// + /// Gets the entire set of tags on a resource or subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The resource scope. + /// + /// + /// The cancellation token. + /// + public static async Task GetAtScopeAsync(this ITagsOperations operations, string scope, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetAtScopeWithHttpMessagesAsync(scope, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes the entire set of tags on a resource or subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The resource scope. + /// + public static void DeleteAtScope(this ITagsOperations operations, string scope) + { + operations.DeleteAtScopeAsync(scope).GetAwaiter().GetResult(); + } + + /// + /// Deletes the entire set of tags on a resource or subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The resource scope. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAtScopeAsync(this ITagsOperations operations, string scope, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteAtScopeWithHttpMessagesAsync(scope, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Gets a summary of tag usage under the subscription. + /// + /// + /// This operation performs a union of predefined tags, resource tags, resource + /// group tags and subscription tags, and returns a summary of usage for each + /// tag name and value under the given subscription. In case of a large number + /// of tags, this operation may return a previously cached result. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListNext(this ITagsOperations operations, string nextPageLink) + { + return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Gets a summary of tag usage under the subscription. + /// + /// + /// This operation performs a union of predefined tags, resource tags, resource + /// group tags and subscription tags, and returns a summary of usage for each + /// tag name and value under the given subscription. In case of a large number + /// of tags, this operation may return a previously cached 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 ITagsOperations 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/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/TemplateSpecVersionsOperations.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/TemplateSpecVersionsOperations.cs new file mode 100644 index 0000000000000..b14ba9649ec43 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/TemplateSpecVersionsOperations.cs @@ -0,0 +1,1449 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager +{ + 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; + + /// + /// TemplateSpecVersionsOperations operations. + /// + internal partial class TemplateSpecVersionsOperations : IServiceOperations, ITemplateSpecVersionsOperations + { + /// + /// Initializes a new instance of the TemplateSpecVersionsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal TemplateSpecVersionsOperations(TemplateSpecsClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the TemplateSpecsClient + /// + public TemplateSpecsClient Client { get; private set; } + + /// + /// Creates or updates a Template Spec version. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Name of the Template Spec. + /// + /// + /// The version of the Template Spec. + /// + /// + /// Template Spec Version supplied to the 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> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string templateSpecName, string templateSpecVersion, TemplateSpecVersion templateSpecVersionModel, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + 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 (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (templateSpecName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "templateSpecName"); + } + if (templateSpecName != null) + { + if (templateSpecName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "templateSpecName", 90); + } + if (templateSpecName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "templateSpecName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(templateSpecName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "templateSpecName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (templateSpecVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "templateSpecVersion"); + } + if (templateSpecVersion != null) + { + if (templateSpecVersion.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "templateSpecVersion", 90); + } + if (templateSpecVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "templateSpecVersion", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(templateSpecVersion, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "templateSpecVersion", "^[-\\w\\._\\(\\)]+$"); + } + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (templateSpecVersionModel == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "templateSpecVersionModel"); + } + if (templateSpecVersionModel != null) + { + templateSpecVersionModel.Validate(); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("templateSpecName", templateSpecName); + tracingParameters.Add("templateSpecVersion", templateSpecVersion); + tracingParameters.Add("templateSpecVersionModel", templateSpecVersionModel); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "CreateOrUpdate", 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.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{templateSpecName}", System.Uri.EscapeDataString(templateSpecName)); + _url = _url.Replace("{templateSpecVersion}", System.Uri.EscapeDataString(templateSpecVersion)); + 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(templateSpecVersionModel != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(templateSpecVersionModel, 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 TemplateSpecsErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + TemplateSpecsError _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); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Updates Template Spec Version tags with specified values. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Name of the Template Spec. + /// + /// + /// The version of the Template Spec. + /// + /// + /// Template Spec Version resource with the tags to be updated. + /// + /// + /// 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> UpdateWithHttpMessagesAsync(string resourceGroupName, string templateSpecName, string templateSpecVersion, TemplateSpecVersionUpdateModel templateSpecVersionUpdateModel = default(TemplateSpecVersionUpdateModel), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + 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 (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (templateSpecName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "templateSpecName"); + } + if (templateSpecName != null) + { + if (templateSpecName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "templateSpecName", 90); + } + if (templateSpecName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "templateSpecName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(templateSpecName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "templateSpecName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (templateSpecVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "templateSpecVersion"); + } + if (templateSpecVersion != null) + { + if (templateSpecVersion.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "templateSpecVersion", 90); + } + if (templateSpecVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "templateSpecVersion", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(templateSpecVersion, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "templateSpecVersion", "^[-\\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("templateSpecName", templateSpecName); + tracingParameters.Add("templateSpecVersion", templateSpecVersion); + tracingParameters.Add("templateSpecVersionUpdateModel", templateSpecVersionUpdateModel); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Update", 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.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{templateSpecName}", System.Uri.EscapeDataString(templateSpecName)); + _url = _url.Replace("{templateSpecVersion}", System.Uri.EscapeDataString(templateSpecVersion)); + 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(templateSpecVersionUpdateModel != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(templateSpecVersionUpdateModel, 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 TemplateSpecsErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + TemplateSpecsError _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 Template Spec version from a specific Template Spec. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Name of the Template Spec. + /// + /// + /// The version of the Template Spec. + /// + /// + /// 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 templateSpecName, string templateSpecVersion, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + 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 (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (templateSpecName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "templateSpecName"); + } + if (templateSpecName != null) + { + if (templateSpecName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "templateSpecName", 90); + } + if (templateSpecName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "templateSpecName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(templateSpecName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "templateSpecName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (templateSpecVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "templateSpecVersion"); + } + if (templateSpecVersion != null) + { + if (templateSpecVersion.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "templateSpecVersion", 90); + } + if (templateSpecVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "templateSpecVersion", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(templateSpecVersion, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "templateSpecVersion", "^[-\\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("templateSpecName", templateSpecName); + tracingParameters.Add("templateSpecVersion", templateSpecVersion); + 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.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{templateSpecName}", System.Uri.EscapeDataString(templateSpecName)); + _url = _url.Replace("{templateSpecVersion}", System.Uri.EscapeDataString(templateSpecVersion)); + 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 TemplateSpecsErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + TemplateSpecsError _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 specific version from a Template Spec. When operation completes, + /// status code 200 returned without content. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Name of the Template Spec. + /// + /// + /// The version of the Template Spec. + /// + /// + /// 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 DeleteWithHttpMessagesAsync(string resourceGroupName, string templateSpecName, string templateSpecVersion, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + 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 (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (templateSpecName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "templateSpecName"); + } + if (templateSpecName != null) + { + if (templateSpecName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "templateSpecName", 90); + } + if (templateSpecName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "templateSpecName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(templateSpecName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "templateSpecName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (templateSpecVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "templateSpecVersion"); + } + if (templateSpecVersion != null) + { + if (templateSpecVersion.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "templateSpecVersion", 90); + } + if (templateSpecVersion.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "templateSpecVersion", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(templateSpecVersion, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "templateSpecVersion", "^[-\\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("templateSpecName", templateSpecName); + tracingParameters.Add("templateSpecVersion", templateSpecVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Delete", 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.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{templateSpecName}", System.Uri.EscapeDataString(templateSpecName)); + _url = _url.Replace("{templateSpecVersion}", System.Uri.EscapeDataString(templateSpecVersion)); + 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 != 204) + { + var ex = new TemplateSpecsErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + TemplateSpecsError _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(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Lists all the Template Spec versions in the specified Template Spec. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Name of the Template Spec. + /// + /// + /// 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 templateSpecName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + 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 (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (templateSpecName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "templateSpecName"); + } + if (templateSpecName != null) + { + if (templateSpecName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "templateSpecName", 90); + } + if (templateSpecName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "templateSpecName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(templateSpecName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "templateSpecName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("templateSpecName", templateSpecName); + 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.Resources/templateSpecs/{templateSpecName}/versions").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{templateSpecName}", System.Uri.EscapeDataString(templateSpecName)); + 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 TemplateSpecsErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + TemplateSpecsError _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 Template Spec versions in the specified Template Spec. + /// + /// + /// 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 TemplateSpecsErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + TemplateSpecsError _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/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/TemplateSpecVersionsOperationsExtensions.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/TemplateSpecVersionsOperationsExtensions.cs new file mode 100644 index 0000000000000..b3e54acdb510a --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/TemplateSpecVersionsOperationsExtensions.cs @@ -0,0 +1,294 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for TemplateSpecVersionsOperations. + /// + public static partial class TemplateSpecVersionsOperationsExtensions + { + /// + /// Creates or updates a Template Spec version. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Name of the Template Spec. + /// + /// + /// The version of the Template Spec. + /// + /// + /// Template Spec Version supplied to the operation. + /// + public static TemplateSpecVersion CreateOrUpdate(this ITemplateSpecVersionsOperations operations, string resourceGroupName, string templateSpecName, string templateSpecVersion, TemplateSpecVersion templateSpecVersionModel) + { + return operations.CreateOrUpdateAsync(resourceGroupName, templateSpecName, templateSpecVersion, templateSpecVersionModel).GetAwaiter().GetResult(); + } + + /// + /// Creates or updates a Template Spec version. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Name of the Template Spec. + /// + /// + /// The version of the Template Spec. + /// + /// + /// Template Spec Version supplied to the operation. + /// + /// + /// The cancellation token. + /// + public static async Task CreateOrUpdateAsync(this ITemplateSpecVersionsOperations operations, string resourceGroupName, string templateSpecName, string templateSpecVersion, TemplateSpecVersion templateSpecVersionModel, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, templateSpecName, templateSpecVersion, templateSpecVersionModel, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Updates Template Spec Version tags with specified values. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Name of the Template Spec. + /// + /// + /// The version of the Template Spec. + /// + /// + /// Template Spec Version resource with the tags to be updated. + /// + public static TemplateSpecVersion Update(this ITemplateSpecVersionsOperations operations, string resourceGroupName, string templateSpecName, string templateSpecVersion, TemplateSpecVersionUpdateModel templateSpecVersionUpdateModel = default(TemplateSpecVersionUpdateModel)) + { + return operations.UpdateAsync(resourceGroupName, templateSpecName, templateSpecVersion, templateSpecVersionUpdateModel).GetAwaiter().GetResult(); + } + + /// + /// Updates Template Spec Version tags with specified values. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Name of the Template Spec. + /// + /// + /// The version of the Template Spec. + /// + /// + /// Template Spec Version resource with the tags to be updated. + /// + /// + /// The cancellation token. + /// + public static async Task UpdateAsync(this ITemplateSpecVersionsOperations operations, string resourceGroupName, string templateSpecName, string templateSpecVersion, TemplateSpecVersionUpdateModel templateSpecVersionUpdateModel = default(TemplateSpecVersionUpdateModel), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.UpdateWithHttpMessagesAsync(resourceGroupName, templateSpecName, templateSpecVersion, templateSpecVersionUpdateModel, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets a Template Spec version from a specific Template Spec. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Name of the Template Spec. + /// + /// + /// The version of the Template Spec. + /// + public static TemplateSpecVersion Get(this ITemplateSpecVersionsOperations operations, string resourceGroupName, string templateSpecName, string templateSpecVersion) + { + return operations.GetAsync(resourceGroupName, templateSpecName, templateSpecVersion).GetAwaiter().GetResult(); + } + + /// + /// Gets a Template Spec version from a specific Template Spec. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Name of the Template Spec. + /// + /// + /// The version of the Template Spec. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this ITemplateSpecVersionsOperations operations, string resourceGroupName, string templateSpecName, string templateSpecVersion, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, templateSpecName, templateSpecVersion, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes a specific version from a Template Spec. When operation completes, + /// status code 200 returned without content. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Name of the Template Spec. + /// + /// + /// The version of the Template Spec. + /// + public static void Delete(this ITemplateSpecVersionsOperations operations, string resourceGroupName, string templateSpecName, string templateSpecVersion) + { + operations.DeleteAsync(resourceGroupName, templateSpecName, templateSpecVersion).GetAwaiter().GetResult(); + } + + /// + /// Deletes a specific version from a Template Spec. When operation completes, + /// status code 200 returned without content. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Name of the Template Spec. + /// + /// + /// The version of the Template Spec. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this ITemplateSpecVersionsOperations operations, string resourceGroupName, string templateSpecName, string templateSpecVersion, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, templateSpecName, templateSpecVersion, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Lists all the Template Spec versions in the specified Template Spec. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Name of the Template Spec. + /// + public static IPage List(this ITemplateSpecVersionsOperations operations, string resourceGroupName, string templateSpecName) + { + return operations.ListAsync(resourceGroupName, templateSpecName).GetAwaiter().GetResult(); + } + + /// + /// Lists all the Template Spec versions in the specified Template Spec. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Name of the Template Spec. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAsync(this ITemplateSpecVersionsOperations operations, string resourceGroupName, string templateSpecName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(resourceGroupName, templateSpecName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Lists all the Template Spec versions in the specified Template Spec. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListNext(this ITemplateSpecVersionsOperations operations, string nextPageLink) + { + return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Lists all the Template Spec versions in the specified Template Spec. + /// + /// + /// 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 ITemplateSpecVersionsOperations 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/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/TemplateSpecsClient.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/TemplateSpecsClient.cs new file mode 100644 index 0000000000000..1581e6bbb4070 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/TemplateSpecsClient.cs @@ -0,0 +1,367 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager +{ + 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; + + /// + /// The APIs listed in this specification can be used to manage Template + /// Spec resources through the Azure Resource Manager. + /// + public partial class TemplateSpecsClient : ServiceClient, ITemplateSpecsClient, 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; } + + /// + /// Subscription Id which forms part of the URI for every service call. + /// + public string SubscriptionId { get; set; } + + /// + /// Client Api version. + /// + 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 ITemplateSpecsOperations. + /// + public virtual ITemplateSpecsOperations TemplateSpecs { get; private set; } + + /// + /// Gets the ITemplateSpecVersionsOperations. + /// + public virtual ITemplateSpecVersionsOperations TemplateSpecVersions { get; private set; } + + /// + /// Initializes a new instance of the TemplateSpecsClient class. + /// + /// + /// HttpClient to be used + /// + /// + /// True: will dispose the provided httpClient on calling TemplateSpecsClient.Dispose(). False: will not dispose provided httpClient + protected TemplateSpecsClient(HttpClient httpClient, bool disposeHttpClient) : base(httpClient, disposeHttpClient) + { + Initialize(); + } + + /// + /// Initializes a new instance of the TemplateSpecsClient class. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + protected TemplateSpecsClient(params DelegatingHandler[] handlers) : base(handlers) + { + Initialize(); + } + + /// + /// Initializes a new instance of the TemplateSpecsClient class. + /// + /// + /// Optional. The http client handler used to handle http transport. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + protected TemplateSpecsClient(HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : base(rootHandler, handlers) + { + Initialize(); + } + + /// + /// Initializes a new instance of the TemplateSpecsClient 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 TemplateSpecsClient(System.Uri baseUri, params DelegatingHandler[] handlers) : this(handlers) + { + if (baseUri == null) + { + throw new System.ArgumentNullException("baseUri"); + } + BaseUri = baseUri; + } + + /// + /// Initializes a new instance of the TemplateSpecsClient 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 TemplateSpecsClient(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 TemplateSpecsClient 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 TemplateSpecsClient(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 TemplateSpecsClient class. + /// + /// + /// Required. Credentials needed for the client to connect to Azure. + /// + /// + /// HttpClient to be used + /// + /// + /// True: will dispose the provided httpClient on calling TemplateSpecsClient.Dispose(). False: will not dispose provided httpClient + /// + /// Thrown when a required parameter is null + /// + public TemplateSpecsClient(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 TemplateSpecsClient 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 TemplateSpecsClient(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 TemplateSpecsClient 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 TemplateSpecsClient(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 TemplateSpecsClient 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 TemplateSpecsClient(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() + { + TemplateSpecs = new TemplateSpecsOperations(this); + TemplateSpecVersions = new TemplateSpecVersionsOperations(this); + BaseUri = new System.Uri("https://management.azure.com"); + ApiVersion = "2021-05-01"; + 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/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/TemplateSpecsOperations.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/TemplateSpecsOperations.cs new file mode 100644 index 0000000000000..ba941eb6ca534 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/TemplateSpecsOperations.cs @@ -0,0 +1,1697 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager +{ + 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; + + /// + /// TemplateSpecsOperations operations. + /// + internal partial class TemplateSpecsOperations : IServiceOperations, ITemplateSpecsOperations + { + /// + /// Initializes a new instance of the TemplateSpecsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal TemplateSpecsOperations(TemplateSpecsClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the TemplateSpecsClient + /// + public TemplateSpecsClient Client { get; private set; } + + /// + /// Creates or updates a Template Spec. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Name of the Template Spec. + /// + /// + /// Template Spec supplied to the 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> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string templateSpecName, TemplateSpec templateSpec, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + 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 (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (templateSpecName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "templateSpecName"); + } + if (templateSpecName != null) + { + if (templateSpecName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "templateSpecName", 90); + } + if (templateSpecName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "templateSpecName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(templateSpecName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "templateSpecName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (templateSpec == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "templateSpec"); + } + if (templateSpec != null) + { + templateSpec.Validate(); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("templateSpecName", templateSpecName); + tracingParameters.Add("templateSpec", templateSpec); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "CreateOrUpdate", 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.Resources/templateSpecs/{templateSpecName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{templateSpecName}", System.Uri.EscapeDataString(templateSpecName)); + 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(templateSpec != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(templateSpec, 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 TemplateSpecsErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + TemplateSpecsError _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); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Updates Template Spec tags with specified values. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Name of the Template Spec. + /// + /// + /// Template Spec resource with the tags to be updated. + /// + /// + /// 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> UpdateWithHttpMessagesAsync(string resourceGroupName, string templateSpecName, TemplateSpecUpdateModel templateSpec = default(TemplateSpecUpdateModel), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + 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 (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (templateSpecName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "templateSpecName"); + } + if (templateSpecName != null) + { + if (templateSpecName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "templateSpecName", 90); + } + if (templateSpecName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "templateSpecName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(templateSpecName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "templateSpecName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("templateSpecName", templateSpecName); + tracingParameters.Add("templateSpec", templateSpec); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Update", 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.Resources/templateSpecs/{templateSpecName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{templateSpecName}", System.Uri.EscapeDataString(templateSpecName)); + 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(templateSpec != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(templateSpec, 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 TemplateSpecsErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + TemplateSpecsError _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 Template Spec with a given name. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Name of the Template Spec. + /// + /// + /// Allows for expansion of additional Template Spec details in the response. + /// Optional. Possible values include: 'versions' + /// + /// + /// 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 templateSpecName, string expand = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + 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 (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (templateSpecName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "templateSpecName"); + } + if (templateSpecName != null) + { + if (templateSpecName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "templateSpecName", 90); + } + if (templateSpecName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "templateSpecName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(templateSpecName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "templateSpecName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("templateSpecName", templateSpecName); + tracingParameters.Add("expand", expand); + 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.Resources/templateSpecs/{templateSpecName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{templateSpecName}", System.Uri.EscapeDataString(templateSpecName)); + List _queryParameters = new List(); + if (expand != null) + { + _queryParameters.Add(string.Format("$expand={0}", System.Uri.EscapeDataString(expand))); + } + 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 TemplateSpecsErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + TemplateSpecsError _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 Template Spec by name. When operation completes, status code 200 + /// returned without content. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Name of the Template Spec. + /// + /// + /// 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 DeleteWithHttpMessagesAsync(string resourceGroupName, string templateSpecName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + 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 (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (templateSpecName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "templateSpecName"); + } + if (templateSpecName != null) + { + if (templateSpecName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "templateSpecName", 90); + } + if (templateSpecName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "templateSpecName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(templateSpecName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "templateSpecName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("templateSpecName", templateSpecName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Delete", 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.Resources/templateSpecs/{templateSpecName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{templateSpecName}", System.Uri.EscapeDataString(templateSpecName)); + 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 != 204) + { + var ex = new TemplateSpecsErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + TemplateSpecsError _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(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Lists all the Template Specs within the specified subscriptions. + /// + /// + /// Allows for expansion of additional Template Spec details in the response. + /// Optional. Possible values include: 'versions' + /// + /// + /// 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>> ListBySubscriptionWithHttpMessagesAsync(string expand = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("expand", expand); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListBySubscription", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Resources/templateSpecs/").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (expand != null) + { + _queryParameters.Add(string.Format("$expand={0}", System.Uri.EscapeDataString(expand))); + } + 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 TemplateSpecsErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + TemplateSpecsError _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 Template Specs within the specified resource group. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Allows for expansion of additional Template Spec details in the response. + /// Optional. Possible values include: 'versions' + /// + /// + /// 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, string expand = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + 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 (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("expand", expand); + 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.Resources/templateSpecs/").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + List _queryParameters = new List(); + if (expand != null) + { + _queryParameters.Add(string.Format("$expand={0}", System.Uri.EscapeDataString(expand))); + } + 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 TemplateSpecsErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + TemplateSpecsError _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 Template Specs within the specified subscriptions. + /// + /// + /// 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>> ListBySubscriptionNextWithHttpMessagesAsync(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, "ListBySubscriptionNext", 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 TemplateSpecsErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + TemplateSpecsError _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 Template Specs within the specified 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 TemplateSpecsErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + TemplateSpecsError _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/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/TemplateSpecsOperationsExtensions.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/TemplateSpecsOperationsExtensions.cs new file mode 100644 index 0000000000000..5f692bd4689d5 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/TemplateSpecsOperationsExtensions.cs @@ -0,0 +1,350 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for TemplateSpecsOperations. + /// + public static partial class TemplateSpecsOperationsExtensions + { + /// + /// Creates or updates a Template Spec. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Name of the Template Spec. + /// + /// + /// Template Spec supplied to the operation. + /// + public static TemplateSpec CreateOrUpdate(this ITemplateSpecsOperations operations, string resourceGroupName, string templateSpecName, TemplateSpec templateSpec) + { + return operations.CreateOrUpdateAsync(resourceGroupName, templateSpecName, templateSpec).GetAwaiter().GetResult(); + } + + /// + /// Creates or updates a Template Spec. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Name of the Template Spec. + /// + /// + /// Template Spec supplied to the operation. + /// + /// + /// The cancellation token. + /// + public static async Task CreateOrUpdateAsync(this ITemplateSpecsOperations operations, string resourceGroupName, string templateSpecName, TemplateSpec templateSpec, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, templateSpecName, templateSpec, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Updates Template Spec tags with specified values. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Name of the Template Spec. + /// + /// + /// Template Spec resource with the tags to be updated. + /// + public static TemplateSpec Update(this ITemplateSpecsOperations operations, string resourceGroupName, string templateSpecName, TemplateSpecUpdateModel templateSpec = default(TemplateSpecUpdateModel)) + { + return operations.UpdateAsync(resourceGroupName, templateSpecName, templateSpec).GetAwaiter().GetResult(); + } + + /// + /// Updates Template Spec tags with specified values. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Name of the Template Spec. + /// + /// + /// Template Spec resource with the tags to be updated. + /// + /// + /// The cancellation token. + /// + public static async Task UpdateAsync(this ITemplateSpecsOperations operations, string resourceGroupName, string templateSpecName, TemplateSpecUpdateModel templateSpec = default(TemplateSpecUpdateModel), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.UpdateWithHttpMessagesAsync(resourceGroupName, templateSpecName, templateSpec, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets a Template Spec with a given name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Name of the Template Spec. + /// + /// + /// Allows for expansion of additional Template Spec details in the response. + /// Optional. Possible values include: 'versions' + /// + public static TemplateSpec Get(this ITemplateSpecsOperations operations, string resourceGroupName, string templateSpecName, string expand = default(string)) + { + return operations.GetAsync(resourceGroupName, templateSpecName, expand).GetAwaiter().GetResult(); + } + + /// + /// Gets a Template Spec with a given name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Name of the Template Spec. + /// + /// + /// Allows for expansion of additional Template Spec details in the response. + /// Optional. Possible values include: 'versions' + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this ITemplateSpecsOperations operations, string resourceGroupName, string templateSpecName, string expand = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, templateSpecName, expand, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes a Template Spec by name. When operation completes, status code 200 + /// returned without content. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Name of the Template Spec. + /// + public static void Delete(this ITemplateSpecsOperations operations, string resourceGroupName, string templateSpecName) + { + operations.DeleteAsync(resourceGroupName, templateSpecName).GetAwaiter().GetResult(); + } + + /// + /// Deletes a Template Spec by name. When operation completes, status code 200 + /// returned without content. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Name of the Template Spec. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this ITemplateSpecsOperations operations, string resourceGroupName, string templateSpecName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, templateSpecName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Lists all the Template Specs within the specified subscriptions. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Allows for expansion of additional Template Spec details in the response. + /// Optional. Possible values include: 'versions' + /// + public static IPage ListBySubscription(this ITemplateSpecsOperations operations, string expand = default(string)) + { + return operations.ListBySubscriptionAsync(expand).GetAwaiter().GetResult(); + } + + /// + /// Lists all the Template Specs within the specified subscriptions. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Allows for expansion of additional Template Spec details in the response. + /// Optional. Possible values include: 'versions' + /// + /// + /// The cancellation token. + /// + public static async Task> ListBySubscriptionAsync(this ITemplateSpecsOperations operations, string expand = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListBySubscriptionWithHttpMessagesAsync(expand, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Lists all the Template Specs within the specified resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Allows for expansion of additional Template Spec details in the response. + /// Optional. Possible values include: 'versions' + /// + public static IPage ListByResourceGroup(this ITemplateSpecsOperations operations, string resourceGroupName, string expand = default(string)) + { + return operations.ListByResourceGroupAsync(resourceGroupName, expand).GetAwaiter().GetResult(); + } + + /// + /// Lists all the Template Specs within the specified resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Allows for expansion of additional Template Spec details in the response. + /// Optional. Possible values include: 'versions' + /// + /// + /// The cancellation token. + /// + public static async Task> ListByResourceGroupAsync(this ITemplateSpecsOperations operations, string resourceGroupName, string expand = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByResourceGroupWithHttpMessagesAsync(resourceGroupName, expand, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Lists all the Template Specs within the specified subscriptions. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListBySubscriptionNext(this ITemplateSpecsOperations operations, string nextPageLink) + { + return operations.ListBySubscriptionNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Lists all the Template Specs within the specified subscriptions. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListBySubscriptionNextAsync(this ITemplateSpecsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListBySubscriptionNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Lists all the Template Specs within the specified resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListByResourceGroupNext(this ITemplateSpecsOperations operations, string nextPageLink) + { + return operations.ListByResourceGroupNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Lists all the Template Specs within the specified 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 ITemplateSpecsOperations 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/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/TenantsOperations.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/TenantsOperations.cs new file mode 100644 index 0000000000000..c92118102a683 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/TenantsOperations.cs @@ -0,0 +1,400 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// 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.ResourceManager +{ + 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; + + /// + /// TenantsOperations operations. + /// + internal partial class TenantsOperations : IServiceOperations, ITenantsOperations + { + /// + /// Initializes a new instance of the TenantsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal TenantsOperations(SubscriptionClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the SubscriptionClient + /// + public SubscriptionClient Client { get; private set; } + + /// + /// Gets the tenants for your account. + /// + /// + /// 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"); + } + // 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("/") ? "" : "/")), "tenants").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 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 tenants for your account. + /// + /// + /// 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 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/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/TenantsOperationsExtensions.cs b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/TenantsOperationsExtensions.cs new file mode 100644 index 0000000000000..906ef49e3c30e --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.ResourceManager/src/Generated/TenantsOperationsExtensions.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.ResourceManager +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for TenantsOperations. + /// + public static partial class TenantsOperationsExtensions + { + /// + /// Gets the tenants for your account. + /// + /// + /// The operations group for this extension method. + /// + public static IPage List(this ITenantsOperations operations) + { + return operations.ListAsync().GetAwaiter().GetResult(); + } + + /// + /// Gets the tenants for your account. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAsync(this ITenantsOperations operations, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets the tenants for your account. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListNext(this ITenantsOperations operations, string nextPageLink) + { + return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Gets the tenants for your account. + /// + /// + /// 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 ITenantsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +}